/* Cages web — the design tokens and rules from design/prototype.html.
   The prototype IS the spec: keep names and values in lockstep with it
   (and with the Flutter theme in apps/app_flutter/lib/theme/tokens.dart). */

:root {
  --page-bg: #dfe8f7;
  --bg: #f2f6fe;
  --surface: #ffffff;
  --surface-2: #e9effc;
  --ink: #1e2a46;
  --muted: #68789b;
  --line: #d9e2f2;
  --accent: #4a6cf7;
  --accent-ink: #ffffff;
  --accent-soft: #e4ebff;
  --accent-deep: #3a55d4;
  --accent-2: #ffb020;
  --good: #1fb886;
  --good-soft: #dcf5ec;
  --bad: #ff5d6c;
  --bad-soft: #ffe3e6;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --card-shadow: 0 6px 18px rgba(30, 42, 70, .10);
  --btn-edge: 0 4px 0 #3a55d4;
  --grid-line: #d7e0f0;
  --cage-line: #26355e;
  --cell-sel: #e4ebff;
  --cell-peer: #f0f4fd;
  --cell-same: #d3ddfa;
  --display: 'Fredoka', ui-rounded, system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --dur-quick: .16s;
  --dur-settle: .24s;
  --dur-pop: .34s;
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, .61, .36, 1);
}

@font-face {
  font-family: 'Fredoka';
  src: url('fonts/Fredoka-400.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('fonts/Fredoka-500.ttf') format('truetype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Fredoka';
  src: url('fonts/Fredoka-600.ttf') format('truetype');
  font-weight: 600 700;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: pointer;
}
svg { display: block; }

/* ------------------------------------------------------- app scaffold */
/* The page frame: a centered content column on the page ground, growing
   with the size class exactly like CagesPageFrame (520/640/760/840). */
/* The browser window IS the device, exactly like the prototype's frame:
   the app surface fills it edge to edge and each screen centers its own
   content column (the size-class caps further down). */
#app { min-height: 100dvh; }
.frame {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* A flex item's default min-height is its content, so a long tab (Settings)
     stretched this box past the frame, which clips: the .tab-scroll inside
     then had nothing to scroll against and the tail was simply unreachable. */
  min-height: 0;
  animation: contentIn var(--dur-settle) var(--ease-out);
}
@keyframes contentIn {
  from { opacity: 0; transform: translateX(26px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- type */
h1 { font: 600 26px/1 var(--display); }
.sub { font: 500 13px/1.5 var(--body); color: var(--muted); margin-top: 6px; }
.micro {
  font: 600 10.5px/1 var(--body);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------ buttons */
.btn {
  border: 0;
  font: 600 16px/1 var(--display);
  letter-spacing: .01em;
  border-radius: var(--r-md);
  padding: 16px 22px;
  transition: transform var(--dur-quick) var(--ease-spring),
    box-shadow var(--dur-quick);
}
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--btn-edge); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:active { transform: scale(.96); }
.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  box-shadow: var(--card-shadow);
  transition: transform var(--dur-quick) var(--ease-spring);
  font-size: 18px;
}
.icon-btn:active { transform: scale(.9); }

/* ---------------------------------------------------------------- hub */
.home-head { padding: 30px 20px 6px; }
.mini-logo { display: flex; align-items: center; gap: 10px; }
.mini-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font: 600 15px/1 var(--display);
}
.hub-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 20px 28px;
}
.hub-card {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--r-lg);
  padding: 22px 20px;
  color: #fff;
  transition: transform var(--dur-quick) var(--ease-spring);
}
.hub-card:active { transform: scale(.98); }
.hub-adv {
  background: linear-gradient(150deg, #7c96ff 0%, #4a6cf7 55%, #3b55d9 100%);
  box-shadow: 0 10px 24px rgba(74, 108, 247, .28);
}
.hub-rand {
  background: linear-gradient(150deg, #ffd469 0%, #ffad33 55%, #f58f0f 100%);
  box-shadow: 0 10px 24px rgba(245, 143, 15, .26);
}
.hub-card h3 { font: 600 24px/1.1 var(--display); margin-top: 16px; }
.hub-card p { font: 500 13px/1.5 var(--body); opacity: .85; margin-top: 6px; max-width: 26ch; }
.hub-foot { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 16px; }
.hub-note { font: 600 11px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.hub-go {
  margin-left: auto;
  flex: 0 0 auto;
  background: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font: 600 13px/1 var(--display);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .12);
}
.hub-adv .hub-go { color: var(--accent); }
.hub-rand .hub-go { color: #c46a00; }

/* Rail sizes: the doors split the width — same rule as the prototype. */
@media (min-width: 840px) and (orientation: landscape) {
  .hub-scroll { flex-direction: row; align-items: center; }
  .hub-card { height: 440px; max-height: 70vh; flex: 1; }
}

/* --------------------------------------------------------------- game */
.appbar { display: flex; align-items: center; gap: 12px; padding: 22px 20px 10px; min-height: 74px; }
.appbar-title { flex: 1; min-width: 0; }
.appbar-title.center { text-align: center; }
.appbar-cur { display: flex; gap: 8px; flex: 0 0 auto; }
.appbar-title h2 { font: 600 19px/1.15 var(--display); letter-spacing: -.01em; }
.appbar-title .bar-sub {
  font: 600 10.5px/1 var(--body);
  letter-spacing: .14em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 4px;
}
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 22px 10px; }
.pips { display: flex; gap: 7px; align-items: center; }
.pip-label {
  font: 600 10px/1 var(--body);
  letter-spacing: .12em;
  color: var(--muted);
  text-transform: uppercase;
  margin-right: 2px;
}
.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
}
.pip.hit { background: var(--bad); border-color: var(--bad); animation: pipPop .34s var(--ease-spring); }
@keyframes pipPop { 50% { transform: scale(1.7); } }
.clock {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 600 15px/1 var(--display);
}
/* Fredoka carries no tnum feature, so font-variant-numeric does nothing and
   its digits stay proportional — a 1 is two thirds the width of a 2, and a
   ticking clock shoves the icon beside it every second. tabularNumber() wraps
   each digit in one of these instead; 0.6em clears the widest digit in every
   Fredoka weight (0.598em at 400). */
.tnum { display: inline-block; width: 0.6em; text-align: center; }
.board-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4px 20px; }

/* ---------------------------------------------------------------- grid
   Ported from the proven old web app: inline SVG chrome + CSS Grid cells.
   One SVG unit = one cell; the border rect is inset half its own stroke. */
.grid {
  --cell: clamp(32px, calc(min(94vw, 56vh) / var(--n)), 88px);
  --grid: calc(var(--cell) * var(--n));
  position: relative;
  width: var(--grid);
  height: var(--grid);
  background: var(--surface);
  border: 3px solid var(--cage-line);
  border-radius: var(--r-sm);
  box-shadow: var(--card-shadow);
  touch-action: manipulation;
  overflow: hidden;
}
/* Chrome ABOVE the cells: the selection/peer washes are cell backgrounds
   and must never cover the cage strokes. pointer-events:none keeps every
   click landing on the cells beneath. */
.chrome { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
/* Fixed-pixel strokes (the prototype's 1 / 2.5 / 3px), whatever the cell
   size — non-scaling-stroke keeps them from fattening on big boards. */
.hairline {
  stroke: var(--grid-line);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  fill: none;
}
.cage {
  stroke: var(--cage-line);
  stroke-width: 2.5px;
  vector-effect: non-scaling-stroke;
  fill: none;
  stroke-linejoin: miter;
}
.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  z-index: 1;
  border-radius: calc(var(--r-sm) - 3px);
  overflow: hidden;
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
}
.cell.peer { background: var(--cell-peer); }
/* Twins of the selected value: under the more specific washes below. */
.cell.same { background: var(--cell-same); }
.cell.mistake { background: var(--bad-soft); }
.cell.hinted { background: var(--good-soft); }
.cell.highlight { background: var(--accent-soft); }
.cell.selected { background: var(--cell-sel); box-shadow: inset 0 0 0 2.5px var(--accent); }
.cell .value { animation: popIn var(--dur-pop) var(--ease-spring); }
.grid.strike { animation: shake .42s ease-in-out; }
@keyframes popIn {
  from { transform: scale(.4); opacity: 0; }
  60% { transform: scale(1.15); }
  to { transform: scale(1); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-7px); }
  35% { transform: translateX(7px); }
  55% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
/* Same inset as the Flutter board: 0.08 cell + a few px. Above the value
   and notes, so nothing a player writes can cover what the cage asks. */
.clue {
  position: absolute;
  top: calc(var(--cell) * 0.08 + 3px);
  left: calc(var(--cell) * 0.08 + 5px);
  font-size: max(11px, calc(var(--cell) * 0.18));
  font-weight: 600;
  color: var(--ink);
  opacity: .85;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}
/* Slightly small and low on every cell, so a row of values shares a
   baseline and clears the clue. */
.value {
  position: relative;
  top: max(3px, calc(var(--cell) * 0.06));
  font-family: var(--display);
  font-size: calc(var(--cell) * 0.46);
  line-height: 1;
  color: var(--ink);
  font-weight: 600;
}
/* No rule for .cell.given: a given is drawn exactly like a value the player
   entered. It is set apart by refusing the write, not by looking different.
   A wrong entry still goes red. */
.cell.mistake .value { color: var(--bad); }
.notes {
  position: absolute;
  inset: 8% 6%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  font-size: max(9px, calc(var(--cell) * 0.2));
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}
.notes span { display: flex; align-items: center; justify-content: center; }
/* In a clue's own cell the marks start under the clue band. */
.cell.anchor .notes { top: calc(var(--cell) * 0.08 + 5px + max(11px, var(--cell) * 0.18)); }

/* ------------------------------------------------------------ controls */
.controls { display: flex; flex-direction: column; gap: 12px; padding: 6px 20px 26px; }
.actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.action {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 0;
  background: none;
  color: var(--ink);
  padding: 6px 0;
  border-radius: var(--r-sm);
  transition: transform var(--dur-quick) var(--ease-spring), opacity var(--dur-quick);
  font-size: 20px;
}
.action:active { transform: scale(.88); }
.action .a-label {
  font: 600 9.5px/1 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.action.active { color: var(--accent); }
.action.active .a-label { color: var(--accent); }
.action.active::before {
  content: '';
  position: absolute;
  inset: -2px -4px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  z-index: -1;
}
.action:disabled { opacity: .32; cursor: default; }
.action:disabled:active { transform: none; }
.badge {
  position: absolute;
  top: -2px;
  right: 8px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #3a2a00;
  font: 700 10px/16px var(--body);
  text-align: center;
  padding: 0 4px;
}
.digits { display: grid; gap: 10px; }
.digit {
  height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font: 600 24px/1 var(--display);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--line);
  transition: transform var(--dur-quick) var(--ease-spring), opacity var(--dur-quick), background var(--dur-quick);
}
.digit:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.digit.placed { opacity: .32; }
.digit.note-mode { background: var(--accent-soft); border-color: var(--accent); }

/* Beside layout at rail sizes: board left, control column right — same
   rule as the prototype and the Flutter app. */
@media (min-width: 840px) and (orientation: landscape) {
  .game-body { flex: 1; display: flex; align-items: stretch; }
  /* Board hugs the column's left edge, on the back button's vertical. */
  .game-body .board-wrap { flex: 1; justify-content: flex-start; padding-left: 20px; }
  .game-side {
    width: 264px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-right: 20px;
  }
  .game-side .status-row { padding: 2px 0 10px; }
  .game-side .controls { padding: 6px 0 0; }
}
@media not ((min-width: 840px) and (orientation: landscape)) {
  .game-body { flex: 1; display: flex; flex-direction: column; }
  .game-side { display: contents; }
  /* The status row markup lives in the side column; on narrow layouts it
     climbs back above the board. */
  .game-side .status-row { order: 1; }
  .board-wrap { order: 2; }
  .game-side .controls { order: 3; }
  /* The walkthrough's caption and its Next button follow the control row
     they describe — the same reading order the Flutter screen has. */
  .game-side .demo-coach { order: 4; }
  .game-side .demo-actions { order: 5; }
}

/* ------------------------------------------------------------ overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(223, 232, 247, .6);
  backdrop-filter: blur(7px);
}
.panel {
  width: 100%;
  max-width: 300px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 30px 24px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: panelIn var(--dur-pop) var(--ease-spring);
}
@keyframes panelIn {
  from { transform: scale(.8) translateY(18px); }
  to { transform: none; }
}
.panel h3 { font: 600 24px/1.1 var(--display); }
.panel p { font: 500 13.5px/1.55 var(--body); color: var(--muted); }
.panel .btn { width: 100%; margin-top: 6px; }
.panel .stat-line {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 10px 0 6px;
  font: 600 14px/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.panel .stat-line b {
  display: block;
  font: 600 10px/1 var(--body);
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
}
.mark.win { background: var(--good-soft); color: var(--good); }
/* Currency popup marks: the flame-badge / coin-chip gradients. */
.mark.flame { background: linear-gradient(180deg, #ffe3c2, #ffd0a0); }
.mark.coin { background: linear-gradient(180deg, #ffe9a8, #ffd469); }
/* EARN / USE rows inside the currency popup. */
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font: 500 12px/1.5 var(--body);
  color: var(--ink);
  text-align: left;
}
.info-row .info-label {
  flex: 0 0 auto;
  padding-top: 2px;
  font: 600 10px/1.5 var(--body);
  letter-spacing: .13em;
  color: var(--muted);
}
/* A currency pill popping in the moment its currency is introduced. */
.pill-in { animation: pillIn var(--dur-pop) var(--ease-spring); }
@keyframes pillIn {
  from { transform: scale(.3); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.mark.fail { background: var(--bad-soft); color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    animation-delay: 0s !important;
    transition-duration: .001s !important;
  }
}

/* --------------------------------------------------------- shell chrome */
.top-actions {
  position: absolute;
  top: 22px;
  right: 20px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cur-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  box-shadow: var(--card-shadow);
  font: 600 13px/1 var(--display);
  font-variant-numeric: tabular-nums;
}
.frame { position: relative; }
.tab-screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tab-scroll { flex: 1; overflow-y: auto; padding: 8px 20px 120px; scrollbar-width: none; }
.tab-scroll::-webkit-scrollbar { display: none; }
.page-head { padding: 30px 20px 6px; }
.page-head h1 { padding-right: 120px; }

.tabbar {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 6px;
  max-width: 520px;
  margin: 0 auto;
}
.tab {
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 0 7px;
  border-radius: var(--r-md);
  color: var(--muted);
  position: relative;
  z-index: 1;
  font-size: 18px;
  line-height: 1;
}
.tab span {
  font: 600 9.5px/1 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tab.on { color: var(--accent); }
.tab.on::before {
  content: '';
  position: absolute;
  inset: 2px 4px;
  border-radius: calc(var(--r-md) - 2px);
  background: var(--accent-soft);
  z-index: -1;
}
.tab.tab-settings { display: none; }
.tab-sep { display: none; }

/* The floating vertical rail at expanded-landscape — the bottom bar stood
   upright, settings as the fifth item; the corner gear disappears. */
@media (min-width: 840px) and (orientation: landscape) {
  .tabbar {
    left: 14px;
    right: auto;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    width: 80px;
    max-width: none;
    margin: 0;
  }
  .tab.tab-settings { display: flex; }
  .tab-sep {
    display: block;
    width: 40px;
    height: 1px;
    background: var(--line);
    margin: 4px auto;
  }
  .corner-gear { display: none; }
  .tab-screen { padding-left: 102px; }
  .tab-scroll { padding-bottom: 28px; }
}

/* ------------------------------------------------------------ rows/cards */
.rows { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; }
/* A row that does one thing (Restart puzzle): the whole card is the button. */
.row-card.row-act { cursor: pointer; font: inherit; color: inherit; }
.row-card .row-go { font-size: 22px; line-height: 1; color: var(--muted); }
.row-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  text-align: left;
  width: 100%;
}
.row-card .row-txt { flex: 1; min-width: 0; }
.row-card .row-txt b { display: block; font: 600 14.5px/1.2 var(--display); }
.row-card .row-txt span {
  display: block;
  font: 500 12px/1.4 var(--body);
  color: var(--muted);
  margin-top: 3px;
}
/* The About card's user id, matching the mobile settings footer: smaller
   than the version line above it, and tappable to copy. */
.row-card .row-txt .acct-id {
  font: 500 10.5px/1.4 var(--body);
  color: var(--muted);
  margin-top: 3px;
  cursor: pointer;
  word-break: break-all;
}
.sec-label {
  font: 600 10.5px/1 var(--body);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 22px 2px 0;
}

/* --------------------------------------------------- how-to-play walkthrough */

/* Shown and explained, never pressed. */
.demo-locked { pointer-events: none; }
.controls.tour .action,
.controls.tour .digits { opacity: .35; }
.controls.tour .action.spot { opacity: 1; }
.controls.tour .action.spot::before {
  content: '';
  position: absolute;
  inset: -2px -4px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  z-index: -1;
}
.demo-coach {
  margin: 10px 0 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  font: 500 13.5px/1.55 var(--body);
  min-height: 88px;
  max-height: 28vh;
  overflow-y: auto;
}
.demo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
}
.demo-actions .step-count {
  flex: 1;
  font: 600 11px/1 var(--body);
  letter-spacing: .12em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* The `compact: true` twin: hugs its label so the row cannot outgrow a
   narrow phone. */
.btn-sm { padding: 11px 14px; font-size: 13.5px; }
.demo-view .board-wrap { align-self: center; }

/* ----------------------------------------------------------- how to play */

.rules { display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.rule-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 16px;
  box-shadow: var(--card-shadow);
}
.rule-num {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 15px/1 var(--display);
}
.rule-txt b { display: block; font: 600 15px/1.2 var(--display); }
.rule-txt span {
  display: block;
  margin-top: 3px;
  font: 500 12.5px/1.4 var(--body);
  color: var(--muted);
}
.rules-cta { width: 100%; margin-top: 20px; }
.rules-more { margin-top: 16px; text-align: center; }
.rules-more a { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------- adventure cards */
.adv-list { display: grid; grid-template-columns: 1fr; gap: 16px; padding-top: 14px; }
@media (min-width: 600px) { .adv-list { grid-template-columns: 1fr 1fr; } }
.adv-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  text-align: left;
  width: 100%;
  padding: 0;
  min-height: 176px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: var(--surface);
  color: #fff;
}
.adv-card.locked { filter: grayscale(.7); }
.adv-card.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(226, 233, 248, .42);
}
.world-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  background: rgba(255, 255, 255, .94);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font: 600 9px/1 var(--body);
  letter-spacing: .12em;
  text-transform: uppercase;
  box-shadow: var(--card-shadow);
}
.adv-cta {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  font: 600 10px/1 var(--body);
  letter-spacing: .12em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 9px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 3px 0 var(--accent-deep), var(--card-shadow);
}
.adv-cta.done { background: var(--good); box-shadow: 0 3px 0 #149a6f, var(--card-shadow); }
.adv-cta.lock { background: rgba(255,255,255,.94); color: var(--muted); box-shadow: var(--card-shadow); }
.adv-cta.coin { background: var(--accent-2); color: #3a2a00; box-shadow: 0 3px 0 #d18e00, var(--card-shadow); }
.world-body { position: relative; padding: 0 16px 10px; z-index: 1; }
.world-name { font: 600 21px/1.15 var(--display); text-shadow: 0 2px 0 rgba(23,32,58,.35); }
.world-blurb { font: 500 12px/1.45 var(--body); opacity: .94; margin-top: 3px; text-shadow: 0 1px 0 rgba(23,32,58,.3); }
.world-foot { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 16px 14px; z-index: 1; }
.world-foot .pbar { flex: 1; height: 8px; background: rgba(255,255,255,.3); border-radius: 99px; overflow: hidden; }
.world-foot .pbar i { display: block; height: 100%; background: #fff; border-radius: 99px; }
.adv-count { font: 600 11px/1 var(--body); font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 rgba(23,32,58,.3); }

/* --------------------------------------------------------------- path */
.adv-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 12px 8px;
  margin-top: 14px;
}
.adv-stat { text-align: center; }
.adv-stat b { display: block; font: 600 15px/1 var(--display); font-variant-numeric: tabular-nums; }
.adv-stat span {
  display: block;
  font: 600 8.5px/1.2 var(--body);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}
.stop-list { display: flex; flex-direction: column; gap: 10px; padding: 14px 0 28px; max-width: 460px; margin: 0 auto; width: 100%; }
.stop-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 12px 16px;
  width: 100%;
  text-align: left;
}
.stop-row:disabled { opacity: .5; }
.stop-num {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font: 600 15px/1 var(--display);
}
.stop-row.solved .stop-num { background: var(--good); color: #fff; }
.stop-row.current { border: 2px solid var(--accent); }
.stop-row.current .stop-num { background: var(--accent); color: #fff; }
.stop-meta { flex: 1; font: 600 14px/1.3 var(--display); }
.stop-meta span { display: block; font: 600 9.5px/1.6 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* --------------------------------------------------------------- daily */
.daily-hero {
  position: relative;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 18px;
  color: var(--accent-ink);
  overflow: hidden;
  margin-top: 14px;
}
.daily-kicker { font: 600 10px/1 var(--body); letter-spacing: .16em; text-transform: uppercase; opacity: .85; }
.daily-title { font: 600 24px/1.15 var(--display); margin-top: 6px; }
.daily-sub { font: 500 12.5px/1.5 var(--body); opacity: .85; margin-top: 3px; }
.daily-play {
  margin-top: 14px;
  border: 0;
  background: #fff;
  color: var(--accent);
  font: 600 15px/1 var(--display);
  border-radius: var(--r-md);
  padding: 14px 22px;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.daily-play:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.streak-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  margin-top: 12px;
}
.streak-num { font: 600 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.streak-label { font: 600 10px/1.4 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.streak-side { margin-left: auto; text-align: right; }
.streak-side b { display: block; font: 600 15px/1.2 var(--display); }
.streak-side span { font: 600 9px/1.4 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  margin-top: 12px;
}
.cal-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.cal-head b { font: 600 14px/1 var(--display); }
.cal-head span { font: 600 9.5px/1 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-grid .dow { font: 600 8.5px/1 var(--body); letter-spacing: .06em; color: var(--muted); text-align: center; }
.cal-day {
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font: 600 10.5px/1 var(--body);
  color: var(--muted);
  max-width: 64px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}
.cal-day.hit { background: var(--good); color: #fff; }
.cal-day.today { box-shadow: 0 0 0 2.5px var(--accent); background: var(--accent-soft); color: var(--accent); }
.cal-day.hit.today { background: var(--good); color: #fff; }
.cal-day.future { opacity: .35; }
.cal-day.missed { background: var(--surface); border: 1.5px dashed var(--accent-2); color: var(--accent-2); font-weight: 700; }
/* Rail sizes: hero+streak left, calendar right — per the prototype. */
@media (min-width: 840px) and (orientation: landscape) {
  .daily-cols { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 0 16px; align-items: start; }
  .daily-cols .cal-card { grid-column: 2; grid-row: 1 / span 3; margin-top: 14px; }
}

/* --------------------------------------------------------------- ranks */
.seg {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: var(--card-shadow);
  margin-top: 14px;
}
.seg button {
  flex: 1;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 13px/1 var(--body);
  padding: 10px 6px;
  border-radius: 999px;
}
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.rank-list { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; max-width: 600px; margin: 0 auto; width: 100%; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 10px 14px;
}
.rank-pos { flex: 0 0 26px; text-align: center; font: 600 14px/1 var(--display); color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-pos.gold, .rank-pos.silver, .rank-pos.bronze {
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
}
.rank-pos.gold { background: linear-gradient(180deg, #ffd469, #e0a400); }
.rank-pos.silver { background: linear-gradient(180deg, #e6ecf5, #aab6cc); color: #5d6b85; }
.rank-pos.bronze { background: linear-gradient(180deg, #e7b98c, #c08552); }
.rank-name { flex: 1; min-width: 0; font: 600 14.5px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.you-tag {
  display: inline-block;
  vertical-align: 1px;
  margin-left: 6px;
  background: var(--accent);
  color: #fff;
  font: 600 8.5px/1 var(--body);
  letter-spacing: .1em;
  padding: 3px 6px;
  border-radius: 99px;
}
.rank-val { text-align: right; font: 600 17px/1 var(--display); font-variant-numeric: tabular-nums; }
.rank-val span { display: block; font: 600 8.5px/1.6 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.rank-row.you { border: 2px solid var(--accent); background: var(--accent-soft); padding: 9px 13px; }
.rank-gap { text-align: center; font: 600 13px/1 var(--body); color: var(--muted); letter-spacing: .4em; padding: 2px 0; }

/* --------------------------------------------------------------- packs */
.pack-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
@media (min-width: 600px) { .pack-grid { grid-template-columns: 1fr 1fr; align-items: stretch; } }
.pack-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 18px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pack-card.pass { border: 2px solid var(--accent); box-shadow: 0 6px 18px rgba(74,108,247,.18); }
.pack-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  font: 600 9.5px/1 var(--body);
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  padding: 6px 10px;
}
.pack-card h3 { font: 600 18px/1.2 var(--display); padding-right: 90px; }
.pack-card > p { font: 500 12.5px/1.5 var(--body); color: var(--muted); margin-top: 5px; }
.perk-list { list-style: none; margin: 12px 0 4px; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.perk-list li { display: flex; align-items: center; gap: 10px; font: 500 13.5px/1.4 var(--body); }
.perk-list li::before { content: '✓'; color: var(--good); font-weight: 700; }
.price-row { display: flex; gap: 10px; margin-top: 14px; }
.price-row .btn { flex: 1; padding: 15px 8px; font-size: 15px; }
.topup-row { display: flex; gap: 12px; margin-top: 10px; }
.topup-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.topup-card h4 { font: 600 14.5px/1.2 var(--display); margin-top: 6px; }
.topup-card p { font: 500 11.5px/1.45 var(--body); color: var(--muted); margin-top: 4px; flex: 1; }
.topup-card .btn { width: 100%; margin-top: 10px; padding: 11px 8px; font-size: 14px; }
.owned-note {
  background: var(--good-soft);
  color: var(--good);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 14px;
  font: 600 13px/1.4 var(--body);
  text-align: center;
}

/* ------------------------------------------------------------ toast */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--bg);
  font: 600 13px/1.3 var(--body);
  padding: 11px 18px;
  border-radius: 99px;
  box-shadow: var(--card-shadow);
  white-space: nowrap;
}

/* =================================================================
   Prototype-fidelity pass: classes and keyframes ported verbatim
   from design/prototype.html. Later rules deliberately override the
   first-draft equivalents above.
   ================================================================= */

/* ---------------------------------------------------------- motion */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.rise { opacity: 0; animation: riseIn .4s var(--ease-out) forwards; }
@keyframes floatProp {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(6px, -10px); }
}
@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}
@keyframes tileIn {
  from { opacity: 0; transform: scale(.3) rotate(-8deg); }
  60% { opacity: 1; transform: scale(1.12); }
  to { opacity: 1; transform: none; }
}
@keyframes cellIn {
  from { opacity: 0; transform: scale(.84); }
  to { opacity: 1; transform: none; }
}
.grid.cascade .cell { opacity: 0; animation: cellIn .38s var(--ease-out) forwards; }
@keyframes pulseRing {
  0%, 100% {
    box-shadow: 0 5px 0 var(--accent-deep), 0 0 0 8px var(--accent-soft),
      var(--card-shadow);
  }
  50% {
    box-shadow: 0 5px 0 var(--accent-deep), 0 0 0 15px rgba(228, 235, 255, .35),
      var(--card-shadow);
  }
}
@keyframes popIn {
  0% { transform: scale(.4); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes flyOut {
  0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.5);
    opacity: 0;
  }
}

/* ---------------------------------------------------------- splash */
.splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 34px;
  cursor: pointer;
  background: var(--bg);
}
.logo {
  display: grid;
  grid-template-columns: repeat(2, 64px);
  grid-template-rows: repeat(2, 64px);
  gap: 8px;
}
.logo-tile {
  position: relative;
  background: var(--surface);
  border: 2.5px solid var(--cage-line);
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font: 600 26px/1 var(--display);
  color: var(--ink);
  box-shadow: var(--card-shadow);
  opacity: 0;
  animation: tileIn .5s var(--ease-spring) forwards;
}
.logo-tile:nth-child(2) { animation-delay: .09s; }
.logo-tile:nth-child(3) { animation-delay: .18s; }
.logo-tile:nth-child(4) { animation-delay: .27s; }
.logo-tile.lt-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.logo-tile .lt-clue {
  position: absolute;
  top: 4px;
  left: 7px;
  font: 600 11px/1 var(--body);
}
.wordmark {
  font: 600 40px/1 var(--display);
  letter-spacing: .02em;
  text-align: center;
  opacity: 0;
  animation: riseIn .5s var(--ease-out) .45s forwards;
}
.splash-tag {
  font: 600 11px/1 var(--body);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
  opacity: 0;
  animation: riseIn .5s var(--ease-out) .6s forwards;
}

/* ------------------------------------------------------------- hub */
.hub-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .22);
  color: #fff;
  margin-bottom: auto;
}
.hub-deco {
  position: absolute;
  top: -28px;
  right: -24px;
  width: 170px;
  height: 170px;
  color: #fff;
  opacity: .16;
  pointer-events: none;
}
.hub-deco svg { width: 100%; height: 100%; }

/* ------------------------------------------------- adventure cards */
.world-tag {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 5px;
}
.wnum {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font: 600 11px/1 var(--display);
}
.adv-card.done-card .wnum { background: var(--good); }
.adv-card.locked .wnum { background: #98a5c2; }
.adv-card.premium-adv .wnum {
  background: linear-gradient(180deg, #ffd469, #f0a800);
  color: #5a3e00;
}
.adv-card.premium-adv { border: 2px solid var(--accent-2); }
.wprop { position: absolute; pointer-events: none; }
.world-blurb { max-width: 32ch; }
.diff-chips { display: flex; gap: 4px; flex: 0 0 auto; }
.dchip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .5);
}
.dchip.e { background: var(--good); }
.dchip.m { background: var(--accent); }
.dchip.h { background: var(--accent-2); }
.dchip.x { background: var(--bad); }
.adv-card:not(.locked):active { transform: scale(.97); }
.adv-card { transition: transform var(--dur-quick) var(--ease-spring); }

/* -------------------------------------------------------- the path */
.scene {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--line);
}
.scene-0 { background: linear-gradient(180deg, #ffe3ae 0, #fff3d6 12%, #bfe596 32%, #a8d97e 100%); }
.scene-1 { background: linear-gradient(180deg, #aedcff 0, #dff3ff 12%, #8fd173 32%, #79c463 100%); }
.scene-2 { background: linear-gradient(180deg, #b8ecff 0, #e3f9ff 12%, #8ad4c0 32%, #6fc7b4 100%); }
.scene-3 { background: linear-gradient(180deg, #a8cfc4 0, #d3eadf 12%, #5fa875 32%, #4c9663 100%); }
.scene-4 { background: linear-gradient(180deg, #8e9cc4 0, #b9c4e0 12%, #8e9ac0 32%, #7986ae 100%); }
.scene-5 { background: linear-gradient(180deg, #d8cef5 0, #efeafc 12%, #a99ae0 32%, #9384d2 100%); }
.scene-6 { background: linear-gradient(180deg, #584d8c 0, #6e63a6 12%, #4b4178 32%, #443a6e 100%); }
.trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.trail path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trail-shadow { stroke: rgba(30, 42, 70, .15); stroke-width: 8; transform: translate(1px, 5px); }
.trail-base { stroke: #fff; stroke-width: 15; opacity: .9; }
.trail-todo { stroke: #d9e2f2; stroke-width: 4; stroke-dasharray: 1 14; }
.trail-done { stroke: var(--good); stroke-width: 7; }
.blob { position: absolute; pointer-events: none; }
.stop {
  position: absolute;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 3px solid var(--line);
  font: 600 19px/1 var(--display);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(30, 42, 70, .14), var(--card-shadow);
  transition: transform var(--dur-quick) var(--ease-spring);
  padding: 0;
}
.stop:active { transform: translateY(3px); }
.stop .psz { font: 600 8.5px/1 var(--body); letter-spacing: .05em; color: var(--muted); }
.stop.e { border-color: var(--good); }
.stop.m { border-color: var(--accent); }
.stop.h { border-color: var(--accent-2); }
.stop.x { border-color: var(--bad); }
.stop.solved {
  background: var(--good);
  border-color: #149a6f;
  color: #fff;
  box-shadow: 0 5px 0 #0e7a57, var(--card-shadow);
}
.stop.solved .psz { color: rgba(255, 255, 255, .85); }
.stop.current {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--accent-ink);
  box-shadow: 0 5px 0 var(--accent-deep), 0 0 0 8px var(--accent-soft),
    var(--card-shadow);
  animation: pulseRing 2s ease-in-out infinite;
}
.stop.current .psz { color: var(--accent-ink); opacity: .85; }
.stop.locked-stop { cursor: default; background: #fff; }
.stars {
  position: absolute;
  bottom: -13px;
  display: flex;
  gap: 1px;
  background: var(--surface);
  border-radius: 99px;
  padding: 2px 5px;
  box-shadow: var(--card-shadow);
}
.stars .star { fill: var(--accent-2); }
.stars .star.off { fill: var(--surface-2); }
.bubble {
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: var(--accent);
  border-radius: 12px;
  padding: 7px 12px;
  font: 600 11px/1 var(--body);
  letter-spacing: .12em;
  white-space: nowrap;
  box-shadow: var(--card-shadow);
  animation: bob 1.4s ease-in-out infinite;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.complete-pill {
  position: absolute;
  left: 50%;
  top: 36px;
  transform: translateX(-50%);
  z-index: 3;
  font: 600 10px/1 var(--body);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--good);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 8px 14px;
  box-shadow: var(--card-shadow);
  animation: bob 1.4s ease-in-out infinite;
  white-space: nowrap;
}
.path-scroll { max-width: 700px; margin: 0 auto; width: 100%; }

/* ----------------------------------------------------------- daily */
.daily-hero::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.flame-badge {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe3c2, #ffd0a0);
}

/* ----------------------------------------------------------- ranks */
.rank-ava {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 600 12.5px/1 var(--display);
}
.rank-name b {
  display: block;
  font: 600 14.5px/1.2 var(--display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-sub {
  display: block;
  font: 600 9.5px/1.4 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.rank-pos.gold, .rank-pos.silver, .rank-pos.bronze {
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14);
}
.rank-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  margin-bottom: 4px;
}
.rank-cta .rc-txt { font: 600 14px/1.3 var(--display); }
.rank-cta .rc-sub { font: 500 11.5px/1.4 var(--body); opacity: .85; margin-top: 2px; }
.rank-cta button {
  border: 0;
  background: #fff;
  color: var(--accent);
  font: 600 13px/1 var(--display);
  border-radius: 99px;
  padding: 11px 16px;
  margin-left: auto;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
  transition: transform var(--dur-quick) var(--ease-spring);
}
.rank-cta button:active { transform: translateY(2px); }

/* ----------------------------------------------------------- packs */
.pack-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.pass-badge { background: linear-gradient(180deg, #c9d4ff, #8fa4ff); color: #2a3c9e; }
.gold-badge { background: linear-gradient(180deg, #ffe29a, #ffc63d); color: #8a6100; }
.perk-list li::before { content: none; }
.perk-check {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--good-soft);
  color: var(--good);
}
.price-btn { position: relative; font: 600 17px/1 var(--display); padding: 15px 8px; }

/* Creating a checkout session is a round trip to our function and on to
   Stripe before the browser navigates, so a pressed price button would sit
   there looking dead. Spin, dim, and lock the rest. */
.btn.is-locked {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}

.btn-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: btn-spin .6s linear infinite;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  /* Still show it is working — just without the spin. */
  .btn-spinner { animation-duration: 2.4s; }
}

.remove-ads-btn { margin-top: 14px; }
.price-btn .suffix { font: 600 11px/1 var(--body); opacity: .75; margin-left: 3px; }
.save-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-2);
  color: #3a2a00;
  font: 700 9px/1 var(--body);
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 99px;
  padding: 5px 9px;
  white-space: nowrap;
}
.topup-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.topup-flame { background: linear-gradient(180deg, #ffe3c2, #ffc98f); }
.topup-coin { background: linear-gradient(180deg, #ffe9a8, #ffd469); }
.set-meta {
  font: 500 11.5px/1.6 var(--body);
  color: var(--muted);
  text-align: center;
  padding: 10px 2px 0;
}

/* -------------------------------------------------------- settings */
.acct-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 14px;
}
.acct-ava {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.acct-txt { flex: 1; min-width: 0; }
.acct-txt b { display: block; font: 600 14.5px/1.2 var(--display); }
.acct-txt span { display: block; font: 500 12px/1.4 var(--body); color: var(--muted); margin-top: 2px; }
.acct-card .btn { flex: 0 0 auto; padding: 11px 14px; font-size: 13.5px; }
.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  font: 600 15px/1 var(--display);
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink);
  transition: transform var(--dur-quick) var(--ease-spring);
}
.provider-btn:active { transform: scale(.97); }
.sw {
  position: relative;
  width: 50px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 99px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background var(--dur-settle) var(--ease-out),
    box-shadow var(--dur-settle);
  padding: 0;
}
.sw::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transition: transform var(--dur-settle) var(--ease-spring);
}
.sw.on { background: var(--accent); box-shadow: none; }
.sw.on::after { transform: translateX(20px); }

/* ------------------------------------------------------ sheet/toast */
.sheet-back {
  position: fixed;
  inset: 0;
  z-index: 32;
  background: rgba(10, 12, 20, .4);
}
.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 520px;
  z-index: 33;
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .25);
  padding: 10px 20px 26px;
  animation: sheetIn .34s var(--ease-spring);
}
@keyframes sheetIn { from { transform: translateX(-50%) translateY(103%); } }
.sheet .grab {
  width: 40px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 14px;
  cursor: pointer;
}
.sheet h3 { font: 600 18px/1 var(--display); }
@media (min-width: 840px) and (orientation: landscape) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, 90%);
    border-radius: var(--r-lg);
    padding: 22px 20px 26px;
    animation: sheetCenterIn var(--dur-pop) var(--ease-spring);
  }
  .sheet .grab { display: none; }
}
/* Centred by transform, so its entrance has to carry the centring with it.
   Borrowing `panelIn` here put the sheet's top-left corner on the viewport
   centre for the length of the animation — down and to the right — and then
   snapped it back the moment the rule's own transform applied again. `.panel`
   gets away with `panelIn` because a flex parent centres it. */
@keyframes sheetCenterIn {
  from { transform: translate(-50%, -50%) scale(.8) translateY(18px); }
  to { transform: translate(-50%, -50%); }
}
.app-toast {
  bottom: 168px;
  animation: toastIn var(--dur-settle) var(--ease-out);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(16px); } }

/* ------------------------------------------------ overlays / coach */
.reward-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  animation: tileIn .5s var(--ease-spring);
}
.reward-mark.flame-grad { background: linear-gradient(180deg, #ffe3c2, #ffc98f); }
.reward-mark.coin-grad { background: linear-gradient(180deg, #ffe9a8, #ffd469); }
.reward-mark.accent-grad { background: var(--accent-soft); color: var(--accent); }
.reward-amount { font: 600 30px/1 var(--display); margin-top: 6px; }
.reward-note {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-top: 12px;
  font: 500 12.5px/1.55 var(--body);
  color: var(--muted);
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.coach-card {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 150px;
  z-index: 25;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--card-shadow);
  padding: 14px 40px 14px 16px;
  font: 500 13.5px/1.55 var(--body);
  max-width: 480px;
  margin: 0 auto;
  animation: riseIn .3s var(--ease-out);
}
.coach-card .coach-x {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 15px/1 var(--body);
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
@media (min-width: 840px) and (orientation: landscape) {
  .coach-card { left: auto; right: 16px; width: 320px; bottom: 24px; }
}

/* --------------------------------------------------------- confetti */
.particles {
  position: fixed;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  overflow: hidden;
}
.pt {
  position: absolute;
  top: 38%;
  left: 50%;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: flyOut 1.6s cubic-bezier(.15, .6, .4, 1) forwards;
}


/* ------------------------------------------- content column caps
   The prototype's size-class caps: full width under 600, a centered
   640 column on tablets, per-screen widths at rail sizes. */
@media (min-width: 600px) {
  .page-head, .home-head, .hub-scroll,
  .tab-scroll { max-width: 640px; margin-inline: auto; width: 100%; }
  .appbar { max-width: 680px; margin-inline: auto; width: 100%; }
  .status-row, .controls,
  .coach-card { max-width: 480px; margin-inline: auto; width: 100%; }
}
@media (min-width: 840px) and (orientation: landscape) {
  .appbar { max-width: 920px; }
  /* In-game app bar shares the game column, so the back button sits on
     the board's vertical line. */
  .appbar:has(+ .screen .game-body) { max-width: 1060px; }
  .hub-screen .home-head, .hub-screen .hub-scroll { max-width: 960px; }
  .daily-screen .page-head, .daily-screen .tab-scroll { max-width: 880px; }
  .ranks-screen .page-head, .ranks-screen .tab-scroll { max-width: 600px; }
  .packs-screen .page-head, .packs-screen .tab-scroll { max-width: 760px; }
  .advs-screen .tab-scroll { max-width: 900px; }
  .settings-screen .tab-scroll { max-width: 640px; }
  .game-body { max-width: 1060px; margin-inline: auto; width: 100%; }
  .game-side .status-row, .game-side .controls { max-width: none; }
}


/* ------------------------------------------- adventures: two tabs */
.adv-tabs { margin-top: 14px; }
.adv-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.adv-tab-badge {
  min-width: 17px;
  height: 17px;
  border-radius: 99px;
  background: var(--accent-2);
  color: #fff;
  font: 600 10px/17px var(--body);
  text-align: center;
  padding: 0 4px;
}
.adv-tabs button.on .adv-tab-badge {
  background: rgba(255, 255, 255, .85);
  color: var(--accent-deep);
}
.adv-shelf-empty {
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
  padding: 28px 18px;
  text-align: center;
  font: 500 13px/1.6 var(--body);
  color: var(--muted);
  margin-top: 14px;
}

/* The floating balance pills track the content column's right edge (the
   same alignment the pushed app bars have), not the window edge. */
@media (min-width: 600px) {
  .top-actions { right: max(20px, calc((100% - 640px) / 2 + 20px)); }
}
/* At rail sizes the tab screens carry 102px of left padding for the
   rail, which shifts the centered column right by 51px — the pill offset
   must subtract it so the coin lands exactly on the content's edge. */
@media (min-width: 840px) and (orientation: landscape) {
  .frame:has(.hub-screen) .top-actions {
    right: max(20px, calc((100% - 102px - 960px) / 2 + 20px));
  }
  .frame:has(.daily-screen) .top-actions {
    right: max(20px, calc((100% - 102px - 880px) / 2 + 20px));
  }
  .frame:has(.ranks-screen) .top-actions {
    right: max(20px, calc((100% - 102px - 600px) / 2 + 20px));
  }
  .frame:has(.packs-screen) .top-actions {
    right: max(20px, calc((100% - 102px - 760px) / 2 + 20px));
  }
  .frame:has(.settings-screen) .top-actions {
    right: max(20px, calc((100% - 102px - 640px) / 2 + 20px));
  }
}

/* Account card: the nickname is the headline identity (pencil renames);
   the link medallion tops the link-account panel — both from the mobile
   settings. */
.acct-nick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
  font: 600 14.5px/1.2 var(--display);
}
.acct-nick svg { color: var(--muted); }
.btn-compact { padding: 11px 16px; font-size: 14px; border-radius: 999px; }
.link-medallion {
  width: 84px;
  height: 84px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}

/* Dev builds only (the component is compiled out of release): the
   mobile DEBUG - SOLVE pill, right-aligned under the game app bar. */
.debug-row { display: flex; justify-content: flex-end; padding: 0 22px; }
.debug-solve {
  border: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 10px;
  font: 600 9.5px/1 var(--body);
  letter-spacing: .08em;
}

/* Settings as a fifth tab. Rail sizes keep the rail and show the
   tab-style title; narrow layouts behave like a pushed route — the
   bar and pills hide, the view's own app bar provides Back. */
.settings-head { display: none; }
@media (min-width: 840px) and (orientation: landscape) {
  .settings-screen .appbar { display: none; }
  .settings-head { display: block; }
}
@media not ((min-width: 840px) and (orientation: landscape)) {
  .frame:has(.settings-screen) .tabbar,
  .frame:has(.settings-screen) .top-actions { display: none; }
}

/* Beside layout: the digit pad wraps at two per row in the side column —
   the prototype's use-rail rule (the !important outranks the component's
   inline per-line column count, which is sized for the below layout). */
@media (min-width: 840px) and (orientation: landscape) {
  .game-side .digits { grid-template-columns: repeat(2, 1fr) !important; }
  /* Fixed board (GridLayout.fixedBoardEdge): one square for every n —
     a 9x9 has smaller cells than a 4x4, never a bigger board. Terms:
     viewport height minus app bar + paddings; width minus rail, side
     column and gaps; the 640px cap. */
  .grid {
    --board: min(calc(100dvh - 180px), calc(100vw - 430px), 640px);
    --cell: calc(var(--board) / var(--n));
  }
}

/* ------------------------------------------------ consent banner */
.consent {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 70;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.consent-card {
  pointer-events: auto;
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
  padding: 16px 18px;
  font: 400 14px/1.45 var(--body);
  animation: toastIn var(--dur-settle) var(--ease-out);
}
.consent-card b { display: block; font-size: 15px; margin-bottom: 6px; }
.consent-card p { margin: 0 0 12px; }
.consent-card a { color: inherit; text-decoration: underline; }
.consent-actions { display: flex; gap: 10px; }
.consent-actions .btn { flex: 1 1 0; }

/* ------------------------------------------------ settings: danger */
.row-card.row-danger b { color: var(--danger, #b3261e); }


/* Install banner — the mobile-web offer to move to the native app.
 *
 * Fixed to the bottom and slim on purpose. Google demotes mobile pages whose
 * content is covered by an app-install prompt on arrival, and this domain now
 * carries three pages whose whole job is to rank; a dismissible bar that
 * leaves the page usable sits outside that guidance. It also must never cover
 * the number pad, which is why the app frame gains padding to match rather
 * than the bar floating over it.
 *
 * safe-area-inset-bottom keeps it clear of the iOS home indicator. */
.install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: #ffffff;
  border-top: 1px solid rgba(30, 42, 70, 0.10);
  box-shadow: 0 -6px 24px rgba(30, 42, 70, 0.10);
}

.install-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.install-banner-text b {
  font-size: 14px;
  color: #1e2a46;
}

.install-banner-text span {
  font-size: 12px;
  color: #6b7899;
  /* One line, ellipsised: a wrapping banner grows tall enough to start
   * covering the thing it is sitting under. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-banner-get {
  flex: 0 0 auto;
  padding: 9px 16px;
  font-size: 14px;
  text-decoration: none;
}

.install-banner-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #6b7899;
  font-size: 15px;
  cursor: pointer;
}

.install-banner-close:hover { background: rgba(30, 42, 70, 0.06); }

/* Desktop never sees it (shouldOfferInstall refuses), but if the viewport is
 * wide the bar would stretch oddly, so keep it phone-width regardless. */
@media (min-width: 720px) {
  .install-banner { left: 50%; right: auto; transform: translateX(-50%); width: 680px; border-radius: 14px 14px 0 0; }
}
