:root {
  --bg: #0a0a0a;
  --panel: #161616;
  --panel2: #222222;
  --line: #333333;
  --text: #f4f4f8;
  --muted: #a3a3a3;
  --accent: #bd1d27;
  --orange: #fe5b1f;
  --brand: #bd1d27; /* 613trending red */
  --good: #2ec27e;
  --mid: #f6c445;
  --bad: #ef4444;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 'Noto Sans', system-ui, -apple-system, sans-serif; }
body { min-height: 100dvh; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(10,10,10,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { background: none; border: 0; padding: 0; display: flex; gap: 6px; align-items: baseline; font-family: Archivo, sans-serif; font-weight: 900; font-size: 22px; letter-spacing: .5px; }
.b613 { color: #bd1d27; }
.top-r { display: flex; gap: 8px; align-items: center; }
.streak { font-weight: 800; background: var(--panel2); padding: 6px 10px; border-radius: 999px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-weight: 800; }

main { max-width: 480px; margin: 0 auto; padding: 16px 16px 48px; }
.loading { text-align: center; color: var(--muted); padding: 80px 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.hero { position: relative; overflow: hidden; border: 0; background: linear-gradient(160deg, var(--accent), color-mix(in srgb, var(--accent) 35%, #0e0f1a)); }
.hero .num { font-weight: 800; font-size: 13px; opacity: .85; letter-spacing: 1px; text-transform: uppercase; }
.hero .emoji { font-size: 64px; line-height: 1; margin: 10px 0 6px; }
.hero h1 { font-family: Archivo, sans-serif; font-weight: 900; font-size: 32px; line-height: 1.05; margin: 0 0 8px; }
.hero p { margin: 0; opacity: .92; }
.rerun { display: inline-block; margin-top: 10px; font-size: 12px; background: rgba(0,0,0,.25); padding: 3px 8px; border-radius: 6px; }

.rounds { display: grid; gap: 8px; }
.round-chip { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--panel2); border-radius: 12px; }
.round-chip .ic { font-size: 26px; width: 36px; text-align: center; }
.round-chip b { display: block; }
.round-chip small { color: var(--muted); }
.round-chip .sc { margin-left: auto; font-weight: 800; }

.btn { display: block; width: 100%; padding: 16px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; font-size: 18px; text-align: center; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--panel2); color: var(--text); }
.btn.small { padding: 10px 14px; font-size: 15px; width: auto; display: inline-block; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.fine { font-size: 13px; color: var(--muted); }

/* round shell */
.rhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rhead .t { font-family: Archivo, sans-serif; font-weight: 900; font-size: 20px; }
.pips { display: flex; gap: 6px; }
.pip { width: 26px; height: 6px; border-radius: 3px; background: var(--line); }
.pip.on { background: var(--accent); }
.pip.done { background: var(--good); }
.stage { position: relative; }
.game-canvas { display: block; width: 100%; border-radius: var(--radius); touch-action: none; user-select: none; -webkit-user-select: none; background: #000; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; font-weight: 800; font-size: 22px; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.intro .big { font-size: 56px; text-align: center; }
.intro h2 { font-family: Archivo, sans-serif; font-weight: 900; margin: 6px 0; text-align: center; }
.intro p { text-align: center; color: var(--muted); }

/* timer */
.timer { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 14px; }
.timer i { display: block; height: 100%; background: var(--accent); width: 100%; transform-origin: left; }

/* items */
.q { font-size: 21px; font-weight: 800; line-height: 1.25; margin: 6px 0 14px; }
.headline { font-family: Georgia, serif; font-size: 23px; line-height: 1.25; background: #f5f1e8; color: #1b1b1b; padding: 18px; border-radius: 12px; margin-bottom: 14px; border-left: 6px solid var(--accent); }
.choices { display: grid; gap: 10px; }
.choice { padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); text-align: left; font-weight: 600; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 25%, var(--panel2)); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 25%, var(--panel2)); }
.rf { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rf .choice { text-align: center; font-size: 20px; font-weight: 800; padding: 20px 10px; }
.feedback { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--panel2); }
.feedback .pts { font-weight: 800; font-size: 20px; }
.feedback a { color: var(--muted); font-size: 13px; }
.est-val { font-family: Archivo, sans-serif; font-weight: 900; font-size: 40px; text-align: center; margin: 10px 0; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 36px; }
.text-in { width: 100%; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; font-size: 17px; }
.tl { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tl li { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; background: var(--panel2); border-radius: 12px; border: 2px solid transparent; touch-action: none; }
.tl li.drag { border-color: var(--accent); opacity: .85; }
.tl li span { flex: 1; font-weight: 600; }
.tl li .yr { flex: none; font-weight: 800; color: var(--muted); }
.tl button { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--line); }
.map { height: 380px; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; background: #ddd; }
.zoom-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); background: #111; display: block; }

/* results */
.score-big { font-family: Archivo, sans-serif; font-weight: 900; font-size: 56px; line-height: 1; text-align: center; }
.score-big small { font-size: 20px; color: var(--muted); }
.grid-line { text-align: center; font-size: 28px; letter-spacing: 4px; margin: 10px 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin: 14px 0; }
.stats div { background: var(--panel2); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-size: 22px; font-family: Archivo, sans-serif; font-weight: 900; }
.stats small { color: var(--muted); font-size: 12px; }
.countdown { font-family: Archivo, sans-serif; font-weight: 900; font-size: 26px; text-align: center; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 9px; border-radius: 10px; border: 0; background: var(--panel2); font-weight: 700; font-size: 14px; }
.tabs button.on { background: var(--accent); color: #fff; }
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.lb li.me { background: color-mix(in srgb, var(--accent) 20%, transparent); border-radius: 8px; }
.lb .rk { width: 34px; color: var(--muted); font-weight: 800; }
.lb .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .pt { font-weight: 800; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); width: min(440px, calc(100vw - 32px)); max-height: 85dvh; padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(100px); background: #fff; color: #111; padding: 10px 16px; border-radius: 999px; font-weight: 700; transition: transform .25s; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { transform: translateX(-50%) translateY(0); }
.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* single-game card */
.game-card .gc-top { display: flex; gap: 14px; align-items: center; }
.game-card .gc-icon { font-size: 44px; width: 64px; height: 64px; display: grid; place-items: center; background: var(--panel2); border-radius: 16px; }
.game-card h2 { font-family: Archivo, sans-serif; font-weight: 900; margin: 0; font-size: 24px; line-height: 1.1; }
.grid-line { font-size: 24px; letter-spacing: 2px; word-break: break-word; }

/* memory */
.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pad { aspect-ratio: 1; border-radius: 22px; border: 0; font-size: 44px; background: color-mix(in srgb, var(--c) 35%, #111); transition: transform .08s, filter .08s; }
.pad.lit { background: var(--c); transform: scale(1.04); filter: brightness(1.3); box-shadow: 0 0 30px var(--c); }
.pad:disabled { cursor: default; }

/* word search */
.ws { display: grid; gap: 3px; touch-action: none; user-select: none; -webkit-user-select: none; }
.wc { aspect-ratio: 1; display: grid; place-items: center; font-weight: 800; font-size: clamp(14px, 4.4vw, 20px); background: var(--panel2); border-radius: 6px; }
.wc.sel { background: var(--accent); color: #fff; }
.wc.found { background: color-mix(in srgb, var(--good) 55%, var(--panel2)); }
.wl { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.wl span { padding: 4px 10px; border-radius: 999px; background: var(--panel2); font-weight: 700; font-size: 13px; }
.wl span.got { background: var(--good); color: #062; text-decoration: line-through; }

/* scramble */
.slots, .tiles { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0; }
.slot { width: 34px; height: 42px; border-bottom: 3px solid var(--line); display: grid; place-items: center; font-family: Archivo, sans-serif; font-weight: 900; font-size: 22px; }
.slot.ok { color: var(--good); border-color: var(--good); }
.slot.no { color: var(--bad); border-color: var(--bad); }
.tilebtn { width: 44px; height: 50px; border-radius: 10px; border: 0; background: var(--panel2); font-family: Archivo, sans-serif; font-weight: 900; font-size: 22px; box-shadow: 0 3px 0 var(--line); }
.tilebtn:disabled { opacity: .25; }

/* emoji clue */
.emoji-clue { font-size: 54px; text-align: center; letter-spacing: 6px; padding: 20px 0; }

/* higher / lower */
.hl { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin-bottom: 14px; }
.hl-card { background: var(--panel2); border-radius: 14px; padding: 14px 10px; text-align: center; min-height: 150px; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.hl-emo { font-size: 36px; }
.hl-val { font-family: Archivo, sans-serif; font-weight: 900; font-size: 20px; color: var(--accent); }
.hl-vs { font-weight: 800; color: var(--muted); }

/* sort */
.sort { display: grid; gap: 8px; }
.sort-row { display: flex; align-items: center; gap: 8px; background: var(--panel2); padding: 8px 8px 8px 12px; border-radius: 12px; }
.sort-row > span { flex: 1; font-weight: 600; }
.segs { display: flex; gap: 4px; }
.seg { border: 2px solid var(--line); background: transparent; border-radius: 8px; padding: 6px 8px; font-size: 13px; font-weight: 700; }
.seg.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg.right { border-color: var(--good); }
.seg.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 30%, transparent); }

/* accounts */
.icon-btn.wide { width: auto; padding: 0 10px; border-radius: 999px; font-size: 14px; }
.icon-btn.cta { background: var(--brand); border-color: var(--brand); color: #fff; font-family: Archivo, sans-serif; font-weight: 800; }
.account-card { border: 2px solid var(--brand); background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 22%, var(--panel)), var(--panel)); }
.auth .btn { background: var(--brand); }
.acct-hook { font-family: Archivo, sans-serif; font-weight: 900; font-size: 24px; line-height: 1.1; }
.auth { display: grid; gap: 10px; margin-top: 8px; }
.auth .err { color: #ff8a80; min-height: 1em; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 14px; padding: 4px; }

/* share sheet */
.share-preview { display: block; width: 100%; max-height: 44svh; object-fit: contain; border-radius: 14px; margin: 10px 0 12px; background: #000; }

/* ---------- mobile fit ---------- */
/* Games must fit the *small* viewport (Safari with toolbars showing) so nobody scrolls mid-game. */
.game-canvas { width: auto; height: auto; max-width: 100%; max-height: calc(100svh - 64px - 34px - 12px - env(safe-area-inset-bottom)); margin: 0 auto; }
body.playing .top { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 6px; }
body.playing main { padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
body.playing .rhead { margin-bottom: 6px; }
body.playing .rhead .t { font-size: 16px; }
.stage { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, .btn, a, input, .wc, .tl li { touch-action: manipulation; }
main { padding-bottom: max(48px, calc(24px + env(safe-area-inset-bottom))); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.icon-btn { width: 44px; height: 44px; font-size: 17px; }
.icon-btn.wide { height: 44px; }
.brand { min-height: 44px; }
.map { height: min(380px, 48svh); }
.zoom-img { max-height: 46svh; object-fit: cover; }
.simon { max-width: min(100%, 52svh); margin: 0 auto; }
@media (max-width: 360px) {
  .top { padding-left: 10px; padding-right: 10px; }
  .top-r { gap: 5px; }
  .brand { font-size: 19px; }
  .streak { padding: 6px 8px; font-size: 13px; }
  .icon-btn { width: 40px; height: 40px; }
  .icon-btn.wide { padding: 0 9px; font-size: 13px; }
  .hero h1 { font-size: 28px; }
  .score-big { font-size: 48px; }
  .stats b { font-size: 19px; }
  .tilebtn { width: 38px; height: 46px; font-size: 19px; }
  .slot { width: 28px; }
  .sort-row { padding: 6px 6px 6px 10px; gap: 6px; font-size: 14px; }
  .seg { padding: 8px 6px; font-size: 12px; min-height: 40px; }
  .wl span { font-size: 12px; padding: 3px 8px; }
}
.share-preview { -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.share-hint b { color: var(--text); }
.sort { gap: 6px; }
.sort-row > span { line-height: 1.25; }
.seg { min-height: 40px; }
.streak, .icon-btn, .brand { white-space: nowrap; flex: none; }
@media (max-width: 360px) {
  .brand { font-size: 17px; gap: 4px; }
  .icon-btn.wide.cta { padding: 0 8px; }
}
.brand { align-items: center; }

/* ---------- new game types ---------- */
.curl-spin { display: flex; gap: 6px; margin: 10px 0 4px; }
.curl-spin .seg { flex: 1; }
.pairs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: min(100%, 58svh); margin: 10px auto 0; }
.pcard { aspect-ratio: 3/4; border: 0; border-radius: 12px; background: linear-gradient(150deg, var(--accent), var(--orange)); font-size: clamp(26px, 9vw, 40px); color: #fff; }
.pcard.up, .pcard.done, .pcard.missed { background: var(--panel2); }
.pcard.done { outline: 3px solid var(--good); }
.pcard.missed { opacity: .45; }
.slide { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: min(100%, 50svh); margin: 10px auto; }
.stile { aspect-ratio: 1; border: 0; border-radius: 14px; background: var(--panel2); font: 900 clamp(26px, 10vw, 44px) Archivo, sans-serif; box-shadow: 0 4px 0 var(--line); }
.stile.ok { background: color-mix(in srgb, var(--good) 30%, var(--panel2)); }
.stile.gap { background: transparent; box-shadow: none; }
.phrase { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin: 16px 0 8px; }
.pw { display: flex; gap: 3px; }
.pl { width: clamp(20px, 7vw, 30px); height: clamp(30px, 9vw, 40px); border-bottom: 3px solid var(--muted); display: grid; place-items: center; font: 900 clamp(17px, 5.5vw, 24px) Archivo, sans-serif; }
.pl.on { border-color: var(--accent); }
.kbd { display: grid; gap: 6px; margin-top: 14px; }
.krow { display: flex; gap: 4px; justify-content: center; }
.key { flex: 1; max-width: 36px; height: 46px; border: 0; border-radius: 8px; background: var(--panel2); font-weight: 800; font-size: 16px; padding: 0; }
.key.yes { background: var(--good); color: #062; }
.key.no { background: #3a1414; color: #888; }
.clues { padding-left: 22px; margin: 8px 0 14px; display: grid; gap: 8px; }
.clues li { background: var(--panel2); padding: 10px 12px; border-radius: 10px; font-weight: 600; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match > div { display: grid; gap: 8px; align-content: start; }
.mcell { position: relative; min-height: 48px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel2); font-weight: 600; font-size: 14px; text-align: left; }
.mcell.sel { border-color: var(--orange); }
.mcell[data-n]:not([data-n=""])::after { content: attr(data-n); position: absolute; top: -8px; right: -6px; background: var(--accent); color: #fff; border-radius: 999px; width: 22px; height: 22px; display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.oddgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice.odd { min-height: 96px; text-align: center; font-size: 17px; }
.type-target { font: 900 clamp(26px, 8vw, 36px) Archivo, sans-serif; text-align: center; padding: 18px 0; }
.text-in.ok { border-color: var(--good); }
.text-in.no { border-color: var(--bad); }
.math-q { font: 900 clamp(40px, 13vw, 56px) Archivo, sans-serif; text-align: center; padding: 10px 0; }
.math-in { text-align: center; font-size: 28px; }
.swipe-card { background: #f5f1e8; color: #1b1b1b; border-radius: 18px; padding: 26px 18px; text-align: center; font: 800 22px Archivo, sans-serif; margin: 6px auto 16px; max-width: 320px; touch-action: none; user-select: none; transition: transform .05s; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.swipe-emo { font-size: 58px; margin-bottom: 8px; }
.rf3 { grid-template-columns: 1fr 1fr 1fr; }
.rf3 .choice { font-size: 14px; padding: 14px 4px; }
/* Games with controls above the canvas get a shorter canvas so everything fits on screen. */
.stage:has(.curl-spin) .game-canvas { max-height: calc(100svh - 64px - 34px - 12px - 78px - env(safe-area-inset-bottom)); }
.curl-spin { margin-top: 0; }

@media (pointer: coarse) { .kbd-hint { display: none; } }
.turnstile:empty { display: none; }
.turnstile { min-height: 0; }

/* pre-launch countdown */
.hero.launch { text-align: center; background: linear-gradient(160deg, var(--brand), #3a0a0e); }
.hero.launch h1 { font-size: clamp(36px, 11vw, 52px); margin: 6px 0 14px; }
.launch-clock { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.launch-clock div { background: rgba(0,0,0,.28); border-radius: 12px; padding: 10px 0 8px; }
.launch-clock b { display: block; font: 900 clamp(28px, 9vw, 40px)/1 Archivo, sans-serif; }
.launch-clock small { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .8; }
