/* ═══ Final Approach — radar tower theme ═══ */

:root {
    --bg: #02100a;
    --panel: #061a10;
    --panel2: #0a2416;
    --line: #16402a;
    --phos: #3ee08a;          /* scope phosphor green */
    --amber: #ffbf5e;
    --danger: #ff4545;
    --cyan: #4dd2ff;
    --text: #d8f5e4;
    --muted: #6f9c84;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100%;
}
body {
    background-image:
        radial-gradient(ellipse at 20% -10%, rgba(30, 130, 80, .22), transparent 55%),
        radial-gradient(ellipse at 90% 115%, rgba(20, 90, 120, .14), transparent 50%);
}

h1, h2, h3 { font-weight: 700; letter-spacing: .04em; }
h2 { font-size: 1.05rem; color: var(--phos); text-transform: uppercase; margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: 'Consolas', monospace; }
.hidden { display: none !important; }

.btn {
    display: inline-block; background: var(--panel2); color: var(--text);
    border: 1px solid var(--line); border-radius: 8px; padding: 10px 18px;
    font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .15s;
    font-family: inherit;
}
.btn:hover { border-color: var(--phos); box-shadow: 0 0 14px rgba(62, 224, 138, .3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(180deg, #10663a, #0a4426); border-color: #2a9458; color: #d8ffe8; }
.btn-large { width: 100%; padding: 14px; font-size: 1.1rem; margin-top: 14px; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

input, select {
    width: 100%; background: #041408; border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); padding: 11px 12px; font-size: 1rem; margin: 6px 0 14px;
    font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--phos); box-shadow: 0 0 12px rgba(62, 224, 138, .25); }
label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.check-row { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: .9rem; margin-bottom: 6px; }
.check-row input { width: auto; margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* ── Home / lobby ── */
.home-container { max-width: 1000px; margin: 0 auto; padding: 28px 16px 60px; }
.hero { text-align: center; padding: 22px 0 30px; }
.game-title {
    font-size: clamp(2rem, 7vw, 3.6rem); letter-spacing: .14em; color: #eafff2;
    text-shadow: 0 0 24px rgba(62, 224, 138, .55);
}
.tagline { margin-top: 12px; color: var(--muted); line-height: 1.6; }
.tagline-hot { color: #a2e8c8; font-style: italic; }
.error-banner {
    background: rgba(255, 69, 69, .12); border: 1px solid #7a2020; color: #ffb0a0;
    border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; text-align: center;
}
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .home-grid { grid-template-columns: 1fr; } }

.registry-head { margin: 20px 0 8px; font-size: .9rem; color: var(--muted); text-transform: uppercase; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--phos); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.room-browser { list-style: none; max-height: 220px; overflow-y: auto; }
.room-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-bottom: 1px solid #0c2416; cursor: pointer; }
.room-row:hover { background: rgba(62, 224, 138, .06); }
.room-code { font-family: monospace; font-size: 1.05rem; color: var(--phos); letter-spacing: .12em; }
.room-row .btn { margin-left: auto; }
.empty-msg { padding: 14px 6px; }

.leaderboard-card { margin-top: 18px; }
.leaderboard { width: 100%; border-collapse: collapse; font-size: .9rem; }
.leaderboard th { color: var(--muted); text-align: left; font-size: .75rem; text-transform: uppercase; padding: 6px 8px; }
.leaderboard td { padding: 8px; border-top: 1px solid #0c2416; }
.crew-names { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.how-to { margin-top: 34px; }
.how-to > h2 { text-align: center; margin-bottom: 18px; }
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.how-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.how-icon { font-size: 1.6rem; display: block; margin-bottom: 8px; }
.how-card b { color: #fff; }
.how-card p { color: var(--muted); font-size: .87rem; margin-top: 6px; line-height: 1.5; }
.home-footer { text-align: center; margin-top: 30px; }

.lobby-container { max-width: 640px; margin: 0 auto; padding: 26px 16px 50px; text-align: center; }
.lobby-card { text-align: left; margin-bottom: 14px; }
.room-code-display { margin: 18px 0 6px; font-size: 1.1rem; }
.room-code-display .code { font-family: monospace; font-size: 1.6rem; color: var(--phos); letter-spacing: .25em; margin: 0 8px; }
.share-hint { color: var(--muted); margin-bottom: 22px; font-size: .9rem; }
.player-list { list-style: none; }
.player-item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid #0c2416; }
.player-dot { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 8px currentColor; flex: none; }
.player-name { font-weight: 600; }
.host-badge {
    background: #0e4426; color: var(--phos); font-size: .65rem;
    border: 1px solid #2a9458; padding: 2px 7px; border-radius: 20px; letter-spacing: .1em;
}
.waiting-msg { margin-top: 22px; color: var(--muted); }
.blink { animation: pulse 1.6s infinite; }
.start-hint { color: var(--muted); font-size: .85rem; margin-top: 10px; }

/* ═══ GAME SCREEN — full-bleed radar scope ═══ */
.game-body { position: fixed; inset: 0; overflow: hidden; }
#scope { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#hud-top {
    position: absolute; top: 0; left: 0; right: 0; z-index: 6;
    display: flex; align-items: center; gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 6px;
    pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
.mini-logo { font-weight: 800; letter-spacing: .06em; color: var(--phos); white-space: nowrap;
    text-shadow: 0 0 12px rgba(62, 224, 138, .6); }
.hud-chip {
    font-family: monospace; font-size: .85rem; color: var(--amber);
    background: rgba(6, 26, 16, .8); border: 1px solid var(--line);
    border-radius: 8px; padding: 4px 10px; white-space: nowrap;
}
#hearts { font-size: .85rem; letter-spacing: 1px; margin-left: auto; white-space: nowrap; }
.hud-icon-btn {
    background: rgba(6, 26, 16, .8); border: 1px solid var(--line); color: var(--text);
    width: 34px; height: 34px; border-radius: 10px; font-size: .95rem; cursor: pointer;
}

#roster-strip {
    position: absolute; top: calc(46px + env(safe-area-inset-top)); left: 12px; z-index: 6;
    display: flex; flex-wrap: wrap; gap: 5px; max-width: 70%;
}
.crew-pip {
    display: flex; align-items: center; gap: 6px; font-size: .7rem;
    background: rgba(6, 26, 16, .85); border: 1px solid #123420; border-radius: 20px;
    padding: 3px 10px 3px 5px;
}
.crew-pip .dot { width: 10px; height: 10px; border-radius: 50%; }
.crew-pip.away { opacity: .45; }
.crew-pip .qd { font-family: monospace; color: var(--muted); }

#event-banner {
    position: absolute; top: 22%; left: 50%; transform: translateX(-50%); z-index: 12;
    font-size: clamp(.95rem, 3.6vw, 1.4rem); font-weight: 800; letter-spacing: .1em;
    color: #d6ffe8; text-shadow: 0 0 18px rgba(62, 224, 138, .8); text-align: center;
    opacity: 0; pointer-events: none; transition: opacity .25s; white-space: nowrap;
}
#event-banner.show { opacity: 1; }
#event-banner.bad { color: #ffc0b0; text-shadow: 0 0 18px rgba(255, 69, 69, .8); }
#event-banner.good { color: #c8ffd8; text-shadow: 0 0 18px rgba(70, 224, 138, .8); }

#hint-toast {
    position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%); z-index: 6;
    background: rgba(6, 26, 16, .92); border: 1px solid var(--line); border-radius: 12px;
    color: var(--muted); font-size: .82rem; padding: 9px 16px; max-width: min(480px, 92vw);
    text-align: center; transition: opacity 1s; pointer-events: none;
}
#hint-toast.fade { opacity: 0; }
#hint-toast b { color: var(--amber); }

/* command panel — bottom sheet */
#cmd-panel {
    position: absolute; left: 50%; transform: translateX(-50%);
    bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 14;
    background: rgba(4, 20, 12, .96); border: 1px solid #2a9458; border-radius: 16px;
    padding: 10px 12px; width: min(380px, 94vw);
    box-shadow: 0 0 30px rgba(62, 224, 138, .25);
}
.cmd-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }
#cmd-callsign { font-family: monospace; font-weight: 800; font-size: 1.15rem; color: var(--amber); }
.cmd-dest { font-family: monospace; font-size: .8rem; color: var(--cyan); }
.cmd-fuel { font-family: monospace; font-size: .8rem; color: var(--muted); margin-left: auto; }
.cmd-fuel.low { color: var(--danger); animation: pulse .6s infinite; }
.cmd-close {
    background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer;
    padding: 2px 6px;
}
.cmd-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.cmd-compass { display: grid; grid-template-columns: repeat(5, 1fr); }
.cmd-label { font-size: .65rem; color: var(--muted); letter-spacing: .1em; width: 30px; }
.cmd-btn {
    background: var(--panel2); border: 1px solid var(--line); color: var(--text);
    border-radius: 9px; padding: 9px 0; font-weight: 700; font-size: .85rem;
    cursor: pointer; font-family: inherit; flex: 1; min-width: 44px;
}
.cmd-btn:active { transform: translateY(1px); }
.cmd-btn.active { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 10px rgba(255, 191, 94, .35); }
.cmd-btn.nudge { color: var(--cyan); }

/* chat dock */
#chat-dock {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
    background: linear-gradient(0deg, rgba(2, 12, 7, .97) 70%, transparent);
    padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
    max-width: 720px; margin: 0 auto;
}
#chat-log {
    max-height: 66px; overflow-y: auto; display: flex; flex-direction: column;
    gap: 2px; font-size: .8rem; padding-bottom: 4px;
}
.chat-line b { margin-right: 4px; }
.chat-line.sys { color: var(--phos); font-style: italic; }
#chat-bar { display: flex; gap: 6px; }
#chat-bar input { margin: 0; flex: 1; padding: 8px 12px; }

/* result overlay */
.overlay {
    position: fixed; inset: 0; z-index: 40; display: flex; align-items: center;
    justify-content: center; background: rgba(1, 8, 5, .88); padding: 14px;
}
.overlay-card {
    background: var(--panel); border: 1px solid #2a9458; border-radius: 16px;
    width: min(500px, 100%); padding: 26px; text-align: center;
}
#result-title { font-size: 1.5rem; letter-spacing: .12em; }
#result-title.lose { color: var(--danger); text-shadow: 0 0 20px rgba(255, 69, 69, .5); }
.result-stats {
    display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 16px 0;
    font-size: .8rem; color: var(--muted);
}
.result-stats b { display: block; font-size: 1.5rem; color: var(--phos); font-family: monospace; }
.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; align-items: center; }

@media (max-width: 700px) {
    .mini-logo { display: none; }
    #hint-toast { bottom: 150px; }
}
