/* Wonder Chime — playful, big-tap-target styling for very little hands. */

:root {
  --round: 28%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;              /* it's a single fixed screen, never scrolls */
}

body {
  min-height: 100dvh;
  color: #fff;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 820px at 18% -12%, #3a2a6b, transparent 70%),
    radial-gradient(1000px 720px at 108% 8%, #10395f, transparent 70%),
    linear-gradient(160deg, #1b1032, #0e1b34);
  /* kill mobile tap quirks so play feels instant */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button { font-family: inherit; }

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vh, 40px);
  overflow: hidden;
}

/* ---------- top bar ---------- */
.hud { display: flex; align-items: center; gap: 12px; padding: 4px 6px 10px; }
.hud-spacer { flex: 1; }

.back {
  width: 54px; height: 54px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  font-size: 36px; line-height: 1; padding: 0 0 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.08s ease;
}
.back:active { transform: scale(0.93); }

/* Escape hatch on the new-player chooser — leave without picking anyone. */
.who-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  font-size: 26px; padding: 0;
}

.hud-right { display: flex; align-items: center; gap: 14px; }

.stars {
  display: flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 22px;
  background: rgba(255, 255, 255, 0.14);
  padding: 8px 16px; border-radius: 22px;
}
.stars .star { font-size: 20px; }

/* Session progress: the whole night as a row of moons — earned ones lit,
   the current one filling, the rest still dark (a progress bar kids can read). */
.moon-row { display: flex; align-items: center; gap: 5px; line-height: 1; }
.moon-slot { font-size: 22px; }
.moon-slot.moon-done { filter: drop-shadow(0 0 6px rgba(255, 225, 150, 0.5)); }
/* The dark 🌑 vanishes on the night sky — lift it so waiting moons stay
   readable, just quieter than the earned/current ones. */
.moon-slot.moon-todo {
  opacity: 0.8;
  filter: brightness(1.9) drop-shadow(0 0 3px rgba(200, 215, 255, 0.3));
}
.moon { font-size: 42px; line-height: 1; transition: filter 0.6s ease; }
.moon.pop { animation: moonpop 0.55s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes moonpop {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.3) rotate(10deg); }
}

/* ---------- home ---------- */
.home { align-items: center; justify-content: center; gap: clamp(28px, 7vh, 64px); }
.logo { text-align: center; }
.title {
  font-weight: 900; line-height: 0.92; letter-spacing: -0.02em;
  font-size: clamp(46px, 14vw, 116px);
  background: linear-gradient(180deg, #ffffff, #ffe1b0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 8px 34px rgba(0, 0, 0, 0.35);
}
.title span {
  display: block;
  background: linear-gradient(90deg, #ffd23f, #ff6fb5 55%, #43a9ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle {
  margin-top: 0.5em; font-weight: 700; opacity: 0.82;
  font-size: clamp(15px, 3.6vw, 22px);
}

.home-buttons { display: flex; flex-wrap: wrap; gap: clamp(16px, 4vw, 28px); justify-content: center; }
.big-btn {
  display: flex; align-items: center; gap: 0.6em;
  padding: 0.72em 1.15em;
  border: none; border-radius: 28px;
  font-weight: 800; font-size: clamp(21px, 4.6vw, 32px);
  color: #241a00; cursor: pointer;
  background: linear-gradient(180deg, #fff, #ffe6b3);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.18), 0 20px 44px rgba(0, 0, 0, 0.42);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.home-buttons .big-btn:nth-child(1) { background: linear-gradient(180deg, #8be9a3, #39c46e); color: #043a1a; } /* Play */
.home-buttons .big-btn:nth-child(2) { background: linear-gradient(180deg, #7fe3e3, #1fb6b6); color: #04302f; } /* Bands */
.home-buttons .big-btn:nth-child(3) { background: linear-gradient(180deg, #ffd98b, #ff8c3f); color: #3a1a04; } /* Guess */
.home-buttons .big-btn:nth-child(4) { background: linear-gradient(180deg, #d7b6ff, #9a5cf0); color: #2a1050; } /* Race */
.big-btn:active {
  transform: translateY(6px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 10px 24px rgba(0, 0, 0, 0.42);
}
.bb-icon { font-size: 1.5em; }
.bb-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.bb-text small { font-size: 0.48em; font-weight: 700; opacity: 0.62; }

.gear {
  position: absolute; right: 16px; bottom: 16px;
  width: 58px; height: 58px; border: none; border-radius: 50%;
  font-size: 26px; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  transition: transform 0.08s ease;
}
.gear:active { transform: scale(0.93); }

/* ---------- progression tree (home) ---------- */
.home-logo { margin-bottom: clamp(2px, 1.5vh, 14px); }
.home-logo .title { font-size: clamp(32px, 8.5vw, 64px); }

.tree { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 3vh, 24px); }
.tree-path { display: flex; flex-direction: column; align-items: center; }
/* the trail between rungs, filling gold as the next node nears waking */
.tree-conn {
  width: 8px; height: clamp(22px, 4.5vh, 44px); border-radius: 4px;
  background: linear-gradient(to top,
    #ffe6a3 calc(var(--fill, 0) * 100%),
    rgba(255, 255, 255, 0.13) calc(var(--fill, 0) * 100%));
  box-shadow: 0 0 10px rgba(255, 225, 150, calc(var(--fill, 0) * 0.6));
}

.node {
  position: relative;
  width: clamp(94px, 16vw, 146px); aspect-ratio: 1;
  border: none; border-radius: 30%; cursor: pointer;
  background: radial-gradient(120% 120% at 30% 22%, #6ea8ff, #2a5fd0);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.16), 0 18px 34px rgba(0, 0, 0, 0.4), inset 0 3px 12px rgba(255, 255, 255, 0.42);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.08s ease, filter 0.25s ease;
}
.node:active { transform: translateY(4px) scale(0.98); }
.node-face { font-size: clamp(30px, 6.5vw, 58px); line-height: 1; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.22)); }
.node-label { font-weight: 800; font-size: clamp(11px, 2.4vw, 18px); color: rgba(0, 0, 0, 0.55); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); }
/* each rung its own hue (matches the old home buttons) */
.node[data-key="bands"] { background: radial-gradient(120% 120% at 30% 22%, #7fe3e3, #1fb6b6); }
.node[data-key="guess"] { background: radial-gradient(120% 120% at 30% 22%, #ffd98b, #ff8c3f); }
.node[data-key="play"]  { background: radial-gradient(120% 120% at 30% 22%, #8be9a3, #39c46e); }
.node[data-key="race"]  { background: radial-gradient(120% 120% at 30% 22%, #d7b6ff, #9a5cf0); }

/* locked = sleeping: dim & grey. Progress toward waking is shown by the gold
   trail (.tree-conn) filling up, not a ring on the node. */
.node-locked { filter: grayscale(0.85) brightness(0.55); cursor: default; }

.tree-side { display: flex; gap: clamp(14px, 4vw, 30px); margin-top: clamp(4px, 1.5vh, 14px); }
.tree-side .node { width: clamp(70px, 11.5vw, 104px); border-radius: 28%; }
.tree-side .node-face { font-size: clamp(24px, 5vw, 44px); }
.tree-side .node-label { font-size: clamp(10px, 2vw, 15px); }

.node.just-woke { animation: woke 1s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes woke {
  0% { transform: scale(0.5) rotate(-12deg); opacity: 0.3; filter: grayscale(0.85) brightness(0.55); }
  60% { transform: scale(1.16) rotate(4deg); }
  100% { transform: scale(1); }
}
.node.wiggle { animation: shake 0.4s ease; }
.node.beckon { animation: moonpop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }

/* avatar hover peek — the player's lifetime star count at a glance */
.avatar-peek {
  position: absolute; bottom: 100%; left: 0; margin-bottom: 10px;
  padding: 10px 14px; border-radius: 16px;
  display: flex; align-items: center; gap: 6px;
  font-size: 20px; font-weight: 800; color: #fff; /* the button parent's UA black is invisible here */
  background: rgba(20, 16, 40, 0.97); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(6px) scale(0.9); transform-origin: bottom left;
  transition: opacity 0.15s ease, transform 0.15s ease; pointer-events: none;
}
.avatar-peek .star { font-size: 18px; }
.avatar-corner:hover .avatar-peek { opacity: 1; transform: translateY(0) scale(1); }
@media (hover: none) { .avatar-peek { display: none; } } /* touch has no hover — tap opens the card */
.avatar-corner-face { font-size: inherit; line-height: 1; }

/* profile card (tap the avatar) */
.profile-card { text-align: center; }
.profile-av {
  width: 84px; height: 84px; margin: 0 auto 6px; border-radius: 26%;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  display: flex; align-items: center; justify-content: center; font-size: 46px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.14), 0 14px 28px rgba(0, 0, 0, 0.4), inset 0 3px 10px rgba(255, 255, 255, 0.5);
}
.profile-name { font-weight: 800; font-size: 22px; margin-bottom: 10px; }
.profile-stars {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 26px; font-weight: 800; margin-bottom: 18px;
}
.profile-stars .star { font-size: 24px; }

/* ---------- creature grid ---------- */
/* Sized wrapper the grid measures itself against (100cqh = space it may fill). */
.grid-fit {
  flex: 1; min-height: 0; align-self: stretch;
  container-type: size;
  display: flex; align-items: center; justify-content: center;
}
.grid {
  --gap: clamp(12px, 3vw, 26px);
  --cols: 1;
  --rows: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
  /* Cells are square (aspect-ratio), so cap the width four ways: a max cell
     size, the viewport width, the wrapper's own width (a Star Race half is
     much narrower than the screen), and whatever keeps the whole grid — rows
     of square cells plus gaps — inside the wrapper height. */
  width: min(
    calc(280px * var(--cols) + (var(--cols) - 1) * var(--gap)),
    94vw,
    100cqw,
    calc((100cqh - (var(--rows) - 1) * var(--gap)) * var(--cols) / var(--rows)
         + (var(--cols) - 1) * var(--gap))
  );
}

/* Two-row grid for order-free targets (bands): both rows centered, so a short
   last row sits centered below (2 on top, 1 centered under). Tiles are sized
   against the free space (.grid-fit is a size container) so both rows always
   fit — same idea as .grid above. */
.stagger {
  --cgap: clamp(12px, 3vw, 26px);
  --rgap: clamp(10px, 2.5vh, 24px);
  width: 100%; height: 100%;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: var(--rgap);
}
.stagger-row { display: flex; gap: var(--cgap); justify-content: center; }
.stagger .creature {
  width: min(
    260px,
    calc((94cqw - (var(--maxcols) - 1) * var(--cgap)) / var(--maxcols)),
    calc((100cqh - (var(--rows) - 1) * var(--rgap)) / var(--rows))
  );
}

.creature {
  position: relative;
  aspect-ratio: 1;
  container-type: inline-size;   /* lets face/label scale with the cell (cqw) */
  border: none; border-radius: var(--round);
  cursor: pointer;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.16),
    0 18px 34px rgba(0, 0, 0, 0.4),
    inset 0 3px 12px rgba(255, 255, 255, 0.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform 0.08s ease, opacity 0.25s ease, filter 0.25s ease;
}
.creature .face {
  font-size: clamp(20px, 46cqw, 96px); line-height: 1;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.22));
}
.creature .label {
  margin-top: 0.28em; font-weight: 800;
  font-size: clamp(9px, 11cqw, 21px);
  color: rgba(0, 0, 0, 0.55); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.creature:active { transform: translateY(4px) scale(0.98); }
/* The black band (Eguchi's ACF) is a dark tile — its label needs light text. */
.creature.band[data-id="inky"] .label { color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45); }
/* Keyboard focus must be visible (mouse taps never trigger :focus-visible). */
.creature:focus-visible, .singer:focus-visible, .big-btn:focus-visible,
.avatar-tile:focus-visible, .back:focus-visible, .gear:focus-visible {
  outline: 4px solid rgba(255, 255, 255, 0.92);
  outline-offset: 3px;
}

.creature.pop   { animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
/* A short finite dance, landing settled — the round advances on a 1.9s timer
   and an infinite loop got cut mid-hop (an abrupt snap back to rest). The
   half cycle is fine: the 50% keyframe is also the resting pose. */
.creature.dance { animation: dance 0.6s ease 1.5; }
/* A wrong tap feels like a real button: it punches DOWN under the finger,
   springs back up, then buzzes "no" — press and shake as one motion. */
.creature.shake { animation: press-shake 0.5s ease; }
.creature.dim   { opacity: 0.34; filter: grayscale(0.35); }
.creature.hint::after {
  content: ""; position: absolute; inset: -6%;
  border-radius: calc(var(--round) + 4%);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.85);
  animation: hintpulse 1s ease infinite;
}

@keyframes pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.12) rotate(-3deg); }
  60% { transform: scale(0.97) rotate(2deg); }
  100% { transform: scale(1); }
}
@keyframes dance {
  0%, 50%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-14px) rotate(-5deg); }
  75% { transform: translateY(-14px) rotate(5deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
/* press (down) then shake (buzz), in one go — see .creature.shake */
@keyframes press-shake {
  0%   { transform: translateY(5px) scale(0.96); }  /* punched down under the finger */
  18%  { transform: translateY(0) scale(1); }        /* springs back up */
  33%  { transform: translateX(-8px); }              /* then buzzes side to side */
  49%  { transform: translateX(8px); }
  65%  { transform: translateX(-6px); }
  82%  { transform: translateX(6px); }
  100% { transform: translateX(0); }
}
@keyframes hintpulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

/* ---------- challenge ---------- */
/* overflow visible: the singer's ring animation spreads ~42px past the button,
   more than the headroom above it — .stage's hidden would slice the halo flat. */
.quiz-stage { justify-content: space-between; padding: clamp(8px, 3vh, 26px) 0; overflow: visible; }
/* On a phone the "Listen" singer sat glued to the very top — a stretch for a
   thumb. Drop the whole cluster down: the answers stay in the easy bottom
   zone and the singer comes within reach. (The kids' wide tablet is unchanged.) */
@media (max-width: 640px) {
  .quiz-stage { padding-top: clamp(48px, 18vh, 180px); }
}
.singer-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.singer {
  position: relative;
  width: clamp(120px, 30vw, 200px); aspect-ratio: 1;
  border: none; border-radius: 50%; cursor: pointer;
  background: radial-gradient(130% 130% at 30% 25%, #fff, #cfe3ff 55%, #8bb4ff);
  box-shadow:
    0 12px 0 rgba(0, 0, 0, 0.14),
    0 22px 50px rgba(0, 0, 0, 0.42),
    inset 0 4px 14px rgba(255, 255, 255, 0.7);
  display: flex; align-items: center; justify-content: center;
}
.singer-face { font-size: clamp(48px, 14vw, 96px); }
.singer:active { transform: translateY(4px) scale(0.99); }
/* Sound ripple: a static ring on the pseudo-element, scaled + faded on the
   GPU — animating box-shadow repaints every frame right as the note sounds. */
.singer::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.7);
  opacity: 0;
  pointer-events: none;
}
.singer.ring::after { animation: ring 0.6s ease-out; }
@keyframes ring {
  from { opacity: 0.7; transform: scale(1); }
  to   { opacity: 0; transform: scale(1.42); }
}
.cue { font-weight: 800; font-size: clamp(18px, 4vw, 26px); opacity: 0.9; }
/* .answers is a JS hook only (see clearAnswerFx); sizing comes from .grid-fit/.grid. */

/* ---------- session finale ---------- */
.finale {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(14px, 3.5vh, 30px);
  background: rgba(9, 7, 22, 0.88); backdrop-filter: blur(8px);
  animation: fadein 0.7s ease;
}
.finale .big-moon {
  font-size: clamp(110px, 32vw, 210px); line-height: 1;
  filter: drop-shadow(0 0 70px rgba(255, 225, 150, 0.55));
  animation: moonfloat 3.6s ease-in-out infinite;
}
.finale-msg { font-weight: 800; font-size: clamp(20px, 4.5vw, 30px); opacity: 0.92; }
.finale .replay {
  width: clamp(84px, 18vw, 110px); aspect-ratio: 1;
  border: none; border-radius: 50%; cursor: pointer;
  font-size: clamp(42px, 9vw, 56px); line-height: 1; padding: 0 0 8px;
  color: #241a00; background: linear-gradient(180deg, #fff, #ffe6b3);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25), 0 18px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.finale .replay:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25), 0 8px 20px rgba(0, 0, 0, 0.5); }
.finale-home {
  width: 54px; height: 54px; border: none; border-radius: 50%;
  font-size: 24px; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  transition: transform 0.08s ease;
}
.finale-home:active { transform: scale(0.93); }
@keyframes fadein { from { opacity: 0; } }
@keyframes moonfloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

/* ---------- settings ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 8, 20, 0.6); backdrop-filter: blur(6px);
  transition: opacity 0.18s ease-out;
  @starting-style { opacity: 0; }
}
.card {
  width: min(460px, 94vw); max-height: 90dvh; overflow: auto;
  background: #20183a; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transition: transform 0.18s ease-out;
  @starting-style { transform: scale(0.97); }
}
.card h2 { margin: 0 0 6px; font-size: 26px; }
.hint-text { margin: 0 0 18px; opacity: 0.75; font-size: 15px; line-height: 1.45; }
.step-label { font-weight: 800; margin-bottom: 10px; text-align: center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px; }
/* Reads under the friends stepper; the star row grows with the count, so the
   more-friends = bigger-prize deal is visible before any catch is made. */
.step-payout { text-align: center; margin: -12px 0 20px; font-size: 15px; opacity: 0.85; letter-spacing: 1px; }
.step {
  width: 66px; height: 66px; border: none; border-radius: 20px;
  font-size: 34px; font-weight: 800; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff;
}
.step:disabled { opacity: 0.3; }
.step-val { font-size: 42px; font-weight: 900; min-width: 60px; text-align: center; }
.step-val.moons { font-size: 24px; letter-spacing: 2px; }
.legend { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.legend-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.06); padding: 8px 12px; border-radius: 14px;
}
.legend-row b { font-weight: 800; }
.legend-row small { opacity: 0.7; }
.legend-row .dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2); }
.legend-row .lg-emoji { font-size: 22px; }
.legend-row .hear {
  margin-left: auto; width: 42px; height: 42px; border: none; border-radius: 50%;
  font-size: 15px; cursor: pointer; background: rgba(255, 255, 255, 0.14); color: #fff;
}
.done {
  width: 100%; padding: 16px; border: none; border-radius: 18px;
  font-weight: 800; font-size: 20px; cursor: pointer;
  background: linear-gradient(180deg, #8be9a3, #39c46e); color: #043a1a;
}

/* ---------- who's playing (Netflix-style picker) ---------- */
.who { align-items: center; justify-content: center; gap: clamp(22px, 5vh, 48px); }
.who-title {
  font-weight: 900; letter-spacing: -0.01em;
  font-size: clamp(28px, 6.5vw, 48px);
  text-shadow: 0 6px 26px rgba(0, 0, 0, 0.4);
}
.who-grid { display: flex; flex-wrap: wrap; gap: clamp(14px, 3vw, 28px); justify-content: center; padding: 0 16px; }
.avatar-tile {
  width: clamp(108px, 24vw, 170px); aspect-ratio: 1;
  border: none; border-radius: 26%;
  cursor: pointer;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  box-shadow:
    0 8px 0 rgba(0, 0, 0, 0.16),
    0 16px 30px rgba(0, 0, 0, 0.4),
    inset 0 3px 10px rgba(255, 255, 255, 0.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform 0.08s ease;
}
.avatar-tile:active { transform: translateY(4px) scale(0.98); }
.avatar-tile .avatar-face { font-size: clamp(42px, 10vw, 72px); line-height: 1; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.22)); }
.avatar-tile .avatar-name { font-weight: 800; font-size: clamp(13px, 2.6vw, 19px); color: rgba(0, 0, 0, 0.55); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35); }
.avatar-tile.add { background: rgba(255, 255, 255, 0.1); box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12), 0 16px 30px rgba(0, 0, 0, 0.3); }
.avatar-tile.add .avatar-face { color: #fff; filter: none; }
.avatar-tile.add .avatar-name { color: rgba(255, 255, 255, 0.8); text-shadow: none; }

/* the always-there corner avatar: who's playing, tap to switch */
.avatar-corner {
  position: absolute; left: 16px; bottom: 16px; z-index: 5;
  width: 58px; height: 58px; border: none; border-radius: 50%;
  font-size: 27px; line-height: 1; cursor: pointer;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18), 0 10px 22px rgba(0, 0, 0, 0.35), inset 0 2px 6px rgba(255, 255, 255, 0.45);
  transition: transform 0.08s ease;
}
.avatar-corner:active { transform: scale(0.93); }

/* guest: a dimmed "mystery friend" — background furniture, not a shiny button.
   Tapping it opens the creature picker; the star peek shows what's waiting. */
.avatar-corner.avatar-guest {
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  box-shadow: none;
}
.avatar-guest .avatar-corner-face { opacity: 0.55; }
.avatar-guest:hover .avatar-corner-face { opacity: 0.9; }

/* first-goodnight identity pick (guest -> avatar; claims the night's stars) */
.finale.compact .big-moon { font-size: clamp(72px, 18vw, 130px); }
.gn-pick { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 0 18px; }
.gn-pick-title { font-weight: 800; font-size: clamp(17px, 3.8vw, 24px); opacity: 0.95; text-align: center; text-wrap: balance; }
.gn-pick-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 880px; }
.gn-pick-grid .creature { width: clamp(58px, 10vw, 88px); }
.gn-pick-grid .creature .label { display: none; }

/* goodnight name ask (parent-typed, always skippable) */
.name-ask { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 0 20px; }
.name-input {
  padding: 12px 16px; border: none; border-radius: 14px;
  font-family: inherit; font-weight: 700; font-size: 17px;
  background: rgba(255, 255, 255, 0.94); color: #241a00;
  width: min(300px, 62vw);
  user-select: text; -webkit-user-select: text;
}
.name-save, .name-later {
  padding: 12px 18px; border: none; border-radius: 14px;
  font-weight: 800; font-size: 16px; cursor: pointer;
}
.name-save { background: linear-gradient(180deg, #8be9a3, #39c46e); color: #043a1a; }
.name-later { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* player rows in grown-up settings */
.prof-name {
  flex: 1; min-width: 0; padding: 8px 10px; border: none; border-radius: 10px;
  font-family: inherit; font-weight: 700; font-size: 15px;
  background: rgba(255, 255, 255, 0.1); color: #fff;
  user-select: text; -webkit-user-select: text;
}
.prof-name::placeholder { color: rgba(255, 255, 255, 0.45); }
.prof-del {
  border: none; border-radius: 10px; padding: 8px 10px; min-width: 44px;
  background: rgba(255, 255, 255, 0.1); color: #fff; cursor: pointer; font-size: 14px; font-weight: 700;
}
.legend-row.active-prof { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4); }
.progress-btn {
  width: 100%; padding: 13px; margin-bottom: 12px; border: none; border-radius: 16px;
  font-weight: 800; font-size: 17px; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff;
}
.prog-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.prog-row {
  display: grid; grid-template-columns: 28px 64px 1fr 74px; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.06); padding: 9px 12px; border-radius: 14px;
}
.prog-row .lg-emoji { font-size: 20px; }
.prog-row b { font-weight: 800; font-size: 15px; }
.prog-row small { text-align: right; opacity: 0.75; font-variant-numeric: tabular-nums; }
.prog-bar { height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #ffd23f, #8be9a3); }
.prog-conf { font-size: 12.5px; opacity: 0.65; padding: 0 12px 2px; margin-top: -4px; }

/* ---------- star race (two players, one screen) ---------- */
/* The split is left/right — the kids sit side by side at the tablet, so each
   racer owns the half in front of them (setup panes and game halves alike). */
.race-body { flex: 1; min-height: 0; display: flex; gap: clamp(6px, 1.2vw, 14px); }

/* setup: pick who's racing and how many friends each side hunts */
.race-setup { gap: clamp(6px, 1.5vh, 14px); }
.race-title { font-weight: 900; font-size: clamp(20px, 4.5vw, 30px); }
.race-pane {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(6px, 1.4vh, 12px);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 24px; padding: 10px;
}
.race-pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.race-pick .avatar-tile { width: clamp(56px, 10vh, 92px); border-radius: 22%; }
.race-pick .avatar-tile .avatar-face { font-size: clamp(24px, 5vh, 42px); }
.race-pick .avatar-tile .avatar-name { font-size: clamp(10px, 1.8vh, 14px); }
.race-pick .avatar-tile.picked { box-shadow: 0 0 0 4px #fff, 0 8px 0 rgba(0, 0, 0, 0.16), 0 16px 30px rgba(0, 0, 0, 0.4); }
/* racing on the other side — still tappable: one tap swaps the kids over */
.race-pick .avatar-tile.taken { opacity: 0.42; filter: grayscale(0.5); }
.race-cast { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; }
.race-cast .step { width: 52px; height: 52px; font-size: 26px; border-radius: 16px; }
.race-faces { font-size: clamp(17px, 3.2vh, 26px); letter-spacing: 3px; text-align: center; }
.race-payout { font-size: 14px; opacity: 0.85; letter-spacing: 1px; text-align: center; }
.race-mid-setup {
  flex: none; align-self: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(14px, 4vh, 30px);
}
.race-rounds { display: flex; align-items: center; gap: 10px; }
.race-rounds .step { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
.race-rounds-val { text-align: center; min-width: 78px; font-weight: 800; line-height: 1.1; }
.race-rounds-val b { font-size: 26px; display: block; }
.race-rounds-val small { opacity: 0.7; font-size: 12px; }
.race-go {
  border: none; border-radius: 22px; cursor: pointer;
  padding: 12px 28px; font-weight: 900; font-size: clamp(20px, 4vw, 26px);
  background: linear-gradient(180deg, #8be9a3, #39c46e); color: #043a1a;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18), 0 16px 34px rgba(0, 0, 0, 0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.race-go:active { transform: translateY(5px); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 8px 18px rgba(0, 0, 0, 0.4); }

/* the race itself: two halves side by side around a shared singer column */
.race-back {
  position: absolute; z-index: 5;
  top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left));
  width: 44px; height: 44px; font-size: 28px;
}
.race { padding-top: max(58px, env(safe-area-inset-top)); } /* clear the back button */
.race-half {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 4px;
  border-radius: 20px; padding: 2px 4px;
  transition: opacity 0.35s ease, filter 0.35s ease;
}
.race-half.waiting { opacity: 0.35; filter: grayscale(0.45); pointer-events: none; }
.race-hud { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.race-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 18px;
  font-weight: 800; font-size: 15px;
  background: radial-gradient(120% 160% at 30% 20%, var(--c1), var(--c2));
  color: rgba(0, 0, 0, 0.6); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.race-chip-face { font-size: 20px; line-height: 1; }
.race-score { font-size: 18px; padding: 5px 12px; }
.race-score .star { font-size: 16px; }
.race-dots { display: flex; gap: 5px; }
.race-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.race-dot.d-done { background: #ffd23f; box-shadow: 0 0 8px rgba(255, 210, 63, 0.8); }
.race-dot.d-current { background: rgba(255, 255, 255, 0.55); animation: hintpulse 1s ease infinite; }
/* overflow visible for the same reason as .quiz-stage: the singer's ring halo */
.race-mid {
  flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2.5vh, 20px); padding: 0 4px; overflow: visible;
}
.race-turn-chip {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16), inset 0 2px 6px rgba(255, 255, 255, 0.4);
}
.race-turn-chip.pop { animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
.singer.race-singer { width: clamp(58px, 10vw, 110px); }
.race-singer .singer-face { font-size: clamp(24px, 4.5vw, 52px); }
.race .cue { font-size: clamp(13px, 1.8vw, 18px); text-align: center; }

/* podium finale: both piles on show, the champ crowned — a winner, no losers */
.race-finale { gap: clamp(10px, 2.5vh, 22px); }
.race-podium { display: flex; align-items: flex-end; gap: clamp(24px, 8vw, 64px); }
.race-podium-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.race-crown { height: 40px; font-size: 34px; line-height: 40px; }
.race-champ .race-crown { animation: moonfloat 2.4s ease-in-out infinite; }
.race-podium-face {
  width: clamp(84px, 18vw, 140px); aspect-ratio: 1; border-radius: 26%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(44px, 9vw, 72px); line-height: 1;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.16), 0 16px 30px rgba(0, 0, 0, 0.4), inset 0 3px 10px rgba(255, 255, 255, 0.5);
}
.race-champ .race-podium-face {
  transform: scale(1.12);
  box-shadow: 0 0 0 5px #ffd23f, 0 0 44px rgba(255, 210, 63, 0.55), 0 16px 30px rgba(0, 0, 0, 0.4), inset 0 3px 10px rgba(255, 255, 255, 0.5);
}
.race-podium-name { font-weight: 800; font-size: clamp(15px, 3vw, 20px); }
.race-podium-score { font-weight: 900; font-size: clamp(18px, 4vw, 26px); }
.race-keep { opacity: 0.75; font-weight: 700; font-size: clamp(13px, 2.8vw, 16px); }

/* ---------- confetti ---------- */
.confetti-piece {
  position: fixed; width: 14px; height: 14px; border-radius: 3px;
  pointer-events: none; z-index: 70;   /* above the finale overlay too */
  will-change: transform, opacity;
  transition: transform 1.1s cubic-bezier(0.15, 0.6, 0.4, 1), opacity 1.1s ease;
}

/* Stars earned by a catch, in flight to the counter (see starBurst). */
.star-fly {
  position: fixed; font-size: 26px; line-height: 1;
  pointer-events: none; z-index: 70;
  transform: translate(-50%, -50%);
  will-change: transform;
  transition: transform 0.52s cubic-bezier(0.3, 0, 0.6, 1);
  filter: drop-shadow(0 0 6px rgba(255, 225, 150, 0.7));
}
.stars.bump { animation: star-bump 0.25s ease; }
@keyframes star-bump {
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Respect users who ask for less motion: drop movement, keep the gentle
   opacity feedback (hint glow, sound ripple, overlay fade). */
@media (prefers-reduced-motion: reduce) {
  .creature.dance { animation: none; }
  .creature.pop { animation: none; }
  .creature.shake { animation: none; }
  .card { transition: none; }
  .confetti-piece { display: none; }
  .finale .big-moon { animation: none; }
  .moon.pop { animation: none; }
  .star-fly { display: none; }
  .stars.bump { animation: none; }
  .race-turn-chip.pop { animation: none; }
  .race-dot.d-current { animation: none; }
  .race-champ .race-crown { animation: none; }
}
