:root {
    --bg-color: #0b0d17;
    --panel-bg: rgba(15, 25, 45, 0.82);
    --primary: #3388ff;
    --accent: #ff3333;
    --text: #e0e6ed;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: linear-gradient(180deg, #87CEFA 0%, #4682B4 100%);
    color: var(--text);
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.hidden { display: none !important; }

/* ── Canvas & UI Overlay ──────────────────────────── */
#gameCanvas {
    position: absolute; top: 0; left: 0;
    pointer-events: none;
}

#ui-overlay {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}

#ui-overlay button,
#ui-overlay input,
#ui-overlay select,
#lobby-id-hud,
#hud-top-tray,
#chat-box {
    pointer-events: all;
}

/* ── Overlay full-screen wrapper ──────────────────── */
.overlay-screen {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    display: flex; justify-content: center; align-items: center;
    z-index: 200;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
}

/* ── Glass Panel (menus / modals) ─────────────────── */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    border-radius: 16px;
    padding: 2.5rem;
    width: min(420px, 92vw);
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

/* Settings modal needs to contain all buttons inside */
#settings-modal .glass-panel {
    width: min(380px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 2.5rem 2.5rem 2rem 2.5rem;
    overflow: hidden;
}

#settings-modal .glass-panel > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Main Menu Container ──────────────────────────── */
#menu-container {
    position: fixed; top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 10;
    /* Don't use overflow:hidden — that clips content */
}

/* Patch Notes: anchored bottom-left */
#news-panel {
    position: absolute;
    bottom: 100px; left: 30px; /* Shifted up to make room for history bar */
    width: min(300px, 42vw);
    text-align: left;
    transform-origin: bottom left;
    z-index: 1;
}

#history-bar {
    position: absolute;
    bottom: 30px; left: 30px;
    width: min(300px, 42vw);
    transform-origin: bottom left;
    z-index: 1;
}

/* Main panel: anchored to right side, vertically centered */
#main-menu-panel {
    position: absolute;
    top: 50%;
    right: 5%;
    transform: translateY(-50%);
    max-height: 96vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    z-index: 1;
}

/* Shrink on small screens instead of clipping */
@media (max-height: 820px) {
    #main-menu-panel { transform: translateY(-50%) scale(0.88); transform-origin: right center; }
    #news-panel { transform: scale(0.88); }
}
@media (max-height: 660px) {
    #main-menu-panel { transform: translateY(-50%) scale(0.76); transform-origin: right center; }
    #news-panel { transform: scale(0.76); }
}

/* Narrow screens: stack vertically, center everything */
@media (max-width: 800px) {
    #menu-container {
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 30px 20px 60px;
        gap: 20px;
    }
    #main-menu-panel {
        position: static;
        transform: none;
        max-height: none;
        width: min(420px, 96vw);
    }
    #news-panel {
        position: static;
        transform: none;
        width: min(420px, 96vw);
        order: 2; /* news below the main panel on mobile */
    }
}

/* ── Typography ───────────────────────────────────── */
h1.glitch {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem; font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(51,136,255,0.8);
    margin-bottom: 0.2rem;
}

.subtitle {
    color: #a0aec0;
    margin-bottom: 1.5rem;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem; letter-spacing: 1px;
}

.form-group { margin-bottom: 1.2rem; text-align: left; }
.form-group label {
    display: block; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 0.4rem; color: #cbd5e0;
}

input[type="text"] {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    color: white; padding: 0.8rem;
    border-radius: 8px; font-size: 1rem;
    outline: none; transition: 0.3s;
}
input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 10px rgba(51,136,255,0.4); }

/* Color Picker */
.color-picker-group .colors { display: flex; gap: 10px; justify-content: center; }
.color-picker-group input[type="radio"] { display: none; }
.color-picker-group label {
    width: 32px; height: 32px; border-radius: 50%;
    cursor: pointer; border: 3px solid transparent; transition: 0.2s;
}
.color-picker-group input[type="radio"]:checked + label { border-color: white; transform: scale(1.2); }

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem; border-radius: 8px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem; font-weight: 700;
    letter-spacing: 1px; cursor: pointer;
    border: none; transition: all 0.2s; width: 100%;
}
.btn.primary { background: linear-gradient(135deg, #3388ff, #0055cc); color: white; }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(51,136,255,0.5); }
.btn.secondary { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); }
.btn.secondary:hover { background: rgba(255,255,255,0.2); }

.action-buttons { display: flex; flex-direction: column; gap: 6px; }
.or-divider { display: flex; align-items: center; gap: 10px; color: #718096; margin: 4px 0; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }

/* ── HUD Glass Panel (ONLY VISUAL STYLING — no absolute position here) ── */
/* Individual HUD elements manage their own position */
.glass-panel-hud {
    background: rgba(10, 20, 40, 0.72);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    padding: 10px 14px;
    color: white;
    font-size: 0.8rem;
    font-family: 'Orbitron', sans-serif;
}

/* ── HUD: Top Status Bars (absolute, centered) ──── */
.hud-top {
    position: absolute;
    top: 12px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 20px;
}

.status-bar label { display: block; font-size: 0.65rem; color: #a0aec0; margin-bottom: 3px; text-transform: uppercase; }
.bar-bg { width: 120px; height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.15s; }
.bar-fill.fuel  { background: linear-gradient(90deg, #ffcc00, #ff8800); width: 100%; }
.bar-fill.hp    { background: linear-gradient(90deg, #33ff33, #00aa00); width: 100%; }
.bar-fill.ammo  { background: linear-gradient(90deg, #3388ff, #0055cc); width: 100%; }

/* ── HUD: Timer + Kills (absolute, top-centre) ─── */
#hud-centre {
    position: absolute;
    top: 70px; left: 50%; transform: translateX(-50%);
    text-align: center; min-width: 130px;
}
#hud-timer {
    font-size: 1.4rem; font-weight: 700; color: white;
    font-family: 'Orbitron', sans-serif; letter-spacing: 2px;
}
#hud-kills {
    font-size: 0.7rem; color: #ffcc00; margin-top: 3px;
    letter-spacing: 1px;
}

/* ── HUD: Lobby Code (top-right, in-game) ────────── */
#lobby-display {
    position: absolute;
    top: 12px; right: 12px;
    display: flex; align-items: center; gap: 8px;
    font-size: 0.75rem;
}
#lobby-id-hud {
    background: #3b82f6;
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 8px #3b82f6;
    transition: background 0.2s;
    user-select: text;
}
#lobby-id-hud:hover { background: #2563eb; }
#lobby-id-hud.flash-success { background: rgba(51,255,51,0.5); color: #fff; }
.copy-hint { color: #a0aec0; font-size: 0.65rem; }

/* ── HUD: Controls (bottom-right) ────────────────── */
#controls-hud {
    position: absolute;
    bottom: 20px; right: 20px;
    font-size: 0.72rem; line-height: 1.8;
}
.key {
    display: inline-block;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px; padding: 1px 6px;
    font-weight: bold;
}

/* ── HUD: Comms Widget (bottom-left) ─────────────── */
/* The wrapper handles absolute positioning.
   Children are flex items (NOT absolute) */
#hud-comms-wrapper {
    position: absolute;
    bottom: 20px; left: 20px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: all;
}

#hud-comms-wrapper #hud-top-tray,
#hud-comms-wrapper #chat-box {
    /* Override any inherited position:absolute — stay in flex flow */
    position: static;
    display: flex;
}

#hud-top-tray {
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
}

#hud-top-tray #lobby-display-unified {
    color: #ddd;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#lobby-id-hud-inline {
    background: #3b82f6;
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 8px #3b82f6;
    transition: background 0.2s;
    user-select: text;
}
#lobby-id-hud-inline:hover { background: #2563eb; }
#lobby-id-hud-inline.flash-success { background: rgba(51,255,51,0.5); }

#copy-hint-txt {
    color: #4ade80;
    font-size: 11px;
    display: none;
    text-shadow: 0 0 5px #4ade80;
}

#btn-settings-hud {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0 4px;
    line-height: 1;
}
#btn-settings-hud:hover { color: #fff; }

#chat-box {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}

#chat-log {
    height: 130px;
    overflow-y: auto;
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

#chat-input {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 4px;
    display: none;
    outline: none;
    width: 100%;
    font-family: 'Roboto', sans-serif;
}
#chat-input:focus { border-color: #3388ff; }

/* ── HUD: Killfeed ────────────────────────────────── */
#killfeed {
    position: absolute; top: 100px; right: 12px;
    display: flex; flex-direction: column; gap: 4px; align-items: flex-end;
}
.killfeed-item {
    background: rgba(0,0,0,0.55);
    border-left: 3px solid #ffcc00;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Orbitron', sans-serif;
    color: white;
    animation: fadeIn 0.3s;
}

/* ── HUD: Warnings ────────────────────────────────── */
#damage-warning, #resupply-warning {
    position: absolute; left: 50%; transform: translateX(-50%);
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    animation: blink 1s infinite alternate;
    pointer-events: none;
}
#damage-warning  { color: #ff3333; text-shadow: 0 0 10px red; bottom: 80px; }
#resupply-warning { color: #ffbb33; text-shadow: 0 0 10px orange; bottom: 40px; }

@keyframes blink {
    from { opacity: 1; }
    to   { opacity: 0.3; }
}

/* ── CRT Ad Panels ────────────────────────────────── */
.crt-ad-container {
    background: #0f1c13;
    border-radius: 8px; padding: 10px;
    box-shadow: inset 0 0 20px rgba(0,0,0,.8), 0 0 10px rgba(50,255,100,.4);
    border: 2px solid #234b33;
    margin: 20px 0;
}
.crt-screen {
    position: relative;
    background: repeating-linear-gradient(0deg, rgba(0,0,0,.15), rgba(0,0,0,.15) 1px, transparent 1px, transparent 2px);
    overflow: hidden; height: 100px;
    display: flex; align-items: center; justify-content: center;
}
.crt-screen::before {
    content: " "; display: block; position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,.25) 50%),
                linear-gradient(90deg, rgba(255,0,0,.06), rgba(0,255,0,.02), rgba(0,0,255,.06));
    z-index: 2; background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}
.sponsor-feed {
    color: #4ade80; font-family: 'Orbitron', monospace; font-size: 12px;
    text-shadow: 0 0 5px rgba(74,222,128,.8);
    display: flex; align-items: center; justify-content: center; width: 100%;
}

/* ── Death / Winner panels ────────────────────────── */
.death-panel {
    background: rgba(30,10,10,.85);
    border: 1px solid rgba(255,50,50,.4);
    box-shadow: 0 10px 50px rgba(255,0,0,.2);
}
.death-panel h1 { color: #ff3333; text-shadow: 0 0 15px rgba(255,51,51,.8); }

/* ── Settings Modal ───────────────────────────────── */
#settings-modal { z-index: 500; }
#winner-screen  { z-index: 300; background: rgba(0,0,0,.7); }

/* ── Lobby Waiting Room ───────────────────────────── */
.lobby-room-panel {
    width: min(920px, 96vw);
    max-height: 94vh;
    overflow-y: auto;
    text-align: left; padding: 2rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.lobby-header {
    border-bottom: 1px solid rgba(255,255,255,.1);
    padding-bottom: 1rem; margin-bottom: 1.5rem;
}
.lobby-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.2rem; color: #fff;
    margin-bottom: 8px;
}
.lobby-code-row { font-size: 0.82rem; color: #a0aec0; }
.wait-code {
    background: rgba(51,136,255,.2);
    border: 1px solid rgba(51,136,255,.5);
    padding: 3px 10px; border-radius: 5px;
    font-weight: bold; color: var(--primary);
    cursor: pointer; letter-spacing: 2px;
    font-family: 'Orbitron', sans-serif;
}
.lobby-body {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 1rem;
}
@media (max-width: 700px) {
    .lobby-body { grid-template-columns: 1fr; }
}
.lobby-section h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem; color: #a0aec0;
    letter-spacing: 1px; margin-bottom: 12px;
    text-transform: uppercase;
}
.player-list { display: flex; flex-direction: column; gap: 8px; }
.player-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,.07);
    border-radius: 8px; padding: 8px 12px;
    font-size: 0.9rem;
}

/* ── Team Boxes ───────────────────────────────────── */
.team-box {
    flex: 1 1 150px;
    min-width: 150px;
    min-height: 110px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.team-box h3 {
    margin: 0; padding: 8px; font-size: 0.8rem;
    text-align: center; color: #fff;
    text-shadow: 0 0 5px rgba(255,255,255,0.5);
    font-family: 'Orbitron', sans-serif;
}
.team-box .list {
    padding: 8px; display: flex; flex-direction: column; gap: 6px; flex-grow: 1;
}
.team-box .player-row {
    background: rgba(255,255,255,.04); padding: 4px 8px; font-size: 0.8rem; border-radius: 4px;
}
.team-box button {
    border: none; padding: 8px; cursor: pointer;
    font-family: 'Orbitron', sans-serif; font-size: 0.75rem; font-weight: bold;
    color: #fff; background: rgba(255,255,255,0.1); transition: 0.2s;
}
.team-box button:hover { background: rgba(255,255,255,0.25); }
.pilot-color {
    width: 14px; height: 14px; border-radius: 50%;
    flex-shrink: 0; border: 2px solid rgba(255,255,255,.3);
}

/* ── Mission Rules ────────────────────────────────── */
.rule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
}
.rule-item label {
    font-size: 0.8rem;
    color: #cbd5e0;
    white-space: nowrap;
    flex-shrink: 0;
}
.rule-select {
    background: rgba(0,0,0,.4); color: white;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 6px; padding: 5px 10px;
    font-family: 'Orbitron', sans-serif; font-size: 0.75rem;
    outline: none; cursor: pointer;
    min-width: 140px;      /* <-- fixed: all dropdowns same width */
    text-align: right;
}

/* ── Service Record / Patch History UI ─────────────────── */
/* #history-bar position moved to main layout section above */
#history-bar { margin: 0; } /* Reset margin since it now uses absolute positioning */

@media (max-height: 820px) { #history-bar { transform: scale(0.88); } }
@media (max-height: 660px) { #history-bar { transform: scale(0.76); } }

#btn-view-history:hover { color: white !important; }

#modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
}

#patch-history-modal {
    max-width: 520px; width: 92%; max-height: 85vh; padding: 32px;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from { transform: scale(0.95); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.history-list { list-style-type: none; }
.history-list li::before {
    content: "•"; color: #4ade80; display: inline-block;
    width: 1.2em; margin-left: -1.2em;
}

