/* =====================================================================
   game-ui.css — shared chrome for every NovaPlay game.

   Each game draws its own world on a canvas; everything *around* that
   world (HUD chips, overlay cards, buttons, level pickers, hints) is
   the same set of components, so it lives here once instead of being
   re-forked per game.

   A game keeps its identity by overriding the token block below in its
   own stylesheet — palette and art direction stay per-game, geometry
   and behaviour stay shared. Load order is always:

       <link rel="stylesheet" href="game-ui.css">
       <link rel="stylesheet" href="<game>.css">

   so anything a game genuinely needs to special-case still wins.
   ===================================================================== */

:root {
  /* ---- one knob that shrinks the whole HUD on small screens ---- */
  --ui: 1;

  /* ---- type ---- */
  --font: ui-rounded, "SF Pro Rounded", "Baloo 2", Fredoka, "Nunito",
          "Segoe UI Variable Display", system-ui, -apple-system, "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --weight-body: 700;   /* prose: readable, not shouty */
  --weight-ui:   800;   /* labels, buttons, chips       */
  --weight-loud: 900;   /* titles, counters             */

  /* ---- ink ---- */
  --ink:    #eef0ff;
  --ink-2:  #eef0ff;
  --ink-3:  #9aa0c8;

  /* ---- HUD chips ---- */
  --panel:    rgba(14, 12, 38, .72);
  --panel-2:  rgba(28, 24, 66, .94);
  --stroke:   rgba(255, 255, 255, .14);
  --stroke-w: 1.5px;
  --blur:     8px;

  /* ---- overlay card ---- */
  --scrim:       radial-gradient(120% 90% at 50% 0%, rgba(20, 18, 60, .55), rgba(6, 5, 22, .84));
  --card-bg:     var(--panel-2);
  --card-border: var(--stroke);
  --card-border-w: var(--stroke-w);

  /* ---- accent (primary buttons, eyebrows, active states) ---- */
  --accent:      #f0a63a;
  --accent-hi:   #ffc46b;
  --accent-lo:   #a35c05;
  --accent-ink:  #3a2400;   /* text drawn ON the accent */

  /* ---- neutral / ghost button ---- */
  --ghost-bg:    rgba(255, 255, 255, .08);
  --ghost-ink:   var(--ink);
  --ghost-lo:    rgba(0, 0, 0, .34);

  /* ---- semantic ---- */
  --gold:  #ffd23c;
  --good:  #46e08a;
  --bad:   #ff5b5b;

  /* ---- shape ---- */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 11px;
  --shadow:      0 14px 34px rgba(0, 0, 0, .45);
  --shadow-chip: 0 6px 16px rgba(0, 0, 0, .35);

  /* depth of the "pressable" lip under buttons and chips */
  --lip: 6px;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  font-weight: var(--weight-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  touch-action: none;
}

a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-weight: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

svg {
  width: 100%; height: 100%;
  fill: none; stroke: currentColor;
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}

/* JS toggles [hidden] on every overlay — it must beat display:flex/grid */
[hidden] { display: none !important; }

.only-touch { display: none; }
.only-wide  { display: inline; }

/* Keyboard users get a ring everywhere; mouse users never see it. */
:focus-visible {
  outline: 3px solid var(--accent-hi);
  outline-offset: 3px;
}

/* --------------------------------------------------------- stroked text
   White text that has to stay legible on top of an arbitrary game scene.
   `paint-order: stroke fill` paints one clean outline instead of stacking
   eight offset shadows, so the glyph edges stay crisp at large sizes. */
.stroked {
  color: #fff;
  paint-order: stroke fill;
  -webkit-text-stroke: 3px var(--stroke-ink, rgba(10, 8, 30, .92));
  /* soft drop only — a hard offset shadow this close to a fat stroke
     reads as a second, blurred copy of the word rather than depth */
  text-shadow: 0 5px 14px rgba(0, 0, 0, .38);
}
.stroked--lg { -webkit-text-stroke-width: 5px; text-shadow: 0 8px 20px rgba(0, 0, 0, .42); }

/* --------------------------------------------------------- stage shell */
.game-shell { position: fixed; inset: 0; }
.stage { position: absolute; inset: 0; overflow: hidden; }
#gameCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
}

/* ================================ HUD ================================ */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.hud > * { pointer-events: auto; }

/* Every floating HUD element shares one recipe so the corners of the
   screen read as one set of controls rather than four unrelated ones. */
.hud-btn,
.stat,
.timer,
.level-tag {
  background: var(--panel);
  border: var(--stroke-w) solid var(--stroke);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow-chip);
  color: var(--ink);
}

.hud-btn {
  display: grid; place-items: center;
  width: calc(46px * var(--ui));
  height: calc(46px * var(--ui));
  flex: 0 0 auto;
  border-radius: calc(14px * var(--ui));
  transition: transform .1s ease, background .15s ease, filter .15s ease;
}
.hud-btn svg { width: calc(24px * var(--ui)); height: calc(24px * var(--ui)); }
.hud-btn:hover { filter: brightness(1.12); }
.hud-btn:active { transform: scale(.92); }

/* corners — safe-area aware so nothing hides under a notch or home bar */
.back-btn {
  position: absolute;
  top: calc(14px * var(--ui) + env(safe-area-inset-top));
  left: calc(14px * var(--ui) + env(safe-area-inset-left));
}
.hud__top-right {
  position: absolute;
  top: calc(14px * var(--ui) + env(safe-area-inset-top));
  right: calc(14px * var(--ui) + env(safe-area-inset-right));
  display: flex; gap: calc(8px * var(--ui));
}
.hud__top-center {
  position: absolute;
  top: calc(14px * var(--ui) + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  gap: calc(6px * var(--ui));
  max-width: calc(100vw - 220px * var(--ui));
}
.hud__top-right .hud-btn { position: static; }

/* stat pill: label over value (Stage / Moves / Score …) */
.stat {
  min-width: calc(76px * var(--ui));
  padding: calc(6px * var(--ui)) calc(14px * var(--ui)) calc(7px * var(--ui));
  border-radius: calc(14px * var(--ui));
  text-align: center;
  line-height: 1.05;
}
.stat__label {
  display: block;
  font-size: calc(9.5px * var(--ui));
  font-weight: var(--weight-loud);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.stat__value {
  display: block;
  font-size: calc(20px * var(--ui));
  font-weight: var(--weight-loud);
  font-variant-numeric: tabular-nums;
}

.timer {
  min-width: calc(96px * var(--ui));
  padding: calc(7px * var(--ui)) calc(18px * var(--ui));
  border-radius: calc(16px * var(--ui));
  text-align: center;
  font-size: calc(26px * var(--ui));
  font-weight: var(--weight-loud);
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.timer.is-low { color: var(--bad); animation: chipPulse .8s ease-in-out infinite; }
@keyframes chipPulse { 50% { transform: scale(1.08); } }

.level-tag {
  padding: calc(4px * var(--ui)) calc(13px * var(--ui)) calc(5px * var(--ui));
  border-radius: calc(11px * var(--ui));
  font-size: calc(12px * var(--ui));
  font-weight: var(--weight-loud);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------------- center shout */
.center-shout {
  position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(52px, 14vw, 130px);
  font-weight: var(--weight-loud);
  color: #fff;
  paint-order: stroke fill;
  -webkit-text-stroke: 6px var(--stroke-ink, rgba(10, 8, 30, .85));
  text-shadow: 0 8px 22px rgba(0, 0, 0, .45);
  text-align: center; white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  z-index: 8;
}
.center-shout__sub {
  display: block;
  font-size: .34em;
  letter-spacing: .16em;
  -webkit-text-stroke-width: 3px;
  margin-top: .35em;
}
/* `.show` (endover) and `.is-show` (everyone else) both drive this */
.center-shout.show,
.center-shout.is-show { animation: shoutPop .95s cubic-bezier(.2, .9, .25, 1) forwards; }
.center-shout.is-hold { opacity: 1; }
@keyframes shoutPop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  76%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -52%) scale(.9); }
}

/* ------------------------------------------------------------- toasts */
.toast {
  position: absolute; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background: var(--panel-2);
  border: var(--stroke-w) solid var(--stroke);
  box-shadow: var(--shadow-chip);
  font-size: calc(14px * var(--ui));
  font-weight: var(--weight-ui);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 8;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hint-tap {
  position: absolute; left: 50%; bottom: calc(64px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 6px 15px;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: var(--stroke-w) solid var(--stroke);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  font-size: calc(13px * var(--ui));
  color: var(--ink-3);
  white-space: nowrap;
  animation: fadeGone .5s ease 4s forwards;
}
@keyframes fadeGone { to { opacity: 0; visibility: hidden; } }

/* ============================== OVERLAYS ==============================
   flex + `margin: auto` on the card centres it while it fits and lets it
   scroll from the top once it doesn't — grid `place-items: center` clips
   the top of an over-tall card instead, which is how the Play button
   ended up unreachable on short viewports. */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--scrim);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: scrimIn .22s ease both;
}
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }

.overlay__card {
  position: relative;
  margin: auto;
  width: min(500px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2.2vw, 17px);
  padding: clamp(22px, 3.6vw, 30px) clamp(20px, 4vw, 30px) clamp(22px, 3.6vw, 28px);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  border: var(--card-border-w) solid var(--card-border);
  box-shadow: var(--shadow);
  text-align: center;
  animation: cardIn .34s cubic-bezier(.2, .9, .3, 1.1) both;
}
.overlay__card--slim { width: min(350px, 100%); }
.overlay__card--wide { width: min(600px, 100%); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.overlay__eyebrow {
  margin: 0;
  font-size: clamp(11px, 1.7vw, 13px);
  font-weight: var(--weight-loud);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
}
.overlay__title {
  margin: 0;
  font-size: clamp(34px, 9vw, 56px);
  font-weight: var(--weight-loud);
  line-height: 1;
  letter-spacing: .01em;
}
.overlay__title--sm { font-size: clamp(24px, 6vw, 36px); }
.overlay__body {
  margin: 0;
  max-width: 42ch;
  color: var(--ink-3);
  font-size: clamp(14px, 2.1vw, 15.5px);
  font-weight: var(--weight-body);
  line-height: 1.55;
}

/* Actions stretch so a row of buttons shares one top *and* one bottom
   edge regardless of label length or which variant is used. */
.overlay__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.overlay__actions--stack { flex-direction: column; }
.overlay__actions--stack .btn { width: 100%; }

/* ============================== BUTTONS ==============================
   Every variant carries the same `--lip` so the 3D edge lands on one
   baseline — a primary next to a ghost used to sit 8px lower. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: clamp(12px, 2vw, 14px) clamp(20px, 3.4vw, 26px);
  border-radius: var(--radius-md);
  border: 0;
  font-size: clamp(15px, 2.2vw, 16.5px);
  font-weight: var(--weight-loud);
  letter-spacing: .02em;
  line-height: 1.1;
  color: var(--accent-ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), transparent), var(--accent);
  box-shadow: 0 var(--lip) 0 var(--accent-lo), 0 calc(var(--lip) * 2) 20px rgba(0, 0, 0, .3);
  margin-bottom: var(--lip);              /* reserve the lip in layout */
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
  user-select: none;
}
.btn:hover { filter: brightness(1.07); }
.btn:active {
  transform: translateY(var(--lip));
  box-shadow: 0 0 0 var(--accent-lo), 0 3px 8px rgba(0, 0, 0, .3);
}
.btn--lg {
  padding: clamp(14px, 2.5vw, 17px) clamp(26px, 4.6vw, 36px);
  font-size: clamp(17px, 2.8vw, 19px);
}

.btn--primary {
  color: var(--accent-ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, .26), transparent), var(--accent);
  box-shadow: 0 var(--lip) 0 var(--accent-lo), 0 calc(var(--lip) * 2) 20px rgba(0, 0, 0, .3);
}
.btn--primary:active { box-shadow: 0 0 0 var(--accent-lo), 0 3px 8px rgba(0, 0, 0, .3); }

.btn--ghost {
  color: var(--ghost-ink);
  background: var(--ghost-bg);
  box-shadow: 0 var(--lip) 0 var(--ghost-lo), 0 calc(var(--lip) * 2) 20px rgba(0, 0, 0, .26),
              inset 0 0 0 var(--stroke-w) var(--stroke);
}
.btn--ghost:active {
  box-shadow: 0 0 0 var(--ghost-lo), 0 3px 8px rgba(0, 0, 0, .26),
              inset 0 0 0 var(--stroke-w) var(--stroke);
}

/* glyphs — drawn with borders so they inherit the button's colour */
.btn__play {
  width: 0; height: 0; flex: 0 0 auto;
  border-left: 13px solid currentColor;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  margin-right: 1px;
}
.btn__next {
  width: 11px; height: 11px; flex: 0 0 auto;
  border-top: 3px solid currentColor;
  border-right: 3px solid currentColor;
  transform: rotate(45deg);
  margin-left: 2px;
}

/* -------------------------------------------------------- keyboard hint */
.controls-hint {
  margin: 0;
  color: var(--ink-3);
  font-size: clamp(12px, 1.9vw, 13.5px);
  font-weight: var(--weight-ui);
  line-height: 1.7;
}
kbd {
  display: inline-block;
  min-width: 1.7em;
  margin: 0 2px;
  padding: 2px 6px 3px;
  border-radius: 7px;
  border: 0;
  background: var(--ghost-bg);
  box-shadow: inset 0 0 0 var(--stroke-w) var(--stroke), 0 2px 0 rgba(0, 0, 0, .3);
  color: var(--ink);
  font-family: inherit;
  font-size: .86em;
  font-weight: var(--weight-loud);
  line-height: 1.35;
  text-align: center;
}

/* ---------------------------------------------------------- form fields */
.overlay__row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.field { display: flex; flex-direction: column; gap: 5px; text-align: left; }
.field__label {
  font-size: 11.5px;
  font-weight: var(--weight-loud);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.field input, .field select {
  width: 150px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: var(--stroke-w) solid var(--stroke);
  background: rgba(0, 0, 0, .32);
  color: var(--ink);
  font-size: 15px;
  font-weight: var(--weight-ui);
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

/* ========================== LEVEL PICKERS ===========================
   `.levelpick` is the card grid (roll-king, sketch-drive); `.levels` is
   the numeric chip grid (endover). Both auto-fit so a five-level list
   no longer leaves an orphan on its own row. */
.levelpick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  width: 100%;
}
/* Icon beside the label rather than above it: the stacked version made a
   five-level list taller than a laptop viewport, which is how the Play
   button below it ended up off-screen. */
.levelcard {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "ico name" "ico stars";
  align-items: center;
  column-gap: 11px; row-gap: 2px;
  padding: 10px 13px;
  text-align: left;
  border-radius: var(--radius-md);
  background: var(--ghost-bg);
  border: var(--stroke-w) solid var(--stroke);
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
  overflow: hidden;
}
.levelcard:not(.is-locked):hover { transform: translateY(-2px); filter: brightness(1.1); }
.levelcard.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.levelcard.is-locked { opacity: .5; cursor: not-allowed; padding-right: 34px; }
.levelcard__emoji {
  grid-area: ico;
  font-size: 24px; line-height: 1;
  -webkit-text-stroke: 0;
}
.levelcard__name {
  grid-area: name; align-self: end;
  font-size: 15px; font-weight: var(--weight-loud); line-height: 1.2;
  color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.levelcard__stars { grid-area: stars; align-self: start; }

/* padlock, drawn rather than an emoji so it matches at every size */
.levelcard__lock {
  position: absolute; top: 50%; right: 12px;
  transform: translateY(-50%);
  width: 15px; height: 12px;
  border-radius: 3px;
  background: currentColor;
  color: var(--ink-3);
  opacity: .85;
  font-size: 0;
}
.levelcard__lock::before {
  content: "";
  position: absolute; left: 50%; bottom: 100%;
  width: 9px; height: 7px;
  margin-left: -4.5px;
  border: 2.5px solid currentColor;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
}

.levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
  width: 100%;
  max-height: 46vh;
  overflow-y: auto;
}
.level-chip {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: var(--ghost-bg);
  box-shadow: inset 0 0 0 var(--stroke-w) var(--stroke);
  font-size: 1.1rem; font-weight: var(--weight-loud);
  font-variant-numeric: tabular-nums;
  transition: transform .08s ease, background .15s ease;
}
.level-chip:hover { filter: brightness(1.25); }
.level-chip:active { transform: scale(.94); }
.level-chip.done {
  color: #04220f;
  background: linear-gradient(180deg, var(--good), color-mix(in srgb, var(--good) 60%, #000));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--good) 45%, #000);
}
.level-chip.locked { opacity: .32; pointer-events: none; }
.level-chip.current { box-shadow: inset 0 0 0 3px var(--accent); }

/* ============================ RESULT STARS ===========================
   CSS-clipped stars instead of the ★ glyph: the glyph renders at a
   different weight and baseline in every font on every platform. */
.stars { display: flex; justify-content: center; align-items: center; gap: clamp(8px, 2vw, 13px); }
.stars .star {
  width: clamp(42px, 9vw, 56px);
  height: clamp(42px, 9vw, 56px);
  flex: 0 0 auto;
  font-size: 0;
  background: var(--ghost-bg);
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .25));
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 34%);
  transition: background .2s ease, filter .2s ease;
}
.stars .star.on,
.stars .star.is-lit {
  background: linear-gradient(180deg, #ffe08a 0%, var(--gold) 48%, color-mix(in srgb, var(--gold) 62%, #000) 100%);
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .3)) drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 70%, transparent));
}
/* Inside a level card the rating is a label, not the celebration moment —
   the full-size star is built for the results screen and overflows here. */
.levelcard__stars .stars { justify-content: flex-start; gap: 3px; }
.levelcard__stars .star {
  width: 13px; height: 13px;
  filter: none;
}
.levelcard__stars .star.is-lit { filter: none; }
.levelcard__stars .stars > * { animation: none; }

.stars > * { animation: starPop .5s cubic-bezier(.34, 1.56, .64, 1) both; }
.stars > *:nth-child(2) { animation-delay: .1s; }
.stars > *:nth-child(3) { animation-delay: .2s; }
@keyframes starPop {
  0%   { opacity: 0; transform: scale(.2) rotate(-35deg); }
  70%  { opacity: 1; transform: scale(1.16) rotate(6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

/* mini stars inside a level card — same clip, chip-sized */
.levelcard__stars { display: flex; gap: 4px; align-items: center; }
.levelcard__stars span {
  width: 13px; height: 13px;
  font-size: 0;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 34%);
}
.levelcard__stars .off { background: currentColor; opacity: .28; }

/* ---------------------------------------------------------- end stats */
.endstats, .end-stats {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: clamp(16px, 4vw, 26px);
}
.endstat, .end-stat { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.endstat__val, .end-stat__value {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: var(--weight-loud);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--ink);
}
.endstat__lbl, .end-stat__label {
  font-size: 11px;
  font-weight: var(--weight-loud);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================= RESPONSIVE ============================= */
@media (max-width: 720px), (pointer: coarse) {
  .only-touch { display: inline; }
  .only-wide  { display: none; }
}

@media (max-width: 560px) {
  :root { --ui: .88; --radius-lg: 20px; --radius-md: 14px; }
  .hud__top-center { max-width: calc(100vw - 190px); }
}

/* Short landscape phones: shed the optional chrome so the primary action
   stays on screen. The overlay still scrolls if a card runs long. */
@media (max-height: 520px) {
  .overlay { padding: 12px; }
  .overlay__card { gap: 9px; padding: 14px 18px 16px; }
  .overlay__body { display: none; }
  .overlay__title { font-size: clamp(24px, 6vw, 34px); }
  .overlay__eyebrow { font-size: 10px; }
  .stars .star { width: 34px; height: 34px; }
  .levels { max-height: 34vh; }

  .levelcard { padding: 7px 11px; }
  .levelcard.is-locked { padding-right: 30px; }
  .levelcard__emoji { font-size: 19px; }
  .levelcard__name { font-size: 13.5px; }
  .levelcard__stars span { width: 11px; height: 11px; }

  .btn { padding: 9px 18px; font-size: 14.5px; --lip: 4px; }
  .btn--lg { padding: 11px 24px; font-size: 16px; }
  .controls-hint { font-size: 11.5px; }
  .endstat__val, .end-stat__value { font-size: 20px; }
}

/* ======================== TOUCH CONTROLS ============================= */
/* Built by ui.js touchPad(). `.only-touch` keeps it off fine-pointer
   devices, so a desktop player never sees a d-pad they cannot use. */
.touchpad {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(16px * var(--ui) + env(safe-area-inset-bottom));
  padding-inline: calc(16px * var(--ui) + env(safe-area-inset-left));
  display: flex;
  gap: calc(12px * var(--ui));
  justify-content: center;
  z-index: 6;
}
/* `.only-touch` is display:none globally (see BASE); re-show as flex. */
@media (pointer: coarse) {
  .touchpad.only-touch { display: flex; }
}
.touchpad__btn {
  display: grid; place-items: center;
  width: calc(62px * var(--ui));
  height: calc(62px * var(--ui));
  border-radius: 50%;
  font-size: calc(22px * var(--ui));
  color: var(--ink);
  background: var(--panel);
  border: var(--stroke-w) solid var(--stroke);
  -webkit-backdrop-filter: blur(var(--blur));
  backdrop-filter: blur(var(--blur));
  box-shadow: var(--shadow-chip);
  /* A held d-pad button must not select text or fire the iOS callout. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform .08s ease, filter .12s ease;
}
.touchpad__btn:active { transform: scale(.9); filter: brightness(1.2); }
.touchpad__btn--action {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-ink);
}

/* stat chip flash, driven by ui.js statBar().pulse() */
.stat.is-pulse { animation: chipPulse .32s ease-out 1; }

/* ========================== REDUCED MOTION =========================== */
@media (prefers-reduced-motion: reduce) {
  .overlay, .overlay__card, .stars > *, .center-shout,
  .hint-tap, .timer.is-low, .stat.is-pulse {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
  }
  .btn, .hud-btn, .levelcard { transition-duration: .01ms !important; }
  * { scroll-behavior: auto !important; }
}
