:root {
    --bg-dark: #0f172a;
    --panel-bg: #1e293b;
    --brick-base: #b45309;
    --brick-edge: #78350f;
    --void-sky: #334155;
    --detonation: #ef4444;
    --gold: #f59e0b;
    --text-white: #f8fafc;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.game-wrapper {
    max-width: 1000px;
    width: 100%;
    text-align: center;
}

h1 { color: var(--gold); margin-bottom: 2px; }
.tagline { margin-top: 0; color: #64748b; font-size: 0.95rem; }

.panel {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.7);
}

.hidden { display: none !important; }

/* --- LOBBY --- */
.form-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
}
.form-row label { color: #94a3b8; font-size: 0.85rem; }

input[type="text"] {
    background: #0f172a;
    border: 2px solid #475569;
    color: var(--text-white);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 1rem;
    text-align: center;
}
input[type="text"]:focus { outline: none; border-color: var(--gold); }

.lobby-actions {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.lobby-box {
    background: #0f172a;
    border: 2px solid #475569;
    border-radius: 8px;
    padding: 20px;
    width: 260px;
}
.lobby-box p { color: #94a3b8; font-size: 0.85rem; min-height: 34px; }
.lobby-box input { width: 100%; box-sizing: border-box; margin-bottom: 10px; letter-spacing: 4px; }

.error-msg { color: var(--detonation); margin-top: 16px; min-height: 20px; font-weight: bold; }

/* --- QUICK PLAY (vs Computer) --- */
.quick-play { margin: 4px 0 20px; }
.quick-play-note { color: #64748b; font-size: 0.8rem; margin-top: 6px; }

.ai-btn {
    background: linear-gradient(135deg, #059669, #10b981);
    padding: 16px 36px;
    font-size: 1.05rem;
}

.divider {
    display: flex;
    align-items: center;
    color: #475569;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 20px 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #334155;
}
.divider span { padding: 0 14px; }

/* --- HOW TO PLAY --- */
.how-to-play {
    margin-top: 24px;
    text-align: left;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px 18px;
}
.how-to-play summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--gold);
    outline: none;
}
.how-to-play ul { margin: 12px 0 4px; padding-left: 20px; color: #cbd5e1; font-size: 0.9rem; line-height: 1.6; }
.how-to-play li { margin-bottom: 4px; }

/* --- WAITING --- */
.room-code {
    font-size: 2.5rem;
    font-weight: bold;
    letter-spacing: 10px;
    color: var(--gold);
    background: #0f172a;
    padding: 16px 24px;
    border-radius: 8px;
    display: inline-block;
    margin: 16px 0;
}
.waiting-text { color: #94a3b8; }

/* --- PLACEMENT SCREEN --- */
.placement-hint { color: #94a3b8; font-size: 0.9rem; margin-top: -8px; margin-bottom: 20px; }

.placement-layout {
    display: flex;
    gap: 32px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.unit-palette {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 140px;
}

.palette-item {
    background: #0f172a;
    border: 2px solid #475569;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    cursor: grab;
    transition: all 0.15s ease;
    user-select: none;
}
.palette-item:active { cursor: grabbing; }
.palette-item.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(245,158,11,0.3); }
.palette-item.depleted { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.palette-token {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    margin: 0 auto 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
    color: white;
}

.palette-label { font-size: 0.8rem; color: #cbd5e1; }
.palette-count { font-weight: bold; color: var(--gold); font-size: 0.9rem; margin-top: 2px; }

.placement-board-wrap { display: flex; flex-direction: column; align-items: center; }

.placement-tile { cursor: grab; }
.placement-tile:hover:not(.unit-B):not(.unit-L):not(.unit-D) { filter: brightness(1.25); }

.placement-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

#placement-status { color: var(--gold); font-size: 0.9rem; margin-top: 14px; min-height: 18px; }

/* --- CHARACTER / BUTTONS --- */
.character-select {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.char-card {
    background: #0f172a;
    border: 2px solid #475569;
    border-radius: 8px;
    padding: 16px;
    width: 180px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-card.active {
    border-color: var(--gold);
    background: #1e293b;
    transform: scale(1.05);
}

.avatar { font-size: 2.5rem; margin-bottom: 8px; }

.btn {
    background: #2563eb;
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: #334155; }
.btn.leave-btn {
    background: transparent;
    color: #94a3b8;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: normal;
    float: right;
}
.btn.leave-btn:hover { color: var(--detonation); }

/* --- MATCH HEADER --- */
#match-header {
    font-size: 1.1rem;
    font-weight: bold;
    color: #cbd5e1;
    margin-bottom: 10px;
}
#match-header .vs { color: var(--gold); margin: 0 8px; }

/* --- BOARDS --- */
.boards-container {
    display: flex;
    gap: 40px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

.board-box h3 { margin-bottom: 8px; }

.labels-x {
    display: grid;
    grid-template-columns: 30px repeat(10, 38px);
    gap: 3px;
    color: #94a3b8;
    font-weight: bold;
    margin-bottom: 4px;
}
.labels-x span { display: flex; align-items: center; justify-content: center; }

/* Single flat CSS grid: column 1 = row labels (A-J), columns 2-11 = the
   10x10 tiles. All 110 cells are appended in order by client.js, so the
   browser's grid auto-placement lines everything up correctly. */
.grid-layout {
    display: grid;
    grid-template-columns: 30px repeat(10, 38px);
    grid-auto-rows: 38px;
    gap: 3px;
    background: #0f172a;
    padding: 3px;
    border-radius: 6px;
}

.label-y {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #94a3b8;
}

#matrix-grid, .matrix-grid { transition: opacity 0.2s ease; }
.matrix-grid.locked { opacity: 0.45; }
.matrix-grid.locked .tile { cursor: not-allowed !important; }

.tile {
    width: 38px;
    height: 38px;
    background: var(--brick-base);
    border: 1px solid var(--brick-edge);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
}

.tile.empty-space { background: var(--void-sky); border-color: #1e293b; cursor: default; }
.tile.ruined { background: var(--detonation); color: white; border-color: #b91c1c; cursor: default; }

.tile.unit-B { background: #10b981; border-color: #047857; color: white; }
.tile.unit-L { background: #06b6d4; border-color: #0e7490; color: white; }
.tile.unit-D { background: #f59e0b; border-color: #b45309; color: white; }

#turn-alert {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--gold);
    margin-bottom: 15px;
}

.squad-status {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
}
.b-badge { background: #10b981; }
.l-badge { background: #06b6d4; }
.d-badge { background: #f59e0b; }

.intel-panel { margin-top: 10px; color: #94a3b8; font-size: 0.85rem; }

#terminal-log {
    margin-top: 25px;
    background: #0f172a;
    padding: 12px;
    border-radius: 8px;
    height: 120px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.85rem;
    text-align: left;
}

/* --- MATCH OVER --- */
#over-screen p { color: #94a3b8; }
.over-actions { display: flex; gap: 12px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
#rematch-status { font-size: 0.85rem; color: var(--gold); min-height: 18px; margin-top: 10px; }

.hero-picker {display:flex;gap:12px;justify-content:center;flex-wrap:wrap}.hero.selected {outline:2px solid #ff6a1a;box-shadow:0 0 18px #ff6a1a44}.online-player {display:block;width:100%;margin:10px 0;text-align:left;border-color:#19e3e3}#online-players{padding:12px;color:#a9c1d5;min-height:70px}.developer-credit{font-size:12px;line-height:1.6;text-align:center;color:#93a5b8;padding:24px}.hero:disabled{opacity:.7}
