/* Synapse Brain Gym
   Layout: one phone-width column; scrolling screens above a fixed tab bar, full-screen game stage.
   Look: chunky, tactile "toy" buttons with pressed shadows; each brain area owns one color. */
:root {
  --bg: #edf1f7;
  --surface: #ffffff;
  --sunk: #e1e7f0;
  --ink: #141b2d;
  --muted: #5a6479;
  --line: #d2d9e5;
  --accent: #2b3bff;
  --accent-ink: #ffffff;
  --press: rgba(20, 27, 45, 0.16);
  --good: #12a150;
  --bad: #e5383b;

  --memory: #ff6a4d;
  --focus: #1e9bf0;
  --speed: #f0a000;
  --flex: #12b886;
  --logic: #a35cf0;
  --lang: #e8488a;

  --c-red: #e5383b;
  --c-blue: #1f6feb;
  --c-green: #16a34a;
  --c-yellow: #d49a00;
  --c-purple: #8b3dff;

  --font-display: 'Bricolage Grotesque', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Figtree', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;

  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1322;
    --surface: #171e33;
    --sunk: #0a0f1c;
    --ink: #eef2fa;
    --muted: #97a2bd;
    --line: #263051;
    --accent: #7b86ff;
    --accent-ink: #0b0f1e;
    --press: rgba(0, 0, 0, 0.5);
    --good: #3ddc84;
    --bad: #ff5c5f;
    --memory: #ff8266;
    --focus: #4db5ff;
    --speed: #ffc13d;
    --flex: #34d3a0;
    --logic: #be8cff;
    --lang: #ff77ae;
    --c-red: #ff5c5f;
    --c-blue: #5c9dff;
    --c-green: #3ddc84;
    --c-yellow: #ffd23f;
    --c-purple: #b57bff;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e1322;
  --surface: #171e33;
  --sunk: #0a0f1c;
  --ink: #eef2fa;
  --muted: #97a2bd;
  --line: #263051;
  --accent: #7b86ff;
  --accent-ink: #0b0f1e;
  --press: rgba(0, 0, 0, 0.5);
  --good: #3ddc84;
  --bad: #ff5c5f;
  --memory: #ff8266;
  --focus: #4db5ff;
  --speed: #ffc13d;
  --flex: #34d3a0;
  --logic: #be8cff;
  --lang: #ff77ae;
  --c-red: #ff5c5f;
  --c-blue: #5c9dff;
  --c-green: #3ddc84;
  --c-yellow: #ffd23f;
  --c-purple: #b57bff;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
}
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
h1,
h2,
h3 {
  font-family: var(--font-display);
  margin: 0;
  text-wrap: balance;
  line-height: 1.1;
}
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}

/* Area color plumbing: any element with .a-<area> gets --area. */
.a-memory {
  --area: var(--memory);
}
.a-focus {
  --area: var(--focus);
}
.a-speed {
  --area: var(--speed);
}
.a-flex {
  --area: var(--flex);
}
.a-logic {
  --area: var(--logic);
}
.a-lang {
  --area: var(--lang);
}

/* ---------- App shell ---------- */
#app {
  height: 100%;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}
#screen {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 20px) var(--gutter-r) 24px var(--gutter-l);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
body.playing #screen {
  overflow: hidden;
  padding-top: calc(var(--safe-top) + 10px);
  padding-bottom: calc(var(--safe-bottom) + 12px);
}
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 6px var(--gutter-r) calc(var(--safe-bottom) + 6px) var(--gutter-l);
}
body.playing .tabs {
  display: none;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-radius: var(--r-sm);
}
.tab svg {
  width: 24px;
  height: 24px;
}
.tab[aria-current='page'] {
  color: var(--accent);
}

/* ---------- Shared pieces ---------- */
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 1px 0 var(--line);
}
.section-title {
  font-size: 20px;
  font-weight: 700;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 0 22px;
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  background: var(--sunk);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--press);
  transition:
    transform 0.06s,
    box-shadow 0.06s;
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--press);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn.block {
  width: 100%;
}
.btn.small {
  min-height: 40px;
  font-size: 15px;
  padding: 0 14px;
}
.btn.danger {
  background: var(--bad);
  color: #fff;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--area, var(--accent)) 18%, transparent);
  color: var(--ink);
}
.chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--area, var(--accent));
}
.bar {
  height: 12px;
  border-radius: 99px;
  background: var(--sunk);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.num {
  font-variant-numeric: tabular-nums;
}
.icon-tile {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--area);
  color: #fff;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--area) 60%, #000);
}
.icon-tile svg {
  width: 30px;
  height: 30px;
}

/* ---------- Today ---------- */
.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.top h1 {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.streak {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 99px;
  background: var(--surface);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 1px 0 var(--line);
}
.streak svg {
  width: 22px;
  height: 22px;
  color: var(--memory);
}
.streak.cold svg {
  color: var(--muted);
}
.level-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.level-badge {
  width: 58px;
  height: 58px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 4px 0 var(--press);
}
.level-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.level-meta h2 {
  font-size: 22px;
}
.level-meta .row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.workout-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.workout-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--sunk);
  text-align: left;
  width: 100%;
}
.wo-item .icon-tile {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}
.wo-item .icon-tile svg {
  width: 26px;
  height: 26px;
}
.wo-text {
  flex: 1;
  min-width: 0;
}
.wo-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
}
.wo-text span {
  font-size: 13px;
  color: var(--muted);
}
.check {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  display: grid;
  place-items: center;
}
.check.on {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}
.check svg {
  width: 16px;
  height: 16px;
}
.wo-done {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.habits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.habit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--r-md);
  background: var(--sunk);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
  border: 2px solid transparent;
}
.habit svg {
  width: 26px;
  height: 26px;
  color: var(--muted);
}
.habit[aria-pressed='true'] {
  border-color: var(--good);
  background: color-mix(in srgb, var(--good) 14%, var(--surface));
}
.habit[aria-pressed='true'] svg {
  color: var(--good);
}
.habit small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.tip svg {
  width: 28px;
  height: 28px;
  flex: none;
  color: var(--speed);
}
.tip p {
  font-size: 15px;
}

/* ---------- Games list ---------- */
.area-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
  width: 100%;
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.06s;
}
.game-card:active {
  transform: translateY(2px);
}
.game-card .gc-text {
  flex: 1;
  min-width: 0;
}
.game-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
}
.game-card span {
  display: block;
  font-size: 14px;
  color: var(--muted);
}
.gc-best {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  flex: none;
}
.gc-best b {
  display: block;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
}

/* ---------- Profile ---------- */
.score-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.score-hero .big {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.radar {
  width: 100%;
  max-width: 340px;
  align-self: center;
}
.radar text {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  fill: var(--muted);
}
.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat {
  background: var(--sunk);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: 13px;
  color: var(--muted);
}
.heat {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.heat i {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--sunk);
}
.heat i[data-l='1'] {
  background: color-mix(in srgb, var(--accent) 35%, var(--sunk));
}
.heat i[data-l='2'] {
  background: color-mix(in srgb, var(--accent) 65%, var(--sunk));
}
.heat i[data-l='3'] {
  background: var(--accent);
}
.heat i.today {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.heat-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}
.bests {
  display: flex;
  flex-direction: column;
}
.best-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.best-row:last-child {
  border-bottom: 0;
}
.best-row .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--area);
  flex: none;
}
.best-row span {
  flex: 1;
}
.best-row b {
  font-variant-numeric: tabular-nums;
}
.science details {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.science details:first-of-type {
  border-top: 0;
}
.science summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.science summary::after {
  content: '+';
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
}
.science details[open] summary::after {
  content: '–';
}
.science details p {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
  max-width: 65ch;
}
.science cite {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}
.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}
.switch {
  width: 52px;
  height: 32px;
  border-radius: 99px;
  background: var(--sunk);
  position: relative;
  flex: none;
  border: 2px solid var(--line);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px var(--press);
  transition: transform 0.15s;
}
.switch[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
}
.switch[aria-checked='true']::after {
  transform: translateX(20px);
}
.install-steps {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
  padding-left: 20px;
}

/* ---------- Sheet (game intro) ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 24, 0.5);
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.2s;
}
.sheet {
  width: 100%;
  max-width: 540px;
  max-height: 92%;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 22px var(--gutter-r) calc(var(--safe-bottom) + 20px) var(--gutter-l);
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: rise 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sheet-head h2 {
  font-size: 28px;
}
.how {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: how;
}
.how li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  counter-increment: how;
}
.how li::before {
  content: counter(how);
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  background: var(--area);
  color: #fff;
}
.why {
  background: var(--sunk);
  border-radius: var(--r-md);
  padding: 14px;
  font-size: 15px;
}
.why b {
  display: block;
  margin-bottom: 4px;
}
.sheet-actions {
  display: flex;
  gap: 10px;
}
.sheet-actions .btn {
  flex: 1;
}

/* ---------- Game screen ---------- */
.game {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  position: relative;
}
.hud {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  background: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--press);
}
.icon-btn svg {
  width: 22px;
  height: 22px;
}
.hud-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.hud-title strong {
  font-family: var(--font-display);
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-title span {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hud-score {
  text-align: right;
}
.hud-score b {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hud-score span {
  font-size: 12px;
  font-weight: 800;
  color: var(--area);
  min-height: 18px;
  display: block;
}
.timebar {
  height: 8px;
  border-radius: 99px;
  background: var(--sunk);
  overflow: hidden;
}
.timebar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--area);
  border-radius: inherit;
  transform-origin: left;
}
.timebar.low i {
  background: var(--bad);
}
.lives {
  display: flex;
  gap: 6px;
  justify-content: center;
  height: 8px;
  align-items: center;
}
.lives i {
  width: 34px;
  height: 8px;
  border-radius: 99px;
  background: var(--area);
}
.lives i.lost {
  background: var(--sunk);
}
.status {
  text-align: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  min-height: 26px;
  color: var(--muted);
}
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.flash-good {
  animation: flashGood 0.35s;
}
.flash-bad {
  animation: shake 0.35s;
}
.floater {
  position: absolute;
  right: 6px;
  top: 52px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--good);
  pointer-events: none;
  animation: floatUp 0.8s forwards;
}
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 120px;
  font-weight: 800;
  color: var(--area);
  background: var(--bg);
  z-index: 5;
}
.countdown span {
  animation: pop 0.6s;
}
.banner {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: var(--area);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  padding: 12px 22px;
  border-radius: var(--r-md);
  white-space: nowrap;
  z-index: 4;
  pointer-events: none;
  animation: banner 1.3s forwards;
}

/* Glow Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 8px;
  width: min(100%, 420px, 58vh);
  aspect-ratio: 1;
}
.tile {
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--press);
  transition:
    background 0.15s,
    transform 0.06s;
}
.tile:active {
  transform: translateY(2px);
}
.tile.lit {
  background: var(--area);
  box-shadow:
    0 0 24px color-mix(in srgb, var(--area) 70%, transparent),
    0 4px 0 var(--press);
}
.tile.hit {
  background: var(--area);
}
.tile.wrong {
  background: var(--bad);
}
.tile.reveal {
  background: color-mix(in srgb, var(--area) 35%, var(--surface));
  outline: 3px dashed var(--area);
  outline-offset: -6px;
}

/* Déjà Vu */
.nb-n {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  padding: 6px 16px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--area) 18%, transparent);
}
.nb-card {
  width: min(62vw, 240px, 34vh);
  aspect-ratio: 1;
  border-radius: 28px;
  background: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 var(--press);
}
.nb-card svg {
  width: 62%;
  height: 62%;
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 0.12s,
    transform 0.12s;
}
.nb-card.show svg {
  opacity: 1;
  transform: scale(1);
}
.nb-card.ok {
  box-shadow:
    0 0 0 4px var(--good),
    0 6px 0 var(--press);
}
.nb-card.no {
  box-shadow:
    0 0 0 4px var(--bad),
    0 6px 0 var(--press);
}
.big-btn {
  width: min(100%, 360px);
  min-height: 84px;
  border-radius: 24px;
  background: var(--area);
  color: #fff;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 0 color-mix(in srgb, var(--area) 55%, #000);
  transition: transform 0.05s;
}
.big-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--area) 55%, #000);
}

/* Choice buttons (Color Clash, Quick Math, Next in Line, Flash Field) */
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: min(100%, 420px);
}
.choice {
  min-height: 76px;
  border-radius: 20px;
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 5px 0 var(--press);
  transition: transform 0.05s;
}
.choice:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--press);
}
.choice.swatch {
  font-size: 0;
}
.choice.word {
  font-size: 20px;
  letter-spacing: 0.06em;
}
.choice.right {
  background: var(--good);
  color: #fff;
}
.choice.wrong {
  background: var(--bad);
  color: #fff;
}
.choices.three {
  grid-template-columns: repeat(3, 1fr);
}
.choices.five {
  grid-template-columns: repeat(6, 1fr);
}
.choices.five .choice {
  grid-column: span 2;
}
.choices.five .choice:nth-child(4) {
  grid-column: 2 / span 2;
}
.stroop-word {
  font-family: var(--font-display);
  font-size: clamp(54px, 17vw, 88px);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
  min-height: 1.1em;
}
.rule-hint {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.equation {
  font-family: var(--font-display);
  font-size: clamp(44px, 13vw, 64px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  text-align: center;
}
.seq {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.seq b {
  min-width: 56px;
  padding: 10px 8px;
  border-radius: 14px;
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 26px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 var(--press);
}
.seq b.q {
  background: var(--area);
  color: #fff;
}
.rule-note {
  min-height: 24px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

/* Rule Switch */
.sw-board {
  width: min(100%, 380px);
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  flex: 1;
  max-height: 380px;
}
.sw-zone {
  border-radius: 22px;
  border: 3px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 4px;
}
.sw-zone.top {
  --zone: var(--flex);
}
.sw-zone.bottom {
  --zone: var(--focus);
}
.sw-zone > span {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--zone);
}
.sw-card {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  background: var(--zone);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 58px;
  font-weight: 800;
  box-shadow: 0 5px 0 var(--press);
  animation: pop 0.18s;
}
.sw-ring {
  height: 6px;
  width: 100px;
  border-radius: 99px;
  background: var(--sunk);
  overflow: hidden;
}
.sw-ring i {
  display: block;
  height: 100%;
  background: var(--zone);
  transform-origin: left;
}
.sw-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: min(100%, 380px);
}
.sw-btn {
  min-height: 86px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 5px 0 var(--press);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
}
.sw-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--press);
}
.sw-btn .t {
  color: var(--flex);
}
.sw-btn .b {
  color: var(--focus);
}

/* Flash Field */
.ff {
  position: relative;
  width: min(100%, 360px, 48vh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 6px 0 var(--press);
}
.ff-slot {
  position: absolute;
  width: 19%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
}
.ff-slot svg {
  width: 100%;
  height: 100%;
}
.ff-slot.pickable {
  background: var(--sunk);
  box-shadow: inset 0 0 0 2px var(--line);
  cursor: pointer;
}
.ff-slot.pickable:active {
  background: color-mix(in srgb, var(--area) 30%, var(--sunk));
}
.ff-slot.answer {
  box-shadow: inset 0 0 0 3px var(--good);
}
.ff-slot.wrongpick {
  box-shadow: inset 0 0 0 3px var(--bad);
}
.ff-center {
  left: 50%;
  top: 50%;
  width: 24%;
}
.ff-fix {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  color: var(--muted);
}

/* ---------- Results ---------- */
.results {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
}
.results-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.results-head h1 {
  font-size: 30px;
}
.results .big {
  font-family: var(--font-display);
  font-size: 84px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stars {
  display: flex;
  gap: 8px;
}
.stars svg {
  width: 40px;
  height: 40px;
  color: var(--line);
}
.stars svg.on {
  color: var(--speed);
  animation: pop 0.4s backwards;
}
.stars svg.on:nth-child(2) {
  animation-delay: 0.15s;
}
.stars svg.on:nth-child(3) {
  animation-delay: 0.3s;
}
.badge-new {
  background: var(--speed);
  color: #1b1300;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 99px;
}
.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.res-stats .stat {
  text-align: center;
  padding: 10px 6px;
}
.res-stats .stat b {
  font-size: 22px;
}
.res-stats .stat span {
  font-size: 12px;
}
.xp-line {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}
.xp-line .plus {
  color: var(--accent);
  font-family: var(--font-display);
}
.res-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.celebrate {
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  width: 100%;
  height: 100%;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 86px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 14px;
  z-index: 40;
  animation: rise 0.2s;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}
@keyframes pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes flashGood {
  50% {
    transform: scale(1.03);
  }
}
@keyframes shake {
  20%,
  60% {
    transform: translateX(-8px);
  }
  40%,
  80% {
    transform: translateX(8px);
  }
}
@keyframes floatUp {
  to {
    transform: translateY(-36px);
    opacity: 0;
  }
}
@keyframes banner {
  0% {
    transform: translate(-50%, -50%) scale(0.6);
    opacity: 0;
  }
  15% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -70%);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
.choice svg {
  width: 44px;
  height: 44px;
  vertical-align: middle;
}

/* ---------- Shared quiz engine ---------- */
.q-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 420px);
}
.q-big {
  font-family: var(--font-display);
  font-size: clamp(38px, 11vw, 58px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
  min-height: 1.1em;
}
.q-mid {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  text-align: center;
}
.q-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 12px 16px;
  width: 100%;
}
.bsym {
  font-size: 1.2em;
}
.pill {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--area);
  margin: 0;
}
.limit {
  width: min(100%, 260px);
  height: 6px;
  border-radius: 99px;
  background: var(--sunk);
  overflow: hidden;
}
.limit i {
  display: block;
  height: 100%;
  background: var(--area);
  transform-origin: left;
}
.choice.txt {
  font-size: 20px;
  padding: 0 6px;
  overflow-wrap: anywhere;
}
.choice.tall {
  min-height: 120px;
  line-height: 1;
}
.choices.compact .choice {
  min-height: 60px;
  font-size: 24px;
}
.choices.tiles {
  gap: 6px;
  width: min(100%, 420px, 54vh);
}
.choices.tiles .choice {
  min-height: 0;
  aspect-ratio: 1;
  border-radius: 10px;
  box-shadow: none;
}
.choices.tiles .choice.right {
  outline: 4px solid var(--good);
  outline-offset: -4px;
}
.choice svg {
  color: var(--ink);
}
.arrows {
  display: flex;
  gap: 4px;
  color: var(--ink);
  min-height: 56px;
  align-items: center;
}
.arrows svg {
  width: 52px;
  height: 52px;
}
.arrows.tight svg {
  width: 42px;
  height: 42px;
}
.cue-arrow {
  width: 132px;
  height: 132px;
  border-radius: 32px;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 6px 0 var(--press);
}
.cue-arrow svg {
  width: 84px;
  height: 84px;
}
.panels {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}
.panel {
  flex: 1;
  max-width: 180px;
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 0 var(--press);
}
.panel svg {
  width: 92%;
  height: 92%;
}
.key {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.key span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border-radius: 10px;
  padding: 6px 8px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.key svg {
  width: 24px;
  height: 24px;
}
.target-sym {
  color: var(--area);
}
.target-sym svg {
  width: 88px;
  height: 88px;
}
.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: clamp(24px, 7.5vw, 36px);
  font-weight: 700;
  letter-spacing: 0.14em;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 12px;
}
.ngrid {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 8px;
}
.ngrid b {
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border-radius: 14px;
  font-family: var(--font-display);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 var(--press);
}
.ngrid b.q {
  background: var(--area);
  color: #fff;
}
.wc-card {
  width: 110px;
  height: 110px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--press);
  padding: 6px;
}
.choice.wc {
  min-height: 0;
  aspect-ratio: 1;
  padding: 4px;
}
.choice.wc svg {
  width: 100%;
  height: 100%;
}

/* ---------- Custom game pieces ---------- */
.tile {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  color: var(--ink);
}
.span-show {
  font-family: var(--font-display);
  font-size: 96px;
  font-weight: 800;
  line-height: 1;
  min-height: 1em;
  color: var(--area);
}
.span-entry {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.2em;
  min-height: 1.3em;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: min(100%, 300px);
}
.keypad button {
  min-height: 54px;
  border-radius: 14px;
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--press);
}
.keypad button:active {
  transform: translateY(2px);
}
.gng {
  width: min(78vw, 280px, 40vh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 var(--press);
}
.gng svg {
  width: 62%;
  height: 62%;
}
.rx-row {
  display: grid;
  gap: 12px;
  width: min(100%, 360px, 50vh);
}
.rx {
  aspect-ratio: 1;
  border-radius: 24px;
  background: var(--sunk);
  box-shadow: 0 5px 0 var(--press);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--muted);
}
.rx.go {
  background: var(--good);
  color: #fff;
}
.hunt {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 5px;
  width: min(100%, 420px, 56vh);
}
.hunt button {
  aspect-ratio: 1;
  border-radius: 9px;
  background: var(--surface);
  font-family: var(--font-body);
  font-size: clamp(16px, 4.6vw, 24px);
  font-weight: 700;
  box-shadow: 0 2px 0 var(--press);
}
.hunt button.found {
  background: var(--area);
  color: #fff;
}
.hunt button.wrong,
.trail button.wrong {
  background: var(--bad);
  color: #fff;
}
.trail {
  position: relative;
  width: min(100%, 420px);
  flex: 1;
  max-height: 480px;
  min-height: 300px;
}
.trail svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.trail button {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 3px 0 var(--press);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
}
.trail button.letter {
  color: var(--area);
}
.trail button.done {
  background: var(--area);
  color: #fff;
}
.ana-slots,
.ana-tiles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.ana-slots span {
  width: 40px;
  height: 50px;
  border-bottom: 3px solid var(--line);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.ana-tiles button {
  width: 44px;
  height: 54px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--press);
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-display);
}
.ana-tiles button.used {
  visibility: hidden;
}
.ana-actions {
  display: flex;
  gap: 10px;
}

/* ---------- Rules sheet ---------- */
.rules-btn {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--area);
}
.paused-flag {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--sunk);
  color: var(--muted);
}
.goal {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
}
.sheet h3 {
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.example {
  border-radius: var(--r-md);
  padding: 14px;
  background: color-mix(in srgb, var(--area) 12%, var(--surface));
  border: 2px dashed color-mix(in srgb, var(--area) 50%, transparent);
}
.example h3 {
  color: var(--ink);
  margin-bottom: 4px;
}
.example p {
  font-size: 15px;
  font-weight: 600;
}
.facts {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
}
.rule-tip {
  font-size: 15px;
  background: var(--sunk);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.rule-tip b {
  display: block;
  margin-bottom: 2px;
}
.why-d summary {
  cursor: pointer;
  font-weight: 700;
}
.why-d p {
  margin-top: 8px;
  font-size: 15px;
  color: var(--muted);
}
.sheet-meta {
  font-size: 14px;
}
.link-btn {
  align-self: center;
  font-weight: 700;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px;
}
/* Keep Play / Resume reachable however long the rules are. */
.sheet .sheet-actions {
  position: sticky;
  bottom: calc(-20px - var(--safe-bottom));
  margin-bottom: calc(-20px - var(--safe-bottom));
  padding: 12px 0 calc(20px + var(--safe-bottom));
  background: var(--surface);
  box-shadow: 0 -12px 12px -12px var(--press);
}

/* ---------- Players ---------- */
body.picking .tabs {
  display: none;
}
.avatar {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 3px 0 var(--press);
}
.avatar.plus {
  background: var(--sunk);
  color: var(--muted);
  box-shadow: none;
  border: 2px dashed var(--line);
}
.players {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.player-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: left;
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.06s;
}
.player-card:active {
  transform: translateY(2px);
}
.player-card.add {
  background: transparent;
  box-shadow: none;
  border: 2px dashed var(--line);
}
.pc-text {
  flex: 1;
  min-width: 0;
}
.pc-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 21px;
  overflow-wrap: anywhere;
}
.pc-text span {
  display: block;
  font-size: 14px;
  color: var(--muted);
}
.pc-go {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--muted);
}
.pc-tools,
.form-actions {
  display: flex;
  gap: 8px;
}
.pc-tools .btn,
.form-actions .btn {
  flex: 1;
}
.field-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
}
.text-input {
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: var(--sunk);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  width: 100%;
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
}
.color-pick {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.color-pick legend {
  margin-bottom: 8px;
}
.color-pick input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.color-pick span {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  box-shadow: inset 0 0 0 3px var(--surface);
}
.color-pick input:checked + span {
  border-color: var(--ink);
}
.color-pick input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.player-confirm p {
  font-size: 16px;
}
.small-note {
  font-size: 13px;
  text-align: center;
}
.top-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.avatar-btn {
  border-radius: 50%;
}
.avatar-btn .avatar {
  width: 44px;
  height: 44px;
  font-size: 20px;
}
.setting .avatar {
  width: 40px;
  height: 40px;
  font-size: 18px;
}
.grow {
  flex: 1;
  min-width: 0;
}
.top h1 {
  font-size: clamp(26px, 7.4vw, 34px);
}
.form-actions .btn {
  padding: 0 12px;
  white-space: nowrap;
}
.pc-go {
  display: grid;
  color: var(--muted);
}
.pc-go svg {
  width: 22px;
  height: 22px;
}
