@charset "UTF-8";

/* ---------- CSS Variables & Theming ---------- */
:root {
    /* Color Palette */
    --bg-base: #050508;
    --panel-bg-dark: rgba(11, 12, 16, 0.7);
    --panel-bg-light: rgba(31, 40, 51, 0.6);
    --panel-border: rgba(102, 252, 241, 0.3);
    
    --text-primary: #ffffff;
    --text-secondary: #c5c6c7;
    --text-muted: #6b6e73;
    
    /* Faction Colors */
    --terran-primary: #66fcf1;
    --terran-glow: rgba(102, 252, 241, 0.6);
    --terran-bg: rgba(102, 252, 241, 0.1);
    
    --zerg-primary: #bf40ff;
    --zerg-glow: rgba(191, 64, 255, 0.6);
    --zerg-bg: rgba(191, 64, 255, 0.1);
    
    --protoss-primary: #e2b426;
    --protoss-glow: rgba(226, 180, 38, 0.6);
    --protoss-bg: rgba(226, 180, 38, 0.1);
    
    --system-primary: #ffb400;
    --system-glow: rgba(255, 180, 0, 0.6);
    
    /* Typography */
    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    
    /* Dimensions */
    --hud-gap: 20px;
    --panel-padding: 20px;
    --corner-cut: 20px;
    --corner-cut-lg: 40px;
}

/* ---------- Global Reset ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(31, 40, 51, 0.3) 0%, transparent 80%),
        linear-gradient(rgba(102, 252, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 252, 241, 0.03) 1px, transparent 1px);
    background-size: 100vw 100vh, 30px 30px, 30px 30px;
    color: var(--text-primary);
    font-family: var(--font-display);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    user-select: none;
}

/* ---------- Custom Scrollbars (Webkit) ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--terran-primary);
}
#panel-p2 ::-webkit-scrollbar-thumb {
    background: rgba(191, 64, 255, 0.5);
}
#panel-p2 ::-webkit-scrollbar-thumb:hover {
    background: var(--zerg-primary);
}

/* ---------- Shape Helpers (Cybernetic Cut-outs) ---------- */
.clip-corner {
    clip-path: polygon(
        0 var(--corner-cut), 
        var(--corner-cut) 0, 
        100% 0, 
        100% calc(100% - var(--corner-cut)), 
        calc(100% - var(--corner-cut)) 100%, 
        0 100%
    );
}

.clip-corner-lg {
    clip-path: polygon(
        0 var(--corner-cut-lg), 
        var(--corner-cut-lg) 0, 
        100% 0, 
        100% calc(100% - var(--corner-cut-lg)), 
        calc(100% - var(--corner-cut-lg)) 100%, 
        0 100%
    );
}

/* ---------- Utilities & Initial Setup Screen ---------- */
.hidden { display: none !important; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    background-image: radial-gradient(circle at 50% 50%, rgba(31, 40, 51, 0.8) 0%, #000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--panel-bg-dark);
    padding: 40px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 50px rgba(102, 252, 241, 0.15);
    max-width: 800px;
    width: 90%;
    text-align: center;
}

/* Image Manager Styles */
.unit-list-race-section {
    margin-bottom: 30px;
}
.unit-list-race-title {
    color: var(--terran-primary);
    border-bottom: 1px dashed rgba(255,255,255,0.2);
    padding-bottom: 5px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
}
.unit-list-item {
    display: flex;
    align-items: center;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    flex-wrap: wrap;
    gap: 10px;
}
.unit-list-thumb {
    width: 60px;
    height: 60px;
    background: #000;
    border: 1px solid var(--panel-border);
    margin-right: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.unit-list-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.unit-list-info {
    flex: 1;
    min-width: 120px;
}
.unit-list-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-primary);
}
.unit-list-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
}
.unit-list-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.unit-list-actions button {
    padding: 5px 15px;
    font-size: 0.8rem;
}

.setup-grid {
    display: flex;
    gap: 30px;
    margin: 30px 0;
    justify-content: center;
}

.setup-player {
    flex: 1;
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border: 1px inset rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.setup-player h3 {
    margin-bottom: 10px;
    text-align: center;
    color: var(--text-secondary);
}

.sci-fi-select, .sci-fi-input {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.sci-fi-select:focus, .sci-fi-input:focus {
    border-color: var(--terran-primary);
    box-shadow: 0 0 10px var(--terran-bg);
}

.sci-fi-btn {
    padding: 15px 50px;
    font-size: 1.2rem;
    font-weight: 900;
    font-family: var(--font-display);
    background: var(--terran-bg);
    color: var(--terran-primary);
    border: 1px solid var(--terran-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 2px;
}

.sci-fi-btn:hover {
    background: var(--terran-primary);
    color: #000;
    box-shadow: 0 0 20px var(--terran-glow);
}

/* ---------- Main Layout ---------- */
#command-center-hud {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    gap: 0;
    position: relative;
    background: #000;
}

/* ---------- Base Panel Styles ---------- */
.hud-header, .side-panel, .hud-footer {
    background: var(--panel-bg-dark);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    position: relative;
}

.hud-header::before, .side-panel::before, .hud-footer::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: -1;
}

/* ---------- Header Section ---------- */
.hud-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    height: 80px;
    background: linear-gradient(to bottom, rgba(11, 12, 16, 0.9), transparent);
    border-bottom: none;
    pointer-events: none; /* 클릭 이벤트는 아래 전장으로 통과 */
}

.hud-header * {
    pointer-events: auto; /* 내부 요소는 클릭 가능 유지 */
}

.player-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.p2 {
    flex-direction: row-reverse;
}

.race-badge {
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    padding: 4px 12px;
    border-radius: 4px;
    text-shadow: none;
}

.terran-badge {
    background: var(--terran-bg);
    color: var(--terran-primary);
    border: 1px solid var(--terran-primary);
    box-shadow: 0 0 10px var(--terran-glow);
}

.zerg-badge {
    background: var(--zerg-bg);
    color: var(--zerg-primary);
    border: 1px solid var(--zerg-primary);
    box-shadow: 0 0 10px var(--zerg-glow);
}

.protoss-badge {
    background: var(--protoss-bg);
    color: var(--protoss-primary);
    border: 1px solid var(--protoss-primary);
    box-shadow: 0 0 10px var(--protoss-glow);
}

.ai-name {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.neon-text {
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--terran-primary),
        0 0 40px var(--terran-primary);
}

.neon-text-alt {
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--zerg-primary),
        0 0 40px var(--zerg-primary);
}

.neon-text-protoss {
    color: #fff;
    text-shadow: 
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--protoss-primary),
        0 0 40px var(--protoss-primary);
}

.vs-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vs-text {
    font-size: 2rem;
    font-weight: 900;
    color: var(--text-secondary);
    font-style: italic;
    letter-spacing: 5px;
}

.status-indicator {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--system-primary);
    margin-top: 5px;
    letter-spacing: 1px;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ---------- Main Middle Section ---------- */
.hud-main {
    flex: 1;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.panels-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 250px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    gap: var(--hud-gap);
    padding: 0 var(--hud-gap) var(--hud-gap) var(--hud-gap);
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%);
    pointer-events: none;
}

/* ---------- Side Panels ---------- */
.side-panel {
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    padding: var(--panel-padding);
    pointer-events: auto;
}

#panel-p2 {
    border-color: rgba(191, 64, 255, 0.3);
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.terran-glow {
    color: var(--terran-primary);
    text-shadow: 0 0 8px var(--terran-glow);
    border-bottom-color: var(--terran-primary);
}

.zerg-glow {
    color: var(--zerg-primary);
    text-shadow: 0 0 8px var(--zerg-glow);
    border-bottom-color: var(--zerg-primary);
}

.global-glow {
    color: var(--system-primary);
    text-shadow: 0 0 8px var(--system-glow);
}

/* Resource Grid */
.resource-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 25px;
}

.resource-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

#panel-p1 .resource-box:hover { border-color: var(--terran-primary); box-shadow: 0 0 10px var(--terran-bg); }
#panel-p2 .resource-box:hover { border-color: var(--zerg-primary); box-shadow: 0 0 10px var(--zerg-bg); }

.supply-box {
    grid-column: span 2;
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 20px;
}

.res-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.supply-box .res-label { margin-bottom: 0; }

.res-value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: var(--text-primary);
}

#panel-p1 .res-value { color: var(--terran-primary); text-shadow: 0 0 5px var(--terran-glow); }
#panel-p2 .res-value { color: var(--zerg-primary); text-shadow: 0 0 5px var(--zerg-glow); }

/* Terminal Area */
.terminal-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.terminal-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.terminal-window {
    flex: 1;
    background: rgba(0, 0, 0, 0.6);
    border: 1px inset rgba(255,255,255,0.05);
    padding: 10px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
}

.log-list {
    list-style: none;
}

.log-list li {
    margin-bottom: 5px;
    word-wrap: break-word;
}

#p1-terminal .log-list li { color: var(--terran-primary); }
#p2-terminal .log-list li { color: var(--zerg-primary); }

.log-prefix {
    opacity: 0.7;
    margin-right: 5px;
}

/* ---------- Center Battlefield ---------- */
.battlefield-section {
    flex: 1;
    background: #000;
    position: relative;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    clip-path: none;
}

.canvas-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
}

#battlefield-canvas {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: cover;
    z-index: 1;
    /* subtle CRT glow */
    filter: drop-shadow(0 0 10px rgba(102, 252, 241, 0.2));
}

/* Battlefield Sci-Fi Overlays */
.grid-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 2;
}

.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20px;
    background: linear-gradient(to bottom, transparent, rgba(102, 252, 241, 0.4), transparent);
    opacity: 0.5;
    pointer-events: none;
    z-index: 3;
    animation: scanSweep 6s linear infinite;
}

@keyframes scanSweep {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100vh); }
}

/* Reticles */
.reticle {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--panel-border);
    z-index: 4;
    pointer-events: none;
    transition: all 0.3s;
}

.battlefield-section:hover .reticle {
    border-color: var(--terran-primary);
    box-shadow: 0 0 10px var(--terran-glow);
}

.top-left { top: 20px; left: 20px; border-right: none; border-bottom: none; }
.top-right { top: 20px; right: 20px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 20px; left: 20px; border-right: none; border-top: none; }
.bottom-right { bottom: 20px; right: 20px; border-left: none; border-top: none; }


/* ---------- Footer Section ---------- */
.hud-footer {
    position: absolute;
    top: 90px;
    left: 20px;
    width: 380px;
    height: 250px;
    max-height: 250px;
    z-index: 15;
    background: rgba(11, 12, 16, 0.7);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    padding: 15px;
    overflow: hidden;
    pointer-events: auto;
    clip-path: none;
    border-radius: 8px;
}

.hud-footer .panel-title {
    margin-bottom: 10px;
}

.global-log-window {
    flex: 1 1 auto;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    height: 100%;
}

#global-match-log {
    list-style: none;
}

#global-match-log li {
    margin-bottom: 4px;
    color: var(--text-secondary);
}

#global-match-log li:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

.timestamp {
    color: var(--system-primary);
    margin-right: 10px;
    opacity: 0.8;
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 1200px) {
    .ai-name { font-size: 1.4rem; }
}

@media (max-width: 900px) {
    body {
        overflow: hidden;
        height: 100vh;
    }
    #command-center-hud {
        height: 100vh;
        padding: 0;
        gap: 0;
        position: relative;
    }
    .hud-header {
        height: auto;
        padding: 10px;
        flex-direction: row;
        justify-content: space-between;
        background: rgba(0, 0, 0, 0.8);
    }
    .hud-header .ai-name { font-size: 0.9rem; }
    .hud-header .vs-text { font-size: 1rem; margin: 0 5px; }
    .hud-header .player-container { flex-direction: column; gap: 5px; }
    .hud-header .status-indicator { font-size: 0.6rem; }
    
    .hud-main {
        flex: 1;
        flex-direction: column;
        gap: 10px;
        min-height: 0;
    }
    .battlefield-section {
        flex: 1;
        min-height: 0;
    }
    .panels-container {
        flex-direction: row;
        height: auto;
        padding: 10px;
        gap: 10px;
        background: rgba(0, 0, 0, 0.7);
    }
    .side-panel {
        flex: 1;
        padding: 10px;
        height: auto;
    }
    .panel-title { margin-bottom: 10px; font-size: 0.75rem; padding-bottom: 5px; text-align: center; }
    .resource-grid { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0; }
    .resource-box { padding: 5px; flex-direction: row; justify-content: space-between; align-items: center; }
    .supply-box { flex-direction: row; padding: 5px; }
    .res-label { font-size: 0.5rem; margin-bottom: 0; }
    .res-value { font-size: 0.8rem; }
    .terminal-wrapper { display: none; } /* 화면 차지를 줄이기 위해 모바일에서는 스트림 숨김 */

    .hud-footer {
        position: absolute;
        top: 70px;
        left: 10px;
        width: 150px;
        height: 120px;
        padding: 5px;
        background: rgba(0, 0, 0, 0.6);
        border: 1px solid var(--panel-border);
        border-radius: 4px;
        z-index: 15;
        pointer-events: none;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .hud-footer .panel-title { display: none; }
    .global-log-window { 
        padding: 0; 
        background: transparent; 
        font-size: 0.65rem; 
    }
    .global-log-window li { margin-bottom: 2px; }
    
    .setup-grid { flex-direction: column; gap: 15px; }
    .modal-content { padding: 20px; }
}

/* VICTORY MODAL STYLES */
.victory-content {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    background: radial-gradient(circle, rgba(31, 40, 51, 0.95) 0%, rgba(5, 5, 8, 0.98) 100%);
    border: 2px solid var(--system-primary);
    box-shadow: 0 0 50px rgba(255, 180, 0, 0.3);
    text-align: center;
}
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
```