:root {
    --color-active: #00FF41;
    --color-idle: #FFD700;
    --color-blocked: #FF4444;
    --color-alliance: #00FFFF;
    --color-alert: #FF0000;
    --color-bg: #0a0a0a;
    --color-grid: #1a1a2e;
    --font-main: 'Courier New', monospace;
}

@keyframes glow {
    0% { box-shadow: 0 0 5px var(--glow-color); }
    50% { box-shadow: 0 0 20px var(--glow-color); }
    100% { box-shadow: 0 0 5px var(--glow-color); }
}

@keyframes pulse-ring {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

@keyframes magnifying-glass-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes cursor-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes gear-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes scan-line {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

@keyframes book-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pen-stroke {
    0% { stroke-dashoffset: 100; }
    100% { stroke-dashoffset: 0; }
}

@keyframes deploy-trail {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

@keyframes dissolve {
    0% { opacity: 1; transform: scale(1); filter: blur(0); }
    100% { opacity: 0; transform: scale(0.5); filter: blur(10px); }
}

@font-face {
    font-family: 'MilitaryFont';
    src: url('https://fonts.cdnfonts.com/s/13926/Military%20Bold.woff') format('woff'); /* Placeholder, ideally self-hosted */
}

body {
    margin: 0;
    font-family: var(--font-main);
    overflow: hidden; /* Prevent scrollbars from animations */
    background-color: var(--color-bg);
    color: var(--color-active);
}

.battlefield-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background-image: 
        linear-gradient(0deg, transparent 24%, rgba(0,255,0,0.1) 25%, rgba(0,255,0,0.1) 26%, transparent 27%, transparent 74%, rgba(0,255,0,0.1) 75%, rgba(0,255,0,0.1) 76%, transparent 77%, transparent), 
        linear-gradient(90deg, transparent 24%, rgba(0,255,0,0.1) 25%, rgba(0,255,0,0.1) 26%, transparent 27%, transparent 74%, rgba(0,255,0,0.1) 75%, rgba(0,255,0,0.1) 76%, transparent 77%, transparent);
    background-size: 50px 50px;
    background-color: var(--color-grid); /* Dark tactical grid background */
    position: relative;
}

.command-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #2a2a3e; /* Dark metal texture feel */
    border-bottom: 2px solid var(--color-active);
    font-family: var(--font-main);
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(0,255,0,0.5);
    position: relative;
    z-index: 1000;
}

.command-bar-section {
    font-size: 1.2em;
    color: var(--color-active);
}

.openclaw-fortress {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5em;
    color: var(--color-alliance);
    text-shadow: 0 0 15px var(--color-alliance);
    animation: glow 3s infinite alternate;
    --glow-color: var(--color-alliance);
    padding: 10px 20px;
    border: 2px solid var(--color-alliance);
    background-color: rgba(0, 50, 50, 0.2);
    border-radius: 5px;
}

.battlefield-main {
    display: flex;
    flex-grow: 1;
    position: relative;
    padding: 20px;
}

.zone {
    flex: 1;
    padding: 20px;
    border: 1px dashed rgba(0,255,0,0.2);
    margin: 10px;
    position: relative;
    min-height: 200px; /* Ensure zones have some height */
}

.left-zone h2 {
    color: var(--color-active);
}

.right-zone h2 {
    color: var(--color-blocked);
}

.divider {
    width: 5px;
    background-color: var(--color-alliance); /* Glowing divider */
    box-shadow: 0 0 20px var(--color-alliance), 0 0 30px var(--color-alliance);
    animation: glow 2s infinite alternate;
    --glow-color: var(--color-alliance);
    margin: 0 10px;
    position: relative;
}

.divider::before {
    content: 'ALLIANCE BRIDGE';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-90deg);
    color: var(--color-alliance);
    font-size: 1.5em;
    white-space: nowrap;
}

.vault-sync-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-alliance);
    font-size: 0.9em;
    animation: pulse-sync 1s infinite alternate;
}

@keyframes pulse-sync {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Agent Units */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Fixed to 3 columns */
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-top: 50px; /* Space for fortress */
}

.agent-unit {
    width: 100px;
    height: 100px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8em;
    font-weight: bold;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
    border: 2px solid transparent;
    --agent-color: var(--color-active); /* Default for Company X */
}

.agent-unit.hex {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background-color: rgba(0, 255, 0, 0.1);
    border-color: var(--color-active); /* Default hex border */
}

.agent-unit.circle {
    border-radius: 0; /* No rounded corners */
    background-color: rgba(255, 0, 0, 0.1);
    border-color: var(--color-blocked); /* Default circle border */
    animation: pulse-ring 2s infinite alternate; /* Default for Company Y */
    --glow-color: var(--color-blocked);
}

.agent-unit.hex.scout-core {
    width: 150px;
    height: 150px;
    font-size: 1.1em;
    --agent-color: var(--color-alliance);
    border-color: var(--color-alliance);
    background-color: rgba(0, 255, 170, 0.15);
}

.agent-unit.circle.special-envoy {
    --agent-color: #FF00FF;
    border-color: #FF00FF;
    background-color: rgba(255, 0, 255, 0.15);
    position: static; /* Remove absolute positioning */
    margin: auto; /* Center it within its grid cell */
    animation: pulse-ring 1.5s infinite alternate;
    --glow-color: #FF00FF;
}

.agent-unit.active {
    --glow-color: var(--color-active);
    animation: glow 1.5s infinite alternate;
    border-color: var(--color-active);
}

.agent-unit.idle {
    opacity: 0.5;
    animation: none;
    border-color: var(--color-idle);
}

.agent-unit.blocked {
    border-color: var(--color-blocked);
    animation: glow 1.5s infinite alternate;
    --glow-color: var(--color-blocked);
}

.agent-unit.complete {
    border-color: var(--color-alliance);
    animation: none;
    opacity: 0.8;
}

.agent-unit:hover {
    transform: scale(1.1);
    z-index: 10;
}

.agent-icon {
    width: 40px;
    height: 40px;
    background-color: rgba(255,255,255,0.1);
    margin-bottom: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.agent-unit.hex .agent-icon {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

/* Role-specific animations */
.agent-unit[data-role="ANALYST"] .agent-icon::before {
    content: '🔎';
    animation: magnifying-glass-rotate 2s infinite linear;
}
.agent-unit[data-role="CODER"] .agent-icon::before {
    content: '💻';
    animation: cursor-flicker 1s infinite step-end;
}
.agent-unit[data-role="STRATEGIST"] .agent-icon::before {
    content: '⚙️';
    animation: gear-spin 3s infinite linear;
}
.agent-unit[data-role="AUDITOR"] .agent-icon {
    background: linear-gradient(to right, transparent, rgba(0,255,0,0.5), transparent);
    background-size: 200% 200%;
    animation: scan-line 2s infinite linear;
}
.agent-unit[data-role="RESEARCHER"] .agent-icon::before {
    content: '📚';
    animation: book-bounce 1s infinite ease-in-out;
}
.agent-unit[data-role="WRITER"] .agent-icon::before {
    content: '✍️';
}

.agent-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 5px;
}

.agent-name {
    color: #fff;
    font-size: 0.7em; /* Shrink font */
    margin-top: 0px;
    line-height: 1.1;
}

.agent-task-label, .agent-status-label {
    color: #aaa;
    font-size: 0.6em; /* Shrink font */
    line-height: 1.1;
    text-transform: uppercase;
}

/* Progress Ring */
.agent-progress-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.progress-ring-circle {
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.progress-ring-progress {
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
    transition: stroke-dashoffset 0.35s ease-out; /* Use CSS transition */
}

.progress-text {
    position: absolute;
    color: #fff;
    font-size: 0.8em;
}

/* Task Complete Animation (example via JS, but CSS can assist) */
.agent-unit.task-complete {
    animation: burst-flash 0.5s forwards, slide-to-center 1s 0.5s forwards; /* Example */
}

@keyframes burst-flash {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.5); box-shadow: 0 0 50px rgba(255,255,0,0.8); }
    100% { opacity: 0; transform: scale(1); box-shadow: none; }
}

/* Hire/Fire Animations (managed via JS, but CSS defines effects) */
.agent-unit.deploy-in {
    animation: fly-in 1s ease-out forwards;
}

@keyframes fly-in {
    0% { transform: translateX(-100vw) scale(0); opacity: 0; }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

.agent-unit.dissolve-out {
    animation: dissolve 1s ease-out forwards;
}

/* Footer Panels */
.footer-panels {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    padding: 10px;
    gap: 20px;
    background-color: #2a2a3e; /* Dark metal texture */
    border-top: 2px solid var(--color-active);
    box-shadow: 0 0 15px rgba(0,255,0,0.5);
    font-family: var(--font-main);
    text-transform: uppercase;
    height: 200px;
    margin-top: auto; /* Push to bottom */
    z-index: 1000;
}

.log-feed, .intel-report-panel, .vault-intel-panel, .task-history-panel {
    min-width: 0; /* Prevents grid items from overflowing */
    background-color: var(--color-bg);
    border: 1px solid var(--color-active);
    padding: 10px;
    overflow-y: auto;
    font-size: 0.9em;
    position: relative; /* For filter buttons */
}

.task-history-panel {
    border-color: var(--color-alliance);
}

.log-feed h3, .intel-report-panel h3, .vault-intel-panel h3, .task-history-panel h3 {
    color: var(--color-active);
    text-align: center;
    margin-top: 0;
    border-bottom: 1px solid rgba(0,255,0,0.3);
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.task-history-panel h3 {
    color: var(--color-alliance);
}

.log-content {
    height: calc(100% - 40px); /* Adjust for header */
    overflow-y: auto;
    padding-right: 5px; /* For scrollbar */
}

.log-content div {
    margin-bottom: 5px;
    line-height: 1.2;
    color: #fff;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status colors for Task History */
.status-done { color: var(--color-active) !important; font-weight: bold; }
.status-failed { color: var(--color-alert) !important; font-weight: bold; }
.status-started { color: var(--color-idle) !important; font-weight: bold; }
.status-progress { color: var(--color-alliance) !important; font-weight: bold; }

.log-content .agent-name-color-scout {
    color: var(--color-alliance);
}
.log-content .agent-name-color-forge {
    color: var(--color-active);
}
.log-content .agent-name-color-system {
    color: #FFFFFF;
}
.log-content .agent-name-color-scheduler {
    color: #FF8C00; /* Darker yellow/orange for contrast */
}
.log-content .agent-name-color-crawler {
    color: var(--color-blocked);
}
.log-content .agent-name-color-agenty {
    color: #FF00FF; /* Magenta for AGENT-Y */
}
.log-content .agent-name-color-guardian {
    color: var(--color-idle);
}

.intel-report-container {
    display: flex;
    height: calc(100% - 40px); /* Adjust for header */
}

.intel-report-panel .company-intel {
    flex: 1;
    padding: 5px;
    border-right: 1px dashed rgba(255,255,255,0.1); /* Divider */
}

.intel-report-panel .company-intel:last-child {
    border-right: none;
}

.intel-report-panel .company-intel h4 {
    font-size: 0.9em;
    color: #fff;
    margin-top: 0;
    margin-bottom: 5px;
    text-align: center;
}

.intel-report-panel .status-line {
    font-size: 0.8em;
    margin-bottom: 3px;
    color: #ddd;
}

.vault-intel-panel .vault-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.vault-intel-panel .vault-stat-item {
    background-color: rgba(0, 255, 65, 0.1);
    border: 1px solid var(--color-active);
    padding: 8px;
    font-size: 0.8em;
    text-align: center;
}

/* Modal Styling */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 2000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.8); /* Black w/ opacity */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--color-bg); /* Dark tactical */
    margin: 15% auto; /* 15% from the top and centered */
    padding: 30px;
    border: 2px solid var(--color-alliance);
    width: 80%; /* Could be more responsive */
    max-width: 600px;
    box-shadow: 0 0 30px rgba(0,255,255,0.7);
    position: relative;
    font-family: var(--font-main);
    color: var(--color-active);
    text-transform: uppercase;
}

.close-button {
    color: var(--color-alliance);
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #fff;
    text-decoration: none;
}

#modal-agent-name {
    color: var(--color-alliance);
    font-size: 1.8em;
    margin-bottom: 10px;
}

.modal-content p {
    font-size: 1.1em;
    margin-bottom: 8px;
}

.modal-content strong {
    color: var(--color-active);
}
