@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* Colour, type, space, motion, elevation and layer names all come from
   tokens.css, which is loaded before this file. There is one vocabulary now:
   the phase-1 aliases (--bg, --line, --text, --muted, --quiet, --accent,
   --body, --display) are no longer read anywhere below, so tokens.css can drop
   them whenever Designer likes.

   Two deliberate exceptions, both of which keep this file readable:

   - the `font:` shorthand stays literal. Bundling weight, size, leading and
     family is the point of the shorthand; splitting it into four var() calls
     costs more than the names are worth. The family is still a token.
   - optical in-betweens stay literal, the way tokens.css says the space scale's
     do: a 9px radius or a 14px one is a judgement about a specific corner, not
     a step on a scale, and forcing it onto one would be a lie about the system.

   Every other value here is a token. The migration was checked by resolving
   both files' var() chains before and after: it changed the computed value of
   no existing declaration. Rules added since — the overlay's safe centring and
   the phone spacing below it — are new declarations, not changed ones. */

* { box-sizing: border-box; }

/* One thumb, no accidents: kill pull-to-refresh, rubber-banding, double-tap
   zoom and long-press callouts so a drag across the board is only ever aiming. */
html {
  min-width: 280px;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 280px;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 50% 25%, var(--color-ground-glow-top) 0, transparent 58%),
    radial-gradient(ellipse at 50% 100%, var(--color-ground-glow-bottom) 0, transparent 62%),
    var(--color-ground);
  color: var(--color-ink);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button, a, canvas { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { opacity: .3; cursor: default; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 5px;
}

svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--stroke-icon);
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] { display: none !important; }

.app {
  width: 100%;
  max-width: 1184px;
  margin-inline: auto;
  /* Safe areas on all four sides. The viewport is viewport-fit=cover, so
     without these the board sits under a notch or a home indicator. */
  padding-top: env(safe-area-inset-top);
  padding-right: max(var(--space-gutter), env(safe-area-inset-right));
  padding-bottom: max(var(--space-7), env(safe-area-inset-bottom));
  padding-left: max(var(--space-gutter), env(safe-area-inset-left));
}

/* A quiet frame keeps attention on the arena. */
.topbar {
  display: flex;
  align-items: center;
  gap: 25px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-line);
}

.brand {
  color: var(--color-ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: var(--weight-black);
  line-height: 1;
  font-size: var(--text-3xl);
  letter-spacing: var(--tracking-brand);
}

.brand-dot { color: var(--color-accent); }

.edition {
  padding-left: 25px;
  border-left: 1px solid var(--color-line-strong);
  color: var(--color-ink-muted);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-widest);
  line-height: var(--leading-normal);
}

.tools {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: var(--size-touch);
  height: var(--size-touch);
  padding: 0;
  border: 1px solid #d0e0c51a;
  border-radius: var(--radius-full);
  background: linear-gradient(155deg, #ffffff05, #ffffff00);
  color: #b9c6b8;
  box-shadow: var(--elevation-inset);
  transition: color var(--duration-snap), border-color var(--duration-snap), background var(--duration-snap), transform var(--duration-snap);
}

.icon-button:active:not(:disabled) { transform: scale(.94); }

.eyebrow {
  display: block;
  color: var(--color-ink-muted);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-wider);
}

.game-layout {
  --arena-width: clamp(280px, calc((100svh - 270px) * .807692), 440px);
  display: grid;
  grid-template-columns: minmax(140px, 196px) minmax(0, var(--arena-width)) minmax(140px, 196px);
  justify-content: center;
  align-items: start;
  column-gap: 44px;
  padding-top: 34px;
}

.score-rail, .next-rail { min-width: 0; padding-top: 66px; }
.score-block { position: relative; }

.score-block > strong {
  display: block;
  width: max-content;
  margin-top: 9px;
  color: var(--color-accent);
  font-family: var(--font-display);
  font-size: var(--text-5xl);
  font-weight: var(--weight-medium);
  line-height: 1.02;
  letter-spacing: var(--tracking-tighter);
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}

#score-gain {
  position: absolute;
  top: 23px;
  right: 0;
  opacity: 0;
  color: var(--color-accent);
  font: 500 16px/1 var(--font-display);
  pointer-events: none;
}

#score-gain.pop { animation: gain var(--duration-gain) var(--ease-out) both; }

.best-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

.best-icon { width: 22px; height: 22px; color: #b5c2a7; }
.best-block .eyebrow { font-size: var(--text-2xs); letter-spacing: .09em; }

.best-block strong {
  display: block;
  margin-top: 4px;
  font: 500 28px/1.12 var(--font-display);
  letter-spacing: var(--tracking-snug);
  font-variant-numeric: tabular-nums;
}

.combo-block {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--color-line);
}

.combo-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--color-ink-muted);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  letter-spacing: var(--tracking-wide);
  transition: color var(--duration-snap);
}

.combo-top strong {
  color: #8b9c88;
  font: 500 26px/1 var(--font-display);
  letter-spacing: var(--tracking-snug);
  font-variant-numeric: tabular-nums;
  transition: color var(--duration-snap), text-shadow var(--duration-snap);
}

.combo-track, .goal-progress {
  height: 3px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #c4dbb217;
}

.combo-track { margin-top: 14px; }

.combo-track > div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
  box-shadow: 0 0 12px var(--color-accent-glow);
  transition: width var(--duration-instant) var(--ease-linear);
}

.combo-block p {
  margin: 12px 0 0;
  color: var(--color-ink-muted);
  font-size: var(--text-2xs);
  line-height: var(--leading-relaxed);
}

.combo-block.active .combo-top, .combo-block.active .combo-top strong { color: var(--color-accent); }
.combo-block.active .combo-top strong { text-shadow: 0 0 20px #d8fa772e; }

.rail-note { display: flex; align-items: center; gap: 13px; margin-top: 48px; }
.rail-note p { margin: 0; color: #d0d9ca; font-size: var(--text-sm); line-height: 1.6; }
.rail-note p span { color: var(--color-ink-quiet); }

.small-orbit {
  position: relative;
  width: 27px;
  height: 27px;
  flex: none;
  border: 1px solid #a3ba863e;
  border-radius: var(--radius-full);
  transform: rotate(-22deg);
}

.small-orbit::after {
  position: absolute;
  top: -3px;
  right: 0;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  box-shadow: 0 0 10px #d8fa7726;
  content: '';
}

/* The board keeps the engine's 420:520 coordinate system at every size. */
.play-column { display: flex; flex-direction: column; align-items: center; min-width: 0; }

.board-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-bottom: 12px;
  color: #8f9f8b;
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  letter-spacing: .085em;
}

.board-top > span:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; }
#drop-label { flex: none; color: #a2b095; font-variant-numeric: tabular-nums; white-space: nowrap; }

.live-dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  box-shadow: 0 0 9px #d8fa7747;
}

.board-shell {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 420 / 520;
  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;
  border: 1px solid var(--color-well-rim);
  border-radius: var(--radius-well);
  background:
    radial-gradient(ellipse at 50% 0%, #2c3e2933, transparent 68%),
    linear-gradient(180deg, var(--color-well-top), var(--color-well-mid) 82%, #152019);
  box-shadow: var(--elevation-board);
  transition: border-color var(--duration-slow), box-shadow var(--duration-slow);
}

.board-shell::before, .board-shell::after {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  content: '';
}

.board-shell::before {
  z-index: var(--layer-well-sheen);
  background: linear-gradient(118deg, #ffffff05 0%, transparent 28%, transparent 72%, #ffffff02 100%);
}

.board-shell::after {
  z-index: var(--layer-well-edge);
  box-shadow: inset 0 1px 0 #efffdb21, inset 1px 0 0 #e0ffbd08, inset 0 -1px 0 #a6c68a1f, inset 0 -25px 35px #07100912;
}

body[data-game-state='playing'] .board-shell {
  border-color: color-mix(in srgb, var(--orb-color, var(--color-accent)) 30%, #263a2b);
}

canvas {
  position: relative;
  z-index: var(--layer-canvas);
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.play-column, .board-shell { user-select: none; -webkit-user-select: none; }

canvas:focus-visible { border-radius: inherit; outline: 2px solid #d8fa7780; outline-offset: -5px; }

.board-overlay {
  position: absolute;
  z-index: var(--layer-overlay);
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* `safe center` and not `center`: a centred flex item that overflows is
     clipped at *both* ends and the top half becomes unreachable, which is
     exactly how the start screen lost its heading off the top of the board.
     Safe centring falls back to flex-start the moment the content is taller
     than the box, and the scroll is the last resort underneath it — the layout
     below is meant to fit without it at 375x667. */
  justify-content: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: clamp(20px, 6cqw, 28px) 22px;
  background: linear-gradient(180deg, var(--color-overlay) 0%, #111b15e8 72%, #111b159c 100%);
  text-align: center;
  backdrop-filter: blur(var(--blur-overlay));
  -webkit-backdrop-filter: blur(var(--blur-overlay));
}

.intro-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(30px, 10cqw, 44px);
  flex: none;
  margin-bottom: clamp(12px, 4cqw, 20px);
}

.intro-mark span {
  display: grid;
  place-items: center;
  width: clamp(27px, 7.5cqw, 33px);
  height: clamp(27px, 7.5cqw, 33px);
  margin-left: -5px;
  border: 1px solid #d8fff55e;
  border-radius: var(--radius-full);
  background: radial-gradient(circle at 32% 23%, #d9fff2, #a4e5de 55%, #80bfb3 100%);
  color: #254c49;
  box-shadow: 0 4px 12px #03090540, inset 0 -2px 3px #24463516;
  font: 600 14px/1 var(--font-display);
}

.intro-mark span:first-child { margin-left: 0; }
.intro-mark span:nth-child(2) { transform: translateY(4px); }
.intro-mark span:last-child {
  width: clamp(35px, 10cqw, 43px);
  height: clamp(35px, 10cqw, 43px);
  margin-left: 12px;
  border-color: #d6d5ff75;
  background: radial-gradient(circle at 32% 23%, #d6d9ff, #abaeff 58%, #868acf 100%);
  color: #373453;
  font-size: 17px;
}

.board-overlay h1 {
  margin: 0 0 clamp(12px, 4cqw, 20px);
  font: 500 clamp(54px, 18cqw, 80px)/.94 var(--font-display);
  letter-spacing: var(--tracking-tighter);
}

/* Daily: the card is the headline. "One more drop." and its subtitle are two
   lines of 60px type saying nothing the date, the streak and the countdown do
   not, and on a 375x667 phone they are the whole difference between the overlay
   fitting inside the board and being clipped by it. app.mjs sets data-mode, so
   this is one state and not a guess about what is on screen. */
#start-screen[data-mode='daily'] h1,
#start-screen[data-mode='daily'] #start-blurb { display: none; }

.board-overlay h1 em { color: var(--color-accent); font-style: normal; }

.board-overlay p {
  margin: 0 0 clamp(18px, 6cqw, 28px);
  color: #afbcaa;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  min-width: 212px;
  min-height: 54px;
  flex: none;
  padding: 14px 23px;
  border: 1px solid #ebffb6b3;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--color-accent-top), #d3f373);
  color: var(--color-accent-ink);
  box-shadow: var(--elevation-button);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  text-align: left;
  transition: transform var(--duration-fast), box-shadow var(--duration-fast), filter var(--duration-fast);
}

.primary-button:active { transform: translateY(2px); box-shadow: var(--elevation-button-pressed); }
.primary-button svg { width: 18px; height: 18px; stroke-width: var(--stroke-icon-bold); }
.primary-button > span { font-size: var(--text-lg); line-height: 1; }

/* Mode choice. Standard is the game; daily is a reason to come back. Both are
   one thumb-reach apart and neither is hidden behind the other. */
.mode-switch {
  display: inline-flex;
  gap: 3px;
  margin-bottom: clamp(14px, 4cqw, 20px);
  padding: 3px;
  border: 1px solid #d0e0c520;
  border-radius: var(--radius-md);
  background: #0c140ea8;
}

.mode-option {
  min-height: 38px;
  padding: 8px 18px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #a9b8a4;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  transition: background var(--duration-snap), color var(--duration-snap);
}

.mode-option[aria-checked='true'] {
  background: linear-gradient(180deg, var(--color-accent-top), #d3f373);
  color: var(--color-accent-ink);
  box-shadow: 0 2px 8px #00000033;
}

.daily-card {
  width: min(100%, 300px);
  margin-bottom: clamp(14px, 4cqw, 20px);
  padding: 13px 15px;
  border: 1px solid #d8fa7726;
  border-radius: 14px;
  background: #101a13cc;
  text-align: left;
}

.daily-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.daily-head .eyebrow { font-size: var(--text-2xs); letter-spacing: .1em; }

.daily-state {
  padding: 3px 9px;
  border-radius: 20px;
  background: #d8fa7716;
  color: var(--color-accent);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: .08em;
}

.daily-state[data-done='true'] { background: #ffffff0f; color: #9fb098; }

.daily-stats { display: flex; gap: 18px; margin-top: 11px; }
.daily-stats > div { display: flex; flex-direction: column; min-width: 0; }
.daily-stats strong { font: 500 22px/1.1 var(--font-display); letter-spacing: var(--tracking-snug); font-variant-numeric: tabular-nums; }
.daily-stats span { margin-top: 3px; color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: var(--leading-snug); }

.daily-timer { margin: 12px 0 0; color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: var(--leading-normal); }
.daily-timer time { color: #c6d5bd; font-variant-numeric: tabular-nums; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  margin-top: 12px;
  padding: 10px 16px;
  border: 1px solid #d0e0c522;
  border-radius: var(--radius-md);
  background: #ffffff05;
  color: #bdcbb6;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  transition: border-color var(--duration-snap), color var(--duration-snap), background var(--duration-snap);
}

.ghost-button svg { width: 17px; height: 17px; color: var(--color-accent); }
.ghost-button span { color: var(--color-ink-muted); font-variant-numeric: tabular-nums; }

/* Skins. Locked ones say what they want and how close you are, because a
   condition you cannot measure is just a locked door. */
/* Settings. Rows are 56px and full width so they are easy to hit with a thumb,
   and on a phone the whole panel becomes a bottom sheet (see the 580px block)
   so the rows sit where the thumb already is. */
.settings-dialog { width: min(480px, calc(100% - 32px)); }
.setting-group { margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--color-line); }
.setting-group:last-of-type { margin-bottom: 14px; padding-bottom: 0; border-bottom: 0; }

.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  text-align: left;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}

.setting-row + .setting-row { margin-top: 2px; }
.setting-icon { width: 21px; height: 21px; flex: none; color: #b6c5ae; }
.setting-row[aria-pressed='true'] .setting-icon { color: var(--color-accent); }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.setting-text strong { font-size: 15px; font-weight: var(--weight-semibold); line-height: 1.35; }
.setting-text em { color: var(--color-ink-muted); font-size: var(--text-2xs); font-style: normal; line-height: 1.45; }

.setting-state {
  flex: none;
  padding: 5px 11px;
  border: 1px solid var(--color-line);
  border-radius: 20px;
  color: var(--color-ink-muted);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

.setting-row[aria-pressed='true'] .setting-state {
  border-color: #d8fa7745;
  background: #d8fa7714;
  color: var(--color-accent);
}

.setting-label { display: block; margin-bottom: 11px; color: #dce6d7; font-size: 15px; font-weight: var(--weight-semibold); }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid #d0e0c520; border-radius: var(--radius-md); background: #0c140ea8; }
.segmented .mode-option { flex: 1; padding: 9px 6px; font-size: 13px; }
.setting-note { margin: 11px 0 0; color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: var(--leading-normal); }
.setting-footer { margin: 0; color: var(--color-ink-quiet); font-size: var(--text-2xs); line-height: 1.6; }

.skins-dialog { width: min(520px, calc(100% - 32px)); }
.dialog-intro { margin: 0 0 22px; color: var(--color-ink-muted); font-size: var(--text-sm); line-height: var(--leading-normal); }
.skin-list { display: flex; flex-direction: column; gap: 10px; padding: 0; margin: 0; list-style: none; }

.skin-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--color-line);
  border-radius: 14px;
  background: #ffffff04;
}

.skin-card[data-selected='true'] { border-color: #d8fa7759; background: var(--color-accent-soft); }
.skin-card[data-locked='true'] { opacity: .62; }

.skin-swatch { display: grid; grid-template-columns: repeat(3, 11px); gap: 3px; flex: none; }
.skin-swatch i { width: 11px; height: 11px; border-radius: var(--radius-full); box-shadow: inset 0 1px 0 #ffffff40; }
.skin-card[data-locked='true'] .skin-swatch { filter: grayscale(.85); }

.skin-body { min-width: 0; }
.skin-body strong { display: block; font: 600 15px/1.35 var(--font-display); }
.skin-body p { margin: 3px 0 0; color: var(--color-ink-muted); font-size: 13px; line-height: 1.45; }

.skin-track { display: block; height: 3px; margin-top: 9px; overflow: hidden; border-radius: var(--radius-sm); background: #c4dbb217; }
.skin-track i { display: block; height: 100%; border-radius: inherit; background: var(--color-accent); }
.skin-count { display: block; margin-top: 5px; color: var(--color-ink-quiet); font-size: var(--text-2xs); font-variant-numeric: tabular-nums; }

.skin-action {
  min-width: 68px;
  min-height: 40px;
  flex: none;
  padding: 0 14px;
  border: 1px solid var(--color-line-accent);
  border-radius: var(--radius-sm);
  background: #d8fa770d;
  color: #e7f3d6;
  font-size: 13px;
  font-weight: var(--weight-semibold);
  transition: background var(--duration-snap), border-color var(--duration-snap);
}

.skin-action:disabled { border-color: var(--color-line); background: transparent; color: var(--color-ink-quiet); opacity: 1; }

.award-use {
  align-self: flex-start;
  min-height: 34px;
  margin-top: 8px;
  padding: 0 12px;
  border: 1px solid #d8fa7755;
  border-radius: 9px;
  background: #d8fa7714;
  color: var(--color-accent);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
}

/* "In use" is a status, not a dead control: it stays focusable (aria-disabled,
   not disabled) so the slot can repaint without dropping the player's focus. */
.award-use:disabled,
.award-use[aria-disabled='true'] { border-color: var(--color-line); background: transparent; color: var(--color-ink-quiet); cursor: default; }

.start-footnote {
  margin-top: 18px;
  color: #97a78e;
  font-size: var(--text-2xs);
  line-height: var(--leading-normal);
}

.play-hint {
  max-width: 100%;
  margin-top: 16px;
  color: var(--color-ink-dim);
  font-size: var(--text-2xs);
  line-height: 1.7;
  text-align: center;
}

kbd {
  display: inline-block;
  min-width: 19px;
  margin-right: 3px;
  padding: 0 5px;
  border: 1px solid #bdd6a61f;
  border-radius: var(--radius-xs);
  background: #bdd6a605;
  color: #c1ceba;
  font: inherit;
  line-height: 1.55;
  text-align: center;
  box-shadow: 0 1px 0 #bdd6a617;
}

.hint-divider { margin-inline: 5px; color: #66775f; }
.touch-hint { display: none; }

/* The next orb and progression use the same color family as the canvas. */
.next-block { text-align: center; }
.next-orb-wrap { position: relative; display: flex; align-items: center; justify-content: center; height: 116px; }

.next-orb-wrap::before {
  position: absolute;
  width: 88px;
  height: 88px;
  border: 1px solid #cfedb710;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, #ccefa508, transparent 68%);
  box-shadow: inset 0 1px 0 #d8eac804;
  content: '';
}

.orb {
  --orb: #a4e5de;
  --ink: #254c49;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  border: 1px solid #ffffff42;
  border-radius: var(--radius-full);
  background:
    radial-gradient(circle at 31% 21%, #ffffff40, transparent 58%),
    radial-gradient(circle at 43% 35%, transparent 50%, #162a241a 100%),
    var(--orb);
  color: var(--ink);
  box-shadow: var(--elevation-orb);
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform var(--duration-base), opacity var(--duration-base), box-shadow var(--duration-base);
}

#next-orb { width: 60px; height: 60px; font-size: 25px; }
/* Tier colours come from the active skin, published onto :root as --orb-N /
   --ink-N. The literals are the fallback, so the HUD is correct on the very
   first paint and stays correct if a skin is ever missing a tier. */
.orb-0 { --orb: var(--orb-0, #a4e5de); --ink: var(--orb-ink-0, #254c49); }
.orb-1 { --orb: var(--orb-1, #abaeff); --ink: var(--orb-ink-1, #373453); }
.orb-2 { --orb: var(--orb-2, #edb5ef); --ink: var(--orb-ink-2, #633966); }
.orb-3 { --orb: var(--orb-3, #ffb4b7); --ink: var(--orb-ink-3, #713e46); }
.orb-4 { --orb: var(--orb-4, #ffc28f); --ink: var(--orb-ink-4, #714826); }
.orb-5 { --orb: var(--orb-5, #f8de82); --ink: var(--orb-ink-5, #6c591d); }
.orb-6 { --orb: var(--orb-6, #d8fa77); --ink: var(--orb-ink-6, #465c19); }
.orb-7 { --orb: var(--orb-7, #72e5b0); --ink: var(--orb-ink-7, #1f5945); }
.orb-8 { --orb: var(--orb-8, #f3ffd6); --ink: var(--orb-ink-8, #405b17); }
.next-caption { color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: var(--leading-normal); }

.goal-block { margin-top: 35px; padding-top: 23px; border-top: 1px solid var(--color-line); }
.goal-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.goal-heading svg { width: 18px; height: 18px; color: #c8e999; }
.goal-heading .eyebrow { letter-spacing: var(--tracking-wider); }

.goal-block > strong {
  display: block;
  margin-top: 8px;
  font: 500 52px/1.05 var(--font-display);
  letter-spacing: var(--tracking-tight);
}

.goal-block p { max-width: 190px; margin: 12px 0 22px; color: var(--color-ink-muted); font-size: var(--text-sm); line-height: var(--leading-normal); }
.goal-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--color-accent); transition: width var(--duration-slower); }
#goal-caption { display: block; margin-top: 10px; color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: 1.6; }

.evolution { display: flex; flex-direction: column; align-items: center; margin-top: 30px; }
.evolution > .eyebrow { color: #879680; font-size: var(--text-2xs); letter-spacing: var(--tracking-widest); }
.evolution-track { display: flex; align-items: center; justify-content: center; gap: 9px; width: 100%; min-width: 0; height: 48px; margin-top: 14px; }
.evolution-track .orb { width: 28px; height: 28px; font-size: var(--text-2xs); opacity: .5; }
.evolution-track .orb-2, .evolution-track .orb-3, .evolution-track .orb-4 { width: 32px; height: 32px; }
.evolution-track .orb-5, .evolution-track .orb-6, .evolution-track .orb-7 { width: 36px; height: 36px; }
.evolution-track .orb-8 { width: 43px; height: 43px; opacity: 1; box-shadow: inset 0 1px 1px #ffffff70, inset 0 -3px 3px #2a402519, 0 0 18px #d8fa7717; }
.evolution-track .orb.reached { opacity: 1; }
.evolution-track .orb.current { outline: 1px solid #d8fa7766; outline-offset: 4px; }
.evolution-arrow { color: #58694f; font: 400 14px/1 var(--font-display); }
.evolution p { margin: 10px 0 0; color: #84927d; font-size: var(--text-2xs); line-height: var(--leading-normal); }

/* Pause, results, and transient feedback retain their existing JS hooks. */
.pause-screen, .end-screen { background: linear-gradient(180deg, #111b15f2, #111b15e8); }
.end-screen { overflow-y: auto; justify-content: safe center; scrollbar-width: thin; }
.board-overlay > .eyebrow { max-width: 100%; color: #b9c9a8; font-size: var(--text-2xs); letter-spacing: var(--tracking-wider); }
.pause-screen h2, .end-screen h2 { margin: 18px 0; font: 500 clamp(36px, 11cqw, 48px)/1.05 var(--font-display); letter-spacing: -.045em; }
.pause-screen p { max-width: 240px; }
.pause-screen .primary-button { margin-top: 4px; }
.end-screen h2 { margin: 12px 0 10px; font-size: clamp(30px, 9.5cqw, 42px); }

.end-score {
  max-width: 100%;
  color: var(--color-accent);
  font: 500 clamp(42px, 15.5cqw, 72px)/1.04 var(--font-display);
  letter-spacing: var(--tracking-tighter);
  font-variant-numeric: tabular-nums;
}

.end-delta {
  margin: 8px 0 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

.end-delta[data-kind='record'] { color: var(--color-accent); }
.end-delta[data-kind='tie'] { color: #c6d5bd; }
.end-delta[data-kind='short'], .end-delta[data-kind='first'] { color: var(--color-ink-muted); }

/* The one useful thing. Set apart from the numbers, because it is a sentence
   and not a statistic. */
.end-insight {
  max-width: 300px;
  margin: 0 0 20px;
  padding: 11px 14px;
  border: 1px solid var(--color-line);
  border-left: 2px solid #d8fa7766;
  border-radius: 4px 12px 12px 4px;
  background: #ffffff05;
  color: #cfdac7;
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
}

.end-screen .mode-switch { margin-bottom: 14px; }
.run-summary { display: flex; justify-content: center; gap: 42px; margin: 24px 0; }
.run-summary > div { display: flex; flex-direction: column; }
.run-summary strong { font: 500 28px/1.1 var(--font-display); letter-spacing: var(--tracking-snug); }
.run-summary span { margin-top: 6px; color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: var(--leading-normal); }
.end-screen .start-footnote { max-width: 275px; margin-top: 18px; }

/* Reserved for phase 2: run milestones and cosmetic unlocks. */
.end-extras {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 20px;
}

.end-extras:empty { display: none; }

/* Milestone banner. Slim, one line, and it moves rather than covering orbs:
   `data-place` is set from how tall the pile is when the milestone lands. */
.milestone-toast {
  position: absolute;
  z-index: var(--layer-coach);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 9px 15px 9px 12px;
  border: 1px solid #d8fa7745;
  border-radius: 14px;
  background: #16211bf5;
  box-shadow: 0 14px 36px #00000073, inset 0 1px 0 #eaffc118;
  text-align: left;
  transform: translateX(-50%);
  pointer-events: none;
}

.milestone-toast[data-place='high'] { top: 21%; }
.milestone-toast[data-place='low'] { bottom: 7%; }
.milestone-toast.show { animation: milestone 2.6s ease-out both; }
.milestone-mark { width: 22px; height: 22px; flex: none; color: var(--color-accent); fill: #d8fa7724; }
/* The emblem from assets/badges.svg carries its own colours — a badge is an
   object, not a glyph — so it opts out of the global stroke/fill defaults. */
svg.badge { fill: initial; stroke: initial; stroke-width: initial; }
svg.badge.milestone-mark { width: 30px; height: 30px; fill: initial; }
.milestone-toast span { display: flex; flex-direction: column; min-width: 0; }
.milestone-toast strong { color: var(--color-accent); font: 600 14px/1.3 var(--font-display); letter-spacing: -.01em; }
.milestone-toast em { color: #b6c5ae; font-size: var(--text-2xs); font-style: normal; line-height: var(--leading-snug); }

/* Awards on the results screen: what this run earned, in the reserved slot. */
.award-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 13px;
  border: 1px solid #d8fa7736;
  border-radius: var(--radius-md);
  background: #d8fa770c;
  text-align: left;
}

.award-chip { flex-direction: row; align-items: center; gap: var(--space-3); }
.award-chip .badge { flex: none; }
.award-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.award-kind { color: var(--color-accent); font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: .11em; }
.award-chip strong { font: 600 14px/1.35 var(--font-display); }
.award-chip em { color: var(--color-ink-muted); font-size: var(--text-2xs); font-style: normal; line-height: var(--leading-snug); }

.board-toast {
  position: absolute;
  z-index: var(--layer-fx);
  top: 26%;
  right: 12px;
  left: 12px;
  opacity: 0;
  color: var(--color-accent);
  font: 600 clamp(22px, 6.9cqw, 30px)/1.15 var(--font-display);
  letter-spacing: -.035em;
  text-align: center;
  text-shadow: 0 2px 8px #0b160af2, 0 0 30px #0b160ae6;
  transform: translateY(8px);
  pointer-events: none;
}

.board-toast.show { animation: toast var(--duration-toast) var(--ease-out) both; }

/* Guided first run. The card passes pointer events through to the canvas so
   coaching can sit over the board without ever blocking a drag; only the Skip
   button is clickable. */
.intro-coach {
  position: absolute;
  z-index: var(--layer-coach);
  top: 23%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100% - 22px);
  padding: 10px 12px 10px 16px;
  border: 1px solid #d8fa7736;
  border-radius: var(--radius-lg);
  background: #16211bf2;
  box-shadow: var(--elevation-card);
  transform: translateX(-50%);
  pointer-events: none;
  backdrop-filter: blur(var(--blur-card));
  -webkit-backdrop-filter: blur(var(--blur-card));
}

.intro-coach p {
  max-width: 24ch;
  margin: 0;
  color: #edf4e4;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.45;
}

.intro-progress { display: flex; gap: 5px; flex: none; }

.intro-progress span {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: #d8fa7733;
  transition: background .25s, transform .25s;
}

.intro-progress span.done { background: #d8fa7780; }
.intro-progress span.now { background: var(--color-accent); transform: scale(1.5); }

.intro-skip {
  flex: none;
  align-self: stretch;
  min-width: 52px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #d0e0c522;
  border-radius: var(--radius-sm);
  background: #ffffff06;
  color: #b3c2ad;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: .04em;
  pointer-events: auto;
}

.secondary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 50px;
  margin-top: 8px;
  padding: 13px 18px;
  border: 1px solid var(--color-line-accent);
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: #e7f3d6;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  transition: background var(--duration-snap), border-color var(--duration-snap);
}

.secondary-button svg { width: 18px; height: 18px; stroke-width: var(--stroke-icon-bold); color: var(--color-accent); }

.danger-message {
  position: absolute;
  z-index: var(--layer-fx);
  top: 19%;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 5px 10px;
  border: 1px solid #edaa8e2b;
  border-radius: 20px;
  background: var(--color-danger-surface);
  color: var(--color-danger-ink);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

/* Three stages of pressure, escalating in the frame as well as on the canvas. */
.board-shell.danger { border-color: var(--color-danger) !important; box-shadow: 0 22px 64px #00000070, 0 0 0 5px #0d140fe6, 0 0 0 6px #e6a18716, 0 0 42px #dc694d0d; }
.board-shell.danger-2 { box-shadow: 0 22px 64px #00000070, 0 0 0 5px #0d140fe6, 0 0 0 6px #e6a1872e, 0 0 60px #dc694d24; }
.board-shell.danger-3 { border-color: var(--color-danger-bright) !important; box-shadow: 0 22px 64px #00000070, 0 0 0 5px #0d140fe6, 0 0 0 7px #ef7f5b4a, 0 0 84px #dc694d40; animation: danger-edge var(--duration-danger-pulse) var(--ease-in-out) infinite alternate; }

.danger-message[data-stage='2'] { border-color: #f3a98c4d; color: #ffd9c9; }

.danger-message[data-stage='3'] {
  top: 15%;
  padding: 6px 18px;
  border-color: #ff9d7a7a;
  background: #2d1a13f2;
  color: #ffd9c9;
  font-family: var(--font-display);
  font-size: clamp(26px, 8cqw, 38px);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-snug);
  font-variant-numeric: tabular-nums;
  animation: danger-count .5s ease-in-out infinite alternate;
}
/* Reserved for the supernova. Every other impact shakes inside the canvas, so
   the frame itself only ever moves for the one moment that earns it. */
.board-shell.shake { animation: shake var(--duration-slower) var(--ease-settle); }
.storage-notice { margin: 22px 0 0; color: var(--color-ink-muted); font-size: var(--text-2xs); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Native dialog remains scrollable on short viewports. */
dialog {
  width: min(508px, calc(100% - 32px));
  max-height: calc(100svh - 32px);
  padding: 42px 36px 34px;
  overflow-y: auto;
  border: 1px solid #c8e2b936;
  border-radius: var(--radius-2xl);
  background: linear-gradient(145deg, #1b281e, var(--color-well-top) 72%);
  color: var(--color-ink);
  box-shadow: var(--elevation-dialog);
}

dialog::backdrop { background: var(--color-scrim); backdrop-filter: blur(var(--blur-scrim)); -webkit-backdrop-filter: blur(var(--blur-scrim)); }
dialog h2 { margin: 12px 0 28px; font: 500 36px/1.06 var(--font-display); letter-spacing: var(--tracking-tight); }
dialog > .eyebrow { margin-right: 20px; font-size: var(--text-2xs); letter-spacing: .1em; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; }
.dialog-close svg { width: 18px; height: 18px; }
.how-steps { padding: 0; margin: 0; list-style: none; }
.how-steps li { display: flex; align-items: flex-start; gap: 17px; margin: 23px 0; }
.how-steps li > span { flex: none; padding-top: 4px; color: var(--color-accent); font: 500 12px/1.5 var(--font-display); letter-spacing: .08em; }
.how-steps strong { font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: var(--leading-normal); }
.how-steps p { margin: 6px 0 0; color: #aab9a4; font-size: var(--text-sm); line-height: 1.6; }
.help-note { margin: 26px 0 22px; padding-top: 20px; border-top: 1px solid var(--color-line); color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: 1.7; }
dialog .primary-button { justify-content: center; width: 100%; }

@keyframes gain {
  0% { opacity: 0; transform: translateY(6px); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px); }
}

@keyframes milestone {
  0% { opacity: 0; transform: translateX(-50%) translateY(6px) scale(.96); }
  8%, 88% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(1); }
}

@keyframes toast {
  0% { opacity: 0; transform: translateY(8px) scale(.96); }
  15%, 66% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-12px) scale(1); }
}

@keyframes danger-edge {
  from { border-color: #ef8b66; }
  to { border-color: #ffc2a8; }
}

@keyframes danger-count {
  from { transform: translateX(-50%) scale(1); }
  to { transform: translateX(-50%) scale(1.07); }
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 2px); }
  32% { transform: translate(4px, -3px); }
  52% { transform: translate(-3px, 1px); }
  74% { transform: translate(2px, -1px); }
  88% { transform: translate(-1px, 0); }
}

@media (hover: hover) {
  .intro-skip:hover { border-color: #d8fa7755; color: var(--color-accent); }
  .ghost-button:hover { border-color: #d8fa7755; background: #d8fa770c; color: var(--color-ink); }
  .skin-action:not(:disabled):hover { border-color: #d8fa7788; background: #d8fa7718; }
  .award-use:not(:disabled):not([aria-disabled='true']):hover { background: #d8fa7724; }
  .secondary-button:hover { border-color: #d8fa7780; background: #d8fa7714; }
  .icon-button:hover:not(:disabled) { border-color: #d8fa7745; background: #d8fa770b; color: var(--color-accent); transform: translateY(-1px); }
  .primary-button:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: inset 0 1px 0 #f5ffd47a, 0 4px 0 var(--color-accent-shade), 0 10px 28px #00000036; }
  .primary-button:active { transform: translateY(2px); box-shadow: var(--elevation-button-pressed); }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .app { padding-inline: var(--space-8); }
  .game-layout { column-gap: 30px; }
  .score-block > strong { font-size: 58px; }
  .rail-note { gap: 10px; }
  .rail-note p { font-size: var(--text-sm); }
}

/* Portrait layout: one compact HUD, visible chain feedback, then the full board. */
@media (max-width: 900px) {
  /* One column of the page, with the arena taking the slack. */
  .app {
    display: flex;
    flex-direction: column;
    min-height: 100svh;
    padding-right: max(var(--space-7), env(safe-area-inset-right));
    padding-left: max(var(--space-7), env(safe-area-inset-left));
  }
  .topbar { flex: none; }
  .game-layout {
    flex: 1 1 auto;
    width: min(100%, 440px);
    min-height: 0;
    margin-inline: auto;
    padding-top: var(--space-6);
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 64px;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    column-gap: 18px;
    row-gap: var(--space-3);
  }
  .play-column > .board-shell { flex: 1 1 auto; }
  .board-top, .play-hint { flex: none; }
  .score-rail, .next-rail { display: contents; }
  .score-block { grid-column: 1; grid-row: 1; align-self: center; }
  .score-block > strong { margin-top: 4px; font-size: 42px; line-height: 1.05; letter-spacing: -.045em; }
  #score-gain { top: 22px; right: -2px; font-size: var(--text-xs); }
  .best-block { grid-column: 2; grid-row: 1; align-self: center; min-width: 0; margin: 0; padding-left: 18px; border-left: 1px solid var(--color-line); }
  .best-block strong { margin-top: 7px; font-size: 29px; }
  .best-icon, .wide-label, .rail-note { display: none; }
  .score-block .eyebrow, .best-block .eyebrow { font-size: var(--text-2xs); letter-spacing: .09em; }
  .combo-block {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 16px;
    min-height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .combo-top { justify-content: flex-start; gap: 10px; font-size: var(--text-2xs); letter-spacing: var(--tracking-wide); }
  .combo-top strong { font-size: var(--text-lg); }
  .combo-track { margin: 0; }
  .combo-block p { display: none; }
  /* The board absorbs whatever height is left rather than being sized from a
     hardcoded guess at the chrome above it. The column is the 1fr row, the
     shell takes the height it is given, and aspect-ratio derives the width —
     so the board can never push the HUD off the screen, whatever is around it. */
  .play-column {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    min-height: 0;
    align-self: stretch;
    justify-content: center;
    justify-self: center;
  }
  /* Width is derived from the height actually left for the arena, which
     app.mjs measures into --arena-height. Deriving width (rather than clamping
     it with max-width) is what keeps the 420:520 ratio exact: a clamped width
     against a fixed height would stretch the board and the canvas with it. */
  .board-shell {
    width: min(100%, calc(var(--arena-height, 62svh) * .807692));
    min-height: 0;
    margin-inline: auto;
  }
  .board-top { margin-bottom: 10px; font-size: var(--text-2xs); letter-spacing: .05em; }
  .board-shell { border-radius: 20px 20px 30px 30px; }
  .next-block { display: flex; grid-column: 3; grid-row: 1; flex-direction: column; align-items: center; justify-content: center; gap: 5px; align-self: center; }
  .next-block .eyebrow { font-size: var(--text-2xs); letter-spacing: .08em; }
  .next-orb-wrap { width: 44px; height: 44px; }
  .next-orb-wrap::before { display: none; }
  #next-orb { width: 41px; height: 41px; font-size: 19px; }
  .next-caption { display: none; }
  .play-hint { margin-top: 12px; }
  .goal-block {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 4;
    grid-template-columns: 81px minmax(0, 1fr);
    grid-template-areas: 'heading copy' 'value copy' 'progress progress' 'caption caption';
    column-gap: 18px;
    margin-top: 6px;
    padding-top: 18px;
  }
  .goal-heading { grid-area: heading; }
  .goal-heading svg { display: none; }
  .goal-block > strong { grid-area: value; margin-top: 2px; font-size: var(--text-3xl); }
  .goal-block p { grid-area: copy; align-self: center; max-width: none; margin: 0; font-size: var(--text-sm); line-height: var(--leading-normal); }
  .goal-progress { grid-area: progress; margin-top: 13px; }
  #goal-caption { grid-area: caption; margin-top: 7px; }
  .evolution { margin-top: 27px; }
  .evolution-track { gap: 7px; }
}

@media (max-width: 580px) {
  .app {
    padding-right: max(var(--space-gutter-tight), env(safe-area-inset-right));
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
    padding-left: max(var(--space-gutter-tight), env(safe-area-inset-left));
  }
  .topbar { height: 72px; }
  .brand { font-size: 34px; }
  .edition { display: none; }
  .tools { gap: 7px; }
  .icon-button { width: 42px; height: 42px; }
  .icon-button svg { width: 20px; height: 20px; }
  .game-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 58px; column-gap: 16px; padding-top: 20px; }
  .score-block > strong { font-size: 36px; }
  .best-block { padding-left: 16px; }
  .best-block strong { font-size: var(--text-xl); }
  .next-block { gap: 4px; }
  .next-orb-wrap { width: 39px; height: 39px; }
  #next-orb { width: 37px; height: 37px; font-size: var(--text-md); }
  .combo-top strong { font-size: 20px; }
  .board-top { letter-spacing: 0; gap: 8px; }
  .board-top > span:first-child { gap: 6px; }
  .board-shell { border-radius: 18px 18px 28px 28px; }
  /* A phone's board is about 420px tall, and the start screen has to fit
     inside it without being clipped by it — so every gap in the overlay comes
     down a notch and the decorative 2+2=4 mark steps aside. It is the one thing
     up there that says nothing: the board behind it is already full of orbs,
     and the words are what a first-time player actually needs.
     tests/layout.test.mjs models this against the real rules. */
  .board-overlay { padding-inline: 18px; padding-block: 16px; }
  .intro-mark { display: none; }
  .board-overlay h1 { font-size: clamp(44px, 15cqw, 64px); margin-bottom: 12px; }
  .board-overlay p { margin-bottom: 16px; }
  .mode-switch { margin-bottom: 10px; }
  .start-footnote { margin-top: 12px; }
  .mode-option { padding: 8px 15px; font-size: 13px; }
  .ghost-button { margin-top: 8px; padding: 9px 14px; font-size: 13px; }
  .skin-card { gap: 11px; padding: 11px 12px; }
  .skin-action { min-width: 60px; padding: 0 11px; }
  .daily-card { padding: 11px 13px; }
  .daily-stats { gap: 14px; }
  .daily-stats strong { font-size: 20px; }
  .intro-coach { top: 21%; gap: 9px; padding: 9px 9px 9px 13px; border-radius: 14px; }
  .intro-coach p { max-width: 21ch; font-size: 13px; }
  .intro-skip { min-width: 46px; min-height: 36px; padding: 0 8px; }
  .secondary-button { font-size: 15px; padding: 12px 15px; }
  .primary-button { min-width: 204px; min-height: 52px; padding: 13px 22px; font-size: var(--text-sm); }
  .end-screen { padding: 18px; }
  .end-screen h2 { margin: 10px 0 8px; }
  .end-score { font-size: clamp(42px, 14cqw, 60px); }
  .run-summary { gap: 36px; margin: 16px 0; }
  .run-summary strong { font-size: 24px; }
  .end-screen .start-footnote { max-width: 100%; margin-top: 16px; }
  .end-insight { margin-bottom: 16px; padding: 10px 12px; font-size: var(--text-2xs); }
  .end-delta { font-size: 13px; }
  .play-hint { font-size: var(--text-2xs); line-height: var(--leading-normal); }
  .hint-divider { margin-inline: 4px; }
  .evolution { margin-top: 24px; }
  .evolution-track { gap: 3px; height: 42px; margin-top: 11px; }
  .evolution-track .orb { width: 22px; height: 22px; font-size: var(--text-2xs); }
  .evolution-track .orb-2, .evolution-track .orb-3, .evolution-track .orb-4 { width: 25px; height: 25px; }
  .evolution-track .orb-5, .evolution-track .orb-6, .evolution-track .orb-7 { width: 28px; height: 28px; }
  .evolution-track .orb-8 { width: 32px; height: 32px; }
  .evolution-arrow { font-size: var(--text-2xs); }
  .evolution p { margin-top: 8px; }
  /* Bottom sheet: every control lands inside thumb reach instead of floating
     in the middle of a tall screen. */
  dialog {
    width: 100%;
    max-width: none;
    max-height: 88svh;
    margin: auto 0 0;
    padding: 46px 20px calc(24px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
  }
  .settings-dialog, .skins-dialog, .signup-dialog { width: 100%; }
  .setting-row { padding: 10px; }
  .setting-text strong { font-size: 15px; }
  .segmented .mode-option { padding: 10px 4px; font-size: var(--text-2xs); }
  dialog h2 { font-size: 30px; margin-bottom: 22px; }
  dialog > .eyebrow { margin-right: 0; letter-spacing: var(--tracking-wide); }
  .dialog-close { top: 10px; right: 10px; width: 38px; height: 38px; }
  .how-steps li { gap: 13px; }
}

/* A phone with room to spare keeps the goal block but not the full sequence
   strip: the four numbers that matter and the board come first. */
@media (max-width: 900px) and (max-height: 880px) {
  .evolution { display: none; }
  .goal-block { margin-top: var(--space-1); padding-top: var(--space-3); }
  .goal-block > strong { font-size: 30px; }
  .goal-block p { font-size: var(--text-xs); }
  .goal-progress { margin-top: var(--space-2); }
  #goal-caption { margin-top: var(--space-1); }
}

/* 375x667 and anything shorter. The board and the four numbers that matter —
   score, best, next and chain — share the screen, and everything that is nice
   to have steps aside rather than pushing them off it. */
@media (max-width: 900px) and (max-height: 730px) {
  .topbar { height: 56px; }
  .game-layout { padding-top: var(--space-3); row-gap: var(--space-2); }
  .combo-block { min-height: 20px; }
  .board-top { margin-bottom: 6px; }
  .goal-block { display: none; }
  .play-hint { margin-top: var(--space-2); }
  .board-overlay { padding-block: 14px; }
  .board-overlay p { margin-bottom: 14px; }
  /* One row of vertical rhythm out of the daily card. Every number it carries
     stays; they simply sit closer together, which is what a short screen is
     asking for. */
  .daily-card { padding-block: 9px; margin-bottom: 12px; }
  .daily-stats { margin-top: 8px; }
  .daily-timer { margin-top: 9px; }
  .end-screen h2 { font-size: 30px; margin: 10px 0 8px; }
  .end-score { font-size: 48px; }
  .run-summary { margin: 14px 0; }
  .end-screen .start-footnote { margin-top: 14px; }
}

/* The walkthrough teaches the controls now, so the hint line is desktop's. */
@media (pointer: coarse) and (max-height: 880px) {
  .play-hint { display: none; }
}

@media (max-width: 900px) and (max-height: 600px) {
  .intro-mark { display: none; }
  .board-overlay h1 { font-size: clamp(48px, 17cqw, 64px); }
  .board-overlay { padding-block: 16px; }
  .end-screen h2 { font-size: 30px; }
  .end-score { font-size: 42px; }
  .run-summary { margin: 14px 0; }
  .run-summary strong { font-size: 24px; }
}

@media (max-width: 360px) {
  .intro-coach p { max-width: 18ch; font-size: var(--text-2xs); }
  .app {
    padding-right: max(14px, env(safe-area-inset-right));
    padding-left: max(14px, env(safe-area-inset-left));
  }
  .game-layout { column-gap: 12px; }
  .best-block { padding-left: 12px; }
  .evolution-track { gap: 3px; }
  .evolution-arrow { display: none; }
  .board-top { font-size: var(--text-2xs); }
  .board-top > span:first-child { gap: 5px; }
}

@media (pointer: coarse) {
  .desktop-hint { display: none; }
  .touch-hint { display: inline; }
}

/* Motion is three-way: follow the device, or override it either way. The media
   query stands down when the player has explicitly asked for full motion, and
   the attribute rule covers the opposite case — asking for reduced motion on a
   device that never did. `body[data-motion]` is set by JS from the same
   resolution the canvas uses, so CSS and canvas can never disagree. */
@media (prefers-reduced-motion: reduce) {
  body:not([data-motion='full']) *,
  body:not([data-motion='full']) *::before,
  body:not([data-motion='full']) *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  body:not([data-motion='full']) .board-toast.show { opacity: 1; transform: none; }
  body:not([data-motion='full']) .milestone-toast.show { opacity: 1; transform: translateX(-50%); }
  body:not([data-motion='full']) #score-gain.pop { opacity: 1; transform: none; }
}

body[data-motion='reduced'] *,
body[data-motion='reduced'] *::before,
body[data-motion='reduced'] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

body[data-motion='reduced'] .board-toast.show { opacity: 1; transform: none; }
body[data-motion='reduced'] .milestone-toast.show { opacity: 1; transform: translateX(-50%); }
body[data-motion='reduced'] #score-gain.pop { opacity: 1; transform: none; }

.signup-dialog { width: min(456px, calc(100% - 32px)); }
.signup-dialog h2 { margin-bottom: 14px; }
#signup-description { margin: 0 0 26px; color: var(--color-ink-muted); font-size: var(--text-sm); line-height: var(--leading-normal); }
#signup-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.signup-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.signup-field label { color: #dce6d7; font-size: var(--text-xs); font-weight: var(--weight-medium); }
.signup-field label span { margin-left: 4px; color: var(--color-ink-muted); font-size: var(--text-2xs); font-weight: var(--weight-regular); }
.signup-field input { width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid #c8e2b92e; border-radius: var(--radius-sm); background: var(--color-surface-sunken); color: var(--color-ink); font: 400 16px/1.4 var(--font-body); transition: border-color var(--duration-snap), box-shadow var(--duration-snap); }
.signup-field input::placeholder { color: #7c8c7c; }
.signup-field input:focus { outline: none; border-color: #d8fa7799; box-shadow: 0 0 0 3px #d8fa7710; }
.signup-field input[aria-invalid='true'] { border-color: #efaa94; }
.field-error { margin: 0; color: #ffc4ae; font-size: var(--text-2xs); line-height: var(--leading-normal); }
.signup-error { margin: 0 0 18px; padding: 11px 13px; border: 1px solid #efaa9429; border-radius: var(--radius-sm); background: #efaa9408; color: #ffc4ae; font-size: var(--text-xs); line-height: var(--leading-normal); }
#signup-submit { justify-content: space-between; min-width: 0; }
#signup-submit:disabled { opacity: .75; cursor: wait; transform: none; }
.signup-note { margin: 19px 0 0; color: var(--color-ink-muted); font-size: var(--text-2xs); line-height: 1.6; }
@media (max-width: 580px) { .signup-dialog { padding-top: 48px; } .signup-dialog h2 { font-size: var(--text-2xl); } #signup-description { margin-bottom: 23px; } }
