/* ===========================================================================
   Number Merge — chrome: HUD, tools, dialogs
   Strict product register. Quiet, fast, familiar. The board is the only lit
   thing on screen; nothing here competes with it.

   Deliberate deviation from the source game: its round white buttons with
   mauve glyphs are replaced by raised dark circles. White discs are the
   second-brightest thing on that screen and pull focus off the board. The one
   colour kept is the amber undo — it marks a limited resource, so it earns it.
   =========================================================================== */

/* --- Icon buttons --------------------------------------------------------- */

.icon-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--ink-dim);
  box-shadow: var(--shadow-pill);
  cursor: pointer;
  transition: background var(--dur-fast) linear, color var(--dur-fast) linear,
              transform var(--dur-fast) var(--ease-out-quint);
}
.icon-btn svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor;
                stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--raised-hi); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --- Instrument panel ------------------------------------------------------
   One panel, set to the board's own edges. The score is the headline: a single
   large figure with nothing boxed round it, because a number that size does
   not need a container to be found. Best sits opposite as the smaller figure
   it is being measured against, and the two controls that are not part of
   play (new game, menu) are quiet and together, out of the reading line. */

.hud {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-6);
}
.hud__score { display: flex; flex-direction: column; min-width: 0; }
.hud__side { display: flex; align-items: center; gap: var(--s-4); }
.hud__best { display: flex; flex-direction: column; align-items: flex-end; margin-right: var(--s-3); }

.hud__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-faint);
  line-height: 1.2;
}
.hud__value {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
  transform-origin: 0 100%;
}
/* Seven figures and their commas still have to clear the Best readout. */
.hud__value[data-long="1"] { font-size: var(--text-2xl); }
.hud__bestv {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  color: var(--accent);
}

/* A brief lift when the score changes: feedback, not decoration. */
.hud__score.is-bumped .hud__value { animation: bump 340ms var(--ease-out-expo); }
@keyframes bump { 0% { transform: scale(1); } 34% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* --- Tier ladder -----------------------------------------------------------
   How far this run has climbed toward 2048, in the tier colours themselves:
   one segment per doubling, lit once that block has been made, the highest
   held bright. It runs the full width of the board, so it reads as a gauge on
   the panel rather than a cluster of dots, and its eleven segments sit under
   the score as its measure: how you are doing, then how far you have got.
   It also teaches the colour cycle before it has been earned. It gives way on
   short screens rather than squeeze the board. */
.ladder {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 0.75rem;
}
.ladder__pip {
  flex: 1 1 0;
  height: 0.3rem;
  border-radius: 0.15rem;
  background: var(--surface-cell-alt);
  box-shadow: inset 0 1px 1px oklch(0 0 0 / 0.5);
  transition: background var(--dur) linear, height var(--dur) var(--ease-out-quint), box-shadow var(--dur) linear;
}
.ladder__pip.is-lit {
  background: var(--block);
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.30);
}
.ladder__pip.is-top {
  height: 0.5rem;
  border-radius: 0.25rem;
  box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.35), 0 0 var(--s-6) var(--block);
}
.ladder__pip.is-new { animation: rung 420ms var(--ease-out-expo); }
@keyframes rung { 0% { transform: scaleY(1); } 30% { transform: scaleY(2.2); } 100% { transform: scaleY(1); } }
.ladder__pip[data-tier="2"]    { --block: var(--t2); }
.ladder__pip[data-tier="4"]    { --block: var(--t4); }
.ladder__pip[data-tier="8"]    { --block: var(--t8); }
.ladder__pip[data-tier="16"]   { --block: var(--t16); }
.ladder__pip[data-tier="32"]   { --block: var(--t32); }
.ladder__pip[data-tier="64"]   { --block: var(--t64); }
.ladder__pip[data-tier="128"]  { --block: var(--t128); }
.ladder__pip[data-tier="256"]  { --block: var(--t256); }
.ladder__pip[data-tier="512"]  { --block: var(--t512); }
.ladder__pip[data-tier="1024"] { --block: var(--t1024); }
.ladder__pip[data-tier="2048"] { --block: var(--t2048); }
@media (max-height: 640px) { .ladder { display: none; } }

/* --- Tools row ------------------------------------------------------------ */

.tools { display: flex; align-items: center; gap: var(--s-6); min-height: 3rem; }
.tools__spacer { flex: 1 1 auto; }

.tool {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  color: var(--ink-dim);
  transition: transform var(--dur-fast) var(--ease-out-quint), opacity var(--dur-fast) linear;
}
.tool:active { transform: scale(0.93); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-md); }
.tool:disabled { opacity: 0.32; cursor: not-allowed; transform: none; }

.tool--undo {
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent-warm);
  color: var(--accent-warm-ink);
  box-shadow: 0 2px 0 oklch(0.62 0.14 70), 0 4px 10px -2px oklch(0 0 0 / 0.5);
}
.tool--undo svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor;
                  stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.tool--undo:disabled { background: var(--raised); color: var(--ink-faint); box-shadow: var(--shadow-pill); }

.tool__badge {
  position: absolute;
  top: -4px; right: -6px;
  min-width: 1.15rem; height: 1.15rem;
  padding-inline: 3px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  background: var(--room);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  box-shadow: 0 0 0 2px var(--room);
}

/* Hold slot — an empty socket until something is parked in it. */
.tool--hold .tool__slot {
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem;
  border-radius: var(--radius-md);
  background: var(--surface-cell);
  box-shadow: inset 0 0 0 1.5px var(--hairline), inset 0 2px 6px oklch(0 0 0 / 0.4);
}
.tool__empty {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tool--hold.is-used { opacity: 0.4; }

/* --- Next queue ----------------------------------------------------------- */

.queue { display: flex; align-items: center; gap: var(--s-4); }
.queue__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-faint);
}
.queue__items { display: flex; align-items: center; gap: var(--s-3); }

/* The queue is a rail cut into the panel, the same socket as the hold slot, so
   undo, hold and what is coming read as one strip of instruments. The next
   block is full size; the two behind it are smaller but still large enough
   to read at arm's length, which the old receding sizes were not. */
.queue__items {
  padding: var(--s-2);
  border-radius: var(--radius-md);
  background: var(--surface-cell);
  box-shadow: inset 0 0 0 1.5px var(--hairline), inset 0 2px 6px oklch(0 0 0 / 0.4);
  min-height: 2.75rem;
}
.chip {
  display: grid;
  place-items: center;
  border-radius: 26%;
  background: var(--block);
  color: oklch(1 0 0);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 2px 0 oklch(1 0 0 / 0.2), 0 2px 0 var(--block-dk);
  transition: opacity var(--dur) var(--ease-out-quint);
}
.chip[data-slot="0"] { width: 2.25rem; height: 2.25rem; font-size: 0.95rem; opacity: 1; }
.chip[data-slot="1"] { width: 1.8rem;  height: 1.8rem;  font-size: 0.78rem; opacity: 0.86; }
.chip[data-slot="2"] { width: 1.8rem;  height: 1.8rem;  font-size: 0.78rem; opacity: 0.62; }
.chip__glyph { width: 62%; height: 62%; }
.chip[data-kind="wild"]  { --block: var(--t-wild);  --block-dk: var(--t-wild-dk); }
.chip[data-kind="bomb"]  { --block: var(--t-bomb);  --block-dk: var(--t-bomb-dk);
                           box-shadow: inset 0 0 0 2px var(--danger), 0 2px 0 var(--block-dk); }
.chip[data-kind="stone"] { --block: var(--t-stone); --block-dk: var(--t-stone-dk); }
.chip[data-kind="wild"] .chip__glyph  { fill: var(--t-wild-dk); }
.chip[data-kind="bomb"] .chip__glyph  { fill: var(--danger); }
.chip[data-kind="stone"] .chip__glyph { fill: oklch(1 0 0 / 0.22); }
.chip[data-kind="vortex"] { --block: var(--t-vortex); --block-dk: var(--t-vortex-dk);
                            box-shadow: inset 0 0 0 2px oklch(0.72 0.19 300), 0 2px 0 var(--block-dk); }
.chip[data-kind="vortex"] .chip__glyph { fill: oklch(0.86 0.13 300); }
/* A Phantom keeps its tier colour (it is a real number) but reads as spectral. */
.chip[data-kind="phantom"] { opacity: 0.85; box-shadow: inset 0 0 0 2px oklch(1 0 0 / 0.5), 0 2px 0 var(--block-dk); }
/* Every dealable kind must be styled in all three families: .block (board and
   staging), .chip (queue and hold) and .mini (menu, coach card, launch screen).
   Missing one leaves a bare glyph with no body. js/specials.test.js checks. */
.chip[data-kind="halver"] { --block: var(--t-halver); --block-dk: var(--t-halver-dk);
  box-shadow: inset 0 0 0 1.5px var(--t-halver-hi), 0 2px 0 var(--block-dk); }
.chip[data-kind="halver"] .chip__glyph { fill: var(--t-halver-hi); }
.chip[data-len="3"] { font-size: 0.62em; }
.chip[data-len="4"] { font-size: 0.5em; }

.chip[data-tier="2"]    { --block: var(--t2);    --block-dk: var(--t2-dk); }
.chip[data-tier="4"]    { --block: var(--t4);    --block-dk: var(--t4-dk); }
.chip[data-tier="8"]    { --block: var(--t8);    --block-dk: var(--t8-dk); }
.chip[data-tier="16"]   { --block: var(--t16);   --block-dk: var(--t16-dk); }
.chip[data-tier="32"]   { --block: var(--t32);   --block-dk: var(--t32-dk); }
.chip[data-tier="64"]   { --block: var(--t64);   --block-dk: var(--t64-dk); }
.chip[data-tier="128"]  { --block: var(--t128);  --block-dk: var(--t128-dk); }
.chip[data-tier="256"]  { --block: var(--t256);  --block-dk: var(--t256-dk); }
.chip[data-tier="512"]  { --block: var(--t512);  --block-dk: var(--t512-dk); }
.chip[data-tier="1024"] { --block: var(--t1024); --block-dk: var(--t1024-dk); }
.chip[data-tier="2048"] { --block: var(--t2048); --block-dk: var(--t2048-dk); color: var(--t2048-dk); }
/* Spawns are hard-capped at 128 so these are unreachable today. They exist so
   that loosening the cap can never leave a chip with no background at all. */
.chip[data-tier="4096"] { --block: var(--t4096); --block-dk: var(--t4096-dk); }
.chip[data-tier="8192"] { --block: var(--t8192); --block-dk: var(--t8192-dk); color: var(--t8192-dk); }
.chip[data-tier="max"]  { --block: var(--tmax);  --block-dk: var(--tmax-dk);  color: var(--tmax-dk); }

/* --- Foot ----------------------------------------------------------------- */

.foot {
  display: flex; align-items: center; justify-content: center;
  gap: var(--s-6);
  padding-top: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-faint);
}
.foot__item { display: inline-flex; gap: var(--s-3); align-items: baseline; }
.foot__k { letter-spacing: var(--tracking-wide); text-transform: uppercase; }
.foot__v { color: var(--ink-dim); font-weight: 600; font-variant-numeric: tabular-nums; }
.foot__sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.4; }

/* Keyboard legend. Only where there is a keyboard to use it with. */
.keys { display: none; }
@media (hover: hover) and (pointer: fine) and (min-width: 700px) {
  .keys {
    display: flex; justify-content: center; gap: var(--s-8);
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--ink-faint);
  }
  .keys span { display: inline-flex; align-items: center; gap: var(--s-2); }
  .keys kbd {
    min-width: 1.5em;
    padding: 0.1em 0.4em;
    border-radius: 0.3em;
    background: var(--surface-cell);
    box-shadow: inset 0 0 0 1px var(--hairline), 0 1px 0 var(--room-deep);
    font: inherit;
    font-weight: 600;
    text-align: center;
    color: var(--ink-dim);
  }
}

/* Focus rings belong to keyboards (see main.js). */
html:not([data-input="keys"]) :focus-visible { outline: none; }
html:not([data-input="keys"]) .switch input:focus-visible + .switch__ui { outline: none; }

/* --- Dialogs -------------------------------------------------------------- */

.sheet {
  width: min(26rem, calc(100vw - 2rem));
  max-height: min(90dvh, 46rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: auto;
  padding: var(--s-16) var(--s-12) var(--s-12);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--raised);
  color: var(--ink);
  box-shadow: var(--shadow-panel), inset 0 1px 0 oklch(1 0 0 / 0.07);
}
.sheet::backdrop { background: oklch(0.10 0.01 265 / 0.72); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheetIn var(--dur-slow) var(--ease-out-expo); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(14px) scale(0.97); } to { opacity: 1; transform: none; } }

.sheet__title { margin: 0 0 var(--s-2); font-size: var(--text-2xl); font-weight: 800; letter-spacing: var(--tracking-tight); }
.sheet__sub { margin: 0 0 var(--s-12); color: var(--ink-dim); font-family: var(--font-mono); font-size: var(--text-sm); }
.sheet__h3 { margin: var(--s-16) 0 var(--s-6); font-size: var(--text-base); font-weight: 700; }
.sheet__actions { display: flex; gap: var(--s-6); margin-top: var(--s-16); }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  flex: 1 1 auto;
  padding: var(--s-8) var(--s-12);
  border: 0;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-fast) linear, transform var(--dur-fast) var(--ease-out-quint);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: oklch(0.87 0.14 172); }
.btn--ghost { background: var(--surface-cell); color: var(--ink-dim); box-shadow: inset 0 0 0 1px var(--hairline); }
.btn--ghost:hover { background: var(--raised-hi); color: var(--ink); }

/* --- Fields, segmented control, switch ------------------------------------ */

.field { margin-bottom: var(--s-12); }
/* Three switches sit within a few pixels of the frame width on a 390px
   phone, so let them wrap rather than overflow on anything narrower. */
.field--row { display: flex; flex-wrap: wrap; gap: var(--s-6) var(--s-12); }
.field__label {
  display: block; margin-bottom: var(--s-4);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600;
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--ink-faint);
}
.field__hint { margin: var(--s-4) 0 0; font-size: var(--text-xs); color: var(--ink-faint); line-height: 1.5; }

.seg { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--surface-cell); }
.seg__btn {
  flex: 1 1 0;
  padding: var(--s-4) var(--s-6);
  border: 0; border-radius: calc(var(--radius-md) - 3px);
  background: transparent; color: var(--ink-dim);
  font-family: var(--font-display); font-size: var(--text-sm); font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-fast) linear, color var(--dur-fast) linear;
}
.seg__btn:hover { color: var(--ink); }
.seg__btn.is-on { background: var(--raised-hi); color: var(--ink); box-shadow: var(--shadow-pill); }
.seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The leaderboard toggle sits inline with its heading rather than filling the
   row, so it reads as a filter on the list below it and not as a second mode
   picker competing with the real one further up the sheet. */
.runs__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-6); flex-wrap: wrap;
  /* The heading's own margin moves up to the row, or its top margin would push
     the h3 down while leaving the toggle stranded at the top of the flex line. */
  margin: var(--s-16) 0 var(--s-6);
}
.runs__head .sheet__h3 { margin: 0; }
.seg--sm { flex: 0 0 auto; padding: 2px; align-self: center; }
.seg--sm .seg__btn { flex: 0 0 auto; padding: var(--s-3) var(--s-6); font-size: var(--text-xs); }

.switch { display: inline-flex; align-items: center; gap: var(--s-6); cursor: pointer; font-size: var(--text-sm); color: var(--ink-dim); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__ui {
  position: relative; width: 2.4rem; height: 1.4rem; flex: 0 0 auto;
  border-radius: var(--radius-pill); background: var(--surface-cell);
  box-shadow: inset 0 0 0 1px var(--hairline);
  transition: background var(--dur-fast) linear;
}
.switch__ui::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 1.05rem; height: 1.05rem; border-radius: 50%;
  background: var(--ink-faint);
  transition: transform var(--dur-fast) var(--ease-out-quint), background var(--dur-fast) linear;
}
.switch input:checked + .switch__ui { background: oklch(0.82 0.14 172 / 0.28); }
.switch input:checked + .switch__ui::after { transform: translateX(1rem); background: var(--accent); }
.switch input:focus-visible + .switch__ui { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --- Stats + run history -------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-6) var(--s-8); margin: 0 0 var(--s-4); }
.stats div { padding: var(--s-6) var(--s-8); border-radius: var(--radius-sm); background: var(--surface-cell); }
.stats dt {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--ink-faint);
}
.stats dd { margin: 2px 0 0; font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }

.runs { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; max-height: 11rem; overflow-y: auto; }
.runs li {
  display: grid; grid-template-columns: 1.4rem 1fr auto auto; gap: var(--s-6); align-items: center;
  padding: var(--s-4) var(--s-6); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-dim);
}
.runs li:nth-child(odd) { background: oklch(1 0 0 / 0.03); }
.runs__rank { color: var(--ink-faint); font-weight: 700; }
.runs__score { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.runs__tier { font-weight: 700; }
/* The empty state is a single sentence, not a row — it must escape the
   four-column grid the run rows use. */
.runs li.runs__empty { display: block; color: var(--ink-faint); background: none; padding-left: 0; }

/* --- Title screen -----------------------------------------------------------
   The first thing you see. It was a grey sheet floating over a dimmed, empty
   board, with its buttons in the middle of the phone and the bottom third
   dead. On a phone it is now the whole screen: the name at the top, the game's
   promise as its one piece of art (the full climb from 2 to 2048, built from
   real blocks, so it follows the palette), and the ways in at the bottom
   where the thumb already is. Resume is dominant when it exists, because
   going back to a run in progress is almost always what you want. */

.start { width: min(26rem, calc(100vw - 2rem)); text-align: center; }
.start[open] { display: flex; flex-direction: column; gap: var(--s-12); }

.start__title {
  margin: 0;
  font-size: clamp(2.25rem, 11.5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
}
.start__sub {
  margin: var(--s-4) 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--ink-dim);
}

/* The climb. Real .block elements, taken out of the board's absolute grid. */
.start__art {
  --cell: clamp(2.1rem, min(13.5vw, 6dvh), 3.5rem);
  --gap: 0.375rem;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: calc(var(--gap) + var(--cell) * 0.05);
  min-height: 0;
  padding-block: var(--s-4);
}
.start__row { display: flex; gap: var(--gap); }
.start__art .block {
  position: relative;
  transform: none;
  will-change: auto;
}
/* Each block drops into the pile in order, bottom row first, apex last. */
.start[open] .start__art .block {
  animation: climbIn 460ms var(--ease-out-quint) both;
  animation-delay: calc(90ms + var(--i) * 34ms);
}
@keyframes climbIn {
  from { opacity: 0; transform: translateY(calc(var(--cell) * -0.9)); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: none; }
}

.start__actions { display: flex; flex-direction: column; gap: var(--s-4); text-align: left; }

.start__resume {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  margin-bottom: var(--s-3);
  padding: var(--s-8) var(--s-10);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / 0.35),
    0 2px 0 oklch(0.55 0.11 172),
    0 10px 20px -10px oklch(0 0 0 / 0.7);
  text-align: left;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out-quint), background var(--dur-fast) linear;
}
.start__resume:hover { background: oklch(0.87 0.14 172); }
.start__resume:active { transform: translateY(1px) scale(0.99); }
.start__resume:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.start__resume-k {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  opacity: 0.75;
}
.start__resume-v { font-size: var(--text-lg); font-weight: 700; }

.start__modes { display: flex; flex-direction: column; gap: var(--s-4); }

.start__mode {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-6) var(--s-10) var(--s-8);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--raised-hi);
  /* A key, not a card: lit along the top edge and resting on a hard shadow
     line, the same construction as a block. */
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / 0.10),
    0 2px 0 var(--room-deep),
    0 10px 20px -10px oklch(0 0 0 / 0.7);
  text-align: left;
  cursor: pointer;
  transition: filter var(--dur-fast) linear, transform var(--dur-fast) var(--ease-out-quint), box-shadow var(--dur-fast) var(--ease-out-quint);
}
.start__mode:hover { filter: brightness(1.08); }
.start__mode:active {
  transform: translateY(1px) scale(0.99);
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / 0.06),
    0 1px 0 var(--room-deep),
    0 4px 10px -6px oklch(0 0 0 / 0.6);
}
.start__mode-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-6); }
.start__chips { display: flex; gap: var(--s-3); margin: var(--s-1) 0; }
.start__chips .mini { width: 1.75rem; height: 1.75rem; --cell: 1.75rem; }
.mini--num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.72rem;
  color: var(--ink);
  text-shadow: 0 1px 0 oklch(0 0 0 / 0.3);
}
.mini[data-tier="2"]  { --block: var(--t2);  --block-dk: var(--t2-dk); }
.mini[data-tier="4"]  { --block: var(--t4);  --block-dk: var(--t4-dk); }
.mini[data-tier="8"]  { --block: var(--t8);  --block-dk: var(--t8-dk); }
.mini[data-tier="16"] { --block: var(--t16); --block-dk: var(--t16-dk); }
.start__mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.start__mode-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--ink);
}
.start__mode-desc { font-size: var(--text-xs); color: var(--ink-dim); line-height: 1.45; }
.start__mode-best {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.start__mode-best:empty { display: none; }

/* Leaving: the screen lifts away and the board is seen to be behind it. */
.start.is-leaving { animation: startOut 240ms var(--ease-out-quint) forwards; }
.start.is-leaving::backdrop { opacity: 0; transition: opacity 240ms linear; }
@keyframes startOut { to { opacity: 0; transform: translateY(-1.5%) scale(1.015); } }

/* Phone: the whole screen, composed for one hand. */
@media (max-width: 699px) {
  .start {
    width: 100vw; max-width: none;
    height: 100dvh; max-height: none;
    margin: 0;
    border-radius: 0;
    padding:
      calc(env(safe-area-inset-top) + var(--s-24))
      calc(env(safe-area-inset-right) + var(--s-10))
      calc(env(safe-area-inset-bottom) + var(--s-16))
      calc(env(safe-area-inset-left) + var(--s-10));
    background:
      radial-gradient(70% 34% at 50% 40%, var(--glow) 0%, transparent 72%),
      linear-gradient(to bottom, var(--room) 0%, var(--room-deep) 100%);
    box-shadow: none;
    overflow: hidden auto;
  }
  .start[open] { animation: startIn var(--dur-slow) linear; gap: var(--s-6); }
  @keyframes startIn { from { opacity: 0; } to { opacity: 1; } }
  .start::backdrop { background: var(--room-deep); backdrop-filter: none; }
}
/* A short phone has no room for the pile and the keys both. The keys win. */
@media (max-width: 699px) and (max-height: 620px) {
  .start__art { display: none; }
  .start { padding-top: calc(env(safe-area-inset-top) + var(--s-12)); }
  .start__actions { margin-top: auto; }
}

/* --- Special block reference + first-run coaching -------------------------- */

.specials { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s-4); }
.specials li {
  display: grid;
  grid-template-columns: 2.1rem 1fr;
  gap: var(--s-6);
  align-items: center;
  font-size: var(--text-xs);
  color: var(--ink-dim);
  line-height: 1.45;
}
.specials b { display: block; color: var(--ink); font-size: var(--text-sm); font-weight: 700; }
/* The teaser for specials the player hasn't met yet. */
.specials li.specials__locked {
  display: block;
  padding: var(--s-4) 0 0;
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-style: normal;
}

/* A miniature of the real block, so the reference and the board agree. */
.mini {
  width: 2.1rem; height: 2.1rem;
  --cell: 2.1rem;
  display: grid; place-items: center;
  border-radius: 24%;
  background: var(--block);
  box-shadow: inset 0 2px 0 oklch(1 0 0 / 0.22), 0 2px 0 var(--block-dk);
}
.mini[data-kind="wild"]  { --block: var(--t-wild);  --block-dk: var(--t-wild-dk); }
.mini[data-kind="bomb"]  { --block: var(--t-bomb);  --block-dk: var(--t-bomb-dk);
                           box-shadow: inset 0 0 0 2px var(--danger), 0 2px 0 var(--block-dk); }
.mini[data-kind="stone"] { --block: var(--t-stone); --block-dk: var(--t-stone-dk); }
.mini[data-kind="halver"] {
  --block: var(--t-halver); --block-dk: var(--t-halver-dk);
  box-shadow: inset 0 0 0 2px var(--t-halver-hi), 0 2px 0 var(--block-dk);
}
.mini[data-kind="vortex"]  { --block: var(--t-vortex);  --block-dk: var(--t-vortex-dk);
                             box-shadow: inset 0 0 0 2px oklch(0.72 0.19 300), 0 2px 0 var(--block-dk); }
.mini[data-kind="phantom"] { --block: var(--t-phantom); --block-dk: var(--t-phantom-dk); }
.mini svg { width: 1.05rem; height: 1.05rem; }
.mini[data-kind="wild"] svg  { fill: var(--t-wild-dk); }
.mini[data-kind="bomb"] svg  { fill: var(--danger); }
.mini[data-kind="stone"] svg { fill: oklch(1 0 0 / 0.22); }
.mini[data-kind="vortex"] svg  { fill: oklch(0.86 0.13 300); }
.mini[data-kind="phantom"] svg { fill: var(--t-phantom-dk); }
.mini[data-kind="halver"] svg  { fill: var(--t-halver-hi); }

.sheet--coach { width: min(22rem, calc(100vw - 2rem)); }
.coach { display: grid; grid-template-columns: 3.25rem 1fr; gap: var(--s-10); align-items: start; }
.coach__block { --cell: 3.25rem; width: 3.25rem; height: 3.25rem; }
.coach__block .mini { width: 3.25rem; height: 3.25rem; --cell: 3.25rem; }
.coach__block .mini svg { width: 1.6rem; height: 1.6rem; }
.coach__title { margin: 0 0 var(--s-3); font-size: var(--text-xl); font-weight: 800; letter-spacing: var(--tracking-tight); }
.coach__body { margin: 0; font-size: var(--text-sm); color: var(--ink-dim); line-height: 1.55; }

/* --- Toast ---------------------------------------------------------------- */

.toast {
  position: absolute;
  left: 50%; bottom: calc(env(safe-area-inset-bottom) + var(--s-20));
  transform: translateX(-50%) translateY(8px);
  z-index: var(--z-toast);
  padding: var(--s-6) var(--s-12);
  border-radius: var(--radius-pill);
  background: var(--raised-hi);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-panel);
  opacity: 0;
  transition: opacity var(--dur) linear, transform var(--dur) var(--ease-out-quint);
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Short viewports: give the board the room ----------------------------- */

@media (max-height: 680px) {
  .hud__value { font-size: var(--text-2xl); }
  .hud__value[data-long="1"] { font-size: var(--text-xl); }
  .icon-btn { width: 2.4rem; height: 2.4rem; }
  .stage { min-height: 3.5rem; }
  .foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ladder__pip.is-new { animation: none; }
  .sheet[open] { animation: none; }
  .hud__score.is-bumped .hud__value { animation: none; }
  .start[open] .start__art .block { animation: none; }
  .start.is-leaving { animation: none; }
}
