/* Windows has no flag emoji: this font only covers the flag characters, so phones and Macs look the same */
@font-face {
  font-family: 'Twemoji Country Flags';
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url('../assets/fonts/twemoji-country-flags.woff2') format('woff2');
  font-display: swap;
}
/* Self-hosted fonts (OFL, see assets/fonts/OFL.txt): variable latin + latin-ext files. Japanese falls back to system fonts. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('../assets/fonts/inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('../assets/fonts/inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 500 700; font-display: swap; src: url('../assets/fonts/space-grotesk-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Grotesk'; font-style: normal; font-weight: 500 700; font-display: swap; src: url('../assets/fonts/space-grotesk-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500 800; font-display: swap; src: url('../assets/fonts/jetbrains-mono-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500 800; font-display: swap; src: url('../assets/fonts/jetbrains-mono-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
:root {
  color-scheme: dark;
  --bg: #06070a;
  --surface: #0d0f14;
  --surface-2: #131620;
  --surface-3: #1a1e2a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f2f3f5;
  --muted: #8b91a1;
  --faint: #5c6273;
  --accent: #d7ff3a;
  --accent-ink: #0a0b0d;
  --gold: #ffc94a;
  --silver: #c9d1dc;
  --bronze: #d89060;
  --ai: #a495ff;
  --danger: #ff4d6d;
  --ok: #3ee08f;
  --game-bg: #08090d;
  --game-track: rgba(255, 255, 255, 0.07);
  --game-accent: var(--accent);
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Twemoji Country Flags', 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --display: 'Twemoji Country Flags', 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --mono: 'Twemoji Country Flags', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --max: 1240px;
  --gutter: clamp(16px, 4vw, 32px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(215, 255, 58, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(164, 149, 255, 0.07), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; line-height: 1.1; }
p { margin: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(6, 7, 10, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter);
  height: 64px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 700; letter-spacing: 0.08em; font-size: 14px; white-space: nowrap; }
.brand b { color: var(--accent); margin-left: 4px; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 10px; font-weight: 500; font-size: 14px; transition: color .15s, background .15s; white-space: nowrap; }
.nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav a.active { color: var(--text); background: rgba(255,255,255,.07); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.reset-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.reset-chip b { color: var(--text); font-family: var(--mono); font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(215,255,58,.6); animation: pulse 1.8s infinite; flex: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(215,255,58,.5); } 70% { box-shadow: 0 0 0 8px rgba(215,255,58,0); } 100% { box-shadow: 0 0 0 0 rgba(215,255,58,0); } }
.me-chip { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-size: 13px; font-weight: 600; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); max-width: 180px; }
.me-chip span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar { --s: 28px; width: var(--s); height: var(--s); border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-family: var(--display); font-weight: 700; font-size: calc(var(--s) * 0.42); color: #0a0b0d; text-transform: uppercase; }

#mode-banner { overflow-wrap: anywhere; background: rgba(164,149,255,.1); border-bottom: 1px solid rgba(164,149,255,.25); color: #d4ccff; font-size: 13px; text-align: center; padding: 8px var(--gutter); }

main { flex: 1; width: 100%; max-width: var(--max); margin: 0 auto; padding: 28px var(--gutter) 64px; outline: none; }
.boot { min-height: 60vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Generic ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-h h2, .card-h h3 { font-size: 15px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); font-weight: 600; font-family: var(--display); }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.03); color: var(--muted); white-space: nowrap; }
.chip.ai { color: var(--ai); border-color: rgba(164,149,255,.3); background: rgba(164,149,255,.08); }
.chip.ok { color: var(--ok); border-color: rgba(62,224,143,.25); background: rgba(62,224,143,.07); }
.chip.gold { color: var(--gold); border-color: rgba(255,201,74,.3); background: rgba(255,201,74,.07); }
.chip a { color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; transition: transform .08s, background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 15px 28px; font-size: 16px; border-radius: 14px; }
.btn.danger { color: var(--danger); }
.link { color: var(--accent); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 14px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 44px 0 16px; flex-wrap: wrap; }
.section-title h2 { font-size: clamp(22px, 3vw, 28px); }

.page-hero { padding: 12px 0 28px; }
.page-hero h1 { font-size: clamp(34px, 6vw, 60px); margin: 12px 0 12px; }
.page-hero p { color: var(--muted); max-width: 640px; font-size: 16px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg); border: 1px solid var(--border-strong); border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 92px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--faint); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Arena ---------- */
.arena-hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; margin-bottom: 24px; }
.arena-hero h1 { font-size: clamp(40px, 7vw, 76px); margin: 10px 0 8px; }
.arena-hero .tagline { color: var(--muted); font-size: 17px; }
.arena-hero .hero-explain { font-size: 18px; line-height: 1.45; max-width: 560px; margin: 12px 0 20px; }
.arena-hero .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.countdown { text-align: right; }
.countdown .label { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.countdown .clock { font-family: var(--mono); font-weight: 700; font-size: clamp(34px, 5vw, 56px); letter-spacing: -0.02em; line-height: 1.05; margin-top: 4px; font-variant-numeric: tabular-nums; }
.countdown .clock span { color: var(--faint); }
.countdown .sub { font-size: 12px; color: var(--faint); margin-top: 4px; }

.arena-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.game-card { padding: 0; overflow: hidden; }
.stage { position: relative; width: 100%; aspect-ratio: 4 / 5; max-height: min(78vh, 760px); background: var(--game-bg); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
@media (min-width: 1000px) { .stage { aspect-ratio: auto; height: min(74vh, 720px); } }
.stage canvas { position: absolute; inset: 0; display: block; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(6,7,10,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: opacity .2s; text-align: center; }
.overlay[hidden] { display: none; }
.overlay-inner { max-width: 420px; width: 100%; }
.overlay h2 { font-size: clamp(28px, 5vw, 40px); margin-bottom: 8px; }
.howto { list-style: none; padding: 0; margin: 18px 0 24px; display: grid; gap: 10px; text-align: left; }
.howto li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; color: #cfd3dc; font-size: 14px; }
.howto li b { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-family: var(--mono); font-size: 12px; color: var(--game-accent); }
.play-btn { min-width: 220px; }
.kbd { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); }
.overlay .meta { margin-top: 14px; font-size: 12px; color: var(--muted); }
.count-num { font-family: var(--mono); font-size: 120px; font-weight: 700; color: var(--game-accent); animation: pop .9s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }
.result-score { font-family: var(--mono); font-weight: 700; font-size: clamp(64px, 12vw, 96px); line-height: 1; margin: 6px 0; }
.result-tag { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 5px 10px; border-radius: 8px; margin-bottom: 8px; }
.result-tag.pb { background: var(--accent); color: var(--accent-ink); }
.result-tag.champ { background: var(--gold); color: #1a1200; }
.result-tag.plain { background: var(--surface-3); color: var(--muted); }
.result-line { color: #cfd3dc; font-size: 15px; margin: 6px 0 20px; }
.result-line b { color: var(--text); }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.game-foot { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); flex-wrap: wrap; }

.side { display: grid; gap: 16px; }
.standing .rank-big { display: flex; align-items: baseline; gap: 10px; }
.standing .rank-big .num { font-family: var(--mono); font-weight: 700; font-size: 56px; line-height: 1; letter-spacing: -0.04em; }
.standing .rank-big .of { color: var(--muted); font-size: 14px; }
.standing .next { margin-top: 14px; font-size: 14px; color: #cfd3dc; }
.standing .next b { color: var(--accent); font-family: var(--mono); }
.bar { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #8cff6a); border-radius: 99px; transition: width .6s; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat .v { font-family: var(--mono); font-weight: 700; font-size: 18px; margin-top: 2px; }
.standing.champ { border-color: rgba(255,201,74,.45); background: linear-gradient(180deg, rgba(255,201,74,.09), var(--surface) 60%); }
.standing.champ .num { color: var(--gold); }

.live-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .14em; color: var(--accent); }
.board-list { list-style: none; margin: 0; padding: 0; }
.board-row { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; font-size: 14px; transition: background .4s; }
.board-row + .board-row { margin-top: 2px; }
.board-row:hover { background: rgba(255,255,255,.03); }
.board-row .r { font-family: var(--mono); font-weight: 700; color: var(--muted); text-align: center; }
.board-row .n { display: flex; align-items: center; gap: 8px; min-width: 0; text-decoration: none; }
.board-row .n span.u { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .s { font-family: var(--mono); font-weight: 700; }
.board-row.r1 .r { color: var(--gold); }
.board-row.r2 .r { color: var(--silver); }
.board-row.r3 .r { color: var(--bronze); }
.board-row.r1 { background: rgba(255,201,74,.07); }
.board-row.me { background: rgba(215,255,58,.09); box-shadow: inset 0 0 0 1px rgba(215,255,58,.35); }
.board-row.me .u::after { content: 'YOU'; font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--accent); margin-left: 8px; }
.board-row.bump { background: rgba(215,255,58,.16); }
.board-gap { text-align: center; color: var(--faint); font-size: 12px; padding: 2px 0; letter-spacing: .3em; }
.board-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12px; color: var(--muted); }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.spot { position: relative; overflow: hidden; }
.spot .who { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.spot .who .avatar { --s: 44px; }
.spot .who .nm { font-family: var(--display); font-weight: 700; font-size: 20px; text-decoration: none; }
.spot .big { font-family: var(--mono); font-weight: 700; font-size: 28px; margin-top: 12px; }
.spot.gold { border-color: rgba(255,201,74,.35); }
.spot.gold::before { content: ''; position: absolute; inset: -40% -20% auto auto; width: 220px; height: 220px; background: radial-gradient(circle, rgba(255,201,74,.18), transparent 65%); pointer-events: none; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; font-size: 14px; color: #cfd3dc; }
.steps li b { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); font-family: var(--mono); color: var(--accent); font-size: 13px; }

/* ---------- Lab ---------- */
.lab-note { display: flex; gap: 14px; align-items: flex-start; background: rgba(164,149,255,.07); border: 1px solid rgba(164,149,255,.22); border-radius: var(--radius); padding: 16px 18px; color: #d4ccff; font-size: 14px; margin-bottom: 24px; }
.lab-note svg { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.toolbar > * { min-width: 0; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 2px; overflow-x: auto; max-width: 100%; }
.seg button { background: none; border: 0; padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.ideas { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.idea { display: flex; flex-direction: column; gap: 10px; }
.idea h3 { font-size: 19px; }
.idea p { color: #cfd3dc; font-size: 14px; }
.idea .mech { font-size: 13px; color: var(--muted); border-left: 2px solid var(--border-strong); padding-left: 10px; }
.idea .foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; gap: 10px; }
.idea .by { font-size: 12px; color: var(--muted); }
.idea.top { border-color: rgba(215,255,58,.28); }
.vote { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: 10px; padding: 7px 12px; cursor: pointer; font-family: var(--mono); font-weight: 700; font-size: 14px; }
.vote svg { width: 14px; height: 14px; }
.vote.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.vote:disabled { cursor: default; opacity: .7; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.under_review { color: #8fc7ff; background: rgba(143,199,255,.1); }
.status.in_development { color: var(--ai); background: rgba(164,149,255,.12); }
.status.added_to_pool { color: var(--ok); background: rgba(62,224,143,.1); }
.status.pending { color: var(--gold); background: rgba(255,201,74,.1); }
.status.rejected { color: var(--danger); background: rgba(255,77,109,.1); }
.credit { font-size: 13px; color: var(--ok); font-weight: 600; }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; counter-reset: p; }
.pipeline div { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; font-size: 13px; color: var(--muted); }
.pipeline div b { display: block; color: var(--text); font-family: var(--display); font-size: 15px; margin-bottom: 4px; }
.pipeline div::before { counter-increment: p; content: '0' counter(p); font-family: var(--mono); font-size: 11px; color: var(--accent); display: block; margin-bottom: 8px; }
.suggest-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.guidelines li { margin-bottom: 8px; color: #cfd3dc; font-size: 14px; }

/* ---------- Champions ---------- */
.reign { display: grid; grid-template-columns: auto 1fr auto; gap: 28px; align-items: center; padding: 28px; border-color: rgba(255,201,74,.4); background: linear-gradient(120deg, rgba(255,201,74,.12), var(--surface) 55%); position: relative; overflow: hidden; }
.reign .crown { width: 84px; height: 84px; color: var(--gold); filter: drop-shadow(0 0 24px rgba(255,201,74,.5)); }
.reign h2 { font-size: clamp(28px, 5vw, 44px); }
.reign .score { font-family: var(--mono); font-weight: 700; font-size: clamp(32px, 5vw, 48px); color: var(--gold); text-align: right; }
.champ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.champ-card { display: grid; gap: 10px; text-decoration: none; transition: border-color .15s, transform .15s; }
.champ-card:hover { border-color: rgba(255,201,74,.35); transform: translateY(-2px); }
.champ-card .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.champ-card .who { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 18px; }
.champ-card .game { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.champ-card .game b { font-family: var(--mono); color: var(--gold); }
.crowns-list .board-row .s { color: var(--gold); }

/* ---------- Profile ---------- */
.profile-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.profile-head .avatar { --s: 84px; }
.profile-head h1 { font-size: clamp(30px, 5vw, 44px); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-top: 24px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.tile .v { font-family: var(--mono); font-weight: 700; font-size: 30px; margin-top: 6px; }
.tile.gold .v { color: var(--gold); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.two-col.champ-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; margin-top: 0; }
.records { display: grid; gap: 10px; }
.record { display: flex; justify-content: space-between; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.record .g { font-family: var(--display); font-weight: 600; }
.record .v { font-family: var(--mono); font-weight: 700; font-size: 20px; }
table.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
table.hist th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.hist td { padding: 10px; border-bottom: 1px solid var(--border); }
table.hist td.num, table.hist th.num { text-align: right; font-family: var(--mono); }
table.hist tr.win td { color: var(--gold); }
.table-wrap { overflow-x: auto; }

/* ---------- Admin ---------- */
.admin-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.admin-row:last-child { border-bottom: 0; }
.admin-row .t { font-weight: 600; }
.admin-row .d { font-size: 13px; color: var(--muted); }
.admin-row select { background: var(--bg); border: 1px solid var(--border-strong); border-radius: 10px; padding: 7px 10px; }
.admin-row > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.admin-row .chip { margin-left: 6px; padding: 2px 8px; font-size: 11px; }
.admin-input { background: var(--bg); border: 1px solid var(--border-strong); border-radius: 10px; padding: 7px 10px; color: var(--text); font: inherit; font-size: 13px; color-scheme: dark; min-width: 0; }
.admin-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 8px; }
.admin-bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.admin-bar i { display: block; width: 100%; max-width: 36px; background: linear-gradient(180deg, var(--accent), rgba(255,255,255,.08)); border-radius: 6px 6px 2px 2px; }
.admin-bar .n { font-family: var(--mono); font-size: 11px; color: var(--text); }
.admin-bar .d { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (max-width: 640px) { .admin-row { grid-template-columns: 1fr; } }

/* ---------- Footer / tabbar ---------- */
.footer { border-top: 1px solid var(--border); padding: 40px 0 48px; }
.footer-inner { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); display: grid; gap: 12px; }
.slogan { font-family: var(--display); font-weight: 700; font-size: clamp(20px, 4vw, 30px); letter-spacing: .02em; }
.slogan span { color: var(--accent); }
.footer p { color: var(--muted); max-width: 640px; font-size: 14px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }
.footer small { color: var(--faint); }
.lang-pick { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.lang-pick select { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 10px; font: inherit; width: auto; }
.tabbar { display: none; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--surface-3); border: 1px solid var(--border-strong); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(255,77,109,.5); }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 24px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .nav a { padding: 8px 9px; }
  .reset-chip { display: none; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 960px) {
  .topbar-inner { gap: 16px; }
  .me-chip { max-width: 120px; }
  .arena-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .info-grid > :last-child { grid-column: 1 / -1; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .suggest-grid, .two-col, .two-col.champ-layout { grid-template-columns: 1fr; }
  .side { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 14px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .nav { display: none; }
  .topbar-inner { height: 56px; gap: 10px; }
  .brand { font-size: 12px; gap: 8px; }
  .brand-mark { width: 22px; height: 22px; }
  .reset-chip .lbl { display: none; }
  .reset-chip { display: inline-flex; padding: 5px 10px; font-size: 12px; }
  .me-chip { display: none; }
  main { padding-top: 20px; }
  .arena-hero { grid-template-columns: 1fr; gap: 16px; }
  .countdown { text-align: left; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; }
  .countdown .clock { font-size: 30px; margin: 0; }
  .countdown .sub { width: 100%; margin: 0; }
  .stage { aspect-ratio: 4 / 5; max-height: 70vh; }
  .side { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tiles .tile:first-child { grid-column: 1 / -1; }
  .tiles .medal-tile { grid-column: 1 / -1; }
  .reign { grid-template-columns: auto 1fr; padding: 20px; gap: 16px; }
  .reign .crown { width: 56px; height: 56px; }
  .reign .score { grid-column: 1 / -1; text-align: left; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: rgba(10, 11, 15, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: grid; justify-items: center; gap: 3px; padding: 9px 0 8px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tabbar a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
  .tabbar a.active { color: var(--accent); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.foot-right { display: inline-flex; align-items: center; gap: 12px; }
.sound-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.sound-btn:hover { color: var(--text); border-color: var(--border-strong); }
.sound-btn[aria-pressed="true"] { color: var(--text); }
@media (max-width: 640px) { .hide-sm { display: none; } }

.streak { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 12px; border-radius: 12px; font-size: 13px; color: var(--muted); background: rgba(255,154,60,.06); border: 1px solid rgba(255,154,60,.18); text-align: left; }
.streak svg { width: 20px; height: 20px; flex: none; color: #ff9a3c; }
.streak b { color: var(--text); }
.streak.warn { background: rgba(255,154,60,.1); border-color: rgba(255,154,60,.4); }
.streak.warn svg { animation: flicker 1.6s ease-in-out infinite; }
.overlay-inner .streak { justify-content: center; margin: 10px auto 0; max-width: 360px; }
.streak.pop { animation: pop .6s ease-out; }
@keyframes flicker { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .65; transform: scale(.9); } }
.streak-tile .v { display: flex; align-items: center; gap: 6px; }
.streak-tile .v svg { width: 24px; height: 24px; color: #ff9a3c; }
.streak-tile .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.share-panel { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.72); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; }
.share-box { position: relative; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px; padding: 18px; width: min(440px, 100%); max-height: 100%; overflow: auto; }
.share-box img { display: block; width: 100%; border-radius: 12px; }
.share-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.share-actions .btn { justify-content: center; text-align: center; }
.share-x { position: absolute; top: 8px; right: 10px; background: rgba(0,0,0,.6); border: 0; color: var(--text); width: 34px; height: 34px; border-radius: 50%; font-size: 22px; line-height: 1; cursor: pointer; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .streak.warn svg, .streak.pop { animation: none; } }

/* creator credit */
.foot-credit { display: inline; white-space: normal; }
.stf-logo { height: 1.4em; width: auto; display: inline-block; margin-left: 0.2em;
  /* Logo's middle on the middle of the capital letters, whatever font loaded: 0.5cap up, half the logo down. */
  vertical-align: -0.32em; vertical-align: calc(0.5cap - 0.7em); }

/* Phones held sideways: keep the whole game on screen (no sticky bar over the HUD). */
@media (orientation: landscape) and (max-height: 520px) {
  .topbar { position: relative; }
  .stage, .arena-grid .stage { aspect-ratio: auto; height: calc(100svh - 64px); max-height: none; }
}

/* Touch-only devices: hide keyboard hints. */
@media (hover: none) and (pointer: coarse) {
  .keys-only { display: none; }
  .cap-first { display: inline-block; }
  .cap-first::first-letter { text-transform: uppercase; }
}

.hero-play { display: none; margin-top: 18px; }
@media (max-width: 960px), (max-height: 760px) { .hero-play { display: inline-flex; } }
.hero-play svg { flex: none; }
@media (max-width: 760px) {
  .hero-play { width: 100%; min-height: 58px; font-size: 18px; margin-top: 16px; }
  .arena-hero .chips { margin-top: 14px; }
}

/* "Beat my score" challenge */
.challenge-banner { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(215, 255, 58, 0.08); border: 1px solid rgba(215, 255, 58, 0.35); font-size: 15px; line-height: 1.4; color: var(--text); max-width: 560px; }
.challenge-banner svg { flex: none; color: var(--accent); }
.challenge-banner b { color: var(--accent); }
.challenge-result { display: flex; align-items: center; justify-content: center; gap: 8px; margin: -8px 0 16px; font-size: 14px; }
.challenge-result svg { flex: none; }
.challenge-result.win { color: var(--ok); }
.challenge-result.lose { color: var(--gold); }
.challenge-result b { color: var(--text); }
.share-actions .challenge-btn { grid-column: 1 / -1; }

/* First run: the one-line "how to play" during the countdown */
.first-run .first-hint { font-size: 17px; line-height: 1.45; color: var(--text); margin: 10px auto 0; max-width: 340px; }
.first-run .count-num { font-size: 84px; line-height: 1.2; }
.first-run .btn { margin-top: 4px; }

/* Overlays can be taller than a small stage: scroll instead of clipping the buttons. */
.overlay { display: flex; overflow-y: auto; overscroll-behavior: contain; }
.overlay > * { margin: auto; }
@media (max-width: 420px) {
  .overlay { padding: 16px; }
  .result-actions .btn.lg { padding: 12px 16px; font-size: 15px; }
}

/* After a run: one small inline offer (reminders or home screen) under the stage */
.post-run { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.post-run[hidden] { display: none; }
.post-run-card { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pr-icon { font-size: 22px; line-height: 1; }
.pr-text { flex: 1 1 180px; display: grid; gap: 2px; font-size: 14px; min-width: 0; }
.pr-text span { color: var(--muted); font-size: 13px; }
.pr-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Money: supporter badge, support page, ads, sponsor ---------- */
.supporter-badge { display: inline-flex; align-items: center; color: #ff5c8a; flex: none; vertical-align: middle; }
.me-chip .supporter-badge { margin-left: -2px; }
.perks { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.perks li { display: flex; gap: 10px; align-items: flex-start; }
.perks li svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--accent); }
.perks li.no svg { color: var(--muted); }
.perks li.no span { color: var(--muted); }
.support-yes { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.ad-slot { margin-top: 24px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 16px; min-height: 120px; overflow: hidden; }
.ad-slot .ad-h { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.ad-slot .ad-h a { text-transform: none; letter-spacing: 0; }
.chip.sponsor { text-decoration: none; border-color: var(--gold); color: var(--text); }
.chip.sponsor b { color: var(--gold); }
.sponsor-form { padding: 12px 0 16px; border-bottom: 1px solid var(--border); }
.legal h2 { font-size: 18px; margin: 22px 0 10px; }
.legal p, .legal li { color: var(--muted); line-height: 1.6; }
.legal p + p { margin-top: 10px; }
.legal ul { padding-left: 20px; display: grid; gap: 8px; }
.legal b { color: var(--text); }

/* Opt-in checkboxes (streak reminders) */
.check { display: flex; align-items: flex-start; gap: 10px; flex-basis: 100%; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1.4; }
.check input { width: 16px; height: 16px; margin: 1px 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.check[hidden] { display: none; }

/* Medals (Bronze → Diamond personal targets) */
.medal-row { display: flex; gap: 6px; margin-top: 14px; }
.medal { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); opacity: .45; filter: grayscale(1); transition: opacity .3s, filter .3s; }
.medal i { font-style: normal; font-size: 20px; line-height: 1; }
.medal b { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.medal.on { opacity: 1; filter: none; border-color: var(--game-accent, var(--accent)); }
.medal.on b { color: var(--text); }
.medal-next { margin-top: 10px; font-size: 13px; color: var(--muted); }
.medal-next b { color: var(--text); }
.overlay-inner .medal-next { font-size: 15px; margin: 10px 0 14px; }
.medal-won { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px auto 14px; max-width: 380px; padding: 10px 14px; border-radius: 12px; background: rgba(255,201,74,.1); border: 1px solid rgba(255,201,74,.45); font-size: 15px; }
.medal-won i { font-style: normal; font-size: 30px; line-height: 1; }
.medal-won b { color: var(--gold); }
.intro-medals { margin: 4px auto 14px; max-width: 340px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.intro-medals .medal-row { margin-top: 6px; }
.medal-tile .v { display: flex; gap: 8px; font-size: 18px; flex-wrap: wrap; }
.medal-tile .v span { display: inline-flex; align-items: baseline; gap: 2px; }
.medal-tile .v small { font-size: 13px; color: var(--muted); }
.medal-tile .v .dim { opacity: .35; filter: grayscale(1); }


/* Full-screen game: works with the Fullscreen API and as a fixed full-window layout (iPhone). */
.game-card.fs { position: fixed; inset: 0; z-index: 1000; margin: 0; border: 0; border-radius: 0; display: flex; flex-direction: column; background: var(--game-bg); }
.game-card.fs .stage { flex: 1; height: auto; max-height: none; aspect-ratio: auto; }
.game-card.fs .post-run { display: none; }
.game-card.fs .game-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
html.game-fs, html.game-fs body { overflow: hidden; }
html.game-fs .tabbar { display: none; }

/* Cloudflare bot check: invisible unless Cloudflare asks for a click, then shown as a card with a hint. */
#ts-host { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 60; }
#ts-host .ts-hint { display: none; margin: 0 0 8px; max-width: 300px; font-size: 14px; line-height: 1.35; color: var(--text, #f4f5f7); }
#ts-host.ask { background: rgba(10, 11, 13, 0.96); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 14px; padding: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
#ts-host.ask .ts-hint { display: block; }
@media (max-width: 760px) {
  /* above the bottom tab bar, centred */
  #ts-host { right: auto; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); }
  html.game-fs #ts-host { bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ---------- Daily chat ---------- */
.chat .card-h { flex-wrap: wrap; gap: 4px 10px; }
.chat .chat-sub { font-size: 12px; }
.chat-empty { font-size: 14px; margin: 8px 0 12px; }
.chat-list { list-style: none; margin: 0 -4px; padding: 0 4px; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
.chat-msg { padding: 7px 8px; border-radius: 10px; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-msg + .chat-msg { margin-top: 2px; }
.chat-msg.me { background: rgba(215,255,58,.07); }
.chat-msg .who { font-weight: 700; text-decoration: none; margin-right: 6px; }
.chat-msg.me .who { color: var(--accent); }
.chat-msg .meta { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); vertical-align: 1px; }
.chat-act { background: none; border: 0; padding: 0 2px; color: var(--muted); cursor: pointer; font-size: 12px; line-height: 1; opacity: .55; }
.chat-act:hover, .chat-act:focus-visible { opacity: 1; color: var(--text); }
.chat-act:disabled { opacity: .25; cursor: default; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form input { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; color: var(--text); padding: 10px 12px; font: inherit; font-size: 16px; }
.chat-form input:focus { outline: none; border-color: var(--accent); }
.chat-rules { font-size: 12px; margin: 8px 0 0; }
