:root { --bg: #0f172a; --panel: #1e293b; --text: #f8fafc; --muted: #94a3b8; --accent: #fbbf24; --danger: #f87171; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
.muted { color: var(--muted); }
.screen { position: absolute; inset: 0; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 340px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.logo { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: min(56px, 12.5vw); font-weight: 900; letter-spacing: 0.06em; line-height: 1; color: var(--text); text-decoration: none; }
.logo-name span { color: var(--accent); }
.logo-name { white-space: nowrap; }
.logo-slogan { font-size: max(0.3em, 11px); font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.logo.small { font-size: 26px; flex-direction: row; align-items: baseline; gap: 10px; }
.logo.small .logo-slogan { font-size: 0.5em; }
.badge { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-style: normal; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; background: var(--accent); color: #0f172a; }
.badge.free { background: #334155; color: var(--text); }
.paywall { display: flex; flex-direction: column; gap: 10px; border: 2px solid var(--accent); border-radius: 14px; padding: 12px; }
.paywall h3 { color: var(--accent); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border: 0; border-radius: 14px; background: var(--accent); color: #0f172a; font: inherit; cursor: pointer; }
.plan b { font-size: 20px; }
.plan span { font-size: 13px; font-weight: 700; }
.paywall summary { color: var(--muted); font-size: 14px; cursor: pointer; }
.code-form { display: flex; gap: 8px; margin-top: 8px; }
.code-form input { flex: 1; min-width: 0; font: inherit; font-weight: 700; text-transform: uppercase; padding: 10px 12px; border-radius: 10px; border: 2px solid #334155; background: var(--bg); color: var(--text); }
.code-form .btn { padding: 10px 14px; font-size: 15px; }
.card { background: var(--panel); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.btn { display: inline-block; border: 0; border-radius: 14px; padding: 14px 20px; font: inherit; font-weight: 800; font-size: 18px; text-align: center; text-decoration: none; cursor: pointer; color: var(--text); }
.btn.primary { background: var(--accent); color: #0f172a; }
.btn.ghost { background: transparent; border: 2px solid var(--muted); }
.btn.big { font-size: 22px; padding: 18px 28px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chip { background: var(--panel); color: var(--text); border: 0; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.banner { position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: #b45309; color: #fff; padding: 10px 16px; text-align: center; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.banner button { font: inherit; font-size: 14px; font-weight: 800; padding: 6px 14px; border: 0; border-radius: 999px; background: #fff; color: #7c2d12; }
.note { color: var(--accent); font-weight: 600; }
.home button.btn.ghost { width: 100%; max-width: 340px; }
.error { color: var(--danger); min-height: 1.2em; font-weight: 600; }

/* Phone: home and join */
.home { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 56px 20px 24px; overflow-y: auto; text-align: center; }
.home .lang { position: absolute; top: 14px; right: 14px; }
.home .tagline { color: var(--muted); max-width: 340px; }
.home .card { width: 100%; max-width: 340px; text-align: center; }
.home label { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.home input { font: inherit; font-size: 22px; font-weight: 700; padding: 12px 14px; border-radius: 12px; border: 2px solid #334155; background: var(--bg); color: var(--text); width: 100%; }
.home #code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; }
.home #name { text-align: center; }
.home .or, .home .hint, .home .credits { color: var(--muted); font-size: 14px; max-width: 340px; }
.home .btn.ghost { width: 100%; max-width: 340px; }
.lobby { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 48px 20px 28px; overflow-y: auto; text-align: center; }
.lang-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.lang-row select { font: inherit; font-weight: 700; padding: 8px 10px; border-radius: 10px; border: 2px solid #334155; background: var(--bg); color: var(--text); }
.fields label span { min-width: 0; }
.lobby .next { font-weight: 800; color: var(--accent); }
.vip { width: 100%; max-width: 380px; text-align: left; }
.vip h3 { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.pick { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; flex-direction: column; gap: 12px; }
.step h2 { font-size: 24px; }
.step-back { align-self: flex-start; background: var(--bg); }
.step-preview { width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: #0b1120; }
.pick-item { text-align: left; background: var(--bg); color: var(--text); border: 3px solid transparent; border-radius: 14px; padding: 12px; font: inherit; cursor: pointer; }
.pick-item.selected { border-color: var(--accent); }
.pick-item b { display: block; font-size: 18px; }
.pick-item span { font-size: 14px; color: var(--muted); }
.fields { display: flex; flex-direction: column; gap: 8px; }
.fields label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fields select { font: inherit; font-weight: 700; padding: 10px 12px; border-radius: 10px; border: 2px solid #334155; background: var(--bg); color: var(--text); min-width: 120px; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 12px; padding: 8px 10px; }
.people .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.people b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .chip { font-size: 13px; padding: 8px 10px; }
.chip.danger { background: #7f1d1d; }
/* Movement controls on the phone (see js/controls.js) */
.ctl { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.ctl-types { display: flex; justify-content: center; gap: 6px; }
.ctl-type { font: inherit; font-size: 12px; font-weight: 700; padding: 5px 12px; border: 0; border-radius: 999px; background: var(--panel); color: var(--muted); }
.ctl-type.on { background: var(--accent); color: #0f172a; }
.ctl-zone { position: relative; flex: 1; min-height: 0; border-radius: 20px; touch-action: none; user-select: none; -webkit-user-select: none; }
.ctl-zone.stick, .ctl-zone.swipe { background: var(--panel); border: 3px dashed rgba(255, 255, 255, 0.22); overflow: hidden; }
.ctl-hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 13px; font-weight: 700; opacity: 0.55; pointer-events: none; }
.ctl-base { position: absolute; left: 50%; top: 50%; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.3); pointer-events: none; }
.ctl-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: var(--me, var(--accent)); opacity: 0.6; }
.ctl-zone.active .ctl-knob { opacity: 1; }
.ctl-zone.active .ctl-hint { display: none; }
.ctl-arrow { position: absolute; font-size: 34px; color: rgba(255, 255, 255, 0.22); pointer-events: none; }
.ctl-arrow.up { top: 6%; left: 50%; transform: translateX(-50%); }
.ctl-arrow.down { bottom: 16%; left: 50%; transform: translateX(-50%); }
.ctl-arrow.left { left: 6%; top: 50%; transform: translateY(-50%); }
.ctl-arrow.right { right: 6%; top: 50%; transform: translateY(-50%); }
.ctl-zone.four[data-now="0"] .ctl-arrow.up, .ctl-zone.four[data-now="1"] .ctl-arrow.right, .ctl-zone.four[data-now="2"] .ctl-arrow.down, .ctl-zone.four[data-now="3"] .ctl-arrow.left,
.ctl-zone.walk[data-now="1"] .ctl-arrow.right, .ctl-zone.walk[data-now="-1"] .ctl-arrow.left { color: var(--accent); }
.ctl-zone.walk .ctl-arrow.down { display: none; }
.ctl-zone.buttons { display: grid; gap: 8px; }
.ctl-zone.buttons.four { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); max-width: 420px; width: 100%; margin: 0 auto; }
.ctl-zone.buttons.four .up { grid-column: 2; grid-row: 1; }
.ctl-zone.buttons.four .left { grid-column: 1; grid-row: 2; }
.ctl-zone.buttons.four .down { grid-column: 2; grid-row: 2; }
.ctl-zone.buttons.four .right { grid-column: 3; grid-row: 2; }
.ctl-zone.buttons.walk { grid-template-columns: 1fr 0.8fr 1fr; }
.ctl-zone.buttons button { font-size: 38px; border: 0; border-radius: 18px; background: var(--accent); color: #0f172a; touch-action: none; }
.ctl-zone.buttons button.on { filter: brightness(0.75); transform: scale(0.98); }
.ctl-zone.buttons .ctl-jump { background: #38bdf8; }
.fb { position: fixed; z-index: 60; overflow-y: auto; }
.fb .card { width: 100%; max-width: 380px; text-align: left; font-weight: 400; }
.fb label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.fb input, .fb textarea { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 2px solid #334155; background: var(--bg); color: var(--text); width: 100%; resize: vertical; }
.fb .fb-trap { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb .error.good { color: #4ade80; }
.fb-open { opacity: 0.8; }
.vip-bar { position: absolute; top: 0; left: 0; right: 0; height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 14px; color: var(--muted); }
.vip-bar .chip { background: #7f1d1d; }
.vip-bar { padding-left: 84px; }
.leave { position: fixed; top: 8px; left: 8px; z-index: 40; font: inherit; font-size: 12px; font-weight: 700; padding: 6px 10px; border: 0; border-radius: 999px; background: var(--panel); color: var(--muted); opacity: 0.85; }
.leave[hidden] { display: none; }
.leave-confirm { position: fixed; z-index: 60; }
.consent { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 340px; padding: 14px; border-radius: 16px; border: 2px solid #334155; font-size: 13px; line-height: 1.35; text-align: left; color: var(--muted); }
.vote { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 8px; }
.vote-buttons { display: flex; gap: 16px; }
.vote-buttons button { font-size: 34px; line-height: 1; padding: 12px 20px; border: 3px solid transparent; border-radius: 18px; background: var(--panel); }
.vote-buttons button.chosen { border-color: var(--accent); }
.vote-buttons button:disabled:not(.chosen) { opacity: 0.35; }
.consent a, .credits a, .legal a { color: var(--accent); }
.consent-buttons { display: flex; gap: 8px; }
.consent-buttons .btn { flex: 1; font-size: 15px; padding: 10px 12px; }
.legal { max-width: 720px; margin: 0 auto; padding: 28px 20px 60px; line-height: 1.5; }
.legal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.legal-head .logo.small { flex-wrap: wrap; }
.legal h1 { font-size: 28px; margin: 18px 0 6px; }
.legal h2 { font-size: 19px; margin: 26px 0 6px; color: var(--accent); }
.legal p, .legal li { color: #cbd5e1; }
.legal ul { padding-left: 20px; }
.legal .muted { color: var(--muted); font-size: 14px; }
body.page { overflow: auto; position: static; height: auto; }
/* Phone: while the connection is down, cover the whole screen, so nothing stale shows behind the message. */
.phone .banner { bottom: 0; z-index: 70; flex-direction: column; flex-wrap: nowrap; gap: 22px; padding: 24px; background: var(--bg); font-size: 20px; line-height: 1.3; }
.phone .banner::before { content: ""; width: 44px; height: 44px; border-radius: 50%; border: 5px solid #334155; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.phone .banner button { font-size: 16px; padding: 12px 22px; background: var(--panel); color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
.game-root { position: absolute; inset: 0; }
/* The top strip is always kept free: it holds the Leave button (and the leader's bar). */
.game .game-root { top: 44px; }
.overlay { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; background: rgba(2, 6, 23, 0.8); text-align: center; }
.overlay .card { width: 100%; max-width: 320px; font-weight: 700; }
.avatar { flex: none; width: 96px; height: 96px; border-radius: 50%; background: var(--me, #fff); border: 6px solid #fff; }
.rank { font-size: 32px; font-weight: 900; color: var(--accent); }
.game { touch-action: none; }

/* Big screen */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.topbar .spacer { flex: 1; }
.topbar .room { background: rgba(15, 23, 42, 0.85); border-radius: 999px; padding: 6px 14px; font-size: 18px; }
.topbar .room b { color: var(--accent); letter-spacing: 0.04em; }
.topbar .sound-hint { color: var(--muted); font-size: 15px; font-weight: 700; }
.topbar .sound-hint[data-state="blocked"] { color: var(--accent); }
.small { font-size: 13px; }
.tv .screen { top: 0; }
/* The big-screen lobby never scrolls: sizes follow the screen height, and the
   game list is a compact grid with details shown for the chosen game only. */
/* Left: how to join, and who is in. Right: the games and a large clip of the chosen one. */
.tv-lobby { display: grid; grid-template-columns: minmax(0, 0.7fr) minmax(0, 2fr); grid-template-rows: auto minmax(0, 1fr); gap: 2vh 1.6vw; height: 100vh; padding: 9vh 2vw 3vh; overflow: hidden; }
.tv-lobby .card { min-height: 0; overflow: hidden; gap: 1.4vh; padding: 2.4vh 1.6vw; font-size: 2.3vh; }
.tv-lobby h2 { font-size: 3.2vh; }
.tv-lobby .join { align-items: center; justify-content: center; text-align: center; grid-column: 1; grid-row: 1; gap: 0.8vh; }
.tv-lobby .people-card { grid-column: 1; grid-row: 2; }
.tv-lobby .pick-card { grid-column: 2; grid-row: 1 / 3; }
.pick-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 0.4fr) minmax(0, 1fr); gap: 1.4vw; }
.pick-main { display: flex; flex-direction: column; gap: 1.2vh; min-height: 0; min-width: 0; }
.tv-lobby .url { font-size: min(1.7vw, 3.4vh); font-weight: 800; overflow-wrap: anywhere; line-height: 1.15; }
/* Sized so that even four of the widest letters fit the card in any font. */
.tv-lobby .code { font-size: min(4.2vw, 10vh); font-weight: 900; letter-spacing: 0.12em; text-indent: 0.12em; white-space: nowrap; color: var(--accent); line-height: 1; max-width: 100%; }
.qr { background: #fff; padding: 1.4vh; border-radius: 1.4vh; line-height: 0; }
.qr svg { width: min(13vw, 23vh); height: auto; }
.players { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.8vh; min-height: 0; }
.players li { display: flex; align-items: center; gap: 0.8vh; font-size: 2.2vh; font-weight: 800; background: var(--bg); border-radius: 1.2vh; padding: 0.7vh 1vh; min-height: 0; min-width: 0; }
.players li span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .dot { width: 1.8vh; height: 1.8vh; border-radius: 50%; flex: none; }
.players small { margin-left: auto; font-size: 1.3vh; color: var(--accent); text-transform: uppercase; }
.games { display: flex; flex-direction: column; gap: 1vh; min-height: 0; }
.game-card { display: flex; align-items: center; min-width: 0; background: var(--bg); color: var(--text); border: 0.4vh solid transparent; border-radius: 1.4vh; padding: 1.1vh 1.4vh; opacity: 0.55; }
.game-card.selected { opacity: 1; border-color: var(--accent); }
.game-card b { display: flex; align-items: center; justify-content: space-between; gap: 1vh; width: 100%; font-size: 2.5vh; line-height: 1.15; overflow-wrap: anywhere; }
.game-card .badge { flex: none; margin-left: 0; font-size: 1.5vh; }
.game-preview { flex: 1 1 0; min-height: 0; min-width: 0; width: 100%; object-fit: contain; border-radius: 1.4vh; background: #0b1120; }
.game-preview[hidden] { display: none; }
.game-detail { display: flex; flex-direction: column; gap: 1vh; }
#game-desc { font-size: 2.3vh; color: var(--muted); line-height: 1.3; }
.settings { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.8vh 1.2vh; }
.settings li { flex: 1 1 0; white-space: nowrap; display: flex; justify-content: space-between; gap: 2vh; font-size: 2.5vh; background: var(--bg); border-radius: 1.2vh; padding: 0.9vh 1.6vh; }
.hint-big { margin-top: auto; font-size: 3vh; font-weight: 800; color: var(--accent); line-height: 1.2; }
.tv-game { background: #dff6f5; }
.game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tv #screen-end { height: 100vh; overflow: hidden; gap: 1.6vh; padding: 9vh 4vw 3vh; }
.tv #screen-end h2 { font-size: 3vh; }
.results { list-style: none; padding: 0; margin: 0; width: min(70vh, 90vw); display: flex; flex-direction: column; gap: 0.9vh; min-height: 0; }
.results li { display: flex; align-items: center; gap: 1.6vh; background: var(--panel); border-radius: 1.4vh; padding: 1vh 2vh; font-size: 3vh; font-weight: 800; }
.results .place { width: 4.5vh; color: var(--muted); }
.results .score { margin-left: auto; }
#winner { font-size: min(6vw, 9vh); color: var(--accent); line-height: 1.1; }
/* A phone or narrow window used as the big screen: stack the cards and allow scrolling. */
@media (max-width: 900px) { .tv-lobby { grid-template-columns: 1fr; grid-template-rows: none; height: auto; overflow-y: auto; position: absolute; inset: 0; } .tv-lobby .card { overflow: visible; grid-column: 1; grid-row: auto; } .pick-body { grid-template-columns: 1fr; } .game-preview { flex: none; } }
