* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --cyan: #00f0ff;
    --cyan-dim: #00f0ff88;
    --cyan-dark: #003a40;
    --red: #cc0000;
    --red-bright: #ff2200;
    --gold: #FFD700;
    --gold-dim: #FFD70088;
    --bg: #0a0e1a;
    --panel-bg: rgba(0, 15, 30, 0.75);
    --panel-border: var(--cyan-dim);
    --text-primary: var(--cyan);
    --text-secondary: #00f0ffaa;
    --combat-primary: #ff4400;
    --combat-secondary: #ff440088;
    --stealth-primary: #445566;
    --stealth-secondary: #44556644;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    cursor: crosshair;
}

body.combat-mode {
    --cyan: #ff4400;
    --cyan-dim: #ff440066;
    --cyan-dark: #401500;
    --panel-border: #ff440066;
    --text-primary: #ff4400;
    --text-secondary: #ff440099;
}

body.stealth-mode {
    --cyan: #445566;
    --cyan-dim: #44556644;
    --cyan-dark: #1a2233;
    --panel-border: #44556644;
    --text-primary: #556677;
    --text-secondary: #55667744;
}

#scene-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
}

#scene-container canvas {
    display: block;
}

/* Scanline overlay */
#scanline-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 240, 255, 0.015) 2px,
        rgba(0, 240, 255, 0.015) 4px
    );
}

body.stealth-mode #scanline-overlay {
    opacity: 0.3;
}

/* HUD */
#hud {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

#hud * {
    pointer-events: none;
}

#hud button, #hud a, .popup-close {
    pointer-events: auto;
}

/* Top Bar */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--panel-border);
    background: linear-gradient(180deg, rgba(0,15,30,0.9) 0%, transparent 100%);
    min-height: 44px;
}

.stark-logo {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 4px;
    color: var(--text-primary);
    text-shadow: 0 0 10px var(--cyan-dim);
}

.status-text {
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 3px;
    color: var(--text-secondary);
}

#status-label {
    color: var(--text-primary);
    text-shadow: 0 0 8px var(--cyan-dim);
}

#clock {
    font-family: 'Share Tech Mono', monospace;
    font-size: 13px;
    color: var(--text-primary);
    letter-spacing: 2px;
}

/* Panels */
.hud-panel {
    position: fixed;
    top: 60px;
    width: 260px;
    max-height: calc(100vh - 160px);
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-y: auto;
    overflow-x: hidden;
}

.hud-panel::-webkit-scrollbar {
    width: 3px;
}

.hud-panel::-webkit-scrollbar-thumb {
    background: var(--cyan-dim);
}

#left-panel {
    left: 15px;
    border-radius: 4px;
}

#right-panel {
    right: 15px;
    border-radius: 4px;
}

.panel-header {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 3px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--panel-border);
    text-shadow: 0 0 8px var(--cyan-dim);
    background: rgba(0, 240, 255, 0.03);
}

.panel-content {
    padding: 10px 14px;
}

/* Status Bars */
.status-row {
    margin-bottom: 8px;
}

.status-row .label {
    display: block;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.bar-container {
    width: 100%;
    height: 6px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid var(--panel-border);
    border-radius: 1px;
    overflow: hidden;
    margin-bottom: 2px;
}

.bar {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 1px;
}

.bar-green {
    background: linear-gradient(90deg, #00ff66, #00cc55);
    box-shadow: 0 0 6px #00ff6644;
}

.bar-cyan {
    background: linear-gradient(90deg, var(--cyan), var(--cyan-dim));
    box-shadow: 0 0 6px var(--cyan-dim);
}

.bar-gold {
    background: linear-gradient(90deg, var(--gold), var(--gold-dim));
    box-shadow: 0 0 6px var(--gold-dim);
}

body.combat-mode .bar-green {
    background: linear-gradient(90deg, #ff6600, #ff4400);
    box-shadow: 0 0 6px #ff440044;
}

body.combat-mode .bar-cyan {
    background: linear-gradient(90deg, #ff4400, #ff220088);
}

body.combat-mode .bar-gold {
    background: linear-gradient(90deg, #ff8800, #ff660088);
}

body.stealth-mode .bar-green,
body.stealth-mode .bar-cyan,
body.stealth-mode .bar-gold {
    background: linear-gradient(90deg, #556677, #44556688);
    box-shadow: 0 0 4px #44556644;
}

.status-row .value {
    font-size: 10px;
    color: var(--text-primary);
    float: right;
    margin-top: -18px;
}

/* Right Panel Specs */
.spec-block {
    margin-bottom: 12px;
}

.spec-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-shadow: 0 0 8px var(--cyan-dim);
}

.spec-line {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 3px;
    padding-left: 8px;
    border-left: 2px solid var(--panel-border);
}

.spec-line span {
    color: var(--text-primary);
    float: right;
}

/* Radar */
.radar-container {
    display: flex;
    justify-content: center;
    margin: 12px 0;
}

#radar-canvas {
    border-radius: 50%;
    border: 1px solid var(--panel-border);
}

.threat-status {
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: #00ff66;
    margin-bottom: 10px;
    animation: pulse-text 2s ease-in-out infinite;
}

body.combat-mode .threat-status {
    color: #ff4400;
}

body.stealth-mode .threat-status {
    color: #556677;
}

@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.threat-icon {
    display: inline-block;
    animation: spin-slow 4s linear infinite;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* System Log */
.log-container {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--panel-border);
    padding: 6px;
    font-size: 9px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
}

.log-container::-webkit-scrollbar {
    width: 2px;
}

.log-container::-webkit-scrollbar-thumb {
    background: var(--cyan-dim);
}

.log-entry {
    border-bottom: 1px solid rgba(0, 240, 255, 0.05);
    padding: 2px 0;
}

.log-time {
    color: var(--text-primary);
    margin-right: 6px;
}

/* Detail Popup */
#detail-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    background: var(--panel-bg);
    border: 1px solid var(--cyan);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 4px;
    z-index: 100;
    pointer-events: auto;
    box-shadow: 0 0 30px var(--cyan-dim), inset 0 0 20px rgba(0,0,0,0.5);
}

#detail-popup.hidden {
    display: none;
}

.popup-header {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 3px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--panel-border);
    text-shadow: 0 0 10px var(--cyan-dim);
}

.popup-body {
    padding: 14px 16px;
    font-size: 11px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.popup-close {
    position: absolute;
    top: 8px; right: 12px;
    background: none;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 2px;
    transition: all 0.2s;
}

.popup-close:hover {
    background: var(--cyan-dim);
    color: #000;
}

/* Bottom Bar */
#bottom-bar {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 20;
}

.hud-btn {
    pointer-events: auto;
    font-family: 'Orbitron', sans-serif;
    font-weight: 500;
    font-size: 10px;
    letter-spacing: 2px;
    padding: 10px 18px;
    background: rgba(0, 15, 30, 0.8);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 3px;
    transition: all 0.25s ease;
    text-shadow: 0 0 6px var(--cyan-dim);
    white-space: nowrap;
}

.hud-btn:hover {
    background: rgba(0, 240, 255, 0.15);
    border-color: var(--cyan);
    box-shadow: 0 0 15px var(--cyan-dim), inset 0 0 15px rgba(0, 240, 255, 0.05);
    transform: translateY(-1px);
}

.hud-btn:active {
    transform: translateY(1px);
    background: rgba(0, 240, 255, 0.25);
}

.hud-btn.active {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--cyan);
    box-shadow: 0 0 20px var(--cyan-dim);
}

.btn-icon {
    margin-right: 4px;
}

/* Footer */
#footer {
    position: fixed;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-secondary);
    opacity: 0.5;
    z-index: 20;
}

#footer a {
    color: var(--text-primary);
    text-decoration: none;
    pointer-events: auto;
}

#footer a:hover {
    text-decoration: underline;
}

/* Decorative circles */
#deco-circles {
    position: fixed;
    bottom: 60px;
    right: -40px;
    width: 200px;
    height: 200px;
    z-index: 5;
    pointer-events: none;
    opacity: 0.15;
}

.deco-circle {
    fill: none;
    stroke: var(--cyan);
    stroke-width: 0.5;
    stroke-dasharray: 8 4;
}

.c1 { animation: rotate-cw 20s linear infinite; transform-origin: center; }
.c2 { animation: rotate-ccw 15s linear infinite; transform-origin: center; }
.c3 { animation: rotate-cw 10s linear infinite; transform-origin: center; }

@keyframes rotate-cw {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rotate-ccw {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* Scanning animation */
#scan-plane {
    position: fixed;
    left: 30%;
    width: 40%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--cyan), transparent);
    box-shadow: 0 0 20px var(--cyan), 0 0 40px var(--cyan-dim);
    z-index: 15;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Deploy animation flash */
.deploy-flash {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--cyan);
    z-index: 50;
    pointer-events: none;
    animation: flash 0.5s ease-out forwards;
}

@keyframes flash {
    0% { opacity: 0.4; }
    100% { opacity: 0; }
}

/* Responsive */
@media (max-width: 900px) {
    #left-panel, #right-panel {
        display: none;
    }
    
    #deco-circles {
        display: none;
    }
    
    #top-center {
        display: none;
    }
    
    .hud-btn {
        font-size: 8px;
        padding: 8px 10px;
        letter-spacing: 1px;
    }
    
    .btn-icon {
        display: none;
    }
}

@media (max-width: 600px) {
    #bottom-bar {
        flex-wrap: wrap;
        justify-content: center;
        bottom: 24px;
        width: 95%;
    }
    
    .hud-btn {
        font-size: 7px;
        padding: 7px 8px;
    }
    
    .stark-logo {
        font-size: 10px;
        letter-spacing: 2px;
    }
    
    #clock {
        font-size: 10px;
    }
}