/* ============ Tokens ============ */
:root {
  --bg: #070914;
  --bg-2: #0d1127;
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .085);
  --surface-solid: #11152c;
  --border: rgba(255, 255, 255, .09);
  --border-2: rgba(255, 255, 255, .16);
  --text: #f1f3ff;
  --text-2: #a6acca;
  --text-3: #7a809f;
  --accent: #ffc233;
  --accent-ink: #1a1200;
  --violet: #8b7bff;
  --danger: #ff6b7d;
  --wall-top: #2f3560;
  --wall-bot: #191d38;
  --wall-edge: rgba(0, 0, 0, .45);
  --floor-dot: rgba(255, 255, 255, .07);
  --board-1: rgba(30, 36, 74, .72);
  --board-2: rgba(14, 18, 40, .82);
  --socket-in: rgba(0, 0, 0, .42);
  --o0: #ff4d6d;
  --o1: #3da9fc;
  --o2: #ffc233;
  --o3: #2ee59d;
  --radius: 22px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: 'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --board-size: min(calc(100vw - 32px), 468px, max(272px, calc(100dvh - 318px)));
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f1ec;
  --bg-2: #e8e4db;
  --surface: rgba(255, 255, 255, .62);
  --surface-2: rgba(255, 255, 255, .9);
  --surface-solid: #fbfaf7;
  --border: rgba(24, 26, 52, .1);
  --border-2: rgba(24, 26, 52, .18);
  --text: #121429;
  --text-2: #4b5070;
  --text-3: #6b708e;
  --accent: #e8a200;
  --accent-ink: #1a1200;
  --wall-top: #454c7d;
  --wall-bot: #2a2f55;
  --wall-edge: rgba(20, 22, 50, .35);
  --floor-dot: rgba(20, 22, 60, .1);
  --board-1: rgba(255, 255, 255, .85);
  --board-2: rgba(236, 233, 245, .9);
  --socket-in: rgba(30, 30, 70, .14);
  color-scheme: light;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
svg { display: block; }
a { color: inherit; }
:focus-visible { outline: 2.5px solid var(--violet); outline-offset: 3px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 10px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }

/* Ambient aurora */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; }
.aurora i:nth-child(1) { width: 60vmax; height: 60vmax; left: -20vmax; top: -25vmax; background: radial-gradient(circle, #3b2a9a 0%, transparent 65%); animation: drift 26s ease-in-out infinite alternate; }
.aurora i:nth-child(2) { width: 55vmax; height: 55vmax; right: -22vmax; top: 10vh; background: radial-gradient(circle, #0f5d8f 0%, transparent 65%); animation: drift 32s ease-in-out infinite alternate-reverse; }
.aurora i:nth-child(3) { width: 45vmax; height: 45vmax; left: 20vw; bottom: -30vmax; background: radial-gradient(circle, #6a1f63 0%, transparent 65%); opacity: .35; animation: drift 38s ease-in-out infinite alternate; }
[data-theme="light"] .aurora i { opacity: .28; }
@keyframes drift { to { transform: translate3d(6vw, 4vh, 0) scale(1.08); } }

/* ============ Header ============ */
.top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  max-width: 560px; margin: 0 auto; padding: 10px 12px 4px;
}
.top-side { display: flex; gap: 4px; }
.top-side.right { justify-content: flex-end; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 14px; color: var(--text-2);
  transition: background .18s, color .18s, transform .18s var(--ease-out);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.logo { width: 32px; height: 32px; filter: drop-shadow(0 4px 10px rgba(139, 123, 255, .45)); }
.wordmark { font-weight: 800; font-size: 25px; letter-spacing: .14em; line-height: 1; background: linear-gradient(180deg, var(--text) 30%, color-mix(in oklab, var(--text) 65%, var(--violet))); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ============ Game ============ */
.game { max-width: 560px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; align-items: center; }
.meta-row { margin: 4px 0 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 14px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; font-weight: 500; color: var(--text-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.pill #day-label { color: var(--text); font-weight: 600; }
.diff { display: inline-flex; gap: 3px; }
.diff i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-2); }
.diff i.on { background: var(--accent); box-shadow: 0 0 6px color-mix(in oklab, var(--accent) 70%, transparent); }
.diff-label { font-size: 13px; }

.hud { display: grid; grid-template-columns: repeat(4, 1fr); width: var(--board-size); margin-bottom: 12px; }
.hud-cell { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.hud-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.hud-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.hud-val.bump { animation: bump .32s var(--ease-spring); }
.hud-val.over { color: var(--danger); }
@keyframes bump { 40% { transform: scale(1.22); } }
.progress { display: flex; gap: 6px; height: 27px; align-items: center; }
.progress i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--c); opacity: .55; transition: all .3s var(--ease-spring); }
.progress i.on { background: var(--c); opacity: 1; box-shadow: 0 0 10px var(--c); transform: scale(1.12); }

/* Stage & board */
.stage { perspective: 1100px; touch-action: none; user-select: none; -webkit-user-select: none; padding: 6px; }
.board-wrap {
  position: relative; width: var(--board-size); aspect-ratio: 1;
  transform-style: preserve-3d; transition: transform .34s var(--ease-spring);
}
.board-wrap.t0 { transform: rotateX(7deg); transition-duration: .14s; transition-timing-function: var(--ease-out); }
.board-wrap.t2 { transform: rotateX(-7deg); transition-duration: .14s; transition-timing-function: var(--ease-out); }
.board-wrap.t1 { transform: rotateY(7deg); transition-duration: .14s; transition-timing-function: var(--ease-out); }
.board-wrap.t3 { transform: rotateY(-7deg); transition-duration: .14s; transition-timing-function: var(--ease-out); }
.board-wrap.shake { animation: shake .32s var(--ease-out); }
@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.board-wrap.won { animation: wonPulse 1.1s var(--ease-out); }
@keyframes wonPulse { 30% { transform: scale(1.025); } }

.board {
  --n: 6;
  position: relative; width: 100%; height: 100%; padding: 3.2%;
  border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, .07), transparent 55%),
    linear-gradient(160deg, var(--board-1), var(--board-2));
  border: 1px solid var(--border-2);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .12) inset,
    0 -14px 30px -18px rgba(0, 0, 0, .5) inset,
    0 30px 60px -24px rgba(0, 0, 0, .65),
    0 0 0 1px rgba(0, 0, 0, .25);
  outline: none;
}
[data-theme="light"] .board { box-shadow: 0 1px 0 #fff inset, 0 24px 50px -24px rgba(40, 40, 90, .35), 0 0 0 1px rgba(255, 255, 255, .6); }
.board:focus-visible { box-shadow: 0 0 0 3px var(--violet), 0 30px 60px -24px rgba(0, 0, 0, .65); }
.grid { position: relative; width: 100%; height: 100%; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); }
.cell { position: relative; }
.cell::before { content: ''; position: absolute; left: 50%; top: 50%; width: 3px; height: 3px; margin: -1.5px; border-radius: 50%; background: var(--floor-dot); }
.cell.wall::before { display: none; }
.cell.wall::after {
  content: ''; position: absolute; inset: 5%; border-radius: 24%;
  background: linear-gradient(180deg, var(--wall-top), var(--wall-bot));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .16) inset, 0 -3px 0 var(--wall-edge) inset, 0 6px 12px -6px rgba(0, 0, 0, .7);
}
.cell.anchor::before { display: none; }
.cell.anchor::after {
  content: ''; position: absolute; inset: 30%; transform: rotate(45deg); border-radius: 22%;
  border: 2px solid var(--text-3); background: color-mix(in oklab, var(--text-3) 18%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--text-3) 10%, transparent);
}
.socket { position: absolute; inset: 15%; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 60%, var(--socket-in), transparent 72%);
  border: 2px solid color-mix(in oklab, var(--c) 75%, transparent);
  box-shadow: 0 0 14px -2px color-mix(in oklab, var(--c) 55%, transparent), inset 0 3px 8px rgba(0, 0, 0, .45);
  color: color-mix(in oklab, var(--c) 85%, transparent);
}
.socket svg { width: 42%; height: 42%; opacity: .9; }
.socket.filled { border-color: var(--c); }

/* Orbs */
.orbs { position: absolute; inset: 3.2%; pointer-events: none; }
.orb {
  position: absolute; left: 0; top: 0; width: calc(100% / var(--n)); height: calc(100% / var(--n));
  transition-property: transform; transition-timing-function: cubic-bezier(.45, .05, .8, .5);
  will-change: transform;
}
.orb .shadow { position: absolute; left: 22%; right: 22%; bottom: 10%; height: 14%; border-radius: 50%; background: rgba(0, 0, 0, .45); filter: blur(4px); }
.ball {
  position: absolute; inset: 14%; border-radius: 50%; display: grid; place-items: center;
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .95) 0 5%, rgba(255, 255, 255, .0) 22%),
    radial-gradient(circle at 40% 35%, color-mix(in oklab, var(--c) 55%, white) 0%, var(--c) 45%, color-mix(in oklab, var(--c) 55%, black) 100%);
  box-shadow: inset -3px -5px 10px rgba(0, 0, 0, .3), inset 2px 3px 6px rgba(255, 255, 255, .25), 0 0 22px -4px color-mix(in oklab, var(--c) 80%, transparent);
  color: rgba(0, 0, 0, .38);
}
.ball svg { width: 40%; height: 40%; opacity: 0; transition: opacity .2s; }
.glyphs .ball svg { opacity: 1; }
.socket svg { opacity: 0; }
.glyphs .socket svg { opacity: .9; }
.ball.impact-x { animation: squashX .26s var(--ease-out); }
.ball.impact-y { animation: squashY .26s var(--ease-out); }
@keyframes squashX { 30% { transform: scale(.82, 1.12); } 65% { transform: scale(1.04, .97); } }
@keyframes squashY { 30% { transform: scale(1.12, .82); } 65% { transform: scale(.97, 1.04); } }
.orb.locked .ball { box-shadow: inset -3px -5px 10px rgba(0, 0, 0, .3), inset 2px 3px 6px rgba(255, 255, 255, .25), 0 0 0 3px var(--bg-2), 0 0 0 5px var(--c), 0 0 26px var(--c); }
.orb.locked .ball svg { opacity: 1; color: rgba(255, 255, 255, .9); }
.orb.locked::after { content: ''; position: absolute; inset: 8%; border-radius: 50%; border: 2px solid var(--c); animation: ring .7s var(--ease-out) forwards; }
@keyframes ring { from { transform: scale(.7); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
.orb.pop .ball { animation: pop .45s var(--ease-spring); }
@keyframes pop { 40% { transform: scale(1.18); } }

.fx { position: absolute; inset: -20%; width: 140%; height: 140%; pointer-events: none; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

.hint-arrow { position: absolute; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-ink); opacity: 0; pointer-events: none; box-shadow: 0 10px 30px -6px color-mix(in oklab, var(--accent) 70%, transparent); transition: opacity .2s; left: calc(50% - 28px); top: calc(50% - 28px); }
.hint-arrow svg { width: 30px; height: 30px; }
.hint-arrow.show { opacity: 1; animation: nudge 1s var(--ease-out) infinite; }
@keyframes nudge { 50% { translate: var(--hx, 0) var(--hy, 0); } }

.swipe-hint { margin: 10px 0 6px; font-size: 13px; color: var(--text-3); text-align: center; }

/* Controls */
.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: var(--board-size); margin-top: 4px; }
.ctl {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 70px; height: 62px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--text-2); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform .15s var(--ease-out), background .2s, color .2s, border-color .2s;
}
.ctl svg { width: 22px; height: 22px; }
.ctl:hover { background: var(--surface-2); color: var(--text); }
.ctl:active { transform: scale(.94); }
.ctl:disabled { opacity: .4; cursor: default; transform: none; }
.ctl.attn { border-color: var(--accent); color: var(--accent); animation: attn 1.2s ease-in-out 3; }
@keyframes attn { 50% { box-shadow: 0 0 0 6px color-mix(in oklab, var(--accent) 22%, transparent); } }
.dpad { display: grid; grid-template-columns: repeat(4, 48px); gap: 6px; }
.dbtn { height: 48px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--text-2); transition: transform .12s var(--ease-out), background .2s, color .2s; }
.dbtn svg { width: 20px; height: 20px; }
.dbtn:hover { background: var(--surface-2); color: var(--text); }
.dbtn:active, .dbtn.press { transform: scale(.9); background: var(--surface-2); color: var(--text); }
.dbtn.hinted { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.secondary-row { display: flex; gap: 18px; margin: 12px 0 8px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--text-3); font-size: 14px; font-weight: 500; padding: 10px 8px; border-radius: 10px; }
.link-btn svg { width: 16px; height: 16px; }
.link-btn:hover { color: var(--text); }

@media (max-width: 380px) {
  .dpad { grid-template-columns: repeat(4, 42px); gap: 4px; }
  .dbtn { height: 44px; }
  .ctl { min-width: 60px; }
}

/* ============ Content ============ */
.ad-slot { max-width: 728px; min-height: 100px; margin: 28px auto 0; padding: 0 16px; display: flex; justify-content: center; }
.seo { max-width: 640px; margin: 48px auto 0; padding: 0 20px; color: var(--text-2); }
.seo h1 { font-size: 24px; line-height: 1.25; color: var(--text); margin: 0 0 10px; }
.seo h2 { font-size: 18px; color: var(--text); margin: 28px 0 6px; }
.seo p { margin: 0 0 10px; }
.seo details { border-top: 1px solid var(--border); padding: 12px 0; }
.seo summary { cursor: pointer; color: var(--text); font-weight: 600; }
.seo details p { margin: 8px 0 0; }
.foot { max-width: 640px; margin: 40px auto 0; padding: 20px 20px 40px; text-align: center; color: var(--text-3); font-size: 14px; }
.studio { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 0 0 6px; color: var(--text-2); font-weight: 500; }
.studio svg { flex: none; }
.langs { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin-bottom: 8px; }
.langs a { color: var(--text-2); text-decoration: none; }
.langs a:hover { color: var(--text); text-decoration: underline; }
.embed-cta { display: none; }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 80;
  transform: translate(-50%, -140%); padding: 11px 18px; border-radius: 14px; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px; text-align: center;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .5); transition: transform .3s var(--ease-spring);
}
.toast.show { transform: translate(-50%, 0); }

/* ============ Dialogs ============ */
dialog.sheet {
  width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); overflow: auto;
  border: 1px solid var(--border-2); border-radius: 28px; padding: 28px 24px 24px;
  background: color-mix(in oklab, var(--surface-solid) 94%, transparent); color: var(--text);
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .7);
}
dialog.sheet[open] { animation: sheetIn .34s var(--ease-spring); }
dialog.sheet.tall { width: min(560px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(4, 6, 16, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
[data-theme="light"] dialog::backdrop { background: rgba(30, 30, 60, .35); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px) scale(.96); } }
dialog h2 { margin: 0 0 16px; font-size: 26px; font-weight: 700; text-align: center; letter-spacing: -.01em; }
dialog h3 { margin: 22px 0 10px; font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); text-align: center; }
.close { position: absolute; right: 12px; top: 12px; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 14px; display: grid; place-items: center; color: var(--text-3); }
.close svg { width: 20px; height: 20px; }
.close:hover { background: var(--surface-2); color: var(--text); }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 54px; margin-top: 18px;
  border: 0; border-radius: 16px; font-size: 17px; font-weight: 700; text-decoration: none;
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 88%, white), var(--accent)); color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 12px 26px -10px color-mix(in oklab, var(--accent) 80%, transparent);
  transition: transform .15s var(--ease-out), filter .2s;
}
.cta svg { width: 20px; height: 20px; }
.cta:hover { filter: brightness(1.05); }
.cta:active { transform: scale(.97); }
.cta.alt { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.ghost { display: flex; align-items: center; justify-content: center; gap: 8px; height: 48px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 15px; color: var(--text); transition: background .2s, transform .15s; }
.ghost svg { width: 18px; height: 18px; color: var(--text-2); }
.ghost:hover { background: var(--surface-2); }
.ghost:active { transform: scale(.97); }
.ghost.wide { width: 100%; margin-bottom: 16px; }

/* Help */
.demo-wrap { width: min(220px, 60vw); aspect-ratio: 1; margin: 0 auto 18px; }
.board.demo { --radius: 18px; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.rules li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: center; color: var(--text-2); font-size: 15px; line-height: 1.4; }
.rule-ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); }
.rule-ico svg { width: 18px; height: 18px; }
.rule-ico.tilt { color: var(--o1); }
.rule-ico.star { color: var(--accent); }
.rule-ico.sock::after { content: ''; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--o0); box-shadow: 0 0 10px -2px var(--o0); }
.rule-ico.anchor::after { content: ''; width: 12px; height: 12px; transform: rotate(45deg); border-radius: 3px; border: 2px solid var(--text-3); }

/* Win */
.stars { display: flex; justify-content: center; gap: 8px; margin: 2px 0 10px; }
.stars svg { width: 46px; height: 46px; color: var(--border-2); transition: color .2s; }
.stars svg:nth-child(2) { width: 58px; height: 58px; margin-top: -10px; }
.stars svg.on { color: var(--accent); filter: drop-shadow(0 6px 14px color-mix(in oklab, var(--accent) 60%, transparent)); animation: starIn .5s var(--ease-spring) both; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } }
.win h2 { margin-bottom: 4px; }
.win-sub { text-align: center; color: var(--text-2); margin: 0 0 18px; }
.win-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.win-grid > div { display: flex; flex-direction: column; align-items: center; padding: 10px 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.big { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.lbl { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.share-preview { margin: 16px 0 0; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px dashed var(--border-2); font-size: 15px; line-height: 1.45; white-space: pre-wrap; text-align: center; color: var(--text-2); }
.win-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.countdown { text-align: center; color: var(--text-3); margin: 18px 0 0; font-size: 14px; }
.countdown strong { color: var(--text); font-variant-numeric: tabular-nums; font-size: 17px; margin-left: 4px; }
.install { display: block; margin: 14px auto 0; background: none; border: 0; color: var(--violet); font-weight: 600; text-decoration: underline; padding: 8px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-grid > div { display: flex; flex-direction: column; align-items: center; text-align: center; }
.dist { display: grid; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 52px 1fr; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.dist-bar { height: 26px; border-radius: 8px; background: var(--surface-2); min-width: 30px; display: flex; align-items: center; justify-content: flex-end; padding: 0 9px; color: var(--text); font-variant-numeric: tabular-nums; transition: width .6s var(--ease-out); }
.dist-bar.hi { background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 60%, transparent), var(--accent)); color: var(--accent-ink); }
.empty { text-align: center; color: var(--text-3); margin: 8px 0; }

/* Settings */
.setting { display: flex; justify-content: space-between; align-items: center; min-height: 56px; border-bottom: 1px solid var(--border); gap: 12px; }
.setting label { font-weight: 500; }
.setting select { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-height: 40px; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--border-2); position: relative; cursor: pointer; transition: background .2s; margin: 0; flex: none; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); transition: transform .25s var(--ease-spring); }
.switch:checked { background: var(--o3); }
.switch:checked::after { transform: translateX(20px); }

/* Archive */
.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.arch {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text-2);
  transition: background .2s, transform .15s;
}
.arch:hover { background: var(--surface-2); }
.arch:active { transform: scale(.96); }
.arch b { font-size: 17px; color: var(--text); }
.arch .st { display: flex; gap: 1px; height: 14px; }
.arch .st svg { width: 13px; height: 13px; color: var(--border-2); }
.arch .st svg.on { color: var(--accent); }
.arch.today { border-color: var(--violet); }

/* Embed mode */
.embed .seo, .embed .foot, .embed .ad-slot, .embed #btn-archive, .embed .aurora { display: none !important; }
.embed .embed-cta { display: block; text-align: center; margin: 4px auto 16px; color: var(--text-2); font-weight: 600; font-size: 14px; }

/* Reduced motion: calm the decorative effects only. Orbs still roll, so the game stays readable. */
@media (prefers-reduced-motion: reduce) {
  .board-wrap.t0, .board-wrap.t1, .board-wrap.t2, .board-wrap.t3 { transform: none; }
  .board-wrap.shake, .board-wrap.won { animation: none; }
  .aurora i { animation: none; }
  .hint-arrow.show, .g-live i { animation: none; }
}
/* Lite mode: set automatically on low-power phones and data-saver. Keeps motion, drops the heavy effects. */
.lite .aurora i { animation: none; }
.lite .orb .shadow { filter: none; }
.lite .ball { box-shadow: inset -3px -5px 10px rgba(0, 0, 0, .3), inset 2px 3px 6px rgba(255, 255, 255, .25); }
.lite .orb.locked .ball { box-shadow: inset -3px -5px 8px rgba(0, 0, 0, .3), 0 0 0 3px var(--bg-2), 0 0 0 5px var(--c); }
.lite .stars svg.on { filter: none; }

/* ============ v2: coach, expert, shields, live stats ============ */
.swipe-hint { transition: color .2s, background .2s; border-radius: 12px; padding: 6px 12px; max-width: var(--board-size); }
.swipe-hint.active { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); font-size: 15px; font-weight: 600; animation: coachIn .35s var(--ease-spring); }
@keyframes coachIn { from { transform: translateY(6px); opacity: 0; } }
body.tutorial #btn-hint, body.tutorial .hud-cell:nth-child(2) { visibility: hidden; }

.pill.expert { border-color: color-mix(in oklab, var(--danger) 55%, transparent); background: color-mix(in oklab, var(--danger) 12%, var(--surface)); }
.diff i.on.x { background: var(--danger); box-shadow: 0 0 6px color-mix(in oklab, var(--danger) 70%, transparent); }
.pill.expert .diff-label { color: var(--danger); font-weight: 700; }
.expert-cta { margin-top: 10px; border-color: color-mix(in oklab, var(--danger) 45%, transparent) !important; }
.expert-cta svg { color: var(--danger); }

.shields { display: inline-flex; gap: 2px; align-items: center; margin-top: 2px; }
.shields svg { width: 13px; height: 13px; color: var(--border-2); }
.shields svg.on { color: var(--o1); filter: drop-shadow(0 0 4px color-mix(in oklab, var(--o1) 60%, transparent)); }
.stat-shields { display: flex; justify-content: center; gap: 6px; margin: 14px 0 0; color: var(--text-2); font-size: 14px; }
.stat-shields svg { width: 18px; height: 18px; }
.stat-shields span { margin-left: 6px; }
.win-note { text-align: center; margin: 12px 0 0; padding: 10px 12px; border-radius: 14px; font-weight: 600; color: var(--accent); background: color-mix(in oklab, var(--accent) 12%, transparent); border: 1px solid color-mix(in oklab, var(--accent) 35%, transparent); }

.global { margin-top: 16px; padding: 14px 14px 10px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); }
.g-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--text-2); font-weight: 600; }
.g-live { display: inline-flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .1em; font-size: 11px; color: var(--o3); }
.g-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--o3); box-shadow: 0 0 0 0 var(--o3); animation: livePulse 1.6s ease-out infinite; }
@keyframes livePulse { 70% { box-shadow: 0 0 0 7px transparent; } }
.g-beat { margin: 6px 0 10px; font-size: 20px; font-weight: 700; text-align: center; }
.g-bars { display: flex; align-items: flex-end; gap: 6px; height: 138px; padding-top: 12px; }
.g-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.g-n, .g-m, .g-bar { flex-shrink: 0; }
.g-n { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; min-height: 14px; }
.g-bar { width: 100%; border-radius: 6px 6px 3px 3px; background: var(--surface-2); border: 1px solid var(--border); transition: height .6s var(--ease-out); }
.g-col.me .g-bar { background: linear-gradient(180deg, var(--accent), color-mix(in oklab, var(--accent) 60%, transparent)); border-color: transparent; box-shadow: 0 6px 18px -6px color-mix(in oklab, var(--accent) 70%, transparent); }
.g-col.me .g-n { color: var(--text); font-weight: 700; }
.g-m { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; flex-direction: column; align-items: center; line-height: 1.2; min-height: 30px; }
.g-m b { font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.g-foot { margin: 6px 0 0; text-align: center; font-size: 13px; color: var(--text-3); }
.arch { position: relative; }
.xbadge { position: absolute; top: 6px; right: 7px; font-size: 10px; font-weight: 800; color: var(--danger); }

/* ============ Responsive polish: phones, tablets, laptops ============ */
/* Controls always fit the board width, never the screen edge. */
.controls { gap: 10px; }
.dpad { flex: 1 1 auto; min-width: 0; max-width: 270px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ctl { flex: none; }
.game { padding-bottom: 12px; }

/* Phones */
@media (max-width: 599px) {
  :root { --board-size: min(calc(100vw - 28px), 468px, max(272px, calc(100dvh - 330px))); }
  .top { padding: 8px 8px 2px; }
  .game { padding-left: 14px; padding-right: 14px; }
  .meta-row { margin: 2px 0 10px; }
  .hud { margin-bottom: 8px; }
  .stage { padding: 4px; }
  .dbtn { height: 52px; border-radius: 16px; }
  .ctl { min-width: 64px; height: 64px; }
  .seo { margin-top: 28px; padding: 0 18px; }
  .seo h1 { font-size: 22px; }
}

/* Tablets */
@media (min-width: 600px) and (max-width: 899px) {
  :root { --board-size: min(calc(100vw - 96px), 540px, max(320px, calc(100dvh - 330px))); }
  .top, .game { max-width: 640px; }
  .hud-val { font-size: 25px; }
  .dbtn { height: 54px; }
  .ctl { height: 68px; min-width: 78px; }
}

/* Small laptops / tablet landscape: single column that still fits the screen height */
@media (min-width: 900px) and (min-height: 600px) {
  :root { --board-size: min(560px, max(340px, calc(100dvh - 450px))); }
  .top { max-width: 800px; padding: 18px 24px 8px; }
  .logo { width: 38px; height: 38px; }
  .wordmark { font-size: 29px; }
  .icon-btn { width: 48px; height: 48px; border-radius: 16px; }
  .game { max-width: 760px; padding-bottom: 20px; }
  .hud-val { font-size: 28px; }
  .dbtn { height: 54px; }
  .ctl { height: 68px; min-width: 88px; }
  .seo { margin-top: 56px; max-width: 720px; }
  .foot { max-width: 720px; }
}

/* Laptops and desktops: board on the left, stats and controls on the right */
@media (min-width: 1100px) and (min-height: 620px) {
  :root { --board-size: min(640px, max(380px, calc(100dvh - 200px))); }
  .top { max-width: 1060px; padding: 22px 28px 10px; }
  .logo { width: 42px; height: 42px; }
  .wordmark { font-size: 32px; }
  .icon-btn { width: 50px; height: 50px; }
  .icon-btn svg { width: 24px; height: 24px; }

  .game {
    max-width: 1060px; margin: 4px auto 0; padding: 26px 36px 30px;
    display: grid; grid-template-columns: var(--board-size) minmax(280px, 330px);
    grid-template-rows: auto auto auto auto 1fr; column-gap: 44px; row-gap: 14px;
    justify-content: center; align-items: start; justify-items: stretch;
    border: 1px solid var(--border); border-radius: 36px;
    background: linear-gradient(180deg, var(--surface), color-mix(in oklab, var(--surface) 35%, transparent));
    box-shadow: 0 40px 90px -50px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 255, 255, .06) inset;
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  }
  .meta-row { grid-column: 1 / -1; grid-row: 1; justify-self: center; margin: 0 0 8px; }
  .pill { font-size: 15px; padding: 8px 18px; }
  .stage { grid-column: 1; grid-row: 2 / 7; padding: 0; justify-self: center; }

  .hud { grid-column: 2; grid-row: 2; width: 100%; margin: 0; grid-template-columns: 1fr 1fr; gap: 10px; }
  .hud-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px; padding: 14px 8px 12px; gap: 4px; }
  .hud-label { font-size: 12px; }
  .hud-val { font-size: 32px; }
  .progress { height: 36px; }
  .progress i { width: 16px; height: 16px; }

  .controls { grid-column: 2; grid-row: 3; width: 100%; margin: 6px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .dpad { grid-column: 1 / -1; order: -1; max-width: none; gap: 10px; grid-template-columns: repeat(4, 1fr); }
  .dbtn { height: 64px; border-radius: 18px; }
  .dbtn svg { width: 24px; height: 24px; }
  .ctl { flex-direction: row; gap: 10px; min-width: 0; height: 60px; font-size: 15px; border-radius: 18px; }
  .ctl svg { width: 22px; height: 22px; }

  .swipe-hint { grid-column: 2; grid-row: 4; margin: 6px 0 0; text-align: left; font-size: 14px; max-width: none; }
  .secondary-row { grid-column: 2; grid-row: 5; align-self: start; justify-content: flex-start; margin: 0; }
  .seo { margin-top: 64px; max-width: 760px; }
  .foot { max-width: 760px; }
}
@media (min-width: 1100px) and (min-height: 620px) and (max-width: 1239px) {
  :root { --board-size: min(560px, max(380px, calc(100dvh - 200px))); }
  .game { column-gap: 32px; padding-left: 28px; padding-right: 28px; }
}
/* Landscape phones: sit the controls beside nothing, just shrink the board so it fits */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --board-size: min(calc(100dvh - 130px), 360px); }
  .meta-row { display: none; }
  .swipe-hint { display: none; }
}
