@font-face { font-family: Chakra; src: url('/fonts/ChakraPetch-600.woff2') format('woff2'); font-weight: 400 650; font-display: swap; }
@font-face { font-family: Chakra; src: url('/fonts/ChakraPetch-700.woff2') format('woff2'); font-weight: 651 900; font-display: swap; }

:root {
  --ink: #090b0a; --panel: #111410; --panel2: #171b15; --line: rgba(255,255,255,.08); --line2: rgba(255,255,255,.14);
  --text: #eef2ea; --dim: #9ba494; --faint: #6d7569;
  --lime: #c3ff5c; --lime-ink: #0b0d0a; --lav: #b9b3ff; --coral: #ff7a6b;
  --r: 14px; --ease: cubic-bezier(.2,.8,.2,1);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); overflow: hidden; overscroll-behavior: none; }
body { font: 500 15px/1.4 Chakra, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
img { image-rendering: pixelated; -webkit-user-drag: none; user-select: none; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.defs { position: absolute; }
svg { width: 22px; height: 22px; flex: none; }
[hidden] { display: none !important; }

/* ---------- frame ---------- */
.app {
  height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: var(--safe-t) var(--safe-r) 0 var(--safe-l);
  background: radial-gradient(120% 60% at 50% -10%, rgba(195,255,92,.07), transparent 60%), var(--ink);
}
.top { display: flex; align-items: center; gap: 10px; padding: 8px 12px 4px 16px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); min-height: 44px; }
.mark { width: 26px; height: 26px; }
.word { font-weight: 800; font-size: 19px; letter-spacing: .14em; }
.setno { font-size: 13px; color: var(--dim); padding: 3px 8px; border: 1px solid var(--line); border-radius: 99px; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); transition: transform .15s var(--ease), background .15s; }
.icon:active { transform: scale(.94); }
.me { margin-left: auto; overflow: hidden; }
.me.on { border-color: rgba(195,255,92,.5); background: #141a10; }
.me img { width: 30px; height: 30px; }

/* ---------- home ---------- */
.home { display: flex; flex-direction: column; min-height: 0; padding: 4px 16px 10px; gap: 12px; overflow-y: auto; scrollbar-width: none; }
.hero { flex: 1 1 auto; min-height: 120px; display: grid; place-items: center; container-type: inline-size; }
.attract { display: grid; grid-template-columns: repeat(4, var(--tile)); gap: 8px; --tile: clamp(44px, min(calc((100cqi - 24px) / 4), 15dvh), 110px); }
.attract:empty { width: calc(4 * var(--tile) + 24px); height: calc(2 * var(--tile) + 8px); border-radius: var(--r); background: linear-gradient(90deg, var(--panel) 30%, var(--panel2) 50%, var(--panel) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.attract .tile { pointer-events: none; }
.pick { display: flex; flex-direction: column; gap: 10px; }
.title { margin: 0; font-size: clamp(22px, 6.4vw, 30px); line-height: 1.1; font-weight: 800; letter-spacing: .01em; text-align: center; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.seg button { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; background: transparent; color: var(--dim); font-weight: 650; transition: background .18s var(--ease), color .18s; }
.seg button svg { width: 18px; height: 18px; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--panel2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.seg button[aria-checked="true"] svg { color: var(--lime); }
.seg button.locked svg { color: var(--lav); }
.seg.small button { min-height: 40px; font-size: 14px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px; min-height: 112px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); transition: transform .15s var(--ease), border-color .18s, background .18s; }
.mode:active { transform: scale(.98); }
.mode[aria-checked="true"] { border-color: rgba(195,255,92,.6); background: linear-gradient(180deg, #151c10, var(--panel)); }
.mode-name { font-size: 18px; font-weight: 800; }
.mode-line { font-size: 13px; color: var(--dim); line-height: 1.3; }
.mode.done::after { content: ''; position: absolute; top: 10px; right: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(195,255,92,.2); }
.mode-art { display: flex; gap: 4px; margin-bottom: 4px; height: 26px; }
.mode-art i { display: grid; place-items: center; width: 20px; height: 26px; border-radius: 5px; background: #20271a; border: 1px solid rgba(195,255,92,.35); font: 700 12px Chakra, sans-serif; color: var(--lime); font-style: normal; }
.pairs-art i:nth-child(2), .pairs-art i:nth-child(3) { background: var(--lime); border-color: var(--lime); }
.recall-art i { width: 22px; }
.mode[aria-checked="false"] .mode-art i { filter: saturate(.3) brightness(.8); }
.deck-note { margin: 0; text-align: center; font-size: 13px; color: var(--dim); min-height: 18px; }
.cta { position: sticky; bottom: 0; padding-top: 2px; }
.primary { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 16px; background: var(--lime); color: var(--lime-ink); font-weight: 800; font-size: 17px; letter-spacing: .02em; box-shadow: 0 10px 30px -12px rgba(195,255,92,.55); transition: transform .15s var(--ease), filter .15s, opacity .2s; }
.primary:active { transform: scale(.97); filter: brightness(.95); }
.primary:disabled { opacity: .45; box-shadow: none; }
.primary.small { width: auto; min-height: 48px; padding: 0 22px; font-size: 16px; }
.ghost { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--line2); background: var(--panel2); font-weight: 650; transition: transform .15s var(--ease); }
.ghost:active { transform: scale(.97); }
.ghost:disabled { opacity: .6; }
.side { display: none; }

/* ---------- tabs and signature ---------- */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px 8px calc(4px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(9,11,10,.92); backdrop-filter: blur(10px); }
.tab { min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--faint); font-size: 12px; font-weight: 650; transition: color .18s; }
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--text); }
.tab.on svg { color: var(--lime); }
.sig { order: 0; text-align: center; font-size: 12px; color: var(--faint); padding: 2px 0 6px; grid-row: 3; }
.sig a { color: var(--dim); text-decoration: none; padding: 6px 2px; }
.app[data-view="game"] .sig { display: none; }
.app .tabs { grid-row: 4; }

/* ---------- game ---------- */
.game { display: flex; flex-direction: column; min-height: 0; padding: 0 12px 8px; gap: 8px; }
.hud { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; }
.hud-mid { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.hud-title { margin: 0; font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.steps li { flex: 1; height: 5px; border-radius: 3px; background: var(--panel2); max-width: 44px; transition: background .25s; }
.steps li.now { background: rgba(195,255,92,.45); }
.steps li.done { background: var(--lime); }
.steps li.miss { background: var(--coral); }
.hud-stats { display: flex; gap: 6px; }
.stat { min-width: 52px; padding: 4px 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.stat b { display: block; font-size: 17px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--faint); }
.stat.hot b { color: var(--lime); }
.board-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.board { display: grid; gap: var(--gap, 8px); --tile: 72px; }
.game-foot { min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 12px; position: relative; }
.hint { margin: 0; font-size: 14px; color: var(--dim); text-align: center; opacity: 0; transition: opacity .25s; }
.hint.on { opacity: 1; }
#ready ~ .hint, .game-foot:has(#ready:not([hidden])) .hint { display: none; }

/* ---------- tiles ---------- */
.tile { position: relative; width: var(--tile); height: var(--tile); padding: 0; border: 0; background: none; perspective: 700px; border-radius: calc(var(--tile) * .14); transition: transform .15s var(--ease), opacity .25s var(--ease); transition-delay: 0s; }
.tile:active:not(.up) { transform: scale(.95); }
.flip { position: absolute; inset: 0; display: block; transform-style: preserve-3d; transition: transform .28s var(--ease); }
.tile.up .flip { transform: rotateY(180deg); }
.back, .face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: calc(var(--tile) * .14); }
.back { color: rgba(195,255,92,.55); background: radial-gradient(90% 70% at 50% 18%, #1f2819, #131711 70%); box-shadow: inset 0 0 0 1px rgba(195,255,92,.18), inset 0 -6px 12px rgba(0,0,0,.35), 0 4px 10px -6px rgba(0,0,0,.8); overflow: hidden; }
.back::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 2px, transparent 2px 6px); }
.back svg { width: 52%; height: 52%; }
.back .emblem { position: absolute; width: 34%; height: 34%; left: 33%; top: 46%; opacity: .9; }
.face { transform: rotateY(180deg); background: radial-gradient(80% 80% at 50% 40%, #1a1f17, #0e110d); box-shadow: inset 0 0 0 1px var(--line2); }
.face img { width: 86%; height: 86%; }
.tile.got .face { box-shadow: inset 0 0 0 2px var(--lime), 0 0 18px -4px rgba(195,255,92,.6); }
.tile.got { animation: got .42s var(--ease); }
.tile.no .face { box-shadow: inset 0 0 0 2px var(--coral); }
.tile.no { animation: no .32s var(--ease); }
@keyframes got { 0% { transform: scale(1); } 45% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes no { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.board.entering .tile { opacity: 0; transform: translateY(10px) scale(.94); }
.board .tile { transition: transform .26s var(--ease), opacity .26s var(--ease); transition-delay: calc(var(--i, 0) * 14ms); }
.board .tile.up, .board .tile:active { transition-delay: 0s; }
.board.cleared .tile { animation: wave .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes wave { 50% { transform: translateY(-6px); } }
.pop { position: absolute; top: -6px; right: -4px; z-index: 3; padding: 2px 7px; border-radius: 99px; background: var(--lime); color: var(--lime-ink); font: 800 13px Chakra, sans-serif; animation: pop .9s var(--ease) forwards; pointer-events: none; }
@keyframes pop { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 20% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }

/* Recall */
.lineup { display: flex; justify-content: center; gap: 8px; --slot: min(calc((100vw - 24px - var(--safe-l) - var(--safe-r) - (var(--n) - 1) * 8px) / var(--n)), 88px, 13dvh); }
.lineup .tile { --tile: var(--slot); }
.game[data-phase="study"] .board-wrap { display: none; }
.game[data-phase="study"] .lineup { flex: 1; min-height: 0; flex-wrap: wrap; align-content: center; gap: 22px 12px; max-width: calc(var(--cols) * (var(--study) + 12px)); margin: 0 auto; width: 100%;
  --study: min(calc((100vw - 32px - var(--safe-l) - var(--safe-r) - (var(--cols) - 1) * 12px) / var(--cols)), 150px, calc((100dvh - 260px) / 2.4)); }
.game[data-phase="study"] .lineup .tile { --tile: var(--study); }
.game[data-phase="study"] .lineup .num { min-width: 26px; height: 26px; font-size: 14px; bottom: -11px; }
.lineup.hidden { padding-bottom: 8px; }
.lineup .num { position: absolute; z-index: 2; left: 50%; bottom: -8px; transform: translateX(-50%); min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 99px; background: var(--ink); border: 1px solid var(--line2); font: 800 12px Chakra, sans-serif; color: var(--text); }
.lineup.study .tile { animation: deal .3s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
.lineup .tile.got .num { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.lineup .tile.missed .face { box-shadow: inset 0 0 0 2px var(--coral); }
.lineup .tile.missed .num { background: var(--coral); color: var(--ink); border-color: var(--coral); }
@keyframes deal { from { opacity: 0; transform: translateY(-8px) scale(.94); } }
.studybar { height: 4px; border-radius: 2px; background: var(--panel2); overflow: hidden; margin: 4px 8px 0; }
.studybar i { display: block; height: 100%; background: var(--lime); transform-origin: left; }
.board.recall .tile.used { opacity: .28; transform: scale(.92); }
.board.recall .tile.wrong .face { box-shadow: inset 0 0 0 2px var(--coral); }
.board.recall .tile.wrong { animation: no .32s var(--ease); }
.board.recall .tile.answer .face { box-shadow: inset 0 0 0 2px var(--lime), 0 0 18px -4px rgba(195,255,92,.6); }
.board.recall .tile.answer { animation: got .5s var(--ease) 2; }

/* ---------- sheets ---------- */
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88dvh; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: #0f120e; color: var(--text); box-shadow: 0 -20px 60px rgba(0,0,0,.6); border-top: 1px solid var(--line2); }
dialog.sheet[open] { animation: up .24s var(--ease); }
dialog.sheet::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(2px); animation: fade .2s; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-in { position: relative; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; padding: 10px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.grab { align-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line2); }
.sheet h2 { margin: 0; font-size: 22px; font-weight: 800; padding-right: 48px; }
.close { position: absolute; top: 10px; right: 12px; }
.kicker { margin: 0; font-size: 13px; color: var(--lav); font-weight: 650; letter-spacing: .03em; }
.big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bigstat { padding: 10px 6px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.bigstat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--lime); }
.bigstat span { font-size: 12px; color: var(--dim); }
.faces { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; justify-content: center; }
.faces li { width: 44px; height: 44px; border-radius: 10px; background: var(--panel); display: grid; place-items: center; animation: deal .3s var(--ease) both; }
.faces li:nth-child(2) { animation-delay: 40ms; } .faces li:nth-child(3) { animation-delay: 80ms; } .faces li:nth-child(4) { animation-delay: 120ms; }
.faces li:nth-child(5) { animation-delay: 160ms; } .faces li:nth-child(6) { animation-delay: 200ms; } .faces li:nth-child(n+7) { animation-delay: 240ms; }
.faces img { width: 38px; height: 38px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row .primary { min-height: 50px; }
.note { margin: 0; font-size: 13px; color: var(--dim); }
.seed { text-align: center; color: var(--faint); font-size: 12px; }
.msg { margin: 0; font-size: 14px; color: var(--lav); min-height: 1em; }
.post-box { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; background: #12170e; border: 1px solid rgba(195,255,92,.25); }
.post-box img { width: 40px; height: 40px; border-radius: 8px; background: var(--panel); }
.post-box .ghost { min-height: 44px; }
.post-box .note { margin-top: 4px; }
.board-panel { display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.rows { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rows li { display: grid; grid-template-columns: 28px 32px 1fr auto; align-items: center; gap: 10px; padding: 6px 10px; min-height: 48px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.rows li.you { border-color: rgba(195,255,92,.5); background: #141a10; }
.rows .rank { font-weight: 800; color: var(--dim); text-align: center; font-variant-numeric: tabular-nums; }
.rows li:nth-child(1) .rank { color: var(--lime); }
.rows img { width: 32px; height: 32px; }
.rows .addr { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .val { text-align: right; display: flex; flex-direction: column; line-height: 1.1; }
.rows .val b { font-variant-numeric: tabular-nums; }
.rows .val small { font-size: 12px; color: var(--faint); }
.mine-row { margin-top: 2px; }
.empty { margin: 0; padding: 18px 12px; text-align: center; color: var(--dim); font-size: 14px; border: 1px dashed var(--line2); border-radius: 14px; }
.join { width: 100%; }
.skeleton-row { height: 48px; border-radius: 12px; background: linear-gradient(90deg, var(--panel) 30%, var(--panel2) 50%, var(--panel) 70%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -300% 0; } }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stat-grid dt { display: none; }
.stat-grid dd { margin: 0; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 4px; }
.stat-grid dd b { font-size: 24px; color: var(--lime); font-variant-numeric: tabular-nums; }
.stat-grid dd span { font-size: 13px; color: var(--dim); }
.stat-grid dd small { flex-basis: 100%; font-size: 12px; color: var(--faint); }
.seedinfo { font-size: 13px; color: var(--dim); }
.seedinfo summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--text); }
.seedinfo code { font-size: 12px; color: var(--lav); word-break: break-all; }
.seedinfo a { color: var(--lime); }
.perks { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.perks li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.perks svg { color: var(--lime); width: 20px; height: 20px; }
.wallets { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.wallet { width: 100%; min-height: 54px; display: flex; align-items: center; gap: 12px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line2); background: var(--panel2); font-weight: 650; text-align: left; }
.wallet img, .wallet svg { width: 30px; height: 30px; border-radius: 8px; image-rendering: auto; }
.addr { font-size: 13px; color: var(--dim); font-weight: 500; }
.mine { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.mine button { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--dim); }
.mine button[aria-pressed="true"] { border-color: var(--lime); color: var(--text); background: #141a10; }
.mine img { width: 56px; height: 56px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 12px); padding: 10px 16px; border-radius: 99px; background: var(--text); color: var(--ink); font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 50; white-space: nowrap; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 24px; text-align: center; }

/* ---------- short phones ---------- */
@media (max-height: 600px) {
  .top { min-height: 48px; padding-top: 4px; padding-bottom: 0; }
  .home { gap: 8px; }
  .title { display: none; }
  .mode { min-height: 92px; padding: 10px; }
  .mode-art { display: none; }
  .tab { min-height: 48px; }
  .attract { --tile: clamp(40px, min(calc((100cqi - 24px) / 4), 12dvh), 80px); }
}

/* ---------- phone landscape ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .app { grid-template-rows: auto minmax(0, 1fr) auto; }
  .tabs { display: none; }
  .sig { grid-row: 3; padding-bottom: calc(4px + var(--safe-b)); }
  .top { min-height: 46px; }
  .home { display: grid; grid-template-columns: 1fr minmax(300px, 1.1fr); grid-template-rows: 1fr auto; column-gap: 20px; row-gap: 8px; padding-top: 0; }
  .hero { grid-row: 1 / 3; min-height: 0; }
  .attract { --tile: clamp(40px, min(calc((100cqi - 24px) / 4), 19dvh), 88px); }
  .pick { align-self: center; gap: 8px; }
  .title { display: none; }
  .mode { min-height: 84px; }
  .mode-art { display: none; }
  .cta { grid-column: 2; }
  .primary { min-height: 48px; }
  .game { display: grid; grid-template-columns: minmax(0, 1fr); padding-bottom: calc(4px + var(--safe-b)); gap: 4px; }
  .hud { grid-template-columns: 44px 1fr auto; }
  .game-foot { min-height: 44px; }
  .lineup { --slot: min(calc((100vw - 24px - var(--safe-l) - var(--safe-r) - (var(--n) - 1) * 8px) / var(--n)), 64px, 17dvh); }
  .toast { bottom: calc(20px + var(--safe-b)); }
}

/* ---------- tablet and desktop ---------- */
@media (min-width: 900px) and (min-height: 600px) {
  .app { grid-template-rows: auto minmax(0, 1fr) auto; }
  .top { padding: 14px 28px 6px; }
  .tabs { grid-row: 1; position: fixed; top: calc(14px + var(--safe-t)); right: 88px; display: flex; gap: 4px; padding: 0; border: 0; background: none; backdrop-filter: none; }
  .tab { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 12px; font-size: 14px; color: var(--dim); }
  .tab:hover { background: var(--panel); color: var(--text); }
  .tab.on { background: transparent; }
  #tab-play { display: none; }
  .sig { grid-row: 3; padding-bottom: calc(10px + var(--safe-b)); }
  .home { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 440px) 320px; grid-template-rows: 1fr auto; column-gap: 32px; row-gap: 14px; padding: 12px 28px 16px; align-items: center; max-width: 1500px; width: 100%; margin: 0 auto; overflow: hidden; }
  .hero { grid-row: 1 / 3; align-self: stretch; }
  .attract { --tile: clamp(60px, min(calc((100cqi - 36px) / 4), 19dvh), 150px); gap: 12px; }
  .pick { grid-column: 2; align-self: end; gap: 14px; }
  .title { text-align: left; font-size: 38px; }
  .deck-note { text-align: left; }
  .cta { grid-column: 2; align-self: start; position: static; }
  .side { grid-column: 3; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 14px; align-self: center; }
  .side-block { padding: 14px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
  .side-block h2 { margin: 0; font-size: 13px; color: var(--dim); font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
  .streak-row { display: flex; align-items: baseline; gap: 8px; }
  .streak-row svg { color: var(--lime); align-self: center; }
  .streak-row b { font-size: 34px; line-height: 1; }
  .streak-row span { color: var(--dim); }
  .side .empty { padding: 12px; }
  .game { padding: 4px 28px 18px; gap: 12px; max-width: 1200px; width: 100%; margin: 0 auto; }
  .hud { grid-template-columns: 44px minmax(0, 1fr) auto; max-width: 900px; width: 100%; margin: 0 auto; }
  .stat { min-width: 70px; padding: 6px 12px; }
  .stat b { font-size: 20px; }
  .tile:hover:not(.up) .back { box-shadow: inset 0 0 0 1px rgba(195,255,92,.45), 0 8px 18px -8px rgba(195,255,92,.35); }
  .tile:hover:not(.up):not(:active) { transform: translateY(-2px); }
  dialog.sheet { margin: auto; border-radius: 22px; border: 1px solid var(--line2); max-height: 84dvh; }
  dialog.sheet[open] { animation: pop-in .22s var(--ease); }
  @keyframes pop-in { from { transform: scale(.96); opacity: 0; } }
  .toast { bottom: 28px; }
}
/* Tablet landscape and small laptops: art and your stats on the left, the picker on the right. */
@media (min-width: 900px) and (max-width: 1279px) and (min-height: 600px) {
  .home { grid-template-columns: minmax(0, 1fr) minmax(360px, 420px); grid-template-rows: minmax(0, 1fr) auto auto; overflow-y: auto; }
  .hero { grid-row: 1; grid-column: 1; }
  .side { grid-column: 1; grid-row: 2 / 4; flex-direction: row; align-self: start; }
  .side-block:first-child { flex: 0 0 150px; }
  .side-board { flex: 1; }
  .pick { grid-row: 1 / 3; align-self: end; }
  .cta { grid-row: 3; }
}
/* Tablet portrait: room for the side board under the game picker. */
@media (min-width: 700px) and (max-width: 899px) and (min-height: 900px) {
  .home { padding: 12px 40px; gap: 18px; max-width: 760px; margin: 0 auto; width: 100%; }
  .attract { --tile: clamp(90px, 16vw, 140px); gap: 12px; }
  .title { font-size: 36px; }
  .side { display: block; }
  .side-block:first-child { display: none; }
  .side-board { display: flex; flex-direction: column; gap: 8px; }
  .side-board h2 { margin: 0; font-size: 13px; color: var(--dim); letter-spacing: .04em; text-transform: uppercase; }
  .tab { flex-direction: row; gap: 8px; font-size: 14px; }
  dialog.sheet { margin: auto; border-radius: 22px; border: 1px solid var(--line2); }
}

/* ---------- reduced motion: fades instead of flips and bounces ---------- */
@media (prefers-reduced-motion: reduce) {
  .flip, .tile.up .flip { transform: none; transition: none; }
  .back, .face { backface-visibility: visible; transition: opacity .18s linear; }
  .face { transform: none; opacity: 0; }
  .tile.up .face { opacity: 1; }
  .tile.up .back { opacity: 0; }
  .tile.got, .tile.no, .board.cleared .tile, .lineup.study .tile, .faces li, .board.recall .tile.answer, .board.recall .tile.wrong { animation: none; }
  .board.entering .tile { transform: none; }
  .board .tile { transition: opacity .18s linear; transition-delay: 0s; }
  dialog.sheet[open], dialog.sheet::backdrop { animation: fade .15s; }
  .attract:empty, .skeleton-row { animation: none; }
  .pop { animation: fade .2s reverse forwards 0.6s; }
}

/* offline and 404 pages */
.offline { height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.offline h1 { margin: 0; font-size: 26px; }
.offline p { margin: 0; color: var(--dim); max-width: 32ch; }
.offline .primary { width: auto; padding: 0 28px; text-decoration: none; }

/* In a game the board gets the whole screen on phones: no tab bar. */
@media (max-width: 899px), (max-height: 599px) {
  .app[data-view="game"] .tabs { display: none; }
  .app[data-view="game"] .game { padding-bottom: calc(8px + var(--safe-b)); }
}
