/* ====================================================
   SNAKE PRO MAX — UI v2 (Phase 1, 2026-09-22)
   Additive layer on top of style.css. Remove the
   <link href="ui-v2.css"> line to fall back visually.
   ==================================================== */
:root {
    --bg: #040912;
    --panel: rgba(9, 18, 36, 0.72);
    --panel-2: rgba(14, 26, 50, 0.6);
    --line: rgba(56, 189, 248, 0.26);
    --line-strong: rgba(56, 189, 248, 0.55);
    --cyan: #22d3ee;
    --cyan-2: #38bdf8;
    --text: #e6edf7;
    --muted: #8da2bf;
    --gold: #fbbf24;
    --good: #22c55e;
    --warn: #f59e0b;
    --bad: #ef4444;
    --radius: 16px;
    --font-ui: 'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-hud: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
    --glow: 0 0 0 1px rgba(56,189,248,0.10) inset, 0 0 22px rgba(34,211,238,0.10), 0 10px 30px rgba(0,0,0,0.45);
}

body {
    font-family: var(--font-ui);
    background:
        radial-gradient(1.2px 1.2px at 12% 18%, rgba(255,255,255,0.55) 50%, transparent 51%),
        radial-gradient(1px 1px at 72% 12%, rgba(255,255,255,0.45) 50%, transparent 51%),
        radial-gradient(1.4px 1.4px at 88% 64%, rgba(186,230,253,0.5) 50%, transparent 51%),
        radial-gradient(1px 1px at 34% 82%, rgba(255,255,255,0.35) 50%, transparent 51%),
        radial-gradient(1px 1px at 55% 40%, rgba(255,255,255,0.25) 50%, transparent 51%),
        radial-gradient(ellipse at 50% 45%, #0b1a33 0%, var(--bg) 70%);
    background-color: var(--bg);
}
body::before {
    background:
        radial-gradient(1px 1px at 20% 60%, rgba(255,255,255,0.3) 50%, transparent 51%) 0 0 / 180px 160px,
        radial-gradient(1px 1px at 70% 30%, rgba(186,230,253,0.28) 50%, transparent 51%) 0 0 / 240px 210px,
        radial-gradient(ellipse at 15% 50%, rgba(6, 182, 212, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 15%, rgba(168, 85, 247, 0.06) 0%, transparent 50%);
}

.ico { width: 22px; height: 22px; display: block; }

/* ---------- SHELL GRID ---------- */
#game-shell {
    position: fixed; inset: 0; z-index: 1;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 262px;
    grid-template-rows: 76px minmax(0, 1fr) 34px;
    grid-template-areas: "top top top" "left arena right" "foot foot foot";
    column-gap: 22px;
    padding: 0 max(22px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(22px, env(safe-area-inset-left));
    box-sizing: border-box;
    pointer-events: none;
}
#game-shell > * { pointer-events: auto; min-width: 0; min-height: 0; }
/* decorative planet (bottom-left) */
#game-shell::before, #game-shell::after {
    content: ''; position: fixed; pointer-events: none; z-index: -1; border-radius: 50%;
}
#game-shell::before {
    width: 520px; height: 520px; left: -300px; bottom: -330px;
    background: radial-gradient(circle at 70% 30%, #1c3b6b 0%, #0b1a33 45%, #050b16 70%);
    box-shadow: -6px -6px 40px rgba(56,189,248,0.35), inset 10px 10px 30px rgba(125,211,252,0.25);
    opacity: 0.85;
}
#game-shell::after {
    width: 260px; height: 260px; right: -170px; top: -150px;
    background: radial-gradient(circle at 30% 70%, #1d3a66 0%, #0a1830 55%, #050b16 75%);
    box-shadow: 0 0 30px rgba(56,189,248,0.25), inset -6px 8px 20px rgba(125,211,252,0.25);
    opacity: 0.7;
}

/* ---------- TOP BAR ---------- */
#topbar { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 44px; height: 44px; filter: drop-shadow(0 0 8px rgba(34,211,238,0.55)); }
.brand-name {
    font-family: var(--font-hud); font-weight: 700; font-style: italic;
    font-size: 30px; letter-spacing: 1.5px; line-height: 1; color: #f1f5f9;
    text-shadow: 0 0 14px rgba(56,189,248,0.25);
}
.brand-name span {
    background: linear-gradient(90deg, #67e8f9, #3b82f6);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-name em {
    font-style: normal; font-size: 11px; letter-spacing: 2px; margin-left: 6px;
    padding: 2px 6px; border-radius: 6px; vertical-align: middle;
    border: 1px solid var(--line-strong); color: var(--cyan);
}
.brand-sub { font-size: 10px; letter-spacing: 5px; color: var(--muted); margin-top: 4px; }
.topbar-tag { font-size: 11px; letter-spacing: 4px; color: var(--muted); }
.topbar-mobile { display: none; }

/* ---------- CARDS ---------- */
.hud-card {
    background: linear-gradient(180deg, rgba(16, 30, 58, 0.72), rgba(8, 16, 32, 0.78));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--glow);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    padding: 16px 18px;
    box-sizing: border-box;
}
.col-label { font-size: 10px; letter-spacing: 3px; color: var(--muted); margin: 2px 2px 6px; }

/* ---------- LEFT COLUMN ---------- */
#col-left { grid-area: left; display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; overflow: hidden; }

#hud-me .hm-head { display: flex; justify-content: space-between; align-items: flex-start; }
.hm-label { font-family: var(--font-hud); font-weight: 700; font-size: 20px; color: var(--cyan); letter-spacing: 1px; text-shadow: 0 0 10px rgba(34,211,238,0.5); }
.hm-name { font-size: 12px; color: var(--muted); max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-orb {
    --c: #22d3ee;
    width: 38px; height: 38px; border-radius: 50%; position: relative; flex: none;
    background: radial-gradient(circle at 35% 30%, #ffffff 0 8%, color-mix(in srgb, var(--c) 60%, white) 18%, var(--c) 48%, color-mix(in srgb, var(--c) 45%, black) 100%);
    box-shadow: 0 0 18px var(--c), inset 0 -4px 8px rgba(0,0,0,0.35);
}
.hm-orb i { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #fff; top: 13px; left: 11px; box-shadow: 11px 0 0 #fff; }
.hm-orb i::after { content: ''; position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #0b1020; top: 2px; left: 3px; box-shadow: 11px 0 0 #0b1020; }
.hm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.hm-stat { display: flex; flex-direction: column; }
.hm-k { font-size: 12px; color: var(--muted); }
.hm-v { font-family: var(--font-hud); font-weight: 700; font-size: 30px; line-height: 1.05; color: #fff; font-variant-numeric: tabular-nums; }
.hm-lives { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.hearts { display: inline-flex; gap: 5px; align-items: center; }
.hearts svg { width: 18px; height: 18px; }
.hearts .on { color: #f43f5e; filter: drop-shadow(0 0 5px rgba(244,63,94,0.7)); }
.hearts .off { color: rgba(148,163,184,0.25); }
.hearts .dead { font-size: 12px; color: var(--bad); font-weight: 700; letter-spacing: 1px; }
.hm-effects { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.hm-effects:empty { display: none; }
.fx-chip { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: rgba(251,191,36,0.12); border: 1px solid rgba(251,191,36,0.35); color: var(--gold); font-weight: 600; }

/* existing player list (all players) re-housed in the column */
#left-ui {
    position: static; width: auto; top: auto; left: auto;
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
    pointer-events: auto; align-items: stretch;
    scrollbar-width: thin; scrollbar-color: rgba(56,189,248,0.3) transparent;
}
#ping-display { display: none; }
#player-list { display: flex; flex-direction: column; gap: 6px; }
#game-shell .player-card {
    margin: 0; transform: none; border-radius: 10px;
    background: var(--panel-2); padding: 7px 10px;
    border: 1px solid rgba(56,189,248,0.12); border-left: 3px solid rgba(71,85,105,0.6);
    box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
    display: grid; grid-template-columns: 1fr auto; column-gap: 8px; align-items: center;
}
#game-shell .player-card.is-me { background: rgba(34,211,238,0.08); border-color: rgba(34,211,238,0.35); }
#game-shell .pc-name { font-size: 12px; text-transform: none; color: var(--text); }
#game-shell .pc-score { font-family: var(--font-hud); font-size: 17px; grid-row: span 2; }
#game-shell .pc-lives { font-size: 9px; }
#game-shell .pc-effects { grid-column: 1 / -1; }
#action-log { margin-top: 8px; }
#game-shell .log-entry { font-size: 11px; padding: 3px 8px; border-radius: 6px; }

/* home / pause / restart */
#controls {
    position: static; flex-direction: row; gap: 10px; margin-top: auto; z-index: auto;
}
#game-shell .ctrl-btn {
    flex: 1; width: auto; height: 46px; border-radius: 12px;
    background: var(--panel-2); border: 1px solid var(--line);
    box-shadow: var(--glow);
}
#game-shell .ctrl-btn:hover { border-color: var(--line-strong); }

/* connection card */
.hn-head { display: flex; align-items: center; justify-content: space-between; }
.hn-title { font-size: 13px; letter-spacing: 1.5px; color: var(--text); font-weight: 600; }
.hn-ping { font-family: var(--font-hud); font-weight: 700; font-size: 20px; color: var(--q, var(--muted)); font-variant-numeric: tabular-nums; }
.hn-body { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.hn-sig { display: inline-flex; align-items: flex-end; gap: 4px; height: 30px; }
.hn-sig i { width: 7px; border-radius: 2px; background: rgba(148,163,184,0.2); }
.hn-sig i:nth-child(1) { height: 25%; } .hn-sig i:nth-child(2) { height: 50%; }
.hn-sig i:nth-child(3) { height: 75%; } .hn-sig i:nth-child(4) { height: 100%; }
.hn-row { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; color: var(--q, var(--muted)); }
.hn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--q, var(--muted)); box-shadow: 0 0 8px var(--q, transparent); }
.hn-desc { font-size: 11px; color: var(--muted); margin-top: 3px; }
[data-q="good"] { --q: var(--good); } [data-q="fair"] { --q: var(--warn); }
[data-q="bad"], [data-q="off"] { --q: var(--bad); } [data-q="wait"] { --q: var(--muted); }
[data-bars="1"] .hn-sig i:nth-child(-n+1), [data-bars="2"] .hn-sig i:nth-child(-n+2),
[data-bars="3"] .hn-sig i:nth-child(-n+3), [data-bars="4"] .hn-sig i:nth-child(-n+4) { background: var(--q); box-shadow: 0 0 6px var(--q); }

/* ---------- ARENA ---------- */
#arena { grid-area: arena; display: flex; align-items: center; justify-content: center; position: relative; padding-bottom: 14px; }
#arena canvas {
    display: block; border-radius: 18px;
    box-shadow: 0 0 0 1.5px var(--line-strong), 0 0 26px rgba(34,211,238,0.35), 0 0 70px rgba(34,211,238,0.12), 0 20px 50px rgba(0,0,0,0.55);
}

/* ---------- RIGHT COLUMN ---------- */
#col-right { grid-area: right; display: flex; flex-direction: column; gap: 14px; }
#leaderboard {
    position: static; width: auto; top: auto; right: auto;
    pointer-events: auto; font-size: 14px;
    background: linear-gradient(180deg, rgba(16, 30, 58, 0.72), rgba(8, 16, 32, 0.78));
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--glow);
    padding: 14px 12px 10px;
}
#leaderboard .lb-title {
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text); text-shadow: none; border: 0; margin: 0 4px 10px; padding: 0; text-align: left;
}
.lb-t { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 1.5px; font-size: 14px; }
.lb-t .ico { color: var(--gold); filter: drop-shadow(0 0 6px rgba(251,191,36,0.6)); }
.lb-online { font-size: 11px; color: var(--muted); font-weight: 500; }
#lb-content { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 13px; }
#leaderboard .lb-row {
    display: grid; grid-template-columns: 26px minmax(0,1fr) auto; align-items: center; gap: 10px;
    padding: 6px 8px; margin: 0; border-radius: 9px; border: 1px solid transparent;
}
#leaderboard .lb-row:nth-child(even) { background: rgba(148,163,184,0.04); }
#leaderboard .lb-row.r1 { background: linear-gradient(90deg, rgba(251,191,36,0.16), rgba(251,191,36,0.03)); border-color: rgba(251,191,36,0.3); }
.lb-rank {
    width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
    font-size: 12px; font-weight: 700; color: #cbd5e1; background: rgba(51,65,85,0.7);
}
.r1 .lb-rank { background: linear-gradient(180deg, #fde68a, #d97706); color: #1c1203; box-shadow: 0 0 8px rgba(251,191,36,0.6); }
.r2 .lb-rank { background: linear-gradient(180deg, #7dd3fc, #2563eb); color: #04111f; }
.r3 .lb-rank { background: linear-gradient(180deg, #fdba74, #b45309); color: #1c0d03; }
#leaderboard .lb-name { max-width: none; color: var(--text); font-weight: 600; font-size: 14px; }
#leaderboard .lb-score { font-family: var(--font-hud); font-weight: 700; font-size: 17px; color: #fff; font-variant-numeric: tabular-nums; }

/* ---------- FLOATING ACTION BUTTONS ---------- */
#menu-container { bottom: calc(48px + env(safe-area-inset-bottom)); right: max(34px, env(safe-area-inset-right)); gap: 12px; }
#menu-container .round-btn {
    width: 54px; height: 54px; color: #e2f6ff;
    background: radial-gradient(circle at 50% 35%, rgba(30,58,100,0.9), rgba(8,16,32,0.92));
    border: 1.5px solid var(--line-strong);
    box-shadow: 0 0 16px rgba(34,211,238,0.28), inset 0 1px 0 rgba(255,255,255,0.1), 0 8px 18px rgba(0,0,0,0.45);
}
#menu-container .round-btn:hover { box-shadow: 0 0 24px rgba(34,211,238,0.5), inset 0 1px 0 rgba(255,255,255,0.12); }
#menu-container .round-btn.has-new::after { top: 2px; right: 2px; }
#lb-toggle { display: none !important; }
#menu-content { border-radius: var(--radius); border-color: var(--line); margin-bottom: 8px; }

/* ---------- FOOTER ---------- */
#footbar { grid-area: foot; display: flex; align-items: center; justify-content: space-between; font-size: 10px; letter-spacing: 3px; color: rgba(141,162,191,0.7); }

/* overlays positioned against arena feel */
#notification-area { top: 86px; }
#warning-overlay { font-family: var(--font-hud); }
.pause-text { font-family: var(--font-hud); }

/* ---------- MEDIUM DESKTOP ---------- */
@media (max-width: 1280px) {
    #game-shell { grid-template-columns: 220px minmax(0,1fr) 230px; column-gap: 16px; }
    .topbar-tag { display: none; }
    .hm-v { font-size: 26px; }
}

/* ---------- MOBILE / TABLET PORTRAIT ---------- */
@media (max-width: 900px) and (orientation: portrait), (max-width: 700px) {
    #game-shell {
        grid-template-columns: minmax(0,1fr);
        grid-template-rows: 54px auto minmax(0,1fr) 70px;
        grid-template-areas: "top" "left" "arena" "foot";
        padding: env(safe-area-inset-top) 10px env(safe-area-inset-bottom) 10px;
    }
    #game-shell::before, #game-shell::after { display: none; }
    .brand-mark { width: 32px; height: 32px; }
    .brand-name { font-size: 19px; white-space: nowrap; } .brand-name em, .brand-sub, .topbar-tag { display: none; }
    .brand { gap: 6px; min-width: 0; }
    .topbar-mobile { display: flex; gap: 6px; align-items: center; }
    .pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; white-space: nowrap; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; }
    .pill small { font-size: 9px; color: var(--muted); letter-spacing: 1px; }
    .pill b { font-family: var(--font-hud); font-size: 16px; }
    .pill.hearts svg { width: 13px; height: 13px; }
    .net-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--q); box-shadow: 0 0 6px var(--q); }
    .net-pill b { color: var(--q); font-size: 14px; }

    #col-left { flex-direction: column; gap: 6px; padding: 0 0 6px; overflow: visible; }
    #hud-me, #hud-net, .col-label, #action-log { display: none; }
    #left-ui { overflow-x: auto; overflow-y: hidden; flex: none; }
    #player-list { flex-direction: row; gap: 6px; }
    #game-shell .player-card { flex: none; width: auto; min-width: 96px; max-width: 150px; padding: 4px 9px; background: rgba(9,18,36,0.6) !important; }
    #game-shell .pc-score { font-size: 15px; }
    #game-shell .pc-lives { display: none; }
    #controls { position: fixed; left: 10px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20; margin: 0; gap: 6px; }
    #game-shell .ctrl-btn { width: 42px; height: 42px; flex: none; border-radius: 11px; }
    #game-shell .ctrl-btn .ico, #menu-container .round-btn .ico { width: 19px; height: 19px; }
    #footbar { visibility: hidden; }
    #arena { padding: 0; }
    #arena canvas { border-radius: 12px; }
    #col-right { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; background: rgba(2,6,14,0.7); backdrop-filter: blur(6px); padding: 20px; }
    body.lb-open #col-right { display: flex; }
    body.lb-open #leaderboard { width: min(340px, 92vw); }
    #lb-toggle { display: flex !important; }
    #menu-container { flex-direction: row-reverse; align-items: flex-end; bottom: calc(12px + env(safe-area-inset-bottom)); right: 10px; gap: 6px; }
    #menu-container .round-btn { width: 42px; height: 42px; }
    #menu-content { position: fixed; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); width: min(300px, 92vw); }
    #notification-area { top: 60px; }
}

/* ---------- PHONE LANDSCAPE ---------- */
@media (max-height: 520px) and (orientation: landscape) {
    #game-shell {
        grid-template-columns: 150px minmax(0,1fr) 62px;
        grid-template-rows: 0 minmax(0,1fr) 0;
        column-gap: 10px; padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    }
    #game-shell::before, #game-shell::after, #topbar, #footbar, #hud-net, .col-label { display: none; }
    #col-left { gap: 6px; padding: 0; }
    #hud-me { padding: 8px 10px; }
    .hm-label { font-size: 15px; } .hm-name { display: none; }
    .hm-orb { width: 24px; height: 24px; } .hm-orb i { display: none; }
    .hm-stats { margin-top: 4px; } .hm-v { font-size: 20px; } .hm-k { font-size: 10px; }
    .hm-lives { margin-top: 4px; } .hearts svg { width: 13px; height: 13px; }
    #game-shell .player-card { padding: 3px 7px; }
    #game-shell .ctrl-btn { height: 38px; }
    #arena { padding: 0; }
    #arena canvas { border-radius: 10px; }
    #col-right { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; background: rgba(2,6,14,0.7); }
    body.lb-open #col-right { display: flex; }
    body.lb-open #leaderboard { width: min(320px, 80vw); max-height: 90vh; overflow: auto; }
    #lb-toggle { display: flex !important; }
    #menu-container { right: max(10px, env(safe-area-inset-right)); bottom: 10px; gap: 8px; }
    #menu-container .round-btn { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ====================================================
   Phase 2 — NET debug overlay, reconnect banner
   ==================================================== */
#net-banner {
    position: absolute; top: 14px; left: 50%; transform: translate(-50%, -10px);
    display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
    background: rgba(40, 8, 12, 0.85); border: 1px solid rgba(239,68,68,0.55); color: #fecaca;
    font-size: 13px; font-weight: 600; box-shadow: 0 0 20px rgba(239,68,68,0.3);
    opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 5; white-space: nowrap;
}
#net-banner.show { opacity: 1; transform: translate(-50%, 0); }
.nb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px var(--bad); animation: nbPulse 1s infinite; }
@keyframes nbPulse { 50% { opacity: .3; } }

#net-debug {
    position: fixed; z-index: 2050; top: 84px; right: 300px; width: 256px;
    display: none; flex-direction: column; gap: 4px;
    background: rgba(3, 8, 18, 0.9); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6); padding: 10px 12px;
    font: 11px/1.35 ui-monospace, SFMono-Regular, Consolas, monospace; color: #cbd5e1;
    pointer-events: auto;
}
#net-debug.show { display: flex; }
.nd-head { display: flex; justify-content: space-between; align-items: center; color: var(--cyan); font-weight: 700; letter-spacing: 1px; }
.nd-head small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.nd-btns { display: flex; gap: 4px; }
.nd-btns button { font: inherit; font-size: 10px; background: rgba(30,41,59,0.8); color: #e2e8f0; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.nd-btns button:hover { border-color: var(--line-strong); }
#nd-spark { width: 100%; height: 38px; background: rgba(15,23,42,0.6); border-radius: 6px; }
.nd-legend { font-size: 9px; color: var(--muted); }
.nd-sec { margin-top: 5px; font-size: 9px; letter-spacing: 2px; color: var(--muted); border-top: 1px solid rgba(56,189,248,0.12); padding-top: 4px; }
.nd-row { display: flex; justify-content: space-between; gap: 8px; }
.nd-row span { color: #94a3b8; }
.nd-row b { color: #e2e8f0; font-weight: 600; text-align: right; }
.nd-row small { color: #64748b; font-weight: 400; }
.nd-row i.w { color: var(--warn); font-style: normal; }
@media (max-width: 1280px) { #net-debug { right: 262px; } }
@media (max-width: 900px) and (orientation: portrait), (max-width: 700px) {
    #net-debug { top: auto; bottom: calc(66px + env(safe-area-inset-bottom)); right: 8px; left: 8px; width: auto; max-height: 45vh; overflow-y: auto; }
}
@media (max-height: 520px) and (orientation: landscape) { #net-debug { top: 8px; right: 70px; max-height: 90vh; overflow-y: auto; } }

/* ====================================================
   Phase 2 — LOBBY redesign (matches in-game UI)
   ==================================================== */
#lobby-screen {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(34,211,238,0.10), transparent 55%),
        radial-gradient(ellipse at 100% 100%, rgba(59,130,246,0.08), transparent 50%),
        rgba(4, 9, 18, 0.94);
    backdrop-filter: blur(4px);
    padding: max(18px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
    box-sizing: border-box; font-family: var(--font-ui);
}
#lobby-screen .lobby-header { max-width: 1180px; border-bottom: 0; padding-bottom: 0; margin-bottom: 16px; gap: 14px; }
#lobby-screen .header-top { gap: 16px; flex-wrap: wrap; }
#lobby-screen .lobby-title { font-size: 30px; text-transform: none; text-shadow: 0 0 14px rgba(56,189,248,0.25); color: #f1f5f9; }
#lobby-screen .lobby-title em b { font-weight: inherit; }
#secret-log-btn { cursor: pointer; }
.name-field { display: flex; flex-direction: column; gap: 5px; }
.name-field > span { font-size: 10px; letter-spacing: 3px; color: var(--muted); }
#lobby-screen .lobby-input {
    width: 240px; text-align: left; font-size: 15px; font-weight: 600; padding: 11px 14px; border-radius: 12px;
    background: rgba(9,18,36,0.8); border: 1px solid var(--line); color: var(--text); font-family: var(--font-ui);
}
#lobby-screen .lobby-input:focus { border-color: var(--line-strong); box-shadow: 0 0 16px rgba(34,211,238,0.25); }
#lobby-screen .lobby-subtitle { width: 100%; display: flex; align-items: baseline; gap: 12px; margin: 0; text-transform: none; letter-spacing: 0; }
#lobby-screen .lobby-subtitle span { font-family: var(--font-hud); font-weight: 700; font-size: 20px; letter-spacing: 3px; color: var(--text); }
#lobby-screen .lobby-subtitle small { font-size: 12px; color: var(--muted); font-weight: 400; }

#lobby-screen #lobby-main { max-width: 1180px; gap: 20px; min-height: 0; }
#lobby-screen #lobby-rooms { padding: 2px 6px 6px 2px; scrollbar-width: thin; scrollbar-color: rgba(56,189,248,0.3) transparent; }
#lobby-screen #room-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

#lobby-screen .room-card {
    height: 132px; padding: 14px 16px; align-items: flex-start; justify-content: flex-start; gap: 6px;
    background: linear-gradient(180deg, rgba(16, 30, 58, 0.72), rgba(8, 16, 32, 0.8));
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--glow);
    box-sizing: border-box; overflow: hidden;
}
#lobby-screen .room-card:hover { border-color: var(--line-strong); box-shadow: 0 0 26px rgba(34,211,238,0.25), 0 10px 30px rgba(0,0,0,0.5); transform: translateY(-2px); }
#lobby-screen .rc-name { font-family: var(--font-hud); font-size: 20px; font-weight: 700; text-align: left; padding-right: 24px; line-height: 1.1; }
#lobby-screen .rc-players { font-size: 12px; color: var(--muted); }
.rc-bar { width: 100%; height: 5px; border-radius: 99px; background: rgba(148,163,184,0.15); overflow: hidden; }
.rc-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22d3ee, #3b82f6); box-shadow: 0 0 8px rgba(34,211,238,0.6); }
#lobby-screen .room-card.full .rc-bar i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
#lobby-screen .rc-status { margin-top: auto; font-size: 11px; letter-spacing: 1.5px; padding: 5px 12px; border-radius: 999px; box-shadow: none; }
#lobby-screen .st-lobby { background: rgba(34,211,238,0.15); color: var(--cyan); border: 1px solid rgba(34,211,238,0.5); }
#lobby-screen .st-run { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.5); }
#lobby-screen .room-pin { top: 12px; right: 12px; font-size: 15px; }

#lobby-screen .new-room-card { align-items: center; justify-content: center; font-size: 40px; font-weight: 300; color: var(--cyan); background: rgba(34,211,238,0.04); border: 1.5px dashed rgba(34,211,238,0.45); box-shadow: none; }
#lobby-screen .new-room-card:hover { background: rgba(34,211,238,0.08); }
#lobby-screen .rc-planner { align-items: center; justify-content: center; border: 1.5px dashed rgba(239,68,68,0.45); background: rgba(239,68,68,0.05); box-shadow: none; }
#lobby-screen .rc-planner-text { text-align: center; letter-spacing: 1.5px; font-size: 12px; }
#lobby-screen .rc-invite { border-color: rgba(251,191,36,0.4); border-left: 3px solid rgba(251,191,36,0.8); }
#lobby-screen .rc-inv-time { font-family: var(--font-hud); font-size: 22px; }

#lobby-screen #lobby-social {
    flex: 0 0 340px; min-width: 0;
    background: linear-gradient(180deg, rgba(16, 30, 58, 0.72), rgba(8, 16, 32, 0.82));
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--glow);
}
#lobby-screen .chat-header { padding: 12px 14px; background: transparent; border-bottom: 1px solid rgba(56,189,248,0.14); }
#lobby-screen .chat-header-title { font-size: 13px; letter-spacing: 2px; color: var(--text); }
#lobby-screen #chat-messages { padding: 12px 14px; font-size: 13px; gap: 6px; }
#lobby-screen .chat-name { color: var(--cyan); }
.online-head { padding: 8px 14px 2px; font-size: 10px; letter-spacing: 3px; color: var(--muted); border-top: 1px solid rgba(56,189,248,0.14); }
.online-head b { color: var(--good); margin-left: 4px; }
#lobby-screen #online-list { height: 76px; border-top: 0; background: transparent; padding: 4px 12px 8px; }
#lobby-screen .online-p { background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.3); color: #d1fae5; border-radius: 999px; padding: 3px 9px; font-size: 12px; }
#lobby-screen #chat-input-area { padding: 10px 12px; background: rgba(4,9,18,0.5); border-top: 1px solid rgba(56,189,248,0.14); gap: 8px; }
#lobby-screen #chat-input { background: rgba(9,18,36,0.8); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13px; color: var(--text); }
#lobby-screen #chat-input:focus { outline: none; border-color: var(--line-strong); }

@media (max-width: 768px) {
    #lobby-screen { padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
    #lobby-screen .lobby-title { font-size: 22px; }
    #lobby-screen .brand-sub, #lobby-screen .lobby-subtitle small { display: none; }
    #lobby-screen .header-top { flex-wrap: nowrap; }
    .name-field > span { display: none; }
    #lobby-screen .lobby-input { width: 150px; padding: 9px 12px; font-size: 14px; }
    #lobby-screen #lobby-main { flex-direction: column; gap: 12px; }
    #lobby-screen #room-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    #lobby-screen .room-card { height: 112px; padding: 12px; }
    #lobby-screen .rc-name { font-size: 17px; }
    #lobby-screen #lobby-social { flex: 1 1 auto; min-height: 220px; }
    #lobby-screen #online-list { height: 44px; }
}
/* keep the floating buttons clear of the lobby content */
body:has(#lobby-screen:not([style*="none"])) #lb-toggle { display: none !important; }
@media (max-width: 1300px) and (min-width: 769px) { #lobby-screen { padding-right: 96px; } }
@media (max-width: 768px) { #lobby-screen { padding-bottom: calc(66px + env(safe-area-inset-bottom)); } }
body:has(#lobby-screen:not([style*="none"])) #net-debug { display: none !important; }
@media (max-width: 900px) and (orientation: portrait), (max-width: 700px) {
    #net-debug { max-height: 36vh; font-size: 10px; background: rgba(3,8,18,0.84); padding: 8px 10px; }
    #nd-spark { height: 28px; }
}
