/* Stopwise — 2027 refresh: soft tonal surfaces, big touch targets, one accent per game (--gc). */
:root {
  --bg: #F4F1EA;
  --bg-2: #ECE7DC;
  --surface: #FFFFFF;
  --surface-2: #F6F3EC;
  --surface-3: #EEEAE1;
  --ink: #14161C;
  --ink-2: #4A4F5C;
  --ink-3: #8A8F9B;
  --line: rgba(20, 22, 28, .08);
  --line-2: rgba(20, 22, 28, .16);
  --good: #23A15A;
  --bad: #E0453A;
  --shadow: 0 1px 1px rgba(20, 22, 28, .04), 0 6px 18px -6px rgba(20, 22, 28, .12);
  --shadow-lg: 0 2px 4px rgba(20, 22, 28, .05), 0 24px 48px -16px rgba(20, 22, 28, .22);
  --radius: 24px;
  --radius-sm: 16px;
  --glass: rgba(255, 255, 255, .72);
  --c-route: #E4572E;
  --c-blocks: #2F7FD1;
  --c-merge: #E3A10F;
  --c-tunnel: #2E9E5B;
  --c-binary: #7A5CC7;
  --c-fare: #D9468C;
  --c-flash: #129C9C;
  --c-pairs: #9A6B3F;
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C0E13; --bg-2: #12151C; --surface: #171A22; --surface-2: #1E222C; --surface-3: #262B36;
    --ink: #F2F0EA; --ink-2: #BCC0CA; --ink-3: #7B808E; --line: rgba(255, 255, 255, .07); --line-2: rgba(255, 255, 255, .14);
    --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 22px -8px rgba(0, 0, 0, .5); --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .7);
    --glass: rgba(23, 26, 34, .72);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C0E13; --bg-2: #12151C; --surface: #171A22; --surface-2: #1E222C; --surface-3: #262B36;
  --ink: #F2F0EA; --ink-2: #BCC0CA; --ink-3: #7B808E; --line: rgba(255, 255, 255, .07); --line-2: rgba(255, 255, 255, .14);
  --shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 8px 22px -8px rgba(0, 0, 0, .5); --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .7);
  --glass: rgba(23, 26, 34, .72);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; min-height: 100vh; overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--gc, var(--ink)) 60%, transparent); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px max(16px, calc((100vw - 1120px) / 2)); background: var(--glass);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-head); font-weight: 700; font-size: 20px; letter-spacing: -.03em; }
.brand svg { width: 32px; height: 32px; }
.topbar .spacer { flex: 1; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; min-width: 40px; padding: 0 12px;
  border-radius: 999px; border: 0; background: var(--surface-3); font-weight: 600; font-size: 14px; text-decoration: none;
  transition: background .15s, transform .1s;
}
.iconbtn:hover { background: color-mix(in srgb, var(--ink) 10%, var(--surface-3)); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 19px; height: 19px; }
.iconbtn.round { width: 40px; padding: 0; }
.back { border: 0; background: var(--surface-3); width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.back svg { width: 20px; height: 20px; }
.gtitle { display: flex; min-width: 0; white-space: nowrap; align-items: center; gap: 9px; font-family: var(--font-head); font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.gtitle > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.gdot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--gc); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gc) 22%, transparent); }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; color: var(--ink-2); background: var(--surface-3); height: 40px; padding: 0 14px; border-radius: 999px; display: inline-flex; align-items: center; }
.streak { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px 0 11px; border-radius: 999px; background: color-mix(in srgb, #E4572E 12%, var(--surface)); font-weight: 700; font-size: 14px; color: var(--ink-2); }
.streak b { color: var(--ink); font-size: 16px; font-family: var(--font-head); }

/* ---------- shared bits ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--surface-3); font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--gc) 14%, transparent); color: color-mix(in srgb, var(--gc) 72%, var(--ink)); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px; border-radius: 999px;
  border: 0; background: var(--surface-3); font-weight: 700; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: transform .1s, filter .15s, background .15s;
}
.btn:hover { background: color-mix(in srgb, var(--ink) 8%, var(--surface-3)); }
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.primary { background: var(--gc, var(--ink)); color: #fff; box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--gc, var(--ink)) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.tonal { background: color-mix(in srgb, var(--gc, var(--ink)) 13%, var(--surface)); color: color-mix(in srgb, var(--gc, var(--ink)) 75%, var(--ink)); }
.btn.tonal:hover { background: color-mix(in srgb, var(--gc, var(--ink)) 20%, var(--surface)); }
.btn.dark { background: var(--ink); color: var(--surface); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .4; cursor: default; pointer-events: none; }
.btn.grow { flex: 1; }
.done-badge { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 48px; padding: 0 16px; border-radius: 999px; font-weight: 700; color: var(--good); font-size: 15px; background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.done-badge svg { width: 18px; height: 18px; }

/* ---------- hub ---------- */
.hub { max-width: 1120px; margin: 0 auto; padding: 18px 16px 64px; }
.today {
  position: relative; overflow: hidden; border-radius: 28px; padding: 22px 22px 20px; margin-bottom: 26px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #3A2A6B 0%, transparent 55%), radial-gradient(90% 120% at 0% 100%, #6B2A1E 0%, transparent 60%), #14161C;
  box-shadow: var(--shadow-lg);
}
.today-top { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.today .date { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.6); margin: 0 0 4px; }
.today h1 { font-family: var(--font-head); font-size: clamp(30px, 6vw, 44px); letter-spacing: -.04em; line-height: 1.02; margin: 0 0 12px; }
.today .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.today .pill { background: rgba(255,255,255,.12); color: rgba(255,255,255,.88); }
.ring { position: relative; flex: none; width: 84px; height: 84px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-head); font-size: 22px; letter-spacing: -.02em; }
.ring b small { font-size: 13px; opacity: .6; margin-left: 1px; }
.today .msg { margin: 18px 0 12px; font-weight: 600; color: rgba(255,255,255,.82); font-size: 15px; }
.metro { display: flex; align-items: center; padding: 4px 4px 0; }
.metro .seg { flex: 1; height: 6px; margin: 0 -2px; border-radius: 3px; background: var(--sc); opacity: .35; }
.metro .seg.on { opacity: 1; }
.metro .stop { position: relative; z-index: 1; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 4px solid var(--sc); background: #14161C; display: grid; place-items: center; text-decoration: none; transition: transform .15s; }
.metro .stop:hover { transform: scale(1.12); }
.metro .stop.on { background: var(--sc); }
.metro .stop svg { width: 14px; height: 14px; color: #fff; }
.metro .stop span { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 600; color: rgba(255,255,255,.7); white-space: nowrap; display: none; }
.today .share { margin-top: 18px; background: rgba(255,255,255,.12); color: #fff; height: 42px; }
.today .share:hover { background: rgba(255,255,255,.2); }
@media (min-width: 760px) {
  .today { padding: 30px 34px 28px; }
  .metro { padding-bottom: 26px; }
  .metro .stop span { display: block; }
  .ring { width: 104px; height: 104px; }
  .ring b { font-size: 28px; }
}

.sect { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 2px 12px; }
.sect h2 { font-family: var(--font-head); font-size: 22px; letter-spacing: -.03em; margin: 0; }
.sect span { color: var(--ink-3); font-size: 14px; font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.card {
  position: relative; display: grid; grid-template-columns: 76px 1fr; column-gap: 14px; row-gap: 14px; align-items: center; padding: 14px;
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card .art { width: 76px; height: 76px; border-radius: 20px; background: color-mix(in srgb, var(--gc) 14%, var(--surface-2)); display: grid; place-items: center; overflow: hidden; }
.card .art svg { width: 118%; height: 118%; }
.card .info { min-width: 0; }
.card h3 { margin: 0 0 4px; font-family: var(--font-head); font-size: 19px; letter-spacing: -.02em; line-height: 1.15; display: flex; align-items: center; gap: 8px; }
.card h3 .ok { width: 20px; height: 20px; border-radius: 50%; background: var(--good); color: #fff; display: inline-grid; place-items: center; flex: none; }
.card h3 .ok svg { width: 12px; height: 12px; }
.card p { margin: 6px 0 0; color: var(--ink-2); font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.card .row { grid-column: 1 / -1; display: flex; gap: 8px; }
.card .row .btn { flex: 1; height: 46px; }

.hub-foot { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 12px 24px; color: var(--ink-3); font-size: 14px; justify-content: space-between; }
.hub-foot a { color: var(--ink-2); }

/* ---------- game page ---------- */
.gamepage { max-width: 1120px; margin: 0 auto; padding: 18px 16px 48px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 880px) { .gamepage { grid-template-columns: 1fr; padding-top: 12px; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.board-panel {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--gc) 9%, var(--surface)) 0%, var(--surface) 70%);
}
.board-host { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.controls { width: 100%; max-width: 560px; display: flex; gap: 10px; }
.controls .btn { height: 52px; }
.note { min-height: 24px; margin: 0; color: var(--ink-2); font-weight: 600; text-align: center; font-size: 15px; transition: color .15s; }
.note.bad { color: var(--bad); }
.note.good { color: var(--good); }
.side { padding: 6px 22px 22px; }
.side details { border-bottom: 1px solid var(--line); }
.side summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 16px 0; font-family: var(--font-head); font-weight: 700; font-size: 18px; }
.side summary::-webkit-details-marker { display: none; }
.side summary::after { content: ""; width: 9px; height: 9px; border-right: 2.5px solid var(--ink-3); border-bottom: 2.5px solid var(--ink-3); transform: rotate(45deg) translateY(-3px); transition: transform .2s; }
.side details[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.side ul { margin: 0 0 16px; padding: 0; list-style: none; color: var(--ink-2); counter-reset: how; }
.side li { position: relative; margin: 0 0 10px; padding-left: 34px; counter-increment: how; }
.side li::before { content: counter(how); position: absolute; left: 0; top: 0; width: 23px; height: 23px; border-radius: 50%; background: color-mix(in srgb, var(--gc) 16%, var(--surface)); color: color-mix(in srgb, var(--gc) 75%, var(--ink)); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.side .sep { display: none; }
.side .kvs { padding-top: 14px; }
.side .kv { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); margin: 7px 0; }
.side .kv b { color: var(--ink); }
.side .legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 0 0 16px; font-size: 14px; color: var(--ink-2); align-items: center; }
.levelnav { display: flex; gap: 8px; margin-top: 14px; }
.levelnav .btn { height: 44px; }

/* generic grid board: width from --bw, never taller than the screen allows */
.board { position: relative; width: 100%; max-width: min(var(--bw, 560px), calc(100svh - 270px)); min-width: min(100%, 260px); display: grid; user-select: none; -webkit-user-select: none; touch-action: none; }
.board .cell { position: relative; display: grid; place-items: center; }

/* route */
.route-board { border-radius: 22px; border: 0; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--line-2); }
.route-board .cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); aspect-ratio: 1; }
.route-board svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.station { position: relative; z-index: 2; width: 58%; aspect-ratio: 1; border-radius: 50%; background: var(--ink); display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: clamp(14px, 3.4vw, 22px); color: var(--surface); box-shadow: 0 3px 8px -2px rgba(0,0,0,.35); transition: background .15s, color .15s, transform .15s; }
.station.on { background: var(--gc); color: #fff; transform: scale(1.06); }
.station.end::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 2.5px dashed color-mix(in srgb, var(--ink) 45%, transparent); }

/* blocks */
.blocks-board { border-radius: 18px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 2px var(--line-2); }
.blocks-board .cell { aspect-ratio: 1; border-right: 1px dashed var(--line-2); border-bottom: 1px dashed var(--line-2); }
.blocks-board .rect { position: absolute; border-radius: 12px; border: 3px solid var(--rc); background: color-mix(in srgb, var(--rc) 26%, transparent); pointer-events: none; transition: background .15s; }
.blocks-board .rect.bad { border-style: dashed; background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--bad) 12%, transparent) 0 6px, transparent 6px 12px); border-color: var(--bad); }
.blocks-board .rect.preview { border-style: dashed; background: color-mix(in srgb, var(--ink) 8%, transparent); border-color: var(--ink-2); }
.clue { position: relative; z-index: 3; width: 60%; aspect-ratio: 1; border-radius: 11px; background: var(--rc); color: #fff; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: clamp(15px, 3.4vw, 24px); box-shadow: 0 3px 8px -3px rgba(0,0,0,.4); }

/* merge */
.merge-board { gap: 10px; }
.tile { aspect-ratio: 1; border-radius: 18px; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; font-size: clamp(20px, 5vw, 36px); background: var(--tc); color: #1b1d24; transition: transform .12s ease, box-shadow .12s ease; box-shadow: inset 0 -5px 0 rgba(0,0,0,.08), 0 4px 10px -6px rgba(0,0,0,.3); cursor: grab; }
.tile.empty { background: transparent; border: 2px dashed var(--line-2); box-shadow: none; cursor: default; }
.tile.sel { outline: 3px solid var(--ink); outline-offset: 3px; transform: scale(1.04); }
.tile.hint { animation: pulse 1s ease-in-out 3; }
.tile.pop { animation: pop .28s ease; }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gc) 0%, transparent); } 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--gc) 45%, transparent); } }
.goal { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink-2); }
.goal b { font-family: var(--font-head); font-size: 22px; color: var(--ink); }

/* tunnel */
.tunnel-board { border-radius: 18px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 3px var(--ink); }
.tunnel-board .cell { aspect-ratio: 1; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-family: var(--font-head); font-weight: 700; font-size: clamp(20px, 4.6vw, 32px); z-index: 1; }
.tunnel-board .cell.used { color: color-mix(in srgb, var(--ink) 75%, var(--surface)); }
.tunnel-board .cell.hinted { box-shadow: inset 0 0 0 3px var(--gc); border-radius: 12px; }
.tunnel-board svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.slots { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.slot { display: flex; gap: 5px; }
.slot span { width: 34px; height: 40px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; }
.slot.found span { background: var(--wc); color: #fff; }
.current-word { font-family: var(--font-head); font-weight: 700; font-size: 22px; letter-spacing: .12em; min-height: 32px; }
.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* binary */
.binary-board { border-radius: 18px; overflow: hidden; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--line-2); }
.binary-board .cell { aspect-ratio: 1; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; }
.binary-board .cell.given { background: color-mix(in srgb, var(--ink) 6%, var(--surface-2)); cursor: default; }
.binary-board .cell.err::after { content: ""; position: absolute; inset: 3px; border-radius: 10px; border: 2px solid var(--bad); }
.tok { width: 58%; aspect-ratio: 1; transition: transform .12s; }
.tok.a { border-radius: 50%; background: #F08A24; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.tok.b { border-radius: 22%; background: #2D5DA8; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); transform: rotate(45deg) scale(.86); }
.binary-board .cell.given .tok { opacity: .9; }
.legend .tok { width: 18px; display: inline-block; vertical-align: middle; }

/* fare */
.target { text-align: center; }
.target small { display: block; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 12px; }
.target b { font-family: var(--font-head); font-size: 60px; line-height: 1; letter-spacing: -.04em; }
.numrow { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.num { width: 76px; height: 76px; border-radius: 22px; border: 0; background: var(--surface); font-family: var(--font-head); font-weight: 700; font-size: 26px; box-shadow: inset 0 0 0 2px var(--line-2), 0 4px 0 var(--line-2); transition: transform .1s; }
.num:active { transform: translateY(2px); }
.num.made { box-shadow: inset 0 0 0 2px var(--gc), 0 4px 0 color-mix(in srgb, var(--gc) 40%, transparent); color: var(--gc); }
.num.sel { background: var(--gc); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--gc) 60%, #000); transform: translateY(-2px); }
.num.hit { background: var(--good); color: #fff; box-shadow: none; }
.oprow { display: flex; gap: 10px; justify-content: center; }
.op { width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--surface-3); font-size: 26px; font-weight: 700; }
.op.sel { background: var(--ink); color: var(--surface); }
.worklog { min-height: 24px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: center; font-size: 15px; }

/* flash */
.flash-board { gap: 8px; }
.fcell { aspect-ratio: 1; border-radius: 14px; background: var(--surface-3); border: 0; transition: background .15s, transform .1s; cursor: pointer; }
.fcell.lit { background: var(--gc); box-shadow: 0 0 18px -2px color-mix(in srgb, var(--gc) 70%, transparent); }
.fcell.ok { background: var(--good); }
.fcell.miss { background: var(--bad); }
.fcell:active { transform: scale(.94); }
.hud { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; font-weight: 600; color: var(--ink-2); }
.hud b { color: var(--ink); }
.lives span { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--bad); margin-left: 4px; }
.lives span.gone { background: var(--line-2); }

/* pairs */
.pairs-board { gap: 10px; perspective: 900px; max-width: min(var(--bw, 560px), calc((100svh - 300px) * var(--ar, 1))); }
.pcard { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; transform-style: preserve-3d; transition: transform .35s ease; }
.pcard.up, .pcard.matched { transform: rotateY(180deg); }
.pcard .face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; display: grid; place-items: center; }
.pcard .shut { background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.22) 0 14%, transparent 15%), linear-gradient(160deg, color-mix(in srgb, var(--gc) 85%, #fff), var(--gc)); box-shadow: inset 0 0 0 3px rgba(255,255,255,.25), 0 4px 10px -6px rgba(0,0,0,.4); }
.pcard .open { background: var(--surface); box-shadow: inset 0 0 0 2px var(--line-2); transform: rotateY(180deg); font-size: clamp(26px, 5vw, 40px); }
.pcard.matched .open { box-shadow: inset 0 0 0 2px var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }

/* ---------- modal (a bottom sheet on phones) ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(8, 10, 14, .5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .2s ease; }
.modal { width: min(440px, 100%); background: var(--surface); border-radius: 30px; padding: 28px 24px 24px; box-shadow: var(--shadow-lg); text-align: center; animation: rise .28s cubic-bezier(.2, .9, .3, 1.1); }
.modal h2 { font-family: var(--font-head); font-size: 28px; margin: 10px 0 4px; letter-spacing: -.03em; line-height: 1.1; }
.modal p { color: var(--ink-2); margin: 0 0 18px; }
.modal .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0 22px; }
.modal .stats div { background: var(--surface-2); border-radius: 18px; padding: 12px 6px; }
.modal .stats b { display: block; font-family: var(--font-head); font-size: 24px; letter-spacing: -.02em; }
.modal .stats small { color: var(--ink-3); font-weight: 600; font-size: 12px; }
.modal .actions { display: flex; flex-direction: column; gap: 8px; }
.modal .badge { width: 68px; height: 68px; margin: 0 auto; border-radius: 22px; background: var(--gc); display: grid; place-items: center; color: #fff; box-shadow: 0 12px 26px -10px var(--gc); }
.modal .badge svg { width: 34px; height: 34px; }
@media (max-width: 600px) {
  .modal-bg { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 30px 30px 0 0; padding-bottom: calc(22px + var(--safe-b, 0px)); }
  .modal::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: -14px auto 14px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 12px 18px; border-radius: 999px; font-weight: 600; z-index: 60; animation: rise .2s ease; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); text-align: center; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 55; }

/* cookie bar */
.cookie { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 70; max-width: 560px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); border-radius: 22px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.cookie p { margin: 0; flex: 1 1 240px; }
.cookie .btn { height: 38px; font-size: 14px; }

@media (max-width: 600px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .topbar .pill { display: none; }
  .gtitle { font-size: 17px; }
  .brand span { font-size: 19px; }
  .streak .lbl-streak { display: none; }
  .timer { padding: 0 11px; }
  .panel { padding: 16px; }
  .side { padding: 2px 16px 16px; }
  .num { width: 64px; height: 64px; font-size: 22px; border-radius: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- app shell (Android: native sets --safe-t = status bar + banner slot, --safe-b = nav bar) ---------- */
.topbar { padding-top: calc(10px + var(--safe-t, 0px)); }
body { padding-bottom: var(--safe-b, 0px); }
.modal-bg { padding-top: calc(16px + var(--safe-t, 0px)); }
.toast { bottom: calc(24px + var(--safe-b, 0px)); }
.board, .numrow, .oprow, .slot { direction: ltr; }
.countdown { margin: 0 0 14px; }
.countdown b { font-family: var(--font-head); font-size: 48px; }
.settings { max-width: 640px; margin: 0 auto; padding: 18px 16px 64px; display: grid; gap: 14px; }
.settings .panel { padding: 6px 20px; }
.setrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; font-weight: 600; font-size: 16px; text-align: start; }
.setrow:last-child { border-bottom: 0; }
.setrow small { color: var(--ink-3); font-weight: 600; font-size: 14px; }
.setbtn { cursor: pointer; }
.setbtn.strong span { color: var(--c-route); }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 32px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch:checked { background: var(--good); }
.switch:checked::after { transform: translateX(20px); }
.settings .credits { padding: 20px; }
.credits h2 { font-family: var(--font-head); font-size: 18px; margin: 0 0 8px; }
.credits p { color: var(--ink-2); margin: 0 0 8px; font-size: 14px; }
.credits .ver { color: var(--ink-3); }
