:root {
  --font-display: 'Clash Display', 'Satoshi', sans-serif;
  --font-body: 'Satoshi', system-ui, sans-serif;
  --ocean: #0a1622;
  --ocean-2: #0e1e2e;
  --land: #22343f;
  --land-hover: #2a404c;
  --border: #36505e;
  --text: #eef2f0;
  --muted: #9aaeb5;
  --faint: #5f7680;
  --accent: #ffb547;
  --accent-ink: #1b1204;
  --good: #7ee0a1;
  --bad: #ff7a6b;
  --panel: rgba(12, 24, 34, 0.86);
  --panel-line: rgba(255, 255, 255, 0.1);
  --radius: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ocean); color: var(--text); font-family: var(--font-body); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
#app { position: fixed; inset: 0; }

/* MAP */
#map { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none;
  background: radial-gradient(120% 90% at 50% 40%, var(--ocean-2), var(--ocean) 70%); }
#map .sphere { fill: #0c1b29; stroke: #1d3242; stroke-width: 1; vector-effect: non-scaling-stroke; }
#map .grat { fill: none; stroke: #16293a; stroke-width: 0.6; vector-effect: non-scaling-stroke; }
#map .land { fill: var(--land); }
#map .borders { fill: none; stroke: var(--border); stroke-width: 0.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
#map .coast { fill: none; stroke: #4b6876; stroke-width: 0.8; vector-effect: non-scaling-stroke; }
#map .arc { fill: none; stroke-width: 2; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; stroke-linecap: round; }
#map .ring { fill: none; stroke: var(--accent); vector-effect: non-scaling-stroke; }
body.playing-guess #map { cursor: crosshair; }

/* HUD */
.hud { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; padding: 14px 16px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-right { justify-self: end; }
.round-chip { display: inline-flex; flex-direction: column; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; padding: 8px 14px; backdrop-filter: blur(10px); }
.round-chip .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.round-chip .num { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.clue { display: flex; flex-direction: column; align-items: center; text-align: center; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 18px; padding: 10px 26px 12px; backdrop-filter: blur(10px); box-shadow: 0 10px 40px rgba(0,0,0,0.35); min-width: 260px; max-width: min(560px, 60vw); }
.clue-kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.clue-city { font-family: var(--font-display); font-weight: 700; font-size: clamp(26px, 3.6vw, 40px); line-height: 1.05; margin-top: 2px; }
.clue-country { font-size: 15px; color: var(--accent); font-weight: 500; margin-top: 2px; }
.clue.pop { animation: pop 420ms var(--ease); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

.timer { position: relative; width: 64px; height: 64px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 50%; backdrop-filter: blur(10px); }
.timer svg { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); transform: rotate(-90deg); }
.timer .t-bg { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 4; }
.timer .t-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 125.66; transition: stroke 200ms; }
.timer span { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.timer.low .t-fg { stroke: var(--bad); }
.timer.low span { color: var(--bad); animation: throb 0.5s infinite alternate; }
@keyframes throb { to { transform: scale(1.15); } }

.turn-banner { position: absolute; top: 136px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 14px; backdrop-filter: blur(10px); pointer-events: none; }
.turn-banner .dot, .board .dot, .results .dot, .podium .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mult { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 900; }

/* Board */
.board { position: absolute; left: 16px; top: 96px; display: flex; flex-direction: column; gap: 6px; width: 220px; }
.board .row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; padding: 8px 12px; backdrop-filter: blur(10px); transition: transform 300ms var(--ease), border-color 200ms; }
.board .row.active { border-color: currentColor; }
.board .name { flex: 1; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.board .pts { font-weight: 900; font-variant-numeric: tabular-nums; font-size: 15px; color: var(--text); }
.board .streak { font-size: 12px; color: var(--accent); font-weight: 700; }

/* Controls */
.controls { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 12px; padding: 16px 16px max(16px, env(safe-area-inset-bottom)); pointer-events: none; }
.controls > * { pointer-events: auto; }
.zoom { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--panel-line); font-size: 20px; font-weight: 700; display: grid; place-items: center; backdrop-filter: blur(10px); transition: background 160ms, transform 160ms var(--ease); }
.icon-btn:hover { background: rgba(30, 50, 64, 0.95); }
.icon-btn:active { transform: scale(0.94); }
.sound { position: absolute; top: 14px; right: 92px; }
.sound.off { opacity: 0.45; text-decoration: line-through; }
body.on-title .sound { right: 16px; }

.btn { border: 0; border-radius: 12px; padding: 12px 20px; font-weight: 700; font-size: 15px; transition: transform 160ms var(--ease), background 160ms, opacity 160ms; min-height: 44px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 30px rgba(255, 181, 71, 0.25); }
.btn-primary:hover { background: #ffc46b; }
.btn-primary:disabled { background: rgba(20, 36, 48, 0.92); color: var(--muted); box-shadow: none; cursor: default; border: 1px solid var(--panel-line); }
.btn-ghost { background: rgba(255,255,255,0.06); border: 1px solid var(--panel-line); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); }
.btn.big { padding: 15px 28px; font-size: 17px; }
.lock { min-width: 280px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Screens */
.screen { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(6, 14, 21, 0.55); backdrop-filter: blur(3px); overflow-y: auto; }
.panel { width: min(560px, 100%); background: var(--panel); border: 1px solid var(--panel-line); border-radius: 22px; padding: 28px; backdrop-filter: blur(16px); box-shadow: 0 30px 80px rgba(0,0,0,0.5); animation: rise 500ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.brand h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(44px, 9vw, 72px); line-height: 0.95; margin: 0; letter-spacing: -0.01em; }
.brand h1::after { content: ''; display: inline-block; width: 0.22em; height: 0.22em; background: var(--accent); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); margin-left: 0.08em; vertical-align: 0.1em; }
.tag { color: var(--muted); font-size: 16px; line-height: 1.5; margin: 10px 0 0; max-width: 46ch; }
.record { margin: 18px 0 4px; padding: 10px 14px; border-radius: 12px; background: rgba(255, 181, 71, 0.08); border: 1px solid rgba(255, 181, 71, 0.25); font-size: 14px; color: var(--text); }
.record b { color: var(--accent); }
.field { margin-top: 18px; }
.field-label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; gap: 4px; background: rgba(0,0,0,0.25); border: 1px solid var(--panel-line); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px 6px; font-weight: 700; font-size: 14px; color: var(--muted); min-height: 40px; }
.seg button.on { background: var(--text); color: var(--ocean); }
.seg.small button { padding: 6px; font-size: 13px; min-height: 34px; }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.teams:empty { display: none; }
.team-input { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.25); border: 1px solid var(--panel-line); border-radius: 10px; padding: 0 10px; }
.team-input input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 14px; padding: 10px 0; outline: none; }
.team-input:focus-within { border-color: var(--accent); }
.diffs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.diffs button { text-align: left; background: rgba(0,0,0,0.25); border: 1px solid var(--panel-line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; transition: border-color 160ms, background 160ms; }
.diffs button b { font-size: 15px; }
.diffs button span { font-size: 12px; color: var(--muted); line-height: 1.35; }
.diffs button.on { border-color: var(--accent); background: rgba(255, 181, 71, 0.1); }
.actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.actions .big { flex: 1; }
.how { margin-top: 16px; color: var(--muted); font-size: 14px; }
.how summary { cursor: pointer; font-weight: 500; color: var(--text); }
.how ul { padding-left: 18px; line-height: 1.6; margin: 10px 0; }
.how b { color: var(--text); }
.keys { font-size: 13px; }
kbd { background: rgba(255,255,255,0.1); border-radius: 5px; padding: 1px 6px; font-family: inherit; font-size: 12px; }
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.handoff { text-align: center; }
.handoff h2 { font-family: var(--font-display); font-size: clamp(36px, 7vw, 56px); margin: 8px 0 6px; line-height: 1; }
.handoff .btn { margin-top: 14px; min-width: 220px; }

/* Reveal sheet */
.sheet { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(620px, calc(100% - 24px)); background: var(--panel); border: 1px solid var(--panel-line); border-radius: 20px; padding: 18px 20px; backdrop-filter: blur(16px); box-shadow: 0 20px 60px rgba(0,0,0,0.5); animation: rise 450ms var(--ease); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-head h3 { font-family: var(--font-display); font-size: 26px; margin: 2px 0 0; line-height: 1.1; }
.results { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 38vh; overflow-y: auto; }
.results li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,0.25); }
.results .who { display: flex; align-items: center; gap: 8px; font-weight: 700; min-width: 0; }
.results .who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .detail { font-size: 13px; color: var(--muted); }
.results .verdict { font-weight: 700; }
.results .total { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; text-align: right; }
.results .total small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.v-bull { color: var(--accent); } .v-sharp { color: var(--good); } .v-close { color: #b9e6c9; } .v-warm { color: #f0c999; } .v-cold { color: var(--bad); }

/* Final */
.final h2 { font-family: var(--font-display); font-size: clamp(34px, 6vw, 50px); margin: 6px 0 14px; line-height: 1.05; }
.podium { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.podium li { display: grid; grid-template-columns: 28px auto 1fr auto; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: rgba(0,0,0,0.25); }
.podium li:first-child { background: rgba(255, 181, 71, 0.12); border: 1px solid rgba(255, 181, 71, 0.4); }
.podium .place { font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; }
.podium li:first-child .place { color: var(--accent); }
.podium .nm { font-weight: 700; }
.podium .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.podium .sc { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.post { margin-top: 18px; }
.post-row { display: flex; gap: 8px; }
.post-row input { flex: 1; min-width: 0; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-line); border-radius: 12px; color: var(--text); font: inherit; padding: 0 14px; min-height: 44px; outline: none; }
.post-row input:focus { border-color: var(--accent); }
.post-msg { min-height: 1.4em; margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.post-msg b { color: var(--accent); }

/* HOF */
.hof-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.hof h2 { font-family: var(--font-display); font-size: 34px; margin: 0; }
.hof-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow-y: auto; }
.hof-list li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,0.2); }
.hof-list li.me { background: rgba(255, 181, 71, 0.14); outline: 1px solid rgba(255, 181, 71, 0.5); }
.hof-list .rk { font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; }
.hof-list li:nth-child(1) .rk { color: var(--accent); }
.hof-list .nm { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hof-list .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.hof-list .sc { font-weight: 900; font-variant-numeric: tabular-nums; }
.hof-empty { color: var(--muted); padding: 16px 4px; }

/* Toast */
.toast { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; font-family: var(--font-display); font-weight: 700; font-size: clamp(34px, 7vw, 64px); color: var(--accent); text-shadow: 0 4px 30px rgba(0,0,0,0.6); opacity: 0; white-space: nowrap; }
.toast.show { animation: toast 1.3s var(--ease); }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 70% { opacity: 1; transform: translate(-50%, -55%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70%) scale(0.98); } }
.shake { animation: shake 380ms; }
@keyframes shake { 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }

.loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--ocean); color: var(--muted); font-weight: 500; z-index: 50; transition: opacity 400ms; }
.loading.done { opacity: 0; pointer-events: none; }
.credit { position: absolute; left: 12px; bottom: 6px; margin: 0; font-size: 11px; color: var(--faint); pointer-events: none; }

/* Mobile */
@media (max-width: 760px) {
  .hud { grid-template-columns: auto 1fr auto; padding: 10px; gap: 8px; }
  .clue { min-width: 0; max-width: none; padding: 8px 12px; }
  .clue-city { font-size: 24px; }
  .clue-country { font-size: 13px; }
  .round-chip { padding: 6px 10px; }
  .round-chip .num { font-size: 15px; }
  .timer { width: 54px; height: 54px; }
  .timer span { font-size: 17px; }
  .turn-banner { top: auto; bottom: 80px; }
  .board { top: auto; left: 10px; right: 64px; bottom: 120px; flex-direction: row; flex-wrap: wrap; width: auto; gap: 4px; }
  .board .row { padding: 5px 9px; gap: 6px; }
  .board .name { max-width: 70px; font-size: 12px; }
  .board .pts { font-size: 13px; }
  .board.solo .row .name { max-width: none; }
  .lock { min-width: 0; flex: 1; margin-right: 56px; }
  .zoom { right: 10px; bottom: 12px; }
  .zoom #zoom-reset { display: none; }
  .sound { top: auto; bottom: 120px; right: 10px; }
  body.on-title .sound { top: 10px; bottom: auto; right: 10px; }
  .panel { padding: 22px 18px; border-radius: 18px; }
  .diffs { grid-template-columns: 1fr; }
  .diffs button { flex-direction: row; justify-content: space-between; align-items: center; }
  .teams { grid-template-columns: 1fr 1fr; }
  .seg button { font-size: 13px; padding: 8px 2px; }
  .sheet { bottom: 10px; padding: 14px; }
  .sheet-head h3 { font-size: 20px; }
  .results { max-height: 30vh; }
  .credit { display: none; }
}

/* Unlock */
button[data-pro] { position: relative; }
body:not(.pro) button[data-pro]::after { content: ''; position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23ffb547' d='M4 7V5a4 4 0 0 1 8 0v2h1v8H3V7h1zm2 0h4V5a2 2 0 0 0-4 0v2z'/%3E%3C/svg%3E"); }
body:not(.pro) .seg button[data-pro] { color: var(--faint); }
body:not(.pro) .diffs button[data-pro] b, body:not(.pro) .diffs button[data-pro] span { opacity: 0.6; }
.pro-strip { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(255,181,71,0.35); font-size: 13px; color: var(--muted); line-height: 1.4; }
.pro-strip b { color: var(--text); }
body.pro .pro-strip { display: none; }
.small-btn { padding: 8px 14px; min-height: 36px; font-size: 14px; flex: none; }
.pay h2 { font-family: var(--font-display); font-size: 34px; margin: 0; line-height: 1.05; }
.perks { list-style: none; padding: 0; margin: 16px 0 20px; display: flex; flex-direction: column; gap: 8px; }
.perks li { padding: 10px 12px 10px 36px; border-radius: 10px; background: rgba(0,0,0,0.25); position: relative; font-size: 15px; color: var(--muted); }
.perks li b { color: var(--text); }
.perks li::before { content: ''; position: absolute; left: 13px; top: 50%; width: 10px; height: 10px; margin-top: -5px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--accent); }
.full { width: 100%; }
.center { text-align: center; }
.restore { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--panel-line); }
.code { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 7vw, 40px); letter-spacing: 0.08em; color: var(--accent); margin: 18px 0 20px; padding: 14px; border-radius: 14px; background: rgba(255,181,71,0.08); border: 1px solid rgba(255,181,71,0.3); user-select: all; }
.pay h2#ul-title { margin-top: 6px; }
.post-locked { margin-top: 18px; padding: 14px; border-radius: 12px; border: 1px dashed rgba(255,181,71,0.35); }
.post-locked p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
