/* Sopo: Bead Strings — two rows of ten beads on a wooden rack.
   Warm cream, wood, honey, gold and the coral/bone bead materials.
   No pure green or blue dominates the interface; green is reserved for OK. */

/* The hidden attribute is a contract, not a hint: no author display rule may
   out-rank it, or a stacked panel, video or still would stay on screen. */
[hidden] { display: none !important; }

@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fredoka-400.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("assets/fredoka-600.woff2") format("woff2");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #cfe9f4;
}

body {
  font-family: "Fredoka", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--wm-ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

img, video { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ shell -- */

.shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  height: 100dvh;
  isolation: isolate;
}

.world {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
}
.world img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 62%; }

#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.screen { position: relative; z-index: 10; }

.shell[data-state="loading"] .screen,
.shell[data-state="intro"] .game,
.shell:not([data-state="intro"]):not([data-state="loading"]) .intro { display: none; }
.shell[data-state="intro"] .intro { display: grid; }
.shell:not([data-state="intro"]):not([data-state="loading"]) .game { display: grid; }

/* Corner rune: fixed, bottom-left, above overlays, never interactive. */
.rune {
  position: fixed;
  left: max(8px, env(safe-area-inset-left));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 200;
  width: clamp(38px, 7vmin, 74px);
  height: auto;
  opacity: 0.92;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgb(61 50 38 / 0.35));
}

/* ------------------------------------------------------------------ intro -- */

.intro {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
}

.intro-art { position: absolute; inset: 0; z-index: -1; }
.intro-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }

.intro-frame {
  justify-self: center;
  align-self: start;
  margin-top: 4px;
  padding: 8px 22px 10px;
  text-align: center;
  background: linear-gradient(180deg, rgb(255 248 230 / 0.96), rgb(246 231 200 / 0.94));
  border: 3px solid var(--wm-wood-2);
  border-radius: var(--wm-radius-card);
  box-shadow: var(--wm-shadow-card);
}
#introTitle {
  margin: 0;
  font-size: clamp(22px, 4.4vmin, 46px);
  line-height: 1.05;
  color: #6f411f;
}

.intro-actions {
  grid-row: 3;
  justify-self: center;
  align-self: end;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

.play-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 128px;
  min-height: 64px;
  padding: 6px 20px 6px 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff8e6, #f6e7c8);
  box-shadow: var(--wm-shadow-card);
  cursor: pointer;
}
.play-button img { width: 56px; height: 56px; object-fit: contain; }
.play-word {
  font-size: clamp(20px, 2.6vmin, 28px);
  font-weight: 700;
  color: var(--wm-wood-2);
  letter-spacing: 0.02em;
}
.play-button:active { transform: translateY(2px) scale(0.98); }

.intro-caption {
  margin: 0;
  padding: 5px 14px;
  max-width: min(92vw, 560px);
  text-align: center;
  font-size: clamp(13px, 1.9vmin, 18px);
  color: #16324a;
  background: rgb(255 248 230 / 0.9);
  border-radius: 999px;
}
.intro-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* -------------------------------------------------------- hud and controls -- */

.game {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
}

.hud {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "controls progress goal";
  align-items: center;
  gap: 6px 12px;
}

.controls {
  grid-area: controls;
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  gap: 6px;
}

.image-button {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
.image-button img { pointer-events: none; }

.control {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  border-radius: 50%;
  filter: drop-shadow(0 3px 2px rgb(70 48 30 / 0.3));
}
.control img { width: 100%; height: 100%; object-fit: contain; }
.control:active { transform: translateY(2px) scale(0.96); }

.hud-progress {
  grid-area: progress;
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
}
.hud-level-name {
  margin: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(12px, 1.9vmin, 18px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wm-wood-2);
}
.hud-tokens { display: flex; flex-flow: row wrap; align-items: center; justify-content: center; gap: 4px 14px; min-width: 0; }
.level-track, .round-track { display: flex; flex-flow: row nowrap; align-items: center; gap: 5px; }

.level-prop {
  width: clamp(18px, 2.6vmin, 26px);
  height: clamp(18px, 2.6vmin, 26px);
  border-radius: 50%;
  border: 2px solid var(--wm-wood-2);
  background: rgb(255 248 230 / 0.55);
}
.level-prop.is-earned {
  background: radial-gradient(circle at 34% 30%, #ffd977, #e98978 70%);
  border-color: #a4483a;
}
.round-track img { width: clamp(20px, 3vmin, 32px); height: clamp(20px, 3vmin, 32px); }

.goal {
  grid-area: goal;
  justify-self: end;
  display: grid;
  justify-items: center;
  min-width: clamp(84px, 12vmin, 132px);
  padding: 4px 14px 6px;
  background: linear-gradient(180deg, rgb(255 248 230 / 0.96), rgb(246 231 200 / 0.94));
  border: 3px solid var(--wm-wood-2);
  border-radius: var(--wm-radius-card);
  box-shadow: var(--wm-shadow-card);
}
.goal-caption {
  margin: 0;
  font-size: clamp(11px, 1.6vmin, 15px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--wm-wood-2);
}
.goal-number {
  margin: -2px 0 0;
  font-size: clamp(30px, 6.4vmin, 64px);
  font-weight: 800;
  line-height: 1;
  color: #6f411f;
}
/* The goal shows the target as real beads — two rows of at most ten, each row
   five coral then five ivory, so the picture matches the rack material. */
.goal-pattern { display: grid; gap: 2px; margin: 3px 0 0; }
.goal-pattern[hidden] { display: none; }
.goal-pattern .mini-rod { display: flex; align-items: center; gap: 1px; }
.goal-pattern .mini-rod .mini-bead:nth-child(5) { margin-right: clamp(2px, 0.7vmin, 5px); }
/* A full row of ten stays legible without widening the card, and a target of
   one to five shows beads large enough for a non-reading child to recognise. */
.goal-pattern .mini-bead { width: clamp(10px, 1.5vmin, 12px); height: clamp(10px, 1.5vmin, 12px); }
.goal-pattern.is-few .mini-bead { width: clamp(18px, 2.8vmin, 26px); height: clamp(18px, 2.8vmin, 26px); }
.goal-note {
  margin: 3px 0 0;
  font-size: clamp(10px, 1.4vmin, 13px);
  color: #5b4b3a;
  text-align: center;
}

/* --------------------------------------------------------------- the stage -- */

.stage {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(0, 3fr) minmax(120px, 0.9fr);
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.guide, .hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 0;
}
.guide-art, .hero-art { width: min(100%, 230px); height: auto; object-fit: contain; }
.hero-art { width: min(100%, 216px); }
.char-loop[hidden] { display: none; }

.speech {
  margin: 0;
  max-width: 30ch;
  padding: 8px 14px;
  text-align: center;
  font-size: clamp(14px, 2vmin, 20px);
  line-height: 1.25;
  color: var(--wm-ink);
  background: linear-gradient(180deg, #fff8e6, #f6e7c8);
  border: 3px solid var(--wm-wood-1);
  border-radius: var(--wm-radius-card);
  box-shadow: var(--wm-shadow-card);
}

.board-area {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

.rack-wrap {
  width: 100%;
  max-width: 920px;
  display: grid;
  padding: clamp(10px, 2vmin, 20px) clamp(10px, 2vmin, 22px);
  background: linear-gradient(180deg, rgb(201 143 90 / 0.94), rgb(138 85 44 / 0.94));
  border: 4px solid #6f411f;
  border-radius: 26px;
  box-shadow: inset 0 3px 0 rgb(255 248 230 / 0.28), 0 12px 22px rgb(40 26 14 / 0.34);
}

.board {
  --bead: 34px;
  --gap: 30px;
  --pad: 12px;
  --grip: 13px;
  display: grid;
  gap: clamp(10px, 2.4vmin, 26px);
  justify-items: center;
  width: 100%;
  touch-action: none;
}

.rod {
  position: relative;
  width: calc(10 * var(--bead) + var(--gap) + 2 * var(--pad));
  max-width: 100%;
  height: calc(var(--bead) + 2 * var(--pad));
}

.rod-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: calc(var(--bead) * 0.2);
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #e6c79b, #b07a45 60%, #7d4a24);
  box-shadow: inset 0 2px 0 rgb(255 248 230 / 0.4);
}

/* Clear left "counted" zone. */
.tray {
  position: absolute;
  left: 0;
  top: 50%;
  height: calc(var(--bead) + 4px);
  transform: translateY(-50%);
  width: calc(var(--c) * var(--bead) + var(--gap) / 2);
  border-radius: 999px;
  background: linear-gradient(180deg, rgb(255 226 166 / 0.5), rgb(242 193 65 / 0.28));
  box-shadow: inset 0 0 0 2px rgb(255 248 230 / 0.4);
  transition: width 180ms cubic-bezier(.22,.9,.3,1.1);
}

.grip {
  position: absolute;
  top: calc(50% - (var(--bead) + var(--pad)) * 0.56);
  width: var(--grip);
  height: calc((var(--bead) + var(--pad)) * 1.12);
  left: calc(var(--c) * var(--bead) + var(--gap) / 2 - var(--grip) / 2);
  border-radius: 999px;
  background: linear-gradient(90deg, #8a552c, #d9a976 45%, #8a552c);
  box-shadow: 0 2px 3px rgb(40 26 14 / 0.45);
  transition: left 180ms cubic-bezier(.22,.9,.3,1.1);
}

.bead {
  position: absolute;
  left: 0;
  top: var(--pad);
  width: var(--bead);
  height: var(--bead);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  touch-action: none;
  transform: translateX(var(--x, 0px));
  transition: transform 180ms cubic-bezier(.22,.9,.3,1.1);
}
.bead::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgb(255 255 255 / 0.75) 0 18%, transparent 40%),
    radial-gradient(circle at 50% 55%, var(--bead-face, #e98978) 0 60%, var(--bead-edge, #b8564a) 100%);
  box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.22), 0 2px 3px rgb(40 26 14 / 0.3);
}
.bead--bone { --bead-face: #f4e6c7; --bead-edge: #cbb489; }
.bead--coral { --bead-face: #ea8f7c; --bead-edge: #b8564a; }

.bead--supply::after { filter: saturate(0.92) brightness(0.99); }
.bead--active::after { filter: saturate(1.06) brightness(1.02); }

.bead.is-preview::after {
  box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.22), 0 0 0 3px var(--wm-gold), 0 0 12px rgb(242 193 65 / 0.75);
}
/* The scripted demonstration: the finger rides this bead and the guided group
   slides without its own transition, so the finger is never behind the bead. */
.bead.is-guided { transition: none; }
.bead.is-grabbed::after {
  box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.22), 0 0 0 3px #fff8e6, 0 0 0 6px var(--wm-gold);
}
/* A brief, unscored gold result on the shown rack after the demo presses OK.
   It never travels to the child's own task and never awards a star. */
.board.is-demo-correct .bead--active::after {
  box-shadow: inset 0 -3px 5px rgb(0 0 0 / 0.22), 0 0 0 3px var(--wm-gold), 0 0 14px rgb(242 193 65 / 0.85);
}
.bead:focus-visible { outline: none; }
.bead:focus-visible::after { box-shadow: 0 0 0 3px #fff8e6, 0 0 0 6px var(--wm-gold); }

.rod.is-drop row, .rod.is-drop { }
.rod.is-drop .rod-track { box-shadow: inset 0 2px 0 rgb(255 248 230 / 0.4), 0 0 0 3px var(--wm-gold); }

/* --------------------------------------------------------- compare + OK bar -- */

.compare {
  display: grid;
  gap: 5px;
  justify-items: center;
  padding: 6px 16px;
  background: rgb(255 248 230 / 0.96);
  border: 3px solid var(--wm-wood-1);
  border-radius: var(--wm-radius-card);
  box-shadow: var(--wm-shadow-card);
  text-align: center;
}
.compare[hidden] { display: none; }
.compare.is-repeat { border-color: #c98f5a; background: #fff3d6; }
.cmp-frames { display: grid; gap: 4px; padding: 4px 6px; border-radius: 12px; background: rgb(201 143 90 / 0.16); }
.cmp-frames[hidden] { display: none; }
.cmp-row { display: flex; align-items: center; }
.cmp-cell {
  display: block;
  width: clamp(9px, 1.6vmin, 15px);
  height: clamp(9px, 1.6vmin, 15px);
  margin-right: 2px;
  border: 2px solid #b07a45;
  border-radius: 3px;
  background: rgb(255 248 230 / 0.9);
}
.cmp-row .cmp-cell:nth-child(5) { margin-right: 9px; }
.cmp-cell.is-on {
  background: radial-gradient(circle at 36% 30%, #ffd977, var(--wm-gold) 65%, #d99b23);
  border-color: #a4691a;
}
.cmp-line { margin: 0; display: flex; gap: 18px; justify-content: center; align-items: baseline; }
.cmp-made, .cmp-goal { font-size: clamp(13px, 1.8vmin, 17px); color: #5b4b3a; }
.cmp-made b, .cmp-goal b { font-size: clamp(20px, 3vmin, 30px); color: #6f411f; }
.cmp-hint { margin: 0; font-size: clamp(12px, 1.7vmin, 16px); color: #6b4a24; }

.answer-bar { display: grid; justify-items: center; }
.ok-button {
  width: clamp(64px, 11vmin, 96px);
  height: clamp(64px, 11vmin, 96px);
  border-radius: 50%;
  filter: drop-shadow(0 4px 3px rgb(40 26 14 / 0.35));
}
.ok-button img { width: 100%; height: 100%; object-fit: contain; }
.ok-button:active { transform: translateY(2px) scale(0.96); }
.ok-button[aria-disabled="true"] { cursor: default; }
.ok-button.is-nudge { animation: ok-nudge 480ms ease-in-out; }
/* The demonstration really presses the button after the check recording; the
   button stays disabled, so this is a visual result, not child input. */
.ok-button.is-demo-press { transform: translateY(3px) scale(0.9); }
@keyframes ok-nudge { 0%,100% { transform: translateY(0) scale(1); } 45% { transform: translateY(-4px) scale(1.08); } }

/* ------------------------------------------------------------- demo helper -- */

.tutorial-hand {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 70;
  width: clamp(44px, 8vmin, 84px);
  pointer-events: none;
  /* Same fingertip anchor game.js applies: the art's tip sits near (17%, 6%). */
  transform: translate(-17%, -6%);
  transition: transform 420ms cubic-bezier(.3,.9,.35,1.05);
  filter: drop-shadow(0 4px 4px rgb(40 26 14 / 0.3));
}
.tutorial-hand img { width: 100%; height: auto; }
/* While the finger rides a bead it must not lag behind its own transform. */
.tutorial-hand.is-dragging { transition: none; }

.skip-button {
  position: absolute;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 80;
}

.tutorial-steps {
  position: absolute;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 10px 16px;
  list-style: none;
  background: rgb(255 248 230 / 0.96);
  border: 3px solid var(--wm-wood-1);
  border-radius: var(--wm-radius-card);
  box-shadow: var(--wm-shadow-card);
}
.tutorial-steps[hidden] { display: none; }
.tutorial-steps li { display: flex; align-items: center; gap: 8px; font-size: clamp(13px, 1.8vmin, 17px); }
.tutorial-steps li span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--wm-gold);
  color: #5b3a12;
  font-weight: 700;
}

/* ---------------------------------------------------------------- overlays -- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(28 44 60 / 0.42);
}
.overlay[hidden] { display: none; }

.panel {
  width: min(520px, 94vw);
  max-height: 92dvh;
  overflow: auto;
  padding: 20px 22px 22px;
  text-align: center;
  background: linear-gradient(180deg, #fff8e6, #f6e7c8);
  border: 4px solid var(--wm-wood-2);
  border-radius: var(--wm-radius-panel);
  box-shadow: 0 18px 40px rgb(20 30 40 / 0.45);
}
.panel h2 { margin: 0 0 6px; font-size: clamp(20px, 3.4vmin, 30px); color: #6f411f; }
.panel-note { margin: 0 0 14px; font-size: clamp(13px, 1.9vmin, 17px); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.wood-button {
  min-height: var(--wm-touch-main);
  min-width: 120px;
  padding: 12px 20px;
  font-size: clamp(15px, 2vmin, 19px);
  font-weight: 700;
  color: #fff8e6;
  background: linear-gradient(180deg, #8a552c, #6f411f);
  border: 3px solid #6f411f;
  border-radius: 999px;
  box-shadow: 0 4px 0 #5e3719, 0 8px 14px rgb(40 26 14 / 0.3);
  cursor: pointer;
  touch-action: manipulation;
}
.wood-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #5e3719; }
.big-button { min-width: 190px; font-size: clamp(17px, 2.4vmin, 22px); }

.reward-card { position: relative; }
.reward-highfive {
  width: min(300px, 74vw);
  margin: 0 auto 6px;
  border-radius: 18px;
}
.finale-card {
  background: linear-gradient(180deg, #fff5da, #f2c141 160%);
  border-color: #b8842a;
}
.audio-note { min-height: 1em; margin: 6px 0 0; font-size: clamp(12px, 1.6vmin, 15px); color: #6b4a24; }

.level-choices { display: grid; gap: 10px; margin: 8px 0 16px; }
.level-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--wm-touch-main);
  padding: 10px 18px;
  font-size: clamp(15px, 2vmin, 19px);
  text-align: left;
  color: var(--wm-ink);
  background: linear-gradient(180deg, #fff8e6, #efe0bf);
  border: 3px solid var(--wm-wood-1);
  border-radius: 999px;
  cursor: pointer;
}
.level-choice.is-current { border-color: #a4691a; box-shadow: 0 0 0 3px rgb(242 193 65 / 0.4); }
.level-choice .choice-done { font-size: 0.85em; color: #6b4a24; }

/* -------------------------------------------------------------- help panel -- */

.help {
  width: min(940px, 96vw);
  max-height: 92dvh;
  padding: 0;
  border: 0;
  background: none;
}
.help::backdrop { background: rgb(28 44 60 / 0.5); }
.help-card {
  display: grid;
  gap: 12px;
  max-height: 92dvh;
  overflow: auto;
  padding: 20px 22px 24px;
  background: linear-gradient(180deg, #fff8e6, #f6e7c8);
  border: 4px solid var(--wm-wood-2);
  border-radius: var(--wm-radius-panel);
}
.help-card h2 { margin: 0; font-size: clamp(20px, 3vmin, 28px); color: #6f411f; }
.help-card h3 { margin: 10px 0 4px; font-size: clamp(15px, 2vmin, 19px); color: #6f411f; }
.help-audio { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.help-audio .wood-button { min-width: 108px; }
.help-steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.help-steps li { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 14px; align-items: center; }
.help-steps strong { display: block; margin-bottom: 2px; color: #6f411f; }
.help-steps p { margin: 0; font-size: clamp(13px, 1.8vmin, 16px); }
.help-art {
  display: grid;
  place-items: center;
  padding: 10px;
  background: linear-gradient(180deg, #c98f5a, #8a552c);
  border-radius: 16px;
  border: 3px solid #6f411f;
}
/* Two rows of ten, each row five coral then five ivory — the real rekenrek
   material. `.on` marks a bead that has been slid over and counted. */
.mini-rack { display: grid; gap: 6px; }
.mini-rod { display: flex; align-items: center; gap: 2px; }
.mini-rod .mini-bead:nth-child(5) { margin-right: 7px; }
.mini-bead {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff, #f4e6c7 60%, #cbb489);
  box-shadow: inset 0 -1px 2px rgb(40 26 14 / 0.25);
}
.mini-bead.coral, .mini-bead.on.coral { background: radial-gradient(circle at 34% 30%, #ffd0c4, #ea8f7c 60%, #b8564a); }
.mini-bead.ivory, .mini-bead.on.ivory { background: radial-gradient(circle at 34% 30%, #fff, #f4e6c7 60%, #cbb489); }
.mini-bead.on { box-shadow: 0 0 0 2px var(--wm-gold), inset 0 -1px 2px rgb(40 26 14 / 0.25); }
.mini-ok { width: 64px; height: 64px; }
.help-spoken, .help-parent { padding: 10px 14px; background: rgb(255 250 235 / 0.85); border-radius: 16px; }
.help-spoken p, .help-parent p { margin: 0 0 8px; font-size: clamp(13px, 1.8vmin, 16px); line-height: 1.45; }
.help-parent p:last-child { margin-bottom: 0; }
.close-button { justify-self: center; margin-top: 6px; min-width: 160px; }

/* ------------------------------------------------------------ orientation -- */

/* Portrait / phone: controls first, the Sopo guide above the rack. */
@media (orientation: portrait) {
  .hud {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "controls" "progress" "goal";
    justify-items: center;
    gap: 6px;
  }
  .hud-progress { justify-self: stretch; }
  .goal { justify-self: center; }
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 6px;
  }
  .guide { flex-direction: row; align-items: center; gap: 10px; }
  .guide-art { width: min(28vw, 118px); }
  .speech { max-width: none; font-size: clamp(13px, 3.4vmin, 18px); padding: 6px 12px; }
  .hero-art { width: min(30vw, 128px); }
  .hero { flex-direction: row-reverse; align-items: flex-end; }
  .board-area { gap: 8px; }
  .help-steps li { grid-template-columns: minmax(132px, 156px) 1fr; }
}

.shell[data-state="level-complete"] .controls,
.shell[data-state="game-complete"] .controls { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .tray, .grip, .bead { transition: none !important; }
  .bead.is-guided { transition: none !important; }
  .ok-button.is-nudge { animation: none; }
  .tutorial-hand { transition: none !important; }
  .tutorial-hand.is-dragging { transition: none !important; }
  .fx { display: none !important; }
}

/* --------------------------------------------------------------- juice fx -- */

/* Small, bounded, pointer-free particles. They mark a beat; they never move a
   counted bead, never shake the screen and never use red. */
.fx {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.fx-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, #fff0bf, var(--wm-gold) 60%, #d99b23);
  box-shadow: 0 0 7px rgb(242 193 65 / 0.75);
  animation: fx-fly 720ms cubic-bezier(.2,.8,.3,1) forwards;
}
.fx-ring {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--wm-gold);
  animation: fx-ring 640ms ease-out forwards;
}
.fx-spark {
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff3cf;
  box-shadow: 0 0 8px rgb(242 193 65 / 0.9);
  animation: fx-fly 620ms ease-out forwards;
}
.fx-puff {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle, rgb(233 137 120 / 0.7), rgb(233 137 120 / 0) 70%);
  animation: fx-puff 780ms ease-out forwards;
}
.fx-confetti {
  width: 9px; height: 13px; border-radius: 3px;
  background: linear-gradient(180deg, #ffd977, var(--wm-gold) 70%, #d99b23);
  animation: fx-confetti 1500ms cubic-bezier(.2,.7,.4,1) forwards;
}

@keyframes fx-fly {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -46px))) scale(0.85); opacity: 0; }
}
@keyframes fx-ring {
  0% { transform: translate(-50%, -50%) scale(0.35); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.7); opacity: 0; }
}
@keyframes fx-puff {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}
@keyframes fx-confetti {
  0% { transform: translate(-50%, -50%) rotate(0deg); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 140px))) rotate(var(--rot, 200deg)); opacity: 0; }
}

/* ------------------------------------------------- compact short screens -- */

@media (max-height: 620px) and (orientation: landscape) {
  .guide-art { width: min(100%, 158px); }
  .hero-art { width: min(100%, 150px); }
  .speech { font-size: clamp(11px, 1.7vmin, 15px); padding: 4px 10px; }
  .goal-number { font-size: clamp(22px, 4.6vmin, 40px); }
  .goal-caption, .goal-note { font-size: clamp(9px, 1.3vmin, 12px); }
  .goal-pattern { gap: 1px; }
  .hud-level-name { font-size: clamp(11px, 1.6vmin, 15px); }
  .cmp-cell { width: 9px; height: 9px; }
}

@media (max-width: 380px) {
  .help-steps li { grid-template-columns: minmax(132px, 156px) 1fr; }
  .goal { min-width: 74px; padding: 3px 10px 5px; }
  .goal-pattern { gap: 1px; }
}
