/* Signblast website. Every colour, size, radius, shadow and duration comes from design/tokens.css (tokens.json v2).
   Layout idea: a soft grey canvas with white cards floating on it in layered shadows; one accent colour the player picks.
   Component names follow design/DESIGN.md §5 so the app can map them one-to-one. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body { overflow-x: clip; }
html, body { margin: 0; background: var(--color-bg); color: var(--color-ink); }
body {
  font-family: var(--font);
  font-size: var(--type-body-size); line-height: var(--type-body-line);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  min-height: 100vh; display: flex; flex-direction: column;
  font-feature-settings: "ss01", "cv11";
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
button { font: inherit; color: inherit; }
a { color: var(--color-accent); }
img, svg, video, canvas { display: block; max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--color-accent-soft); }
.skip-link { position: absolute; left: -9999px; top: 8px; }
.skip-link:focus { left: 16px; z-index: 50; background: var(--color-surface); padding: 8px 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.noscript { padding: var(--space-lg); text-align: center; }

/* ---------- Type (DESIGN.md §3) ---------- */
.t-hero { font-size: var(--type-hero-size); line-height: var(--type-hero-line); font-weight: 600; letter-spacing: var(--type-hero-tracking); }
.t-display { font-size: var(--type-display-size); line-height: var(--type-display-line); font-weight: 600; letter-spacing: var(--type-display-tracking); }
.t-large { font-size: var(--type-large-title-size); line-height: var(--type-large-title-line); font-weight: 600; letter-spacing: var(--type-large-title-tracking); }
.t-title1 { font-size: var(--type-title1-size); line-height: var(--type-title1-line); font-weight: 600; letter-spacing: var(--type-title1-tracking); }
.t-title2 { font-size: var(--type-title2-size); line-height: var(--type-title2-line); font-weight: 600; letter-spacing: var(--type-title2-tracking); }
.t-headline { font-size: var(--type-headline-size); line-height: var(--type-headline-line); font-weight: 600; letter-spacing: -0.005em; }
.t-body { font-size: var(--type-body-size); line-height: var(--type-body-line); }
.t-callout { font-size: var(--type-callout-size); line-height: var(--type-callout-line); }
.t-subhead { font-size: var(--type-subhead-size); line-height: var(--type-subhead-line); }
.t-footnote { font-size: var(--type-footnote-size); line-height: var(--type-footnote-line); }
.eyebrow { font-size: var(--type-eyebrow-size); line-height: var(--type-eyebrow-line); font-weight: 600; letter-spacing: var(--type-eyebrow-tracking); text-transform: uppercase; color: var(--color-muted); }
.muted { color: var(--color-muted); }
.soft { color: var(--color-muted); }
@media (min-width: 900px) { .t-hero { font-size: 80px; line-height: 80px; } }
@media (max-width: 520px) { .t-hero { font-size: 44px; line-height: 46px; } }

/* ---------- Top bar: translucent canvas, brand mark, pill nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--color-bg) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(20px); -webkit-backdrop-filter: saturate(1.6) blur(20px);
  border-bottom: 1px solid color-mix(in srgb, var(--color-hairline) 70%, transparent);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; height: 64px;
  padding-left: max(var(--space-sm), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-xs), env(safe-area-inset-right, 0px));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-sm);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--color-ink); text-decoration: none; font-weight: 600; font-size: var(--type-headline-size); letter-spacing: -0.02em; justify-self: start; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; background: var(--color-accent); color: var(--color-accent-ink);
  display: grid; place-items: center; font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 10px -4px var(--color-accent);
}
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--color-ink) 6%, transparent); }
.tabs a {
  color: var(--color-muted); text-decoration: none; font-size: var(--type-subhead-size); font-weight: 500;
  padding: 6px 16px; border-radius: var(--radius-pill);
  transition: color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.tabs a:hover { color: var(--color-ink); }
.tabs a[aria-current="page"] { color: var(--color-ink); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.topbar .icon-btn { justify-self: end; }
body.focus-mode .tabs { visibility: hidden; }
@media (max-width: 480px) {
  .brand-name { display: none; }
  .tabs a { padding: 6px 12px; }
}

/* ---------- Screen layout ---------- */
#view { outline: none; flex: 1; }
.screen {
  width: 100%; max-width: calc(var(--size-content-max) + 2 * var(--space-sm)); margin: 0 auto;
  padding-left: max(var(--space-sm), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-sm), env(safe-area-inset-right, 0px));
  padding-block: var(--space-lg) var(--space-xxl);
  display: flex; flex-direction: column; gap: var(--space-lg);
  animation: screen-in var(--dur-slow) var(--ease) both;
}
.screen.wide { max-width: calc(1080px + 2 * var(--space-sm)); }
.screen.narrow { max-width: calc(var(--size-play-max) + 2 * var(--space-sm)); }
/* Movement only, never opacity 0: a screen must be readable even if the animation never runs. */
@keyframes screen-in { from { transform: translateY(10px); } to { transform: none; } }
.intro { display: grid; gap: var(--space-xs); }
.intro .t-body { max-width: 54ch; }
.stack { display: grid; gap: var(--space-xs); }
.stack-md { display: grid; gap: var(--space-sm); }
.row { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.section { display: grid; gap: var(--space-sm); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); }
@media (min-width: 900px) {
  .screen { padding-left: var(--space-lg); padding-right: var(--space-lg); padding-block: var(--space-xl) var(--space-xxl); max-width: calc(var(--size-content-max) + 2 * var(--space-lg)); gap: var(--space-xl); }
  .screen.wide { max-width: calc(1080px + 2 * var(--space-lg)); }
  .screen.narrow { max-width: calc(var(--size-play-max) + 2 * var(--space-lg)); gap: var(--space-lg); }
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; text-decoration: none;
  font-size: var(--type-headline-size); line-height: var(--type-headline-line); font-weight: 600; letter-spacing: -0.005em;
  height: var(--size-button); padding: 0 var(--space-md); border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs); white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn.primary {
  background: var(--color-accent); color: var(--color-accent-ink); width: 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 2px rgba(0, 0, 0, 0.08), 0 10px 24px -10px var(--color-accent);
}
.btn.primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 2px rgba(0, 0, 0, 0.08), 0 14px 30px -10px var(--color-accent); transform: translateY(-1px); }
.btn.secondary { background: var(--color-surface); color: var(--color-ink); width: 100%; box-shadow: var(--shadow-sm); }
.btn.secondary:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn.destructive { background: var(--color-surface); color: var(--color-danger); width: 100%; box-shadow: var(--shadow-sm); }
.btn.text { background: none; color: var(--color-accent); height: var(--size-min-tap); padding: 0 var(--space-xs); }
.btn.text:hover { opacity: .75; }
@media (min-width: 600px) { .btn.primary, .btn.secondary, .btn.destructive { width: auto; min-width: 200px; } }
.icon-btn {
  width: var(--size-min-tap); height: var(--size-min-tap); display: inline-grid; place-items: center;
  border: 0; background: none; color: var(--color-ink); border-radius: var(--radius-pill); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--color-ink) 7%, transparent); }
svg.i { width: var(--size-icon); height: var(--size-icon); fill: none; stroke: currentColor; stroke-width: var(--size-icon-stroke); stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Surfaces ---------- */
.card { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-md); display: grid; gap: var(--space-xs); box-shadow: var(--shadow-sm); }
.stage { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-md); display: grid; gap: var(--space-md); box-shadow: var(--shadow-md); }
@media (max-width: 520px) { .stage { padding: var(--space-sm); gap: var(--space-sm); border-radius: 24px; } }
.badge { display: inline-flex; align-items: center; gap: 6px; background: var(--color-accent-soft); border-radius: var(--radius-pill); padding: 4px 12px; font-size: var(--type-footnote-size); font-weight: 600; color: var(--color-accent); width: fit-content; }
.badge svg { width: 14px; height: 14px; }
.badge-icon { width: 44px; height: 44px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--color-accent-soft); color: var(--color-accent); flex: none; }
.badge-icon svg { width: 22px; height: 22px; }

/* ---------- Home: hero ---------- */
.hero-wrap { position: relative; }
.hero-wrap::before {
  content: ""; position: absolute; inset: -120px -40vw auto; height: 520px; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 60% at 70% 30%, var(--color-accent-soft), transparent 70%);
}
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); align-items: center; gap: var(--space-xl); padding-top: var(--space-md); }
.hero .lead { display: grid; gap: var(--space-md); }
.hero .lead .t-body { font-size: 19px; line-height: 28px; max-width: 34ch; }
.hero h1 .soft { display: block; }
.cta { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.cta .btn { width: auto; min-width: 0; }
.chip-note { display: inline-flex; align-items: center; gap: 8px; width: fit-content; padding: 5px 12px 5px 6px; border-radius: var(--radius-pill); background: var(--color-surface); box-shadow: var(--shadow-sm); font-size: var(--type-footnote-size); font-weight: 500; color: var(--color-ink); }
.chip-note .dot { width: 20px; height: 20px; border-radius: 50%; background: var(--color-accent); color: var(--color-accent-ink); display: grid; place-items: center; }
.chip-note .dot svg { width: 12px; height: 12px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; gap: var(--space-lg); } }

/* Demo device: a small live preview of a game, floating in the hero */
.demo { background: var(--color-surface); border-radius: 32px; box-shadow: var(--shadow-lg); padding: var(--space-md); display: grid; gap: var(--space-sm); max-width: 440px; justify-self: end; width: 100%; transform: rotate(-1.2deg); }
.demo .top { display: flex; justify-content: space-between; align-items: center; }
.demo .word { font-size: 64px; line-height: 70px; min-height: 0; padding-block: var(--space-xs); }
.demo .cam { aspect-ratio: 16 / 10; }
.demo .bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.demo .bars span { height: 6px; border-radius: 6px; background: var(--color-fill); overflow: hidden; }
.demo .bars span i { display: block; height: 100%; width: 0; background: var(--color-accent); border-radius: 6px; transition: width var(--dur-slow) var(--ease); }
@media (max-width: 860px) { .demo { justify-self: center; max-width: 420px; transform: none; } }
.hand-skel { position: absolute; inset: 0; width: 100%; height: 100%; }
.hand-skel circle { fill: var(--color-accent); }
.hand-skel path { stroke: color-mix(in srgb, var(--color-accent) 55%, transparent); stroke-width: 2; fill: none; stroke-linecap: round; }

/* Facts strip */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-sm); }
.fact { background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-sm) var(--space-md); box-shadow: var(--shadow-sm); display: grid; gap: 2px; }
.fact .v { font-size: var(--type-title1-size); line-height: var(--type-title1-line); font-weight: 600; letter-spacing: -0.02em; }
.fact .k { font-size: var(--type-footnote-size); color: var(--color-muted); }
@media (max-width: 520px) { .fact { padding: 12px 14px; } .fact .v { font-size: var(--type-title2-size); } }

/* Featured card (Today's five) */
.featured {
  appearance: none; border: 0; cursor: pointer; text-align: left; width: 100%; color: var(--color-accent-ink); text-decoration: none; position: relative; overflow: hidden;
  background: var(--color-accent); border-radius: var(--radius-lg); padding: var(--space-md) var(--space-lg);
  display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-md); align-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 18px 40px -18px var(--color-accent);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.featured::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255, 255, 255, 0.10); pointer-events: none; }
.featured:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 24px 48px -18px var(--color-accent); }
.featured:active { transform: scale(.99); }
.featured .eyebrow { color: inherit; opacity: .75; }
.featured .copy { display: grid; gap: 4px; }
.featured .ico { width: 52px; height: 52px; border-radius: 16px; background: rgba(255, 255, 255, 0.18); display: grid; place-items: center; }
.featured .ico svg { width: 24px; height: 24px; }
.featured .chev { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, 0.18); position: relative; z-index: 1; }
.featured[aria-disabled="true"] { cursor: default; background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-sm); transform: none; }
.featured[aria-disabled="true"]::after { display: none; }
.featured[aria-disabled="true"] .eyebrow { color: var(--color-muted); opacity: 1; }
.featured[aria-disabled="true"] .ico, .featured[aria-disabled="true"] .chev { background: var(--color-accent-soft); color: var(--color-accent); }
@media (max-width: 520px) { .featured { grid-template-columns: 1fr auto; padding: var(--space-md); } .featured .ico { display: none; } }

/* Game grid */
.games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
@media (min-width: 900px) { .games { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-md); } }
.game-tile {
  appearance: none; border: 0; cursor: pointer; text-align: left; color: var(--color-ink); text-decoration: none;
  background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-md);
  display: grid; grid-template-rows: auto 1fr auto; gap: var(--space-sm); min-height: 200px; position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.game-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.game-tile:active { transform: scale(.985); }
.game-tile .copy { display: grid; gap: 4px; align-content: start; }
.game-tile .foot { display: flex; justify-content: space-between; align-items: center; color: var(--color-muted); font-size: var(--type-footnote-size); font-variant-numeric: tabular-nums; }
.game-tile .go { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--color-fill); color: var(--color-ink); transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.game-tile .go svg { width: 16px; height: 16px; }
.game-tile:hover .go { background: var(--color-accent); color: var(--color-accent-ink); }
@media (max-width: 520px) { .game-tile { padding: var(--space-sm); min-height: 176px; border-radius: 22px; } }

/* Footer */
.site-foot { border-top: 1px solid var(--color-hairline); margin-top: var(--space-lg); }
.site-foot .inner { max-width: 1120px; margin: 0 auto; padding: var(--space-lg) max(var(--space-sm), env(safe-area-inset-right, 0px)) calc(var(--space-lg) + env(safe-area-inset-bottom, 0px)) max(var(--space-sm), env(safe-area-inset-left, 0px)); display: flex; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; align-items: center; }
.site-foot a { color: var(--color-muted); text-decoration: none; }
.site-foot a:hover { color: var(--color-ink); }
.site-foot .links { display: flex; gap: var(--space-md); flex-wrap: wrap; }
body.focus-mode .site-foot { display: none; }

/* ---------- Mode cards, lists, segmented ---------- */
.mode {
  appearance: none; border: 0; text-align: left; cursor: pointer; width: 100%; text-decoration: none; color: var(--color-ink);
  background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-md); box-shadow: var(--shadow-sm);
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-sm);
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.mode:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.mode .copy { display: grid; gap: 2px; }
.mode > svg { color: var(--color-muted); }
.list { border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.li { min-height: var(--size-row); padding: var(--space-xs) var(--space-md); display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); position: relative; color: inherit; text-decoration: none; }
.li + .li::before { content: ""; position: absolute; top: 0; left: var(--space-md); right: 0; height: 1px; background: var(--color-hairline); }
button.li { appearance: none; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; }
button.li:active, a.li:active { background: var(--color-fill); }
a.li:hover { background: color-mix(in srgb, var(--color-fill) 50%, transparent); }
.li .danger { color: var(--color-danger); }
.li.col { flex-direction: column; align-items: stretch; gap: var(--space-sm); padding-block: var(--space-sm); }
.seg { display: inline-flex; background: var(--color-fill); border-radius: var(--radius-pill); padding: 3px; flex: none; }
.seg button {
  appearance: none; border: 0; background: none; cursor: pointer; color: var(--color-muted);
  padding: 6px 14px; border-radius: var(--radius-pill);
  font-size: var(--type-subhead-size); line-height: var(--type-subhead-line); font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.seg button[aria-pressed="true"] { background: var(--seg-on, var(--color-surface)); color: var(--color-ink); box-shadow: var(--shadow-sm); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --seg-on: color-mix(in srgb, var(--color-ink) 20%, var(--color-surface-high)); } }
:root[data-theme="dark"] { --seg-on: color-mix(in srgb, var(--color-ink) 20%, var(--color-surface-high)); }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-sm); }
.stat { display: grid; gap: 2px; min-width: 0; background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-sm) var(--space-md); box-shadow: var(--shadow-sm); }
.stat .n { font-size: var(--type-title1-size); line-height: var(--type-title1-line); font-weight: 600; letter-spacing: var(--type-title1-tracking); font-variant-numeric: tabular-nums; }
.stat .l { font-size: var(--type-footnote-size); line-height: var(--type-footnote-line); color: var(--color-muted); }
@media (max-width: 420px) { .stat { padding: 12px 14px; } .stat .n { font-size: var(--type-title2-size); line-height: var(--type-title2-line); } }

/* ---------- Letter tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); }
@media (min-width: 600px) { .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; } }
.tile {
  appearance: none; border: 0; cursor: pointer; color: var(--color-ink); text-decoration: none;
  aspect-ratio: 1; background: var(--color-surface); border-radius: var(--radius-md);
  display: grid; place-items: center; position: relative; box-shadow: var(--shadow-sm);
  font-size: var(--type-title1-size); line-height: 1; font-weight: 600; letter-spacing: -0.02em;
  transition: transform var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease), background-color var(--dur-fast) var(--ease);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tile:active { transform: scale(.96); }
.tile.beta { color: var(--color-muted); }
.tile.mastered::after { content: ""; position: absolute; top: 10px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.tile[aria-pressed="false"] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--color-hairline); color: var(--color-muted); }
.tile[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--color-accent), var(--shadow-sm); color: var(--color-accent); }
.mini-tiles { display: grid; grid-template-columns: repeat(3, 76px); gap: var(--space-xs); }

/* ---------- Hold ring + word display ---------- */
.word {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap; column-gap: 0.06em;
  font-size: var(--type-display-size); line-height: var(--type-display-line); font-weight: 600; letter-spacing: var(--type-display-tracking);
  min-height: calc(var(--type-display-line) + 24px); padding-block: 12px;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
}
@media (min-width: 900px) { .stage .word { font-size: 88px; line-height: 92px; min-height: 116px; } }
.word.leaving { opacity: 0; transform: translateY(-8px); }
.word.entering { animation: word-in var(--dur-base) var(--ease) both; }
@keyframes word-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.word .ch { display: inline-grid; place-items: center; min-width: .62em; position: relative; transition: color var(--dur-base) var(--ease); }
.word .done { color: var(--color-ink); }
.word .next { color: color-mix(in srgb, var(--color-muted) 70%, transparent); }
.word .cur { color: var(--color-accent); width: 1.22em; height: 1.22em; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
/* Stroke in viewBox units so pathLength dashes stay exact. */
.ring circle { fill: none; stroke-width: 7; }
.ring .track { stroke: var(--color-fill); }
.ring .fill { stroke: var(--color-accent); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset 120ms linear, stroke var(--dur-base) var(--ease); }
.ring.ok .fill { stroke: var(--color-success-fill); stroke-dashoffset: 0; }

/* ---------- Camera frame ---------- */
.cam {
  position: relative; aspect-ratio: 4 / 3; width: 100%; background: var(--color-fill);
  border-radius: var(--radius-md); overflow: hidden; display: grid; place-items: center; color: var(--color-muted);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}
.cam video, .cam canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam video { transform: scaleX(-1); }
.cam .placeholder { display: grid; place-items: center; gap: var(--space-xs); text-align: center; padding: var(--space-md); }
.cam .placeholder svg { width: 36px; height: 36px; }
.cam .status {
  position: absolute; left: 50%; bottom: var(--space-sm); transform: translateX(-50%); z-index: 2;
  background: var(--color-surface-high); box-shadow: var(--shadow-md); border-radius: var(--radius-pill);
  padding: 7px 16px; font-size: var(--type-footnote-size); line-height: var(--type-footnote-line); font-weight: 600;
  color: var(--color-ink); white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis;
}
.cam .status.ok { color: var(--color-success); }
.status .sig { display: inline-grid; place-items: center; width: 22px; height: 22px; position: relative; margin-right: 6px; font-weight: 600; color: var(--color-accent); vertical-align: -6px; }
.status .sig .ring circle { stroke-width: 10; }
.cam .divider { position: absolute; top: 12px; bottom: 12px; left: 50%; width: 2px; margin-left: -1px; background: rgba(255, 255, 255, .8); z-index: 1; border-radius: 2px; }
.cam .side-tag { position: absolute; top: 10px; z-index: 2; font-size: var(--type-footnote-size); font-weight: 600; background: var(--color-surface-high); color: var(--color-ink); border-radius: var(--radius-pill); padding: 3px 12px; box-shadow: var(--shadow-sm); }
.cam .side-tag.l { left: 10px; } .cam .side-tag.r { right: 10px; }

/* ---------- Game screens ---------- */
.play-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); min-height: var(--size-min-tap); }
.play-bar .right { display: flex; align-items: center; gap: var(--space-xs); }
.play-bar .title { display: flex; align-items: center; gap: 10px; }
.play-bar .title .badge-icon { width: 32px; height: 32px; border-radius: 10px; }
.play-bar .title .badge-icon svg { width: 17px; height: 17px; }
.timer { font-size: var(--type-title2-size); line-height: var(--type-title2-line); font-weight: 600; font-variant-numeric: tabular-nums; padding: 4px 14px; border-radius: var(--radius-pill); background: var(--color-surface); box-shadow: var(--shadow-sm); transition: color var(--dur-base) var(--ease); }
.timer.low { color: var(--color-accent); }
.play-foot { display: flex; justify-content: space-between; align-items: center; min-height: var(--size-min-tap); }
.hint-card { background: var(--color-surface); border-radius: var(--radius-md); padding: var(--space-sm) var(--space-md); display: flex; align-items: center; gap: var(--space-sm); box-shadow: var(--shadow-md); animation: word-in var(--dur-base) var(--ease) both; }
.hint-card .big { font-size: var(--type-title1-size); font-weight: 600; width: 52px; height: 52px; border-radius: var(--radius-sm); background: var(--color-accent-soft); color: var(--color-accent); display: grid; place-items: center; flex: none; }
.btn.text.pulse { animation: pulse 1.2s var(--ease) 1; }
@keyframes pulse { 0%, 100% { opacity: 1; } 40% { opacity: .35; } }

.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); }
.chip { background: var(--color-fill); border-radius: var(--radius-sm); padding: 10px 14px; display: grid; min-width: 0; }
.chip .v { font-size: var(--type-title2-size); line-height: var(--type-title2-line); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.chip .k { font-size: var(--type-footnote-size); color: var(--color-muted); }
.chip.accent .v { color: var(--color-accent); }

.target {
  display: grid; place-items: center; margin: var(--space-xs) auto; position: relative;
  width: 172px; height: 172px; border-radius: 48px; background: var(--color-fill);
  font-size: 108px; line-height: 1; font-weight: 600; letter-spacing: -0.03em;
  transition: background-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.target .ring { inset: -12px; width: calc(100% + 24px); height: calc(100% + 24px); }
.target .ring circle { stroke-width: 3.5; }
.target .ring .track { stroke: transparent; }
.target.pop { animation: pop var(--dur-base) var(--ease); }
.target.dim { color: var(--color-muted); }
.target.lit { background: var(--color-accent); color: var(--color-accent-ink); box-shadow: 0 20px 40px -16px var(--color-accent); }
@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }
@media (min-width: 900px) { .target { width: 200px; height: 200px; font-size: 128px; border-radius: 56px; } }

.flash { min-height: var(--type-callout-line); text-align: center; font-size: var(--type-callout-size); line-height: var(--type-callout-line); color: var(--color-muted); font-weight: 500; }
.flash.good { color: var(--color-success); }
.flash.in { animation: word-in var(--dur-base) var(--ease); }

.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-xs); padding-block: var(--space-sm); }
.slot { width: 50px; height: 60px; border-radius: var(--radius-sm); background: var(--color-fill); display: grid; place-items: center; font-size: var(--type-title2-size); font-weight: 600; color: var(--color-muted); transition: background-color var(--dur-base) var(--ease), color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.slot.done { color: var(--color-ink); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.slot.cur { background: var(--color-accent-soft); color: var(--color-accent); box-shadow: inset 0 0 0 2px var(--color-accent); }

.masked { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-xs); padding-block: var(--space-sm); }
.masked .m { width: 46px; height: 58px; display: grid; place-items: end center; padding-bottom: 6px; font-size: var(--type-title1-size); font-weight: 600; border-bottom: 3px solid var(--color-hairline); }
.masked .m.got { border-color: var(--color-accent); animation: pop var(--dur-base) var(--ease); }
.lives { display: flex; gap: 3px; color: var(--color-accent); }
.lives svg { width: 17px; height: 17px; }
.lives .full svg { fill: currentColor; }
.lives .lost { color: var(--color-hairline); }
.tried { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 28px; }
.tried span { font-size: var(--type-subhead-size); font-weight: 600; color: var(--color-muted); background: var(--color-fill); border-radius: 8px; padding: 2px 9px; text-decoration: line-through; }
.clue { display: inline-flex; gap: 6px; align-items: center; justify-self: center; background: var(--color-accent-soft); color: var(--color-accent); border-radius: var(--radius-pill); padding: 5px 16px; font-size: var(--type-subhead-size); font-weight: 600; }

.duel-score { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-xs); }
.duel-score .p { background: var(--color-fill); border-radius: var(--radius-md); padding: var(--space-sm) var(--space-md); display: grid; gap: 2px; transition: background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease); }
.duel-score .p.right { text-align: right; }
.duel-score .p .v { font-size: var(--type-title1-size); line-height: var(--type-title1-line); font-weight: 600; font-variant-numeric: tabular-nums; }
.duel-score .p.scored { background: var(--color-accent-soft); box-shadow: inset 0 0 0 2px var(--color-accent); }

/* ---------- Game intro ---------- */
.ready-head { display: flex; align-items: center; gap: var(--space-sm); }
.ready-head .badge-icon { width: 64px; height: 64px; border-radius: 20px; box-shadow: var(--shadow-sm); }
.ready-head .badge-icon svg { width: 28px; height: 28px; }
.rules { list-style: none; margin: 0; padding: 0; background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.rules li { display: flex; gap: var(--space-sm); align-items: flex-start; padding: 16px var(--space-md); position: relative; font-size: var(--type-callout-size); line-height: var(--type-callout-line); }
.rules li + li::before { content: ""; position: absolute; top: 0; left: calc(var(--space-md) + 40px); right: 0; height: 1px; background: var(--color-hairline); }
.rules .n { width: 24px; height: 24px; border-radius: 50%; background: var(--color-accent-soft); color: var(--color-accent); font-size: 12px; font-weight: 600; display: grid; place-items: center; flex: none; }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); flex-wrap: wrap; background: var(--color-surface); border-radius: var(--radius-md); padding: 12px var(--space-md); box-shadow: var(--shadow-sm); }

/* ---------- Results ---------- */
.score-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-lg) var(--space-md); box-shadow: var(--shadow-md); display: grid; gap: 4px; justify-items: center; text-align: center; position: relative; overflow: hidden; }
.score-card::before { content: ""; position: absolute; inset: -40% -20% auto; height: 260px; background: radial-gradient(50% 50% at 50% 50%, var(--color-accent-soft), transparent 70%); pointer-events: none; }
.score-big { font-size: var(--type-display-size); line-height: var(--type-display-line); font-weight: 600; letter-spacing: var(--type-display-tracking); font-variant-numeric: tabular-nums; position: relative; }
@media (min-width: 900px) { .score-big { font-size: 104px; line-height: 108px; } }
.actions { display: flex; flex-direction: column; gap: var(--space-xs); align-items: stretch; }
@media (min-width: 600px) { .actions { flex-direction: row; align-items: center; } }

/* ---------- Letter detail ---------- */
.letter-hero { display: grid; grid-template-columns: auto 1fr; gap: var(--space-md); align-items: center; }
.letter-big {
  width: 132px; height: 132px; border-radius: 36px; background: var(--color-surface); box-shadow: var(--shadow-md);
  display: grid; place-items: center; position: relative; font-size: 76px; line-height: 1; font-weight: 600; letter-spacing: -0.03em;
}
.letter-big .ring { inset: -10px; width: calc(100% + 20px); height: calc(100% + 20px); }
.letter-big .ring circle { stroke-width: 4; }
.letter-big .ring .track { stroke: transparent; }
@media (max-width: 420px) { .letter-big { width: 104px; height: 104px; font-size: 60px; border-radius: 28px; } }
.nav-back { display: inline-flex; align-items: center; gap: 2px; color: var(--color-accent); text-decoration: none; font-size: var(--type-headline-size); font-weight: 500; margin-left: -8px; padding: 8px; width: fit-content; border-radius: var(--radius-pill); }
.nav-back:hover { background: var(--color-accent-soft); }
.meter { height: 6px; border-radius: 6px; background: var(--color-fill); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--color-accent); border-radius: 6px; transition: width 120ms linear; }

/* ---------- Progress ---------- */
.week-card { background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-md); box-shadow: var(--shadow-sm); display: grid; gap: var(--space-sm); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-xs); align-items: end; height: 150px; }
.week .day { display: grid; grid-template-rows: 1fr auto; gap: 8px; height: 100%; text-align: center; }
.week .bar-wrap { display: flex; align-items: flex-end; justify-content: center; }
.week .bar { width: min(100%, 30px); border-radius: 8px; background: var(--color-fill); min-height: 6px; transition: height var(--dur-slow) var(--ease); }
.week .bar.has { background: var(--color-accent); box-shadow: 0 8px 18px -8px var(--color-accent); }
.week .day.today .lbl { color: var(--color-ink); font-weight: 600; }
.week .lbl { font-size: var(--type-footnote-size); color: var(--color-muted); }

/* ---------- Camera setup ---------- */
.setup { text-align: center; align-items: center; padding-top: var(--space-xl); }
.setup .intro { justify-items: center; }
.setup .icon-circle { width: 96px; height: 96px; border-radius: 30px; background: var(--color-surface); box-shadow: var(--shadow-md); display: grid; place-items: center; color: var(--color-accent); }
.setup .icon-circle svg { width: 40px; height: 40px; }
.setup .actions { align-items: center; justify-content: center; width: 100%; }
.setup .note { max-width: 40ch; }

/* ---------- Settings ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 14px; padding: 2px; }
.swatch {
  appearance: none; border: 0; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .22), 0 4px 10px -4px var(--sw); transition: transform var(--dur-fast) var(--ease);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--color-surface), 0 0 0 5px var(--sw); }

/* ---------- Toast + sheet ---------- */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px)); display: grid; justify-items: center; gap: var(--space-xs); pointer-events: none; z-index: 40; padding: 0 var(--space-sm); }
.toast { background: var(--color-surface-high); color: var(--color-ink); box-shadow: var(--shadow-lg); border-radius: var(--radius-pill); padding: 12px 20px; font-size: var(--type-subhead-size); line-height: var(--type-subhead-line); font-weight: 500; max-width: 440px; animation: toast-in var(--dur-base) var(--ease) both; }
.toast.out { animation: toast-out var(--dur-base) var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }
.sheet-host { position: fixed; inset: 0; z-index: 30; display: grid; align-items: end; justify-items: center; background: var(--color-overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade-in var(--dur-base) var(--ease) both; }
@media (min-width: 600px) { .sheet-host { align-items: center; } }
@keyframes fade-in { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 420px; background: var(--color-surface-high); box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-md) var(--space-md) calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  display: grid; gap: var(--space-md); animation: sheet-in var(--dur-base) var(--ease) both;
}
@media (min-width: 600px) { .sheet { border-radius: var(--radius-lg); } }
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet .actions { flex-direction: column; align-items: stretch; }
.sheet .btn.primary, .sheet .btn.secondary, .sheet .btn.destructive { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .demo { transform: none; }
}
