:root {
  /* Every Capy portrait shares one frame (tools/normalize-capy.py), so the box can
     be reserved before the image decodes. Without this, render() replaces the <img>
     on each outfit change and `height: auto` measures 0 until it loads - measured
     220x0 - so the panel collapsed and snapped back on every try-on. */
  --capy-aspect: 636 / 1219;

  --ink: #2f231d;
  --ink-soft: #6f5a4e;
  --paper: #fffaf0;
  --paper-cool: #f7fcfb;
  --line: #4b3228;
  --teal: #178f93;
  --teal-dark: #0f676c;
  --sky: #70d7df;
  --leaf: #63b85d;
  --coral: #ef6f5e;
  --mango: #f2b94f;
  --cream: #fff2cf;
  --stone: #d9e2e2;
  --shadow: 0 18px 40px rgba(47, 35, 29, 0.18);
  --soft-shadow: 0 10px 24px rgba(47, 35, 29, 0.12);
  --focus: 0 0 0 4px rgba(23, 143, 147, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Rubik", "Varela Round", "Segoe UI", "Noto Sans Hebrew", sans-serif;
  /* Rubik first: Arial Rounded carries no Hebrew glyphs, so Hebrew fell through
     to a system serif. Rubik is rounded, child-friendly and has real nikud. */
  background:
    radial-gradient(circle at 12% 10%, rgba(112, 215, 223, 0.28), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(239, 111, 94, 0.12), transparent 24%),
    linear-gradient(180deg, #f7fcfb 0%, #fff7e6 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none !important;
  box-shadow: 0 3px 0 rgba(75, 50, 40, 0.08) !important;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(160px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 2px solid rgba(75, 50, 40, 0.08);
  background: rgba(255, 250, 240, 0.88);
  backdrop-filter: blur(18px);
}

.brand-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  color: var(--ink);
  background: transparent;
  border: 0;
  text-align: right;
}

.brand-button strong {
  display: block;
  font-size: 1.02rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: url("assets/mvp/ui/capy-icon-v1.png") center / cover no-repeat, #f6e6c8;
  box-shadow: 0 3px 0 rgba(75, 50, 40, 0.14);
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* 48px is the floor from docs/child-facing-ui.md, and it is not a phone-only
   number - it is the size a five-year-old's finger actually hits. These four sat
   at 42 everywhere, which is why nearly every button in the app failed the
   contract its own doc states. */
.main-nav button,
.secondary-button,
.primary-button,
.ghost-button {
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 rgba(75, 50, 40, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.main-nav button {
  padding: 0 16px;
}

.main-nav button:hover,
.secondary-button:hover,
.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 rgba(75, 50, 40, 0.13);
}

.main-nav button:active,
.secondary-button:active,
.primary-button:active,
.ghost-button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 rgba(75, 50, 40, 0.14);
}

.primary-button {
  padding: 0 20px;
  color: #fff;
  background: var(--teal);
}

.secondary-button,
.ghost-button {
  padding: 0 16px;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.58);
}

.mini-progress {
  justify-self: end;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.mini-progress span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 2px solid rgba(75, 50, 40, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.screen {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
  flex: 1;
}

.view-frame {
  display: grid;
  gap: 18px;
}

.view-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.view-title h1,
.view-title h2,
.view-title p {
  margin: 0;
}

.view-title h1 {
  font-size: 2rem;
  line-height: 1.1;
}

.view-title p {
  max-width: 620px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.island-layout {
  display: grid;
  /* dir="rtl" numbers grid columns right-to-left, so column 1 is the RIGHT edge.
     The sidebar sits there - it reads first in Hebrew and leaves the map the
     wider column. grid-row keeps both on one row regardless of DOM order. */
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.island-sidebar {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  gap: 12px;
  align-content: start;
}

/* The shops' own wrapper only matters on a phone, where it moves to the top
   (see the island sidebar's phone rules). Elsewhere it dissolves, so the cards
   stay items of the sidebar's grid exactly as before. */
.shop-menu { display: contents; }

.island-stage {
  grid-column: 2;
  grid-row: 1;
}

.island-stage,
.lesson-card,
.parent-card,
.reward-card {
  border: 2px solid rgba(75, 50, 40, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.island-stage {
  position: relative;
  width: min(100%, 960px);
  min-width: 0;
  margin-inline: auto;
  overflow: hidden;
  aspect-ratio: var(--map-aspect, 16 / 9);
  min-height: auto;
  isolation: isolate;
  background: linear-gradient(180deg, #dffbff, #f8fff4);
}

.island-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.world-node {
  position: absolute;
  border: 0;
  background: transparent;
  padding: 0;
  z-index: var(--world-depth, 1);
  transform: translate(calc(var(--anchor-x, 50%) * -1), calc(var(--anchor-y, 50%) * -1));
  animation: floaty 4.8s ease-in-out infinite;
}

.world-node img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 14px 18px rgba(47, 35, 29, 0.26));
  transition: transform 180ms ease, filter 180ms ease;
}

/* Hover only where there is a real mouse; a touch screen gets the press state below
   instead, and would otherwise keep a tapped world raised (docs/game-screen-layout.md). */
@media (hover: hover) and (pointer: fine) {
  .world-node:hover img {
    transform: translateY(-8px) scale(1.03);
    filter: drop-shadow(0 22px 22px rgba(47, 35, 29, 0.24));
  }
}

.world-node:active > img {
  transform: scale(.97);
  transition-duration: 80ms;
}

.world-node.is-locked {
  cursor: not-allowed;
  animation: none;
}

.world-node.is-locked img {
  opacity: 1;
  filter: drop-shadow(0 14px 18px rgba(47, 35, 29, 0.26));
}

.world-node .world-lock {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 21%;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  animation: lock-bob 3.6s ease-in-out infinite;
}

.world-node .world-lock img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(47, 35, 29, 0.32));
  transition: none;
}

.world-node:hover .world-lock img {
  transform: none;
}

@keyframes lock-bob {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, calc(-50% - 5px)); }
}

.world-node.is-active img {
  filter:
    drop-shadow(0 14px 18px rgba(47, 35, 29, 0.24))
    drop-shadow(0 0 9px rgba(255, 255, 255, 0.92))
    drop-shadow(0 0 12px rgba(23, 143, 147, 0.7));
}

/* Alpha-only miniatures share a CSS-pixel halo at both viewport sizes.
   Scope to the artwork, excluding labels and lock icons. */
.island-stage .world-node.has-code-halo > img {
  --world-halo: #fff9e9;
  filter: drop-shadow(1px 0 0 var(--world-halo))
    drop-shadow(-1px 0 0 var(--world-halo))
    drop-shadow(0 1px 0 var(--world-halo))
    drop-shadow(0 -1px 0 var(--world-halo))
    drop-shadow(0 3px 3px rgba(47, 35, 29, .24));
}
.island-stage .world-node.has-code-halo:is(:focus-visible, :active) > img {
  filter: drop-shadow(1px 0 0 var(--world-halo))
    drop-shadow(-1px 0 0 var(--world-halo))
    drop-shadow(0 1px 0 var(--world-halo))
    drop-shadow(0 -1px 0 var(--world-halo))
    drop-shadow(0 0 3px var(--world-halo))
    drop-shadow(0 4px 4px rgba(47, 35, 29, .24));
}
@media (hover: hover) and (pointer: fine) {
  .island-stage .world-node.has-code-halo:hover > img {
    filter: drop-shadow(1px 0 0 var(--world-halo))
      drop-shadow(-1px 0 0 var(--world-halo))
      drop-shadow(0 1px 0 var(--world-halo))
      drop-shadow(0 -1px 0 var(--world-halo))
      drop-shadow(0 0 3px var(--world-halo))
      drop-shadow(0 4px 4px rgba(47, 35, 29, .24));
  }
}
.island-stage .world-node.has-code-halo:focus-visible > img { transform: translateY(-8px) scale(1.03); }
.island-stage .world-node.has-code-halo:active > img { transform: scale(.97); transition-duration: 80ms; }

/* An invisible twin of .world-node: same box, same anchor, same float, built from
   the same placement string in app.js, so the name inside it lands exactly where
   it did when it was the node's own child. The single difference is the one that
   matters - it sits in a layer above every island, so no neighbour's artwork can
   be painted over the words.

   110 is chosen, not "a big number". It has to clear the depth sort, whose values
   are spotY percentages and so never exceed 100 - and it has to stay UNDER the
   walking Capy at 120, who is given that number precisely so he walks in front of
   every island. A label layer above him crossed his head with the name of the
   world next door. Nothing else in the stage sits between 100 and 120. */
.world-tag-anchor {
  position: absolute;
  /* width comes from the inline placement string, exactly as the node's does */
  z-index: 110;
  pointer-events: none;
  transform: translate(calc(var(--anchor-x, 50%) * -1), calc(var(--anchor-y, 50%) * -1));
  animation: floaty 4.8s ease-in-out infinite;
}

/* A locked island holds still; its name has to hold still with it. */
.world-tag-anchor.is-locked {
  animation: none;
}

/* Present for its height only - it is what makes the anchor the node's twin.
   visibility, not display:none, because a removed box has no height either. */
.world-tag-spacer {
  display: block;
  width: 100%;
  height: auto;
  visibility: hidden;
}

.world-tag {
  position: absolute;
  top: var(--tag-y, 90%);
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: max-content;
  min-width: 88px;
  max-width: 148px;
  min-height: 34px;
  padding: 6px 12px 8px;
  border: 2px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fffdf6;
  box-shadow:
    inset 0 -4px 0 color-mix(in srgb, var(--tag-color) 72%, white),
    0 4px 0 rgba(75, 50, 40, 0.16),
    0 8px 12px rgba(47, 35, 29, 0.12);
  font-family: "Rubik", "Varela Round", "Segoe UI", "Noto Sans Hebrew", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  white-space: normal;
  pointer-events: none;
  transform: translateX(-50%) rotate(var(--tag-rotate, 0deg));
}

.world-tag::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 9px;
  height: 9px;
  border-top: 2px solid var(--line);
  border-left: 2px solid var(--line);
  background: #fffdf6;
  transform: translateX(-50%) rotate(45deg);
}

.world-tag-anchor.is-active .world-tag {
  color: #fff;
  background: var(--teal);
  box-shadow:
    inset 0 -4px 0 rgba(0, 0, 0, 0.13),
    0 4px 0 rgba(75, 50, 40, 0.18),
    0 9px 16px rgba(15, 103, 108, 0.25);
}

.world-tag-anchor.is-active .world-tag::before {
  background: var(--teal);
}

.animal-phone-label { display: none; }
@media (max-width: 720px) {
  .screen:has(.animal-world-stage) { padding-inline: 0; }
  .lesson-shell:has(.animal-world-stage) { display:flex; flex-direction:column; gap:12px; }
  .lesson-shell:has(.animal-world-stage) > *,
  .lesson-shell:has(.animal-world-stage) .lesson-main { min-width:0; width:100%; }
  .lesson-shell:has(.animal-world-stage) .lesson-head { padding-inline:14px; }
  .lesson-shell:has(.animal-world-stage) .lesson-card { display:contents; }
  .lesson-shell:has(.animal-world-stage) .capy-guide { order:1; width:calc(100% - 28px); margin-inline:14px; padding:6px; grid-template-columns:48px minmax(0,1fr); gap:8px; }
  .lesson-shell:has(.animal-world-stage) .capy-guide > img { width:48px; height:64px; object-fit:contain; }
  .lesson-shell:has(.animal-world-stage) .speech-bubble { padding:6px 10px; }
  .lesson-shell:has(.animal-world-stage) .speech-bubble strong { display:none; }
  .lesson-shell:has(.animal-world-stage) .speech-bubble p { margin:2px 0; font-size:.85rem; }
  .lesson-shell:has(.animal-world-stage) .replay-button { min-height:48px; padding:4px 10px; }
  .lesson-shell:has(.animal-world-stage) .lesson-main { order:2; }
  .lesson-shell:has(.animal-world-stage) .world-games-nav { order:3; width:calc(100% - 28px); margin:0 14px 20px; }
  .lesson-main .animal-world-stage { aspect-ratio:var(--animal-phone-aspect); border:0; border-radius:0; box-shadow:none; }
  .animal-world-stage .animal-region-frame,
  .animal-world-stage .world-tag-anchor {
    left:var(--animal-phone-x) !important; top:var(--animal-phone-y) !important;
    width:var(--animal-phone-w) !important;
    --anchor-x:50%; --anchor-y:var(--animal-phone-anchor-y);
  }
  .animal-world-stage .animal-region-frame { z-index:10; }
  .animal-world-stage button.animal-region-frame { min-width:48px; min-height:48px; touch-action:pan-y; }
  .animal-world-stage .world-tag-anchor { z-index:110; }
  .animal-world-stage .animal-map-capy { z-index:120; }
  .animal-world-stage .world-tag { display:none; }
  .animal-world-stage .animal-phone-label { display:block; position:absolute; left:50%; top:100%; transform:translateX(-50%); white-space:nowrap; padding:7px 16px; min-height:38px; font-size:17px; line-height:1.2; font-weight:700; background:#fffaf0; color:#4b3228; border:2px solid #725946; border-radius:7px; box-shadow:0 3px 0 #72594655; }
  .animal-world-stage .animal-phone-label::before { content:''; position:absolute; top:-7px; left:calc(50% - 5px); width:10px; height:10px; background:inherit; border-left:2px solid #725946; border-top:2px solid #725946; transform:rotate(45deg); }
  .animal-world-stage .animal-phone-label.is-active { background:#178f93; color:white; }
  .animal-world-stage .animal-entry-icon { bottom:10%; right:7%; width:30px; height:30px; padding:4px; border:1px solid #725946; background:#fffaf0; }
}
.animal-world-stage {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: var(--animal-map-aspect);
  overflow: hidden;
  isolation: isolate;
  border: 2px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--soft-shadow);
}
.animal-world-base {
  display: block;
  width: 100%;
  height: auto;
}
.animal-map-capy {
  position: absolute;
  height: auto;
  min-width: 0;
  z-index: 120;
  transform: translate(-50%, -100%);
  pointer-events: none;
}
.animal-capy-facing, .animal-capy-facing > img { display:block; width:100%; height:auto; }
.animal-map-capy.is-walking { animation:animal-route var(--animal-walk-duration) var(--animal-walk-delay) linear both; }
.animal-map-capy.is-walking .animal-capy-facing { animation:animal-facing var(--animal-walk-duration) var(--animal-walk-delay) steps(1,end) both; }
.animal-map-capy.is-walking img { transform-origin:50% 100%; animation:animal-footstep .36s var(--animal-walk-delay) ease-in-out infinite; }
@keyframes animal-footstep {
  0%,100% { transform:rotate(-2deg); }
  50% { transform:translateY(-3px) rotate(2deg); }
}
@media (prefers-reduced-motion:reduce) {
  .animal-map-capy.is-walking img { animation:none; }
}
.animal-region-frame {
  position: absolute;
  z-index: var(--world-depth, 1);
  min-width: 0;
  aspect-ratio: 3 / 2;
  transform: translate(calc(var(--anchor-x) * -1), calc(var(--anchor-y) * -1));
  pointer-events: none;
}
.animal-region-frame > img {
  display: block;
  width: 100%;
  height: auto;
}
.animal-world-stage .world-tag-anchor {
  min-width: 0;
  animation: none;
}
.animal-world-stage .animal-region-label { pointer-events:auto; cursor:pointer; min-height:48px; min-width:48px; touch-action:pan-y; }
.animal-world-stage .world-tag.animal-region-label { display:flex; align-items:center; justify-content:center; gap:5px; }
.animal-world-stage .animal-region-label > svg { width:16px; height:16px; vertical-align:middle; flex-shrink:0; }
.animal-world-stage .animal-phone-label > svg { margin-inline-end:5px; }
.animal-world-stage .animal-region-label:focus-visible { outline:3px solid #327b75; outline-offset:3px; }
@media (max-width:720px) {
  .screen:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) { padding:0; }
  .animal-world-stage .world-tag.animal-region-label { display:none; }
}
[data-region-tag="sea"] .world-tag {
  left: 35%;
  transform: translate(-50%, calc(-100% - 8px));
}
[data-region-tag="sea"] .world-tag::before {
  top: auto;
  bottom: -6px;
  transform: translateX(-50%) rotate(225deg);
}
@media (max-width: 720px) {
  .animal-world-stage { border-radius: 14px; }
  [data-region-tag="sea"] .world-tag { left: 85%; }
  .animal-world-stage .world-tag {
    font-size: 13px;
    min-width: 68px;
    max-width: 94px;
    min-height: 30px;
    padding: 4px 7px 6px;
  }
}

.map-debug-point {
  position: absolute;
  z-index: 8;
  width: 18px;
  height: 18px;
  border: 2px solid #e84b3c;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.map-debug-point::before,
.map-debug-point::after {
  content: "";
  position: absolute;
  background: #e84b3c;
}

.map-debug-point::before {
  left: 50%;
  top: -10px;
  width: 2px;
  height: 34px;
  transform: translateX(-50%);
}

.map-debug-point::after {
  left: -10px;
  top: 50%;
  width: 34px;
  height: 2px;
  transform: translateY(-50%);
}

.map-debug-point span {
  position: absolute;
  right: 16px;
  bottom: 14px;
  min-width: 68px;
  padding: 4px 6px;
  border: 2px solid #e84b3c;
  border-radius: 8px;
  color: #2f231d;
  background: #fff;
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: left;
  direction: ltr;
  box-shadow: var(--soft-shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border: 2px solid rgba(75, 50, 40, 0.12);
  border-radius: 8px;
  color: var(--teal-dark);
  background: #e7fbf8;
  font-size: 0.82rem;
  font-weight: 800;
}

.lesson-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* min-width: 0 on every item in the shell, including the ones that .lesson-card
   promotes into the grid with display:contents on mobile.
   A grid item keeps `min-width: auto`, which resolves to its min-content width, so
   one wide descendant anywhere below can push the whole COLUMN wider than the grid
   box that holds it. Measured on a 390px phone: the column resolved to 376px inside
   a 345px shell, and .view-title, .capy-guide and .lesson-main all hung 31px off the
   left edge of the screen with a horizontal scrollbar under them. It is the same
   fault, and the same cure, as the note on .shelf-top further down - it just has to
   be applied at the top of the tree as well as inside the shelves. */
.lesson-shell > *,
.lesson-shell > .lesson-card > *,
.lesson-main > * {
  min-width: 0;
}

/* The title spans both columns so Capy's card starts level with the game panel
   beside it. It used to sit inside .lesson-main, which pushed the panel down by
   the height of the heading while the sidebar stayed at the top - the two columns
   began at different heights and the layout read as slightly broken. */
.lesson-shell > .lesson-head {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.lesson-card {
  padding: 16px;
}

.lesson-card.is-sticky {
  position: sticky;
  top: 92px;
}

.capy-guide {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.capy-guide img {
  width: min(220px, 76%);
  height: 250px;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 14px 18px rgba(47, 35, 29, 0.18));
  animation: capy-breathe 2.6s ease-in-out infinite;
}

.speech-bubble {
  position: relative;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.speech-bubble::before {
  content: "";
  position: absolute;
  top: -11px;
  right: 44px;
  width: 18px;
  height: 18px;
  border-top: 2px solid var(--line);
  border-right: 2px solid var(--line);
  background: #fff;
  transform: rotate(-45deg);
}

.speech-bubble strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.04rem;
}

.speech-bubble p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* The speaker sits under the instruction it reads, never beside the game board:
   a pre-reader connects "these words" to "this button" only when they touch. */
.speech-bubble .replay-button {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

.lesson-progress {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.step-pill {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 2px solid rgba(75, 50, 40, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

.step-pill span:first-child {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(75, 50, 40, 0.16);
  border-radius: 50%;
  font-weight: 900;
}

.step-pill.is-current {
  border-color: rgba(23, 143, 147, 0.42);
  background: #e7fbf8;
}

/* A locked game in a world menu: the padlock its object wears, at the end of the pill. */
.step-pill.is-locked { grid-template-columns: 28px minmax(0, 1fr) 28px; }
.pill-lock { position: relative; display: block; width: 28px; height: 28px; }
/* Three dots under a lock: one for each of the three words the game waits for, filled as the
   child comes to know them (Dana, December 1, 2026: a bare lock only frustrates). */
.gate-dots { position: absolute; left: 50%; top: 100%; translate: -50% 3px; display: flex; gap: 4px; direction: ltr; pointer-events: none; }
.gate-dots i { display: block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #5b4636; background: #fffaf0; box-sizing: border-box; }
.gate-dots i.is-on { background: #f3c73f; }
/* In the room the dots sit over the lock: under it, the blocks' dots ran off the bottom of a phone's picture. */
.room-object .gate-dots { top: auto; bottom: 100%; translate: -50% -3px; }
.pill-lock .gate-dots { top: 50%; left: calc(100% + 6px); translate: 0 -50%; gap: 3px; }
.pill-lock .gate-dots i { width: 9px; height: 9px; border-width: 1.5px; }
.world-games-nav .step-pill .world-lock { position: relative; }
.world-games-nav .step-pill .world-lock .gate-dots { top: 50%; left: calc(100% + 6px); translate: 0 -50%; gap: 3px; }
.world-games-nav .step-pill .world-lock .gate-dots i { width: 9px; height: 9px; border-width: 1.5px; }
/* The round's card says so when it opened a game. */
.completion-opened { display: grid; justify-items: center; gap: 8px; margin-top: 18px; width: 100%; min-width: 0; padding: 10px 12px; border-radius: 14px; background: #eef8ef; border: 2px solid #5aa86b; box-sizing: border-box; }
.completion-opened strong { font-size: 1.05rem; }
.completion-opened-game { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.completion-opened-game svg { width: 34px; height: 34px; flex: none; }
.pill-lock img { display: block; width: 100%; height: 100%; object-fit: contain; }

.step-pill.is-done span:first-child {
  color: #fff;
  border-color: var(--teal-dark);
  background: var(--teal);
}

/* The play area is never shorter than Capy's card beside it. The shell is
   align-items: start so each column sizes to its own content, and the guide card
   has a fixed floor - a 250px portrait plus the speech bubble and the replay
   button - that the game panel does not. In the colours game that left the panel
   108px short of the card, so Capy's column hung below the game and the two
   columns ended at visibly different heights.

   align-self: stretch, not a min-height: the card's height depends on how long
   the spoken instruction is, and CSS cannot read one element's height into
   another. Stretching makes the grid row itself the shared measure, so this holds
   for every instruction length and every world screen without a number to keep in
   sync. .lesson-main is transparent, so the stretch has to carry through to the
   panel that is actually painted - align-content: stretch is what passes it down
   to the auto row, and it is set explicitly rather than left to `normal`
   resolving to stretch on its own. When the game is TALLER than the card the row
   grows instead and the card stays its natural height, which is why this is on
   the play area alone and not align-items on the shell. */
.lesson-main {
  display: grid;
  gap: 16px;
  align-self: stretch;
  align-content: stretch;
}

.room-hero {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  border: 2px solid rgba(75, 50, 40, 0.14);
  border-radius: 8px;
  background: #e7fbf8;
  box-shadow: var(--shadow);
}

.room-hero img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
}

.room-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent 34%),
    radial-gradient(circle at 76% 20%, rgba(255, 255, 255, 0.3), transparent 22%);
}

/* A column, so the stars and the onward button hold the bottom edge of the panel
   rather than floating wherever the content above them happens to end. The panel
   is now stretched to Capy's height (see .lesson-main), and any game whose board
   is shorter than his card inherits that slack: the teach phase ended up with
   126px of dead space UNDER its star row while the guided phase, whose board is
   taller, looked correct. The footer is the same element in both, so it is the
   footer that has to be pinned - not each game's content padded to match. */
.lesson-panel {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 2px solid rgba(75, 50, 40, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--soft-shadow);
}

/* Takes the slack, so the board above keeps its natural height and the row lands
   on the padding edge. On the screens whose game is already taller than Capy there
   is no free space, auto resolves to 0 - and it overrides the 14px margin the row
   carries by default, which silently closed the gap between board and footer and
   shortened those panels by exactly 14px. padding-top restores that separation as
   a floor auto cannot eat, rather than reinstating a margin auto would override. */
.lesson-panel > .action-row {
  margin-top: auto;
  padding-top: 14px;
}

/* Panel children that centre themselves with `margin: 0 auto` need an explicit width
   now that .lesson-panel is a flex column. A block-level child took the full width and
   let max-width cap it; a FLEX child with auto margins on the cross axis has its
   stretch suppressed by those margins and sizes to its CONTENT instead. That collapsed
   the shelves from 520px to 98px - the shelf rows went 482px to 60px with them - and
   narrowed the tray by 16px. width: 100% restores the block behaviour and max-width
   still caps it at 520; the auto margins keep doing the centring.

   .block-speaker escaped this only because it declares width: 84px itself. Any new
   centred child of a lesson panel needs a width for the same reason. */
.block-shelves,
.block-tray {
  width: 100%;
}

.lesson-panel h2,
.lesson-panel h3,
.lesson-panel p {
  margin-top: 0;
}

.lesson-panel p {
  color: var(--ink-soft);
  line-height: 1.5;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.palette-intro-panel {
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.9), rgba(231, 251, 248, 0.82)),
    #fff;
}

.palette-lesson {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(220px, 300px);
  gap: 16px;
  align-items: stretch;
}

/* The teach board sits in the middle of its slack, not at the top of it. The panel
   is stretched to Capy's height and the footer is pinned to the bottom, which left
   the palette and the colour card hard against the top edge with ~108px of empty
   sky under them. flex-grow hands this element the leftover space; align-content
   centre then keeps the ROW at its content height inside that space instead of
   letting it stretch, which is what actually moves the two columns down together.

   align-items stays stretch, so the palette and the card still match each other's
   height as they did before - centring the row is a different axis from sizing the
   items in it, and swapping to align-items: center would instead collapse each
   column onto its own min-height and pull them apart.

   Scoped to the teach panel: the guided phase is .palette-lesson.is-solo in a plain
   .lesson-panel, its board fills the width, and it has almost no slack to centre. */
.palette-intro-panel > .palette-lesson {
  flex-grow: 1;
  align-content: center;
}

/* One game, one board: with no side panel the palette gets the whole width
   rather than sitting against an empty reserved column. */
.palette-lesson.is-solo {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
}

.paint-palette {
  position: relative;
  min-height: 520px;
  border: 3px solid var(--line);
  border-radius: 48% 52% 45% 55% / 52% 42% 58% 48%;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.62), transparent 23%),
    radial-gradient(circle at 72% 76%, rgba(112, 215, 223, 0.28), transparent 28%),
    linear-gradient(145deg, #fff7e8, #e8f6f3 48%, #c9dedb);
  box-shadow:
    inset 0 -18px 0 rgba(23, 143, 147, 0.12),
    inset 0 12px 0 rgba(255, 255, 255, 0.34),
    0 16px 0 rgba(75, 50, 40, 0.12);
}

.palette-hole {
  position: absolute;
  right: 8%;
  top: 38%;
  width: 82px;
  height: 68px;
  border: 3px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle at 48% 42%, rgba(23, 143, 147, 0.16), transparent 54%),
    #f7fcfb;
  box-shadow:
    inset 0 7px 0 rgba(75, 50, 40, 0.1),
    0 4px 0 rgba(75, 50, 40, 0.08);
}

.palette-shine {
  position: absolute;
  left: 16%;
  top: 9%;
  width: 42%;
  height: 34%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  transform: rotate(-10deg);
  pointer-events: none;
}

.paint-well {
  position: absolute;
  display: grid;
  place-items: center;
  left: var(--well-x);
  top: var(--well-y);
  width: clamp(92px, 17%, 136px);
  aspect-ratio: 1 / 0.82;
  padding: 8px;
  border: 0;
  color: var(--ink);
  background: transparent;
  transform-origin: center;
  transform: translate(-50%, -50%) rotate(var(--well-rotate)) scale(var(--well-scale));
  transition: transform 170ms ease, filter 170ms ease;
}

.paint-well:hover,
.paint-well.is-active {
  filter: saturate(1.08);
  transform: translate(-50%, -57%) rotate(var(--well-rotate)) scale(var(--well-scale));
}

.paint-well-blob {
  position: absolute;
  inset: 7px;
  border: 3px solid var(--line);
  border-radius: var(--blob-radius, 56% 44% 52% 48% / 44% 54% 46% 56%);
  background:
    radial-gradient(circle at 35% 26%, rgba(255, 255, 255, 0.48), transparent 18%),
    var(--paint);
  box-shadow:
    inset 0 -10px 0 rgba(47, 35, 29, 0.14),
    0 8px 0 rgba(75, 50, 40, 0.12);
}

.paint-well-word {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 84px;
  padding: 7px 10px;
  border: 2px solid rgba(75, 50, 40, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 4px 0 rgba(75, 50, 40, 0.1);
}

.paint-well-word small {
  margin-top: 2px;
  color: var(--ink-soft);
}

.paint-well.is-active .paint-well-blob {
  animation: paint-pulse 1.15s ease-in-out infinite;
}

.intro-canvas {
  position: relative;
  display: grid;
  gap: 10px;
  align-content: center;
  justify-items: center;
  min-height: 370px;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffaf0, #f7fcfb);
  box-shadow: 0 10px 0 rgba(75, 50, 40, 0.1);
  text-align: center;
}

.intro-canvas-paper {
  position: relative;
  display: block;
  width: min(180px, 86%);
  aspect-ratio: 4 / 3;
  border: 3px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(75, 50, 40, 0.12);
}

.intro-brush-stroke {
  position: absolute;
  left: 16%;
  right: 16%;
  top: 38%;
  height: 34%;
  border: 3px solid var(--line);
  border-radius: 999px 40% 999px 50%;
  background: var(--active-paint);
  box-shadow: inset 0 -7px 0 rgba(47, 35, 29, 0.13);
  transform: rotate(-4deg);
}

.intro-canvas strong,
.intro-canvas small {
  position: relative;
  z-index: 1;
}

.intro-canvas strong {
  display: grid;
  gap: 3px;
  font-size: 1.2rem;
}

.intro-canvas small {
  color: var(--ink-soft);
  line-height: 1.4;
}

.color-card,
.palette-button {
  position: relative;
  min-height: 124px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 5px 0 rgba(75, 50, 40, 0.14);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.color-card:hover,
.palette-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 rgba(75, 50, 40, 0.14);
}

.color-card.is-seen {
  background: #f1fffb;
}

.swatch {
  display: block;
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  border: 3px solid var(--line);
  border-radius: 50%;
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.12);
}

.english-word {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-weight: 900;
}

.color-card small,
.palette-button small {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  gap: 10px;
}

.palette-button {
  min-height: 90px;
}

.palette-button.is-target {
  animation: target-glow 1.1s ease-in-out infinite;
}

.palette-button.is-selected {
  background: #e7fbf8;
  transform: translateY(-3px);
}

.play-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: stretch;
}

.paint-board,
.hunt-board,
.reward-scene {
  position: relative;
  min-height: 330px;
  overflow: hidden;
  border: 2px solid rgba(75, 50, 40, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(112, 215, 223, 0.18), rgba(99, 184, 93, 0.12)),
    #fff;
}

.paint-object {
  position: absolute;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  color: var(--ink);
  background: var(--stone);
  box-shadow: 0 10px 0 rgba(75, 50, 40, 0.1);
  transition: transform 180ms ease, background 180ms ease;
}

.paint-object:hover {
  transform: translateY(-5px) scale(1.02);
}

.paint-object.is-active {
  animation: target-glow 1.15s ease-in-out infinite;
}

.paint-object.is-painted {
  animation: pop 360ms ease both;
}

.paint-object[data-object="ball"] {
  right: 14%;
  top: 28%;
  width: 108px;
  height: 108px;
  border-radius: 50%;
}

.paint-object[data-object="star"] {
  left: 14%;
  top: 22%;
  width: 126px;
  height: 126px;
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.paint-object[data-object="block"] {
  right: 40%;
  bottom: 15%;
  width: 116px;
  height: 116px;
  border-radius: 8px;
  transform: rotate(-6deg);
}

.object-label {
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.9rem;
}

.mission-card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  border: 2px solid rgba(75, 50, 40, 0.14);
  border-radius: 8px;
  background: var(--paper);
}

.mission-card strong,
.mission-card span {
  display: block;
}

.mission-card strong {
  font-size: 1.08rem;
}

.mission-card span {
  color: var(--ink-soft);
  line-height: 1.45;
}

.hunt-board img {
  width: 100%;
  height: 100%;
  min-height: 330px;
  object-fit: contain;
  background: linear-gradient(180deg, #f7fcfb, #fffaf0);
}

.hotspot {
  position: absolute;
  width: 84px;
  height: 84px;
  border: 3px dashed rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: rgba(23, 143, 147, 0.08);
  box-shadow: 0 0 0 3px rgba(47, 35, 29, 0.18), var(--soft-shadow);
  transform: translate(-50%, -50%);
  transition: transform 160ms ease, background 160ms ease;
}

.hotspot:hover {
  transform: translate(-50%, -50%) scale(1.08);
  background: rgba(239, 111, 94, 0.2);
}

.hotspot.is-found {
  border-style: solid;
  background: rgba(99, 184, 93, 0.32);
  animation: pop 360ms ease both;
}

.feedback {
  min-height: 34px;
  margin-top: 10px;
  color: var(--teal-dark);
  font-weight: 800;
}

.feedback.is-error {
  color: #a74338;
}

.reward-scene {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 30%, rgba(242, 185, 79, 0.28), transparent 26%),
    radial-gradient(circle at 84% 72%, rgba(112, 215, 223, 0.34), transparent 25%),
    #fff;
}

.sticker-book {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 10px;
}

.sticker {
  display: grid;
  place-items: center;
  min-height: 76px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(75, 50, 40, 0.14);
  font-weight: 900;
  text-align: center;
}

.sticker.is-empty {
  color: rgba(47, 35, 29, 0.3);
  border-style: dashed;
  background: rgba(255, 255, 255, 0.46);
}

.parent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.parent-card {
  padding: 16px;
}

.parent-card h3 {
  margin: 0 0 10px;
}

.metric {
  display: block;
  margin: 6px 0;
  font-size: 2rem;
  font-weight: 900;
  color: var(--teal-dark);
}

.word-table {
  display: grid;
  gap: 8px;
}

.word-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
}

.meter {
  height: 12px;
  overflow: hidden;
  border: 2px solid rgba(75, 50, 40, 0.12);
  border-radius: 8px;
  background: #edf4f3;
}

.meter span {
  display: block;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--teal), var(--leaf));
}

.toast {
  position: fixed;
  z-index: 30;
  /* Physical left matches translateX(-50%) in the RTL document too. */
  left: 50%;
  bottom: 22px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(20px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.confetti {
  position: fixed;
  z-index: 40;
  top: -12px;
  width: 10px;
  height: 16px;
  border: 2px solid var(--line);
  border-radius: 3px;
  pointer-events: none;
  animation: confetti-fall 1.4s ease-in forwards;
}

@keyframes floaty {
  0%,
  100% {
    margin-top: 0;
  }
  50% {
    margin-top: -10px;
  }
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.86);
    opacity: 0.95;
  }
  100% {
    transform: scale(1.28);
    opacity: 0;
  }
}

@keyframes capy-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.015);
  }
}

@keyframes target-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 111, 94, 0.18), 0 5px 0 rgba(75, 50, 40, 0.14);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 111, 94, 0.18), 0 5px 0 rgba(75, 50, 40, 0.14);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.92);
  }
  55% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes paint-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 -10px 0 rgba(47, 35, 29, 0.14),
      0 8px 0 rgba(75, 50, 40, 0.12),
      0 0 0 0 rgba(255, 255, 255, 0.42);
  }
  50% {
    box-shadow:
      inset 0 -10px 0 rgba(47, 35, 29, 0.14),
      0 8px 0 rgba(75, 50, 40, 0.12),
      0 0 0 9px rgba(255, 255, 255, 0.42);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(540deg);
    opacity: 0;
  }
}

@media (max-width: 1080px) {
  .island-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .island-sidebar,
  .island-stage {
    grid-column: 1;
    /* release the base rule's grid-row pin, or both land in the same cell
       and render on top of each other instead of stacking */
    grid-row: auto;
  }

  /* Two rows: identity and purse on top, the three destinations underneath at
     full width. .topbar-end keeps `grid-column: 3` from the desktop rule, and a
     single-column grid does not delete that - the browser materialises implicit
     columns to honour it and resolved the bar as 152px | 16px | 166px. The nav
     got SIXTEEN pixels for three buttons, which overlapped each other so
     completely that the island button could not be clicked at all. Pin every
     child explicitly rather than leaving one to conjure columns from nothing. */
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand end"
      "nav   nav";
    gap: 10px 12px;
  }

  /* Child selectors, not bare classes: `.topbar-end { grid-column: 3 }` lives
     several hundred lines FURTHER DOWN the file, and a media query adds no
     specificity, so a plain `.topbar-end` here loses the cascade to it and the
     phantom third column survives. Note also that grid-area is what retires that
     grid-column - do not "help" it with a separate grid-column declaration,
     which would only override the area back to auto placement. */
  .topbar > .brand-button { grid-area: brand; justify-self: start; }
  .topbar > .topbar-end   { grid-area: end; justify-self: end; }
  .topbar > .main-nav     { grid-area: nav; }

  .mini-progress {
    justify-self: center;
  }

  .island-layout,
  .lesson-shell,
  .play-zone,
  .palette-lesson,
  .reward-scene {
    grid-template-columns: 1fr;
  }

  /* Stacked, DOM order decides what a child sees first, and on both of the app's
     two layouts it chose wrong. The island put its sidebar - Capy, the purse and
     three shops, 733px of it - above the map, so the ISLAND screen opened with
     no islands on it: the first world node sat at y=856 on an 844px phone. The
     map is the game; it goes first. */
  .island-sidebar { order: 2; }
  .island-stage   { order: 1; }

  /* Same fault in every world screen. The shell's sidebar holds Capy's portrait
     AND the game menu, so stacking buried the board under both - in Capy's room
     the room picture, whose clickable objects ARE the navigation, landed below
     seven text buttons. display:contents dissolves the card so its two halves
     can be placed independently: instruction first (a pre-reader needs telling
     what to do before they can do it), then the board, then the menu. */
  .lesson-shell > .lesson-card {
    display: contents;
  }

  .lesson-shell > .lesson-card > .capy-guide {
    order: 1;
    padding: 16px;
    border: 2px solid rgba(75, 50, 40, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
  }

  .lesson-shell > .lesson-main { order: 2; }

  /* Whatever else the card carried - the ways list, a progress rail - follows the
     board instead of pushing it down. */
  .lesson-shell > .lesson-card > *:not(.capy-guide) { order: 3; }

  .lesson-card.is-sticky {
    position: static;
  }

  .island-stage {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .screen {
    padding: 14px;
  }

  .main-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .main-nav button {
    /* No side padding to fight over: three equal thirds of 390px leave ~114px
       each, so the label fits next to its icon without either being squeezed. */
    padding: 0 4px;
    font-size: 0.86rem;
  }

  /* "אִי הַהַרְפַּתְקָאוֹת שֶׁל קָפִּי" wrapped to three lines beside the purse and
     inflated the bar to 91px of a 844px screen. Capy's face is the home button a
     pre-reader actually uses, and every screen already names itself in its own
     <h1>, so the wordmark is the part that can go. aria-label carries it for
     anyone who needs the text. */
  .brand-button strong {
    display: none;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }


  /* Capy stood 250px tall above his own speech bubble, so the portrait plus the
     bubble spent half the phone before the child reached anything playable - in
     the studio it pushed the paper to y=815 and the palette to y=1066, meaning
     paper and paints could never be on screen at once. Sat BESIDE the bubble he
     is still present and still breathing, at a third of the cost. */
  .capy-guide {
    grid-template-columns: 84px minmax(0, 1fr);
    align-items: center;
    justify-items: stretch;
    gap: 12px;
  }

  .capy-guide img {
    width: 84px;
    height: 84px;
    object-position: center;
  }

  /* The tail pointed up at a portrait that is now alongside, so it turns to face
     him. Column 1 is the RIGHT edge under dir="rtl", which is where Capy sits. */
  .speech-bubble::before {
    top: 22px;
    right: -11px;
    transform: rotate(45deg);
  }

  .view-title {
    display: grid;
  }

  .view-title h1 {
    font-size: 1.55rem;
  }

  .island-stage {
    min-height: auto;
  }

  /* The label's anchor has to narrow with its island, or the `left: 50%` inside it
     is measuring against a different box and every name slides off its world. */
  .world-node,
  .world-tag-anchor {
    width: var(--mobile-w) !important;
  }

  .world-tag {
    min-width: 66px;
    max-width: 92px;
    min-height: 27px;
    padding: 4px 7px 6px;
    font-size: 0.66rem;
  }

  .color-grid,
  .parent-grid {
    grid-template-columns: 1fr;
  }

  .palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intro-canvas {
    min-height: 420px;
  }


  .paint-well-word {
    min-width: 62px;
    padding: 5px 7px;
    font-size: 0.78rem;
  }

  .room-hero,
  .room-hero img {
    min-height: 260px;
  }

  .paint-board,
  .hunt-board,
  .reward-scene {
    min-height: 280px;
  }

  .word-row {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .word-row .badge {
    grid-column: 1 / -1;
  }
}

/* Capy walking the island. Anchored bottom-centre so he stands on the coordinate. */
/* Only the main island changes composition on phones. Region maps retain theirs. */
.island-phone-continuation { display: none; }
/* Phone backgrounds have their own artwork; keep their colour intensity near desktop.
   Filter the painted layer only, so shared sprites and vocabulary colours retain theirs. */
@media (max-width:720px) {
  .room-hub .room-base { filter: saturate(.72); }
}
@media (max-width: 720px) {
  .island-stage {
    aspect-ratio: var(--phone-map-aspect);
    touch-action: pan-y pinch-zoom;
  }
  .island-stage .world-node,
  .island-stage .world-tag-anchor {
    left: var(--phone-x) !important;
    top: var(--phone-y) !important;
    width: var(--phone-w) !important;
    animation: none;
    --anchor-y: var(--phone-anchor-y) !important;
  }
  .island-stage .map-debug-point {
    left: var(--phone-x) !important;
    top: var(--phone-y) !important;
  }
  .island-stage .island-base { height: 50%; }
  .island-phone-continuation {
    display: block;
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 50%;
  }
  .island-stage .world-tag {
    top: 65%;
    left: var(--phone-tag-x);
    min-width: 88px;
    max-width: 95px;
    min-height: 36px;
    font-size: 0.85rem;
    padding: 5px 10px 7px;
    transform: translate(var(--phone-tag-shift), -50%);
  }
  .island-stage .world-tag::before {
    top: 50%;
    left: var(--phone-tag-edge);
    border-left: 0;
    border-right: 2px solid var(--line);
    transform: translate(-50%, -50%) rotate(var(--phone-tag-turn));
  }
  .island-stage .capy-walker {
    left: var(--phone-capy-x) !important;
    top: var(--phone-capy-y) !important;
    width: 12%;
  }
}

.capy-walker {
  position: absolute;
  width: 9%;
  height: auto;
  z-index: 120;
  pointer-events: none;
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) scaleX(var(--capy-face, 1));
  filter: drop-shadow(0 10px 12px rgba(47, 35, 29, 0.32));
  transition-property: left, top;
  transition-timing-function: cubic-bezier(0.42, 0, 0.4, 1);
  transition-duration: 0ms;
  animation: capy-idle 3.4s ease-in-out infinite;
}

.capy-walker.is-walking {
  animation: capy-step 0.42s ease-in-out infinite;
}

@keyframes capy-idle {
  0%, 100% { transform: translate(-50%, -100%) scaleX(var(--capy-face, 1)); }
  50% { transform: translate(-50%, calc(-100% - 4px)) scaleX(var(--capy-face, 1)); }
}

@keyframes capy-step {
  0%, 100% { transform: translate(-50%, -100%) scaleX(var(--capy-face, 1)) rotate(-3.5deg); }
  50% { transform: translate(-50%, calc(-100% - 9px)) scaleX(var(--capy-face, 1)) rotate(3.5deg); }
}

@media (max-width: 720px) {
  /* Scaled up from the desktop 9% so he is not a speck on a 362px map, but 15%
     put his head through the name of the world above him - he stands at the
     centre of the island, which is exactly where that label hangs. 11% keeps him
     40x76, a real presence next to the ~85px islands, and clears the label. */
  .capy-walker { width: 11%; }
}


/* ---- Island sidebar: Capy, coin balance, shop entry cards ---- */
.sidebar-capy {
  display: grid;
  place-items: center;
  padding: 10px;
  border: 2px solid rgba(75, 50, 40, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.sidebar-capy img {
  width: 62%;
  height: auto;
}

.coin-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fffdf6;
  font-size: 1.15rem;
}

.coin-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #b98a2a;
  background: radial-gradient(circle at 35% 30%, #f7d774, #e0a92c);
  flex: none;
}

.shop-card {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-inline-start: 7px solid var(--tone, var(--line));
  border-radius: 10px;
  background: #fffdf6;
  text-align: start;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 140ms ease;
}

.shop-card:hover { transform: translateY(-2px); }
.shop-card strong { font-size: 1rem; }
.shop-card small { opacity: 0.72; }

/* ---- Shop: picture first, Hebrew label underneath for the adult ---- */
.shop-card {
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 10px;
}

.shop-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.shop-card span {
  display: grid;
  gap: 2px;
}

/* Placed after the island sidebar rules above, not with the rest of the phone
   layout, for the reason spelled out over the palette: a media query carries no
   specificity, so an override written earlier in the file loses to what follows
   it. Written further up, `grid-template-columns: minmax(0, 1fr)` here lost to
   the `52px 1fr` above and the cards stayed two columns - the label then
   overflowed its own card and scrolled the page sideways.

   The sidebar spent 406px - 48% of the phone - on a Capy who only stands there,
   then 44px on a coin count the sticky purse in the bar was already showing, and
   only then reached the shops: nothing a child could touch was above the fold.
   Capy is not deletable, though. capyPortrait() draws the OUTFIT the child
   bought and this is the only screen that shows it, so hiding him would quietly
   remove the whole payoff of the clothes shop. He shrinks and shares a row with
   the purse. Three columns: Capy and the purse on one row, the three shops on
   the next, and the island - map included - comes in under one screen. */
@media (max-width: 720px) {
  .island-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: stretch;
  }

  /* Capy gets the two-thirds and the purse the third, not the other way round.
     He is the one carrying information here - the outfit - while the coin count
     is already pinned in the top bar on every screen, so a big empty box
     restating it was the widest thing in the row for the least reason. */
  .sidebar-capy {
    grid-column: 1 / span 2;
    padding: 8px;
  }

  .sidebar-capy img {
    width: auto;
    height: 104px;
  }

  .coin-balance {
    grid-column: 3;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
  }

  /* Stacked, the chip and the number read as one coin rather than a sentence. */
  .coin-balance small { display: none; }

  /* The shops are a menu at the top, right under the main menu (Dana, November
     28, 2026). Below the map they sat about 1,500px down, past eight islands.
     The sidebar dissolves so its parts can be placed on the island's own grid:
     the shops first, then the map, then Capy and the purse sharing a row as
     before. Three columns, the same thirds as the main menu above, so the two
     rows line up and the first shop sits at the right edge. */
  .island-layout {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .island-sidebar { display: contents; }

  .shop-menu {
    order: 0;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    /* The top bar is inset 8px further than the screen, so this matches it and
       each shop sits exactly under a main-menu button. */
    padding-inline: 8px;
  }

  .island-stage {
    order: 1;
    grid-column: 1 / -1;
    margin-bottom: 4px;
  }

  /* stretch: the island's grid aligns to the start, and the purse should still
     fill Capy's height as it did inside the sidebar. */
  .sidebar-capy,
  .island-sidebar > .coin-balance { order: 2; align-self: stretch; }

  /* Icon beside a two-line name: a menu row, not a card, so the map still
     starts high on the screen. 52px tall, above the 48px touch minimum. */
  .shop-card {
    grid-column: auto;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    gap: 5px;
    min-height: 52px;
    padding: 5px 6px;
    border-inline-start-width: 5px;
    text-align: start;
  }

  .shop-card img { width: 30px; height: 30px; }
  .shop-card span { min-width: 0; }
  .shop-card strong { font-size: 0.74rem; line-height: 1.2; }
  /* The hint line is for the adult, and there is no room for it three-up. */
  .shop-card small { display: none; }
}

.shop-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.shop-head h1 { margin: 0; flex: 1; }



.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.shop-item {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fffdf6;
  text-align: center;
}

.shop-item.is-owned { background: #f2fbf1; }

/* 48dp minimum touch target per docs/kids-gamification.md */
.item-art {
  width: 112px;
  height: 112px;
  padding: 6px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 160ms ease;
}

.item-art img { width: 100%; height: 100%; object-fit: contain; }
.item-art:hover { transform: translateY(-4px) scale(1.05); }

.item-price {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.item-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  font-size: 0.9rem;
}

.item-state.is-worn { color: #3f7d46; font-weight: 700; }
.item-state.is-locked { color: #b4472f; }
/* An item the coins do not reach yet: a quieter button that still answers a tap. */
.shop-item .item-short { min-height: 48px; display: inline-flex; align-items: center; gap: 6px; color: #b4472f; }
.shop-item .item-short svg { width: 1.5em; height: 1.5em; opacity: .55; }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.sticker-slot {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 18px 14px;
  border: 3px dashed rgba(75, 50, 40, 0.28);
  border-radius: 16px;
  background: #fffdf6;
  text-align: center;
}

.sticker-slot img { width: 84px; height: 84px; object-fit: contain; }
.sticker-slot.is-empty { opacity: 0.5; }
.sticker-slot.is-empty span { font-size: 2.2rem; }

/* ---- Capy's room: layered objects from the room manifest ---- */
.room-stage {
  position: relative;
  width: min(100%, 1100px);
  margin-inline: auto;
  aspect-ratio: var(--room-aspect, 3 / 2);
  border: 2px solid rgba(75, 50, 40, 0.16);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
}

.room-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

/* same anchor model as the island: the asset's anchor point lands on the spot */
.room-object,
.room-capy {
  position: absolute;
  transform: translate(calc(var(--anchor-x, 50%) * -1), calc(var(--anchor-y, 50%) * -1));
}

.room-capy {
  height: auto;
  aspect-ratio: var(--capy-aspect);
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(47, 35, 29, 0.28));
}

.room-object {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.room-object img {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: 50% 100%;   /* grows upward from where it stands, not off its base */
  transition: filter 180ms ease, transform 180ms ease;
}

/* Idle objects hold perfectly still - only the halo breathes. Under the pointer
   the object also grows, which is the clearest "you can press this" a child gets. */
.room-object:focus-visible img {
  animation: none;
  transform: scale(1.08);
  filter:
    drop-shadow(0 0 9px rgba(255, 255, 255, 1))
    drop-shadow(0 0 22px rgba(255, 255, 255, 1))
    drop-shadow(0 8px 10px rgba(47, 35, 29, 0.26));
}
@media (hover: hover) and (pointer: fine) {
  .room-object:hover img {
    animation: none;
    transform: scale(1.08);
    filter:
      drop-shadow(0 0 9px rgba(255, 255, 255, 1))
      drop-shadow(0 0 22px rgba(255, 255, 255, 1))
      drop-shadow(0 8px 10px rgba(47, 35, 29, 0.26));
  }
}

/* The press is the touch screen's answer to hover: it shows at once, under the finger. */
.room-object:active img {
  animation: none;
  transform: scale(.97);
  transition-duration: 80ms;
  filter:
    drop-shadow(0 0 9px rgba(255, 255, 255, 1))
    drop-shadow(0 0 22px rgba(255, 255, 255, 1))
    drop-shadow(0 8px 10px rgba(47, 35, 29, 0.26));
}

/* a playable object breathes so the child can find it without reading */
.room-object.is-ready img {
  animation: room-halo 2.6s ease-in-out infinite;
}

.room-object.is-soon img {
  filter: saturate(0.85) drop-shadow(0 6px 8px rgba(47, 35, 29, 0.2));
}

@media (max-width: 720px) {
  /* The cabinet is intentionally small beside the wardrobe, but its tap area still
     meets the child-UI floor. Keep the art centered at its manifest scale. */
  .room-object[data-room-object="badge-board"] {
    display: grid;
    place-items: center;
    /* The room stage scales by a fractional amount on narrow screens; 48px here
       measured as 47.986px in Playwright. One extra CSS pixel keeps the rendered
       target above the 48px child-control floor. */
    min-width: 49px;
    min-height: 49px;
  }

  .room-object[data-room-object="badge-board"] img {
    width: 71%;
  }
}

.room-object-icon {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (max-width: 720px) {
  .screen:has(.room-hub) { padding-inline: 0; }
  .lesson-shell:has(.room-hub) > .lesson-head,
  .lesson-shell:has(.room-hub) .capy-guide,
  .lesson-shell:has(.room-hub) .world-games-nav { margin-inline: 14px; }
  .room-hub { width: 100%; aspect-ratio: var(--room-phone-aspect); }
  .room-hub .room-object, .room-hub .room-capy {
    left: var(--room-phone-x) !important;
    top: var(--room-phone-y) !important;
    width: var(--room-phone-w) !important;
    --anchor-x: var(--room-phone-anchor-x) !important;
    --anchor-y: var(--room-phone-anchor-y) !important;
    --sx: var(--psx) !important; --sy: var(--psy) !important; --ax: var(--pax) !important; --ay: var(--pay) !important;
  }
  .room-hub .room-object { min-width: 49px; min-height: 49px; }
  .room-hub .room-object[data-room-object="badge-board"] img { width: 100%; }
  .room-hub .room-object .world-lock {
    left: auto;
    right: 0;
    top: auto;
    bottom: 0;
    width: 28px;
    transform: none;
    animation: none;
  }
  .room-hub .room-object .world-lock img { animation: none; }
  .lesson-shell:has(.room-hub) { gap: 12px; }
  .lesson-shell:has(.room-hub) .capy-guide { padding: 6px; grid-template-columns: 48px minmax(0,1fr); gap: 8px; }
  .lesson-shell:has(.room-hub) .capy-guide > img { width: 48px; height: 64px; object-fit: contain; }
  .lesson-shell:has(.room-hub) .speech-bubble { padding: 6px 10px; }
  .lesson-shell:has(.room-hub) .speech-bubble strong { display: none; }
  .lesson-shell:has(.room-hub) .speech-bubble p { margin: 2px 0; font-size: .85rem; }
  .lesson-shell:has(.room-hub) .replay-button { min-height: 48px; padding: 4px 10px; }
}

/* The halo follows the cut-out's own silhouette, because drop-shadow reads the
   alpha channel - a box outline would frame the transparent PNG, not the object. */
@keyframes room-halo {
  0%, 100% {
    filter:
      drop-shadow(0 0 4px rgba(255, 255, 255, 0.95))
      drop-shadow(0 0 10px rgba(255, 255, 255, 0.7))
      drop-shadow(0 8px 10px rgba(47, 35, 29, 0.26));
  }
  50% {
    filter:
      drop-shadow(0 0 8px rgba(255, 255, 255, 1))
      drop-shadow(0 0 20px rgba(255, 255, 255, 0.95))
      drop-shadow(0 8px 10px rgba(47, 35, 29, 0.26));
  }
}

.room-note {
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fffdf6;
}

/* Hunt phase reuses the room stage; only the target objects respond. */
.room-stage.is-hunt {
  width: 100%;
  max-width: none;
}

.room-prop {
  position: absolute;
  height: auto;
  pointer-events: none;
  transform: translate(calc(var(--anchor-x, 50%) * -1), calc(var(--anchor-y, 50%) * -1));
}

.room-object.is-target img {
  animation: room-halo 2.6s ease-in-out infinite;
}

.room-object.is-found img {
  animation: none;
  filter: drop-shadow(0 0 12px rgba(99, 184, 93, 0.9)) saturate(1.15);
}

/* The parent dashboard is the one adult destination. It sits alone at the far left
   of the bar, away from the child's two big playful buttons, and is styled plainly
   rather than cutely - a grown-up control among toys. Plain is NOT faded: the ink
   is full strength, because a greyed label reads as a switched-off button. */
.parent-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1.5px solid rgba(75, 50, 40, 0.3);
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: none;
}

.parent-link:hover {
  border-color: var(--line);
  background: rgba(75, 50, 40, 0.06);
}

.parent-link svg {
  width: 1.15em;
  height: 1.15em;
}

/* ---- Palette: the real painted artwork, colours unlabelled ---- */
.palette-viewport { min-width: 0; width: 100%; }
.paint-palette {
  position: relative;
  width: min(100%, 560px);
  margin-inline: auto;
  aspect-ratio: 949 / 641;
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
}

.paint-palette > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(47, 35, 29, 0.22));
}

/* Round hit area over each painted blob. Generous for small hands: at 560px wide
   this is ~62px, comfortably over the 48dp minimum. */
.paint-palette .paint-well {
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.paint-palette .paint-well:hover {
  transform: translate(-50%, -50%) scale(1.18);
  border-color: rgba(255, 255, 255, 0.9);
}

.paint-palette .paint-well.is-active {
  border-color: #fffdf6;
  box-shadow: 0 0 0 3px var(--paint), 0 0 16px var(--paint);
  animation: paint-pulse 1.8s ease-in-out infinite;
}
/* During the praise the practice palette's colours are disabled, and the global disabled style
   (half faded, a grey shadow, no transform) moved the ring of a right answer half a circle off
   its colour and washed it out (Dana, December 2, 2026: practice showed no ring like the
   introduction). Here it keeps its place, its colour and its pulse; `scale` pulses because the
   global rule pins `transform`. */
.palette-lesson .paint-palette .paint-well:disabled { opacity: 1; cursor: default; transform: translate(-50%, -50%) !important; box-shadow: none !important; }
.palette-lesson .paint-palette .paint-well.is-active:disabled { box-shadow: 0 0 0 3px var(--paint), 0 0 16px var(--paint) !important; animation: paint-pulse-scale 1.8s ease-in-out infinite; }
@keyframes paint-pulse-scale { 0%, 100% { scale: 1.05; } 50% { scale: 1.2; } }
@media (prefers-reduced-motion: reduce) { .palette-lesson .paint-palette .paint-well.is-active:disabled { animation: none; } }

@keyframes paint-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1.05); }
  50% { transform: translate(-50%, -50%) scale(1.2); }
}

/* The grid was stretching .paint-palette taller than the artwork, so object-fit
   letterboxed the image and every percentage-positioned well drifted by ~71px.
   Shrink-wrap the image instead: no aspect-ratio, no object-fit, so the container
   box IS the artwork box and percentages map 1:1. */
.paint-palette {
  aspect-ratio: auto;
  height: auto;
  min-height: 0;
  align-self: start;
  justify-self: center;
  line-height: 0;
}

.paint-palette > img {
  width: 100%;
  height: auto;
  object-fit: fill;
}

.paint-palette > .palette-phone-art { display: none; }
/* The paint over the empty palette, shown only where a colour is open (paletteMask). It lies
   exactly on the empty picture under it, which carries the shadow. */
.paint-palette > img.palette-paint-layer { position: absolute; left: 0; top: 0; width: 100%; height: 100%; filter: none; pointer-events: none; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
/* A colour still waiting to be heard for the first time shines softly (the introduction). */
.paint-palette .paint-well.is-new { border-color: rgba(255, 248, 205, .95); box-shadow: 0 0 0 3px rgba(255, 236, 150, .8), 0 0 18px rgba(255, 226, 120, .9); animation: paint-new 1.6s ease-in-out infinite; }
@keyframes paint-new { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .paint-palette .paint-well.is-new { animation: none; } }

/* Keep the image and anchors in one coordinate space. At least 400px
   makes 12% wells reach 48px without overlap. The viewport clips the decorative
   brush on the right, not the palette controls; narrow phones also give up the
   card gutter. These rules follow the desktop declarations to win the cascade. */
@media (max-width: 720px) {
  .palette-viewport {
    width: auto;
    min-width: 0;
    margin-inline: -16px;
    overflow: hidden;
    direction: ltr;
  }
  .paint-palette {
    width: max(100%, 400px);
    justify-self: start;
    max-width: none;
    margin: 0;
  }

  .paint-palette > .palette-desktop-art { display: none; }
  .paint-palette > .palette-phone-art { display: block; }

  .paint-palette .paint-well {
    width: 12%;
  }
}

/* Explicit "hear it again" control - the auto-repeat is invisible, so a child who
   missed the instruction has nothing to reach for. */
@media (max-width: 350px) {
  /* Give up the card gutter before clipping the black answer on a narrow phone. */
  .palette-viewport { margin-inline: -30px; }
}

/* Explicit "hear it again" control - the auto-repeat is invisible, so a child who
   missed the instruction has nothing to reach for. */
.replay-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fffdf6;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
}

.replay-button:hover { transform: translateY(-2px); }

/* The rescue highlight, shown only after two misses (see chooseGuidedColor).
   The question itself never carries a cue - if this is on screen, the child has
   already tried twice and the point is that they finish by tapping it themselves. */
.paint-palette .paint-well.is-target {
  border-color: #fffdf6;
  box-shadow: 0 0 0 4px var(--paint), 0 0 20px var(--paint);
  animation: paint-pulse 1.4s ease-in-out infinite;
  z-index: 3;
}

/* Dimming the other nine is NOT possible by styling them: .paint-well is a
   transparent hotspot sitting over the palette artwork, so it has no visible body
   and opacity on it changes nothing on screen. (An earlier attempt set opacity
   here, measured "9 wells dimmed", and was completely invisible - the check passed
   on elements the child cannot see.) The artwork itself is washed out instead, and
   the ring below is drawn in CSS so it stays vivid on top of it. */
.paint-palette.is-guiding > img {
  /* The drop-shadow is repeated here on purpose: `filter` is a single shorthand,
     not an additive list, so naming only the wash silently drops the palette's
     shadow and it visibly flattens the moment the aid appears. */
  filter: drop-shadow(0 10px 14px rgba(47, 35, 29, 0.22)) saturate(0.3) brightness(1.05);
  transition: filter 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .paint-palette .paint-well.is-target,
  .paint-palette .paint-well.is-active { animation: none; }
}

/* ---- Icons on every control a child touches ---- */
.main-nav button svg,
.icon-button svg,
.primary-button svg,
.secondary-button svg,
.ghost-button svg,
.step-pill svg,
.replay-button svg {
  width: 1.6em;
  height: 1.6em;
  flex: none;
  vertical-align: -0.32em;
}

/* Phase icons carry the most meaning for a non-reader, so they are largest. */
.step-pill svg { width: 2em; height: 2em; }

.main-nav button,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fffdf6;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover { transform: translateY(-2px); }

/* Phase pills are buttons now: any phase is reachable directly, not only in order. */
.step-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fffdf6;
  font-family: inherit;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease;
}

.step-pill:hover { transform: translateY(-2px); }
.step-pill.is-current { background: #e8f6f8; border-color: #70d7df; }
.step-pill.is-done { opacity: 0.75; }
.step-pill strong { flex: 1; font-size: 0.95rem; }

.step-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(75, 50, 40, 0.1);
  font-size: 0.85rem;
  font-weight: 700;
  flex: none;
}

/* Paint targets are shapes, not words: the child recognises a ball, not "כדור". */
.paint-board {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.paint-object {
  width: 76px;
  height: 76px;
  padding: 6px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: transparent;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

.paint-object svg { width: 100%; height: 100%; }
.paint-object:hover { transform: translateY(-4px) scale(1.05); }
.paint-object.is-active { border-color: #70d7df; background: #eaf7f9; }
.paint-object.is-painted { border-color: rgba(75, 50, 40, 0.18); }

/* The speaker is the whole game in the guided phase, so it leads visually. */
.icon-button.is-prompt {
  min-height: 60px;
  padding: 10px 22px;
  font-size: 1.05rem;
  font-weight: 700;
  border-color: #70d7df;
  background: #eaf7f9;
}

.icon-button.is-prompt svg { width: 2.1em; height: 2.1em; }

/* The only way out of a finished game. Deliberately loud - it is the one thing
   the child should reach for once the game is done. */
.primary-button.is-next-game {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  min-height: 60px;
  padding: 12px 26px;
  font-size: 1.1rem;
  font-weight: 700;
  animation: next-game-bob 2.4s ease-in-out infinite;
}

.primary-button.is-next-game svg { width: 2em; height: 2em; }

/* The pointing hand: when one thing must be pressed, it points at it (Dana chose the hand on
   November 30, 2026). The button out of a finished game always carries it, beside it and clear
   of the stars above; a scene puts .point-here on the one object to press on a first visit,
   and that object comes in front of Capy so the hand is never hidden. It taps towards its
   target, stands still under reduced motion, and never takes a tap. */
.primary-button.is-next-game { position: relative; overflow: visible; }
.point-here { overflow: visible; z-index: 60 !important; }
/* The way to the shop from an empty closet, toy box or album: the loud button with the hand.
   The hand stands to the button's right, so the row keeps that room free. */
.shop-way { display: flex; justify-content: center; width: 100%; min-width: 0; padding-right: 66px; box-sizing: border-box; }
.shop-way .primary-button { margin-top: 6px; }
.primary-button.is-next-game::before, .point-here::after {
  content: ""; position: absolute; z-index: 6; width: 52px; height: 72px; pointer-events: none;
  background: url("assets/mvp/ui/pointer-hand-v1.webp") center / contain no-repeat;
  filter: drop-shadow(0 3px 2px rgba(75, 50, 40, .25));
  animation: point-hand 1s ease-in-out infinite;
}
.point-here::after { left: 50%; margin-left: -26px; top: var(--point-top, -70px); }
.numbers-tree.point-here { --point-top: 12%; }
/* In Capy's room the hand comes in diagonally from the left, so it never covers Capy, who
   stands beside the palette on a phone and a tablet (Dana, November 30). */
/* The picture clips what leaves it, so the hand keeps a distance from its left and top edges
   (Dana, December 1, 2026: on a phone the hand at the newly opened bed was hidden at the side).
   The object's own edge is at --sx cqw minus --ax percent of its width; the hand moves in only
   as far as it must. The margins hold the turned hand and the way it travels. */
.room-hub { container-type: size; }
.room-object.point-here::after {
  left: max(-24%, calc(34px - var(--sx) * 1cqw + var(--ax) * 1%));
  top: max(-50px, calc(26px - var(--sy) * 1cqh + var(--ay) * 1%));
  margin-left: 0; rotate: -40deg; animation-name: point-hand-diagonal;
}
@keyframes point-hand-diagonal { 0%, 100% { translate: -8px -8px; } 50% { translate: 0 0; } }
/* On the colour practice's speaker the hand comes from the right, over the bare wood, so it
   covers none of the colours around the speaker (December 1, 2026). */
.palette-speaker.point-here::after { left: calc(100% + 6px); top: 50%; margin-left: 0; margin-top: -36px; rotate: 90deg; animation-name: point-hand-side; }
/* In the building game the speaker is a wide bar between the toy and the tray: the hand points
   from inside it, at the ear in its middle, so it covers neither a block nor the toy (December 2). */
.build-panel .block-speaker.point-here { position: relative; }
/* In the quilt the speaker bar carries the ear and "מה נגרור?": the hand points from the bar's
   right end at the ear, covering neither the words nor a patch (December 2). */
.quilt-panel .block-speaker.point-here { position: relative; }
.quilt-panel .block-speaker.point-here::after { left: auto; right: 14px; top: 50%; margin-left: 0; margin-top: -36px; rotate: 90deg; animation-name: point-hand-side; }
.build-panel .block-speaker.point-here::after { left: calc(50% + 34px); top: 50%; margin-left: 0; margin-top: -36px; rotate: 90deg; animation-name: point-hand-side; }
.primary-button.is-next-game::before { left: calc(100% + 14px); top: 50%; margin-top: -36px; rotate: 90deg; animation-name: point-hand-side; }
@keyframes point-hand { 0%, 100% { translate: 0 -10px; } 50% { translate: 0 0; } }
@keyframes point-hand-side { 0%, 100% { translate: 10px 0; } 50% { translate: 0 0; } }
@media (prefers-reduced-motion: reduce) { .primary-button.is-next-game::before, .point-here::after { animation: none; } }

@media (prefers-reduced-motion: reduce) { .primary-button.is-next-game { animation: none; } }
@keyframes next-game-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* ---- Free-drawing studio: the canvas is the game ---- */
.paint-studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 320px);
  gap: 18px;
  align-items: start;
}

.paint-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1000 / 700;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
  box-shadow: 0 14px 0 rgba(75, 50, 40, 0.1);
  touch-action: none;          /* the finger draws; it must not scroll the page */
}

.studio-side {
  display: grid;
  gap: 12px;
}

.studio-tools {
  display: grid;
  gap: 8px;
}

.studio-tools button {
  width: 100%;
  justify-content: center;
}

/* The centre of the palette shows the colour now on the brush. */
.palette-center-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--paint);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.13);
}

@media (max-width: 980px) {
  .paint-studio {
    grid-template-columns: 1fr;
  }
}

/* Measured slot: the centroid of the ten paint blobs is bare wood, 18.7% of the
   image width clear of the nearest blob, so a control here covers no colour. */
.palette-center {
  position: absolute;
  left: 35.3%;
  top: 44.9%;
  width: 19%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
}

.palette-speaker {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 0;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: #fffdf6;
  box-shadow: 0 5px 0 rgba(75, 50, 40, 0.16);
  cursor: pointer;
  animation: capy-breathe 2.4s ease-in-out infinite;
}

.palette-speaker:hover { transform: translateY(-2px); }
.palette-speaker:active { transform: translateY(1px); }

.palette-speaker svg {
  width: 60%;
  height: 60%;
}

/* Reduced motion keeps every control and drops the idle breathing. */
@media (prefers-reduced-motion: reduce) {
  .palette-speaker,
  .capy-guide img { animation: none; }
}

/* Phone: the colour game's guide is the same compact card the other games use, and
   the practice heading, which repeats the guide, gives its line to the palette. */
@media (max-width: 720px) {
  .lesson-shell:has(.palette-lesson) .capy-guide { padding: 8px; }
  .lesson-shell:has(.palette-lesson) .capy-guide > img { width: 52px; height: 80px; object-fit: contain; }
  .lesson-shell:has(.palette-lesson) .speech-bubble { padding: 8px 12px; }
  .lesson-shell:has(.palette-lesson) .speech-bubble p { margin: 4px 0; font-size: .95rem; }
  /* No heading on a phone, as in building, the window and the studio: the body says it. */
  .lesson-shell:has(:is(.palette-lesson, .quilt-panel)) .speech-bubble > strong { display: none; }
  .lesson-panel:has(> .palette-lesson.is-solo) > h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* ---- The child's own paintings, kept in their album ---- */
.gallery-title {
  margin: 22px 0 10px;
  font-size: 1.15rem;
}

.art-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

/* Each painting is a button: tapping it opens the picture large. */
.art-gallery button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 14px;
  transition: transform 0.12s ease;
}

.art-gallery button:hover,
.art-gallery button:focus-visible {
  transform: translateY(-3px) scale(1.02);
}

.art-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 10 / 7;
  object-fit: cover;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fffdf7;
  box-shadow: 0 8px 0 rgba(75, 50, 40, 0.1);
}

/* ---- One painting, opened big ---- */
.artwork-viewer {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.artwork-large {
  display: block;
  width: 100%;
  max-width: 720px;
  /* The picture must fit WITHOUT the download button scrolling off: a child who
     cannot see the button will not find it. The modal card's own padding and the
     heading are what the subtraction accounts for. */
  max-height: min(58vh, 520px);
  object-fit: contain;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fffdf7;
  box-shadow: 0 10px 0 rgba(75, 50, 40, 0.12);
}

.artwork-viewer .primary-button {
  min-width: min(100%, 320px);
}

/* Two ways out of a finished picture: keep drawing on it, or keep a copy of it.
   Continuing is the child's - a paintbrush, leading back into the game - so it is the
   primary; downloading is the adult's and stays quiet beside it, the same way the
   parent dashboard nav is deliberately recessed.

   One ROW, not stacked: .artwork-large sizes itself to leave room for the controls
   below it, and a child who has to scroll to find the button will not find it. Both
   buttons fit on a line inside the 720px card, so the viewer is no taller than it was
   with the single download button. */
.artwork-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.artwork-actions .primary-button,
.artwork-actions .ghost-button {
  min-width: min(100%, 230px);
  justify-content: center;
}

/* ---- Blank paper or a colouring page: a change of paper, not of game ---- */
.art-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.art-mode {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 6px 14px;
  border: 2.5px solid var(--line);
  border-radius: 12px;
  background: #fffdf6;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 4px 0 rgba(75, 50, 40, 0.13);
  cursor: pointer;
}

.art-mode.is-active {
  background: #f3c73f;
  box-shadow: 0 4px 0 rgba(75, 50, 40, 0.26);
}

.art-mode svg {
  width: 1.5em;
  height: 1.5em;
  flex: none;
}

/* ---- A room title belongs over the room, not off in a corner ----
   Three columns so the heading is centred on the stage no matter how wide the
   button beside it is. In RTL, grid column 1 is the visual RIGHT edge. */
.shop-head.is-centered,
.view-title.is-centered {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.shop-head.is-centered h1,
.view-title.is-centered h1 {
  grid-column: 2;
  grid-row: 1;
  text-align: center;
}

.view-title.is-centered .ghost-button {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

/* The purse stays out at the edge so the title keeps the middle to itself. */
.shop-head.is-centered .coin-balance {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

@media (max-width: 720px) {
  .shop-head.is-centered,
  .view-title.is-centered {
    grid-template-columns: auto 1fr;
  }

  .shop-head.is-centered h1,
  .view-title.is-centered h1 {
    grid-column: 2;
    text-align: start;
  }
}

/* ---- Capy's wardrobe: what the coins actually bought, worn ---- */
.wardrobe-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin-top: 16px;
}

.wardrobe-capy {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  border: 3px solid var(--line);
  border-radius: 22px;
  background: #fffdf6;
  box-shadow: 0 10px 0 rgba(75, 50, 40, 0.1);
}

.wardrobe-capy img {
  aspect-ratio: var(--capy-aspect);
  object-fit: contain;
  width: 100%;
  max-width: 240px;
  height: auto;
}

.wardrobe-capy p {
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* A slot with nothing in it is quiet, not broken-looking. */
.shop-item.is-empty-slot img {
  opacity: 0.38;
  filter: grayscale(0.7);
}

.shop-item.is-worn-now {
  border-color: #f3c73f;
  box-shadow: 0 8px 0 rgba(243, 199, 63, 0.4);
}

@media (max-width: 860px) {
  .wardrobe-layout {
    grid-template-columns: 1fr;
  }
}

/* ---- The closet opens over the room it belongs to ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(47, 35, 29, 0.45);
  backdrop-filter: blur(3px);
}

/* Only on the render that opened it - see modalEntering in app.js. */
.modal-backdrop.is-entering {
  animation: modal-in 180ms ease-out;
}

/* The card is a FRAME, not the scroller. It used to scroll itself, and because the
   close button is positioned against it the X scrolled away with the content - in the
   album, 425px above the top of the card, so the one control a child needs to get out
   was simply gone. The title and the X sit on the frame and stay put; .modal-body is
   what scrolls underneath them. */
.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 900px);
  max-height: 88vh;
  padding: 26px;
  border: 3px solid var(--line);
  border-radius: 26px;
  background: var(--paper, #fffaf0);
  box-shadow: 0 22px 0 rgba(75, 50, 40, 0.18);
}

/* min-height: 0 or the flex item refuses to shrink below its content and the card
   grows past its own max-height instead of scrolling. */
.modal-body {
  overflow-y: auto;
  min-height: 0;
  /* room for the scrollbar so it never sits on top of the content it scrolls */
  padding-inline-end: 2px;
}

.modal-card h2 {
  margin: 0;
  text-align: center;
  font-size: 1.6rem;
}

/* Pinned to the corner the reading eye leaves from: in RTL that is the left. */
.modal-close {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.modal-close svg {
  width: 38px;
  height: 38px;
}

.modal-close:hover svg { transform: scale(1.08); }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---- Progress a five-year-old can read: stars, not a fraction ---- */
.progress-stars {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: #fffdf6;
  box-shadow: 0 4px 0 rgba(75, 50, 40, 0.12);
}

.progress-star {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  transition: transform 220ms ease, opacity 220ms ease, filter 220ms ease;
}

.progress-star svg {
  width: 100%;
  height: 100%;
}

/* Not yet earned: present, so the child can see how many are still to come, but
   clearly not theirs yet. */
.progress-star:not(.is-earned) {
  opacity: 0.3;
  filter: grayscale(1);
  transform: scale(0.84);
}

.progress-star.is-earned {
  opacity: 1;
  filter: drop-shadow(0 2px 3px rgba(243, 199, 63, 0.55));
  transform: scale(1);
}

/* The last star landing completes the row - worth a beat of celebration. */
.progress-stars:not(:has(.progress-star:not(.is-earned))) {
  border-color: #f3c73f;
  background: #fff8e2;
  /* --stars-delay: a screen that redraws while the row is full (the numbers introduction, once
     per coconut) resumes the pulse where it was, so the stars do not shake (November 30). */
  animation: stars-complete 620ms var(--stars-delay, 0ms) ease-out both;
}

@keyframes stars-complete {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.09); }
  100% { transform: scale(1); }
}

@media (max-width: 720px) {
  /* Ten stars at 26px with 6px gaps and 12px padding need 344px, and a phone's
     lesson panel has about 307px inside it. Being an inline-flex row that refuses
     to shrink, that 344 became the panel's min-content width and pushed the whole
     BLOCKS screen 31px off the left edge of the phone, with a horizontal scrollbar
     under it. Smaller stars and tighter spacing fit the row at 390px; wrapping is
     the backstop for narrower phones, so it folds to two rows instead of pushing
     the page sideways again. */
  .progress-stars {
    flex-wrap: wrap;
    justify-content: center;
    min-width: 0;
    gap: 4px;
    padding: 6px 8px;
  }

  .progress-star { width: 24px; height: 24px; }
}

/* ---- The sticker album: a book the child sticks into ---- */
.album-hint {
  margin: 14px 0 10px;
  text-align: center;
  color: var(--ink-soft);
}

.album-book {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: min(100%, 880px);
  justify-self: center;
  border: 3px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fffdf6;
  box-shadow: 0 16px 0 rgba(75, 50, 40, 0.14);
}

.album-page {
  position: relative;
  aspect-ratio: 1 / 1;
  background:
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(75, 50, 40, 0.07) 38px 39px),
    linear-gradient(180deg, #fffefa, #fdf6e6);
}

/* The spine: an inner shadow on each facing edge reads as a fold. */
.album-page:first-child {
  box-shadow: inset -22px 0 26px -18px rgba(75, 50, 40, 0.55);
  border-inline-end: 2px solid rgba(75, 50, 40, 0.35);
}

.album-page:last-child {
  box-shadow: inset 22px 0 26px -18px rgba(75, 50, 40, 0.55);
}

.album-book.is-placing .album-page {
  cursor: copy;
  background:
    repeating-linear-gradient(0deg, transparent 0 38px, rgba(75, 50, 40, 0.07) 38px 39px),
    linear-gradient(180deg, #fffbe9, #fff4d4);
}

.album-sticker {
  position: absolute;
  width: 17%;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%) rotate(var(--spin, 0deg));
  cursor: pointer;
  filter: drop-shadow(0 4px 5px rgba(75, 50, 40, 0.28));
  transition: transform 160ms ease;
}

.album-sticker img { display: block; width: 100%; height: auto; }

.album-sticker:hover {
  transform: translate(-50%, -50%) rotate(var(--spin, 0deg)) scale(1.09);
}

/* ---- The tray: bought, not yet stuck down ---- */
.album-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: min(100%, 1000px);
  justify-self: center;
  margin-top: 16px;
  padding: 12px;
  border: 3px dashed rgba(75, 50, 40, 0.3);
  border-radius: 18px;
  min-height: 96px;
  align-items: center;
}

.tray-sticker {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: 92px;
  padding: 8px 6px;
  border: 2.5px solid var(--line);
  border-radius: 14px;
  background: #fffdf6;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(75, 50, 40, 0.14);
}

.tray-sticker img { width: 56px; height: 56px; object-fit: contain; }
.tray-sticker small { font-size: 0.78rem; }

.tray-sticker.is-held {
  border-color: #f3c73f;
  background: #fff8e2;
  box-shadow: 0 0 0 4px rgba(243, 199, 63, 0.45);
  transform: translateY(-3px);
}

.tray-empty {
  margin: 0;
  color: var(--ink-soft);
  text-align: center;
}

@media (max-width: 720px) {
  .album-book { grid-template-columns: 1fr; }
  .album-page:first-child,
  .album-page:last-child { box-shadow: none; }
}

/* ---- Dragging a sticker ---- */
.sticker-ghost {
  position: fixed;
  z-index: 90;
  width: 84px;
  height: 84px;
  object-fit: contain;
  transform: translate(-50%, -50%) rotate(-6deg) scale(1.12);
  pointer-events: none;          /* must never block the drop target underneath */
  filter: drop-shadow(0 10px 12px rgba(75, 50, 40, 0.4));
}

.tray-sticker.is-dragging,
.album-sticker.is-dragging {
  opacity: 0.28;
}

/* The whole book invites a drop while something is in the air. */
.album-book:has(~ .album-tray .is-dragging),
.album-book:has(.is-dragging) {
  outline: 3px dashed rgba(243, 199, 63, 0.9);
  outline-offset: 4px;
}

.tray-sticker,
.album-sticker {
  touch-action: none;            /* the finger drags the sticker, not the page */
}

/* ---- The purse in the top bar ---- */
.topbar-end {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

.coin-balance.is-topbar {
  padding: 5px 12px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: #fff8e2;
  box-shadow: 0 3px 0 rgba(75, 50, 40, 0.14);
}

.coin-balance.is-topbar strong {
  font-size: 1.02rem;
  min-width: 1.2em;
  text-align: center;
}

/* A coin on its way to the purse: bigger than the one in the purse so a small child sees it,
   above everything, and never in the way of a tap. */
.coin-fly { position: fixed; z-index: 2000; width: 36px; height: 36px; margin: 0; pointer-events: none; box-shadow: 0 3px 6px rgba(75, 50, 40, .28); will-change: transform; }
.coin-balance.is-topbar.just-earned {
  animation: coin-pop 520ms ease-out;
}

@keyframes coin-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); background: #ffe9a8; }
  100% { transform: scale(1); }
}

@media (max-width: 720px) {
  .coin-balance.is-topbar { padding: 4px 9px; }
  .coin-balance.is-topbar strong { font-size: 0.92rem; }
}

/* The album needs more room than a wardrobe: two pages side by side plus a tray. */
.modal-card.is-wide {
  width: min(100%, 1000px);
}

/* Signed out: the offer to save the child's progress, read by the parent. A choice, not
   a notice, so it has two answers and no X; the primary one comes first. */
.save-prompt .modal-card { width: min(100%, 520px); text-align: center; }
/* Capy greets the parent from behind a little hill of island grass (Dana, November 27: the
   popup was too plain). Decoration only, so a pseudo-element: the card keeps its frame of
   heading plus scroller. The first layer paints on top, so the hill hides his legs. His
   frame is 636x1219 with empty headroom for hats, hence the negative offset. */
.save-prompt .modal-card::before {
  content: "";
  flex: 0 0 auto;
  display: block;
  width: 180px;
  height: 140px;
  margin: -6px auto 8px;
  background:
    radial-gradient(ellipse 42% 20% at 50% 100%, #a9cf8f 0 97%, transparent 100%),
    radial-gradient(ellipse 30% 13% at 20% 100%, #c3dea6 0 96%, transparent 100%),
    radial-gradient(ellipse 30% 13% at 80% 100%, #c3dea6 0 96%, transparent 100%),
    url("assets/mvp/ui/capy-none-v2.png") 50% -24px / 92px auto no-repeat;
}
@media (max-width: 720px) {
  .save-prompt .modal-card::before { width: 130px; height: 100px; margin: -10px auto 2px;
    background-size: auto, auto, auto, 66px auto; background-position: 0 0, 0 0, 0 0, 50% -17px; }
}
.save-prompt .modal-body p { margin: 14px 0 20px; font-size: 1.1rem; line-height: 1.5; }
/* A parent arriving on the site meets this popup first, so it says what the site is before it
   asks anything (Dana, November 27): the guide's own opening, three facts, then the question. */
.save-prompt .modal-body .save-prompt-lead { margin: 6px 0 12px; font-size: 1.05rem; }
.save-prompt-points { display: grid; gap: 6px; margin: 0 0 4px; padding: 12px 14px; list-style: none; text-align: start;
  background: #f3efe2; border-radius: 14px; font-size: 1rem; line-height: 1.45; }
.save-prompt-points li { position: relative; padding-inline-start: 18px; }
.save-prompt-points li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .55em; width: 8px; height: 8px;
  border-radius: 50%; background: var(--teal); }
.save-prompt .modal-body .save-prompt-ask { margin: 12px 0 14px; }
.save-prompt .modal-card { max-height: calc(100dvh - 40px); }
.save-prompt-actions { display: grid; gap: 12px; flex: 0 0 auto; }
.save-prompt-guide { flex: 0 0 auto; }
@media (max-height: 720px) {
  .save-prompt .modal-card { padding: 16px 18px; max-height: calc(100dvh - 24px); }
  .save-prompt .modal-card::before { width: 96px; height: 72px; margin: -6px auto 0; }
  .save-prompt .modal-card h2 { font-size: 1.35rem; }
  .save-prompt-actions { gap: 8px; }
  .save-prompt-actions button { min-height: 50px; }
  .save-prompt-guide { margin-top: 6px; }
}
.save-prompt-actions button { width: 100%; min-height: 56px; justify-content: center; }
/* The page the confirmation email opened: the address is confirmed, signing in is next. */
.save-prompt .modal-body .save-prompt-status { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: #dcefee; color: var(--teal-dark); font-size: 1rem; font-weight: 700; }
/* A link to the parents' guide under the popup's two actions: quieter than both. */
.save-prompt-guide { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; margin: 14px auto 0; padding: 0 12px; border: 0; background: none; color: var(--teal-dark); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.save-prompt-guide svg { width: 22px; height: 22px; flex: 0 0 auto; }
.parent-headline.is-empty { display: grid; gap: 10px; justify-items: start; }
.parent-headline.is-empty > * { margin: 0; min-width: 0; }
.parent-headline.is-empty h3 { font-size: 1.35rem; }
.parent-headline.is-empty p { font-size: 1.1rem; }
.parent-headline.is-empty button { min-height: 48px; }

/* The parents' question (parent.js renderParentGate): plain parent text, the number in
   words large on a cream panel, the digits typed left to right. */
.parent-gate .modal-card { width: min(100%, 480px); }
.parent-gate .modal-body { display: grid; gap: 14px; padding-top: 14px; }
.parent-gate .modal-body > * { min-width: 0; margin: 0; }
.parent-gate-words { padding: 12px; border-radius: 14px; background: var(--cream); text-align: center; font-size: 1.9rem; font-weight: 900; }
.parent-gate-field { display: grid; gap: 8px; font-weight: 700; }
.parent-gate-field input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 52px; padding: 0 12px; border: 2px solid var(--line); border-radius: 14px; background: #fff; text-align: center; font-size: 1.4rem; font-weight: 700; }
.parent-gate-actions { display: grid; gap: 12px; }
.parent-gate-actions button { width: 100%; min-height: 52px; justify-content: center; }

.modal-card.is-wide .album-book,
.modal-card.is-wide .album-tray {
  width: 100%;
}


/* ---- Parent dashboard: a report card, not a leaderboard ---- */
.parent-headline {
  margin: 18px 0 6px;
  padding: 18px 20px;
  background: #fffdf6;
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 0 rgba(75, 50, 40, 0.08);
}

.parent-headline p {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.5;
}

.parent-headline strong {
  color: #2f83e6;
  font-size: 1.6rem;
}

.parent-headline small,
.parent-card small {
  display: block;
  margin-top: 8px;
  color: #7a675e;
  line-height: 1.6;
}

.parent-group-title {
  margin: 22px 0 10px;
  font-size: 1.05rem;
}

.parent-group-title span {
  color: #7a675e;
  font-weight: 500;
}

.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.parent-topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 18px; margin: 24px 0; align-items: start; }
.parent-topic { min-width: 0; padding: 20px; background: #fffdf6; border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 5px 0 rgba(75, 50, 40, .06); }
.parent-topic-heading { display: flex; align-items: center; gap: 12px; min-width: 0; padding-bottom: 14px; border-bottom: 1px solid #e7dfd1; }
.parent-topic-heading > div { min-width: 0; }
.parent-topic h2 { margin: 0; font-size: 1.25rem; }
.parent-topic-counts { margin: 5px 0 0; color: #68574e; font-size: .95rem; }
.parent-topic-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; background: #e8f2ee; }
.parent-topic-icon svg { width: 28px; height: 28px; }
.parent-topic .parent-group-title { margin: 16px 0 10px; font-size: .95rem; }
.parent-topic .word-chip { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }

/* The parents' area tabs: the dashboard and the guide (parent.js renderParentTabs). */
.parent-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: min(100%, 400px); margin: 4px 0 20px; }
.parent-tabs button { min-width: 0; min-height: 48px; justify-content: center; }
.parent-tabs button[aria-pressed="true"] { color: #fff; background: var(--teal); border-color: var(--teal-dark); }

/* The guide (parent.js renderParentGuide): the dashboard's card look, one column on a
   phone and two read right to left above it. */
.parent-guide { display: grid; gap: 18px; min-width: 0; }
.parent-guide > * { min-width: 0; }
.parent-guide-intro { max-width: 760px; }
.parent-guide-intro h2 { margin: 0 0 8px; font-size: 1.6rem; }
.parent-guide-intro p { margin: 0; font-size: 1.05rem; line-height: 1.6; color: #4b3a31; }
.parent-guide-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: stretch; }
.parent-guide-card { min-width: 0; display: grid; align-content: start; gap: 10px; padding: 20px; background: #fffdf6; border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 5px 0 rgba(75, 50, 40, .06); }
.parent-guide-card > * { min-width: 0; margin: 0; }
.parent-guide-card h3 { font-size: 1.2rem; }
.parent-guide-card p, .parent-guide-card li { line-height: 1.6; }
.parent-guide-muted { color: var(--ink-soft); font-size: .95rem; }
.parent-guide-steps { display: grid; gap: 10px; padding-inline-start: 1.4em; }
.parent-guide-note { padding: 10px 12px; border-radius: 12px; background: var(--cream); }
.parent-guide-note p { margin: 4px 0 0; }
.parent-guide-chip { display: flex; align-items: center; gap: 12px; }
.parent-guide-chip .word-chip { flex: 0 0 auto; }
.parent-guide-chip p { margin: 0; min-width: 0; font-size: .95rem; }
.parent-guide-signup { display: grid; gap: 12px; min-width: 0; padding: 18px 20px; border: 2px solid var(--teal-dark); border-radius: 18px; background: #dcefee; }
.parent-guide-signup > * { min-width: 0; }
.parent-guide-signup h3, .parent-guide-signup p { margin: 0; }
.parent-guide-signup h3 { margin-top: 6px; font-size: 1.2rem; }
.parent-guide-signup p { margin-top: 4px; line-height: 1.6; }
.parent-guide-tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: #fff; border: 1px solid var(--teal-dark); color: var(--teal-dark); font-size: .8rem; font-weight: 700; }
.parent-guide-signup button { min-height: 52px; justify-content: center; }
/* Who built the site: the guide's last card, a person rather than a rule. */
.parent-guide-about { display: grid; gap: 6px; min-width: 0; padding: 18px 20px; border: 2px solid var(--line); border-radius: 18px; background: var(--cream); }
.parent-guide-about > * { min-width: 0; margin: 0; }
.parent-guide-about h3 { margin-bottom: 4px; font-size: 1.2rem; }
.parent-guide-about p { line-height: 1.6; overflow-wrap: anywhere; }
.parent-guide-about a { color: var(--teal-dark); font-weight: 700; text-underline-offset: 3px; }
/* The guide's pictures: one example per card, right under its heading. Nothing here is a
   control, so nothing answers the pointer. */
.parent-guide img { max-width: 100%; }
.parent-guide-intro { display: flex; align-items: center; gap: 14px; }
.parent-guide-intro > div { min-width: 0; }
.parent-guide-capy { flex: 0 0 auto; width: auto; height: 88px; }
.parent-guide-pic { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; user-select: none; -webkit-user-select: none; pointer-events: none; }
.parent-guide-screens { flex-wrap: nowrap; }
.parent-guide-screen { flex: 0 1 150px; min-width: 0; margin: 0; text-align: center; }
.parent-guide-screen img { display: block; width: 100%; height: auto; aspect-ratio: 480 / 536; border: 2px solid var(--line); border-radius: 14px; background: var(--cream); }
.parent-guide-screen figcaption { margin-top: 4px; font-weight: 700; }
.parent-guide-animal { margin: 0; display: grid; justify-items: center; gap: 2px; }
.parent-guide-animal > span { position: relative; display: grid; place-items: center; width: 64px; height: 64px; }
.parent-guide-animal img { width: 56px; height: auto; }
.parent-guide-animal figcaption { font-size: .95rem; }
.parent-guide-join > span { border: 2px dashed var(--line); border-radius: 50%; }
.parent-guide-join img { width: 46px; }
.parent-guide-join > span::before { content: "+"; position: absolute; top: -8px; inset-inline-start: -8px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--teal-dark); color: #fff; font-weight: 700; line-height: 1; }
.parent-guide-island { display: block; width: 100%; height: auto; aspect-ratio: 800 / 468; border-radius: 14px; }
.parent-guide-shop { flex: 1 1 0; min-width: 0; max-width: 150px; margin: 0; padding: 10px 6px; display: grid; justify-items: center; gap: 4px; border: 2px solid var(--line); border-bottom: 5px solid var(--tone); border-radius: 14px; background: #fff; text-align: center; }
.parent-guide-shop img { width: 64px; height: 64px; object-fit: contain; }
.parent-guide-shop figcaption { font-weight: 700; font-size: .9rem; line-height: 1.3; }
.parent-guide-shops { flex-wrap: nowrap; align-items: stretch; }
@media (min-width: 721px) {
  .parent-guide-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .parent-guide-capy { height: 120px; }
  .parent-guide-screen { flex-basis: 170px; }
  .parent-guide-signup { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
}
@media (max-width: 720px) {
  .parent-tabs { width: 100%; }
}

.word-chip {
  display: grid;
  gap: 2px;
  justify-items: center;
  min-width: 96px;
  padding: 10px 14px;
  background: #fffdf6;
  border: 2px solid var(--line);
  border-radius: 14px;
}

.word-chip.is-known {
  background: #eaf7ea;
  border-color: #56b85a;
}

.word-chip strong {
  font-size: 1.05rem;
}

.word-chip small {
  color: #7a675e;
}

/* The last four answers - the exact window mastery is judged on. */
.chip-dots {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.chip-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e6ded4;
}

.chip-dots i.is-ok { background: #56b85a; }
.chip-dots i.is-miss { background: #e0b4ad; }


/* ---- The clothes shop is a fitting room ---- */
/* Capy sits beside the rail rather than above it, so trying a coat on does not
   scroll him off screen - the whole point is seeing the change as it happens. */
.shop-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.fitting-room {
  position: sticky;
  top: 16px;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  border: 3px solid var(--line);
  border-radius: 22px;
  background: #fffdf6;
  box-shadow: 0 10px 0 rgba(75, 50, 40, 0.1);
}

.fitting-room h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.1rem;
}

.fitting-room h2 svg {
  width: 1.25em;
  height: 1.25em;
  flex: none;
}

.fitting-room img {
  aspect-ratio: var(--capy-aspect);
  object-fit: contain;
  width: 100%;
  max-width: 220px;
  height: auto;
}

.fitting-room p {
  margin: 0;
  text-align: center;
  color: var(--ink-soft);
  line-height: 1.45;
}

@media (max-width: 720px) {
  .shop-layout { grid-template-columns: minmax(0, 1fr); }
  /* Stacked, a sticky mirror would sit on top of the clothes it is meant to show. */
  .fitting-room { position: static; }
  .fitting-room img { max-width: 150px; }
}


/* ---- Capy's shelves: the blocks game ---- */
/* The shelves are the progress display. Ten blocks fill them over a session, so
   there is no star row here - the child watches the thing they are building.
   Constrained in width on purpose: stretched across the panel the planks read as
   bare lines with blocks stranded at one end, not as a piece of furniture. */
.block-shelves {
  max-width: 520px;
  margin: 0 auto 20px;
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 3px solid var(--line);
  background: linear-gradient(#f0dcbc, #e6cda6);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 8px 0 rgba(75, 50, 40, 0.14);
}

.shelf {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 10px;
}

/* The swatch is what makes a shelf legible without a word on it: this shelf wants
   THIS colour. A pre-reader needs the target to be a thing they can see. */
.shelf-swatch {
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
  border-radius: 9px;
  background: var(--paint);
  border: 3px solid var(--line);
  box-shadow: 0 3px 0 rgba(75, 50, 40, 0.2);
}

/* min-width: 0 all the way down. A grid or flex item keeps `min-width: auto`, which
   resolves to its min-content width, so ANY level that still has it lets the block row
   take its max-content width and hang off the shelf instead of compressing. The
   .shelf column is already minmax(0, 1fr), but that bounds the COLUMN, not the item
   sitting in it - both of these need it too or the shrink never reaches the blocks. */
.shelf-top {
  display: grid;
  min-width: 0;
}

.shelf-blocks {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 46px;
  min-width: 0;
  padding: 0 8px;
}

/* A BACKSTOP, not the mechanism. Overflow is prevented by SHELF_CAPACITY in app.js:
   a shelf takes five blocks and its colour then stops being asked, and five fits at
   full size on every width measured (9 fit at 482px, 8 at the 600px breakpoint).
   These rules only matter on a screen narrower than anything tested, where they let
   the blocks compress a little instead of hanging off the plank.

   min-width: 0 is the part that does the work, and it is needed at all three levels
   (see .shelf-top): a flex or grid item will not shrink past its automatic minimum
   size, which is why fixed-width blocks overflowed rather than compressing.
   aspect-ratio with height: auto keeps them square on the way down - shrinking width
   against a fixed 42px height would have made rectangles. Do not raise SHELF_CAPACITY
   expecting this to absorb it: past nine the blocks get small enough to lose the
   moulded-block look entirely, which is why capping beat shrinking. */
.shelf-block {
  width: 42px;
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
  flex-shrink: 1;
  border-radius: 11px;
  transform: rotate(var(--tilt, 0deg));
}

/* Opt-in, never on .shelf-block itself: render() rebuilds every node on every
   click, so an animation declared on the element would replay across the whole
   shelf each time and read as the board refreshing instead of one block landing. */
.shelf-block.is-landing {
  animation: block-land 0.34s cubic-bezier(0.22, 1.4, 0.4, 1);
}

@keyframes block-land {
  0% { transform: translateY(-40px) rotate(0deg); opacity: 0; }
  100% { transform: translateY(0) rotate(var(--tilt, 0deg)); opacity: 1; }
}

.shelf-plank {
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(#c69a5e, #a97b3e);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 rgba(75, 50, 40, 0.2);
}

/* A finished shelf reads as an achievement, not a lockout - which is the whole
   argument for letting it stop the colour being asked. docs/kids-gamification.md
   forbids failure framing, so this is a warm glow on the swatch and a lit plank,
   never a grey-out or a strike-through: the child completed this colour, they did
   not lose access to it. */
.shelf.is-full .shelf-swatch {
  box-shadow:
    0 3px 0 rgba(75, 50, 40, 0.2),
    0 0 0 4px rgba(255, 255, 255, 0.8),
    0 0 18px var(--paint);
}

.shelf.is-full .shelf-plank {
  background: linear-gradient(#e0b273, #c08e4c);
}

/* The word is spoken, never written - this IS the question, and a child who could
   read the answer off the screen would not be answering it. */
.block-speaker {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: #fffdf6;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(75, 50, 40, 0.16);
  transition: transform 140ms ease;
}

.block-speaker svg { width: 2.4em; height: 2.4em; }
.block-speaker:hover { transform: translateY(-3px); }
.block-speaker:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(75, 50, 40, 0.16); }

.block-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 20px;
  background: #f3e7d2;
  border: 3px solid var(--line);
  box-shadow: inset 0 4px 0 rgba(75, 50, 40, 0.08);
}

/* Chunky wooden toy blocks, not flat swatches. The look is built from one colour
   token so every block stays exactly the palette hex the child is learning: a lit
   top edge, a shaded base, a recessed face panel and a corner glint. A flat square
   reads as a UI element; this reads as a thing you pick up. */
.tray-block,
.shelf-block {
  position: relative;
  background: var(--paint);
  border: 3px solid var(--line);
  box-shadow:
    inset 0 9px 0 rgba(255, 255, 255, 0.30),     /* light catching the top */
    inset 0 -11px 0 rgba(75, 50, 40, 0.22),      /* the block sitting in its own shadow */
    inset 9px 0 0 rgba(255, 255, 255, 0.10),
    inset -9px 0 0 rgba(75, 50, 40, 0.10),
    0 5px 0 rgba(75, 50, 40, 0.22);
}

/* The recessed panel real wooden blocks have on each face. */
.tray-block::before,
.shelf-block::before {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 22%;
  box-shadow:
    inset 0 2px 0 rgba(75, 50, 40, 0.16),
    inset 0 -2px 0 rgba(255, 255, 255, 0.22);
}

/* A single glint, top-start corner. One highlight reads as light; two read as dirt. */
.tray-block::after,
.shelf-block::after {
  content: "";
  position: absolute;
  top: 12%;
  inset-inline-start: 13%;
  width: 22%;
  height: 13%;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.5);
}

.tray-block {
  width: 66px;
  height: 66px;
  min-width: 48px;
  min-height: 48px;          /* 48dp floor per docs/kids-gamification.md */
  padding: 0;
  border-radius: 16px;
  cursor: pointer;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 150ms ease, opacity 0.25s ease, filter 0.25s ease;
}

.tray-block:hover,
.tray-block:focus-visible {
  transform: translateY(-4px) rotate(var(--tilt, 0deg)) scale(1.05);
}

/* The rescue highlight, after two misses - same ladder as the palette game.
   Dimming the others WORKS here, unlike on the palette: these are real elements
   with a real background, not transparent hotspots sitting over artwork. */
.block-tray.is-guiding .tray-block:not(.is-target) {
  opacity: 0.3;
  filter: saturate(0.35);
}

.block-tray .tray-block.is-target {
  border-color: #fffdf6;
  box-shadow: 0 0 0 4px var(--paint), 0 0 22px var(--paint);
  animation: block-pulse 1.4s ease-in-out infinite;
}

/* Its OWN keyframe, not paint-pulse. paint-pulse was written for the palette
   wells, which are absolutely positioned and therefore carry
   `translate(-50%, -50%)` in every frame. A tray block sits in normal flow, so
   borrowing that keyframe shifted the highlighted block half its own size up and
   left - it jumped out of the row exactly when the child was being asked to find
   it. Keep the tilt, animate only the scale. */
@keyframes block-pulse {
  0%, 100% { transform: rotate(var(--tilt, 0deg)) scale(1.04); }
  50%      { transform: rotate(var(--tilt, 0deg)) scale(1.16); }
}

@media (prefers-reduced-motion: reduce) {
  .block-tray .tray-block.is-target,
  .shelf-block.is-landing { animation: none; }
}

/* The speaker asks the question and the tray holds the answer. On a wide screen they
   stack and the wrapper contributes nothing - display:contents keeps the desktop
   layout byte-for-byte what it was. */
.block-ask { display: contents; }

@media (max-width: 720px) {
  .shelf-swatch { width: 28px; height: 28px; }
  .shelf-block { width: 34px; height: 34px; border-radius: 9px; }
  .tray-block { width: 56px; height: 56px; }

  /* The speaker is the QUESTION - hearTarget() is the only way to learn which colour
     is being asked for, so nothing can be answered until it is pressed. It was put
     beside the tray to save height and came out 64x64 against a 237x146 tray: 12% of
     the area of the thing it is supposed to come BEFORE, reading as a stray control
     rather than the first step. It goes back above the tray, but as a full-width bar
     rather than the desktop's 84px circle - more prominent than the circle and
     shorter, so prominence is not paid for in scroll. */
  .block-ask {
    display: grid;
    gap: 10px;
    max-width: 520px;
    margin: 0 auto;
  }

  .block-speaker {
    width: 100%;
    height: 64px;
    margin: 0;
    border-radius: 999px;
  }

  .block-speaker svg { width: 2.2em; height: 2.2em; }

  .block-tray {
    min-width: 0;
    margin: 0;
    padding: 10px;
    gap: 10px;
  }

  /* space-between on a wrapping row strands whatever wraps: the star rail and the
     finish button could not share 311px, so the button dropped to a second line and
     sat 97px off the panel's centre while the stars sat 7px off it. Stacked and
     centred, both line up on the middle of the screen. */
  .action-row {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
  }

  /* One centre line down the panel: the board, the speaker, the tray, the answer
     line, the stars and the finish button. The feedback was the last thing still
     hugging the start edge and it broke that line. */
  .lesson-panel > .feedback {
    text-align: center;
  }

  /* The shelves are the scoreboard, not a control - they give up the slack so the
     two controls fit above the fold. */
  .block-shelves {
    padding: 10px 12px;
    gap: 5px;
    margin-bottom: 12px;
  }

  .shelf-blocks {
    min-height: 38px;
    gap: 5px;
    padding: 0 6px;
  }

  .shelf { gap: 8px; }
}

/* ---- The completion moment ---------------------------------------------- */
/* The ending a finished game did not have. Its entry animation lives on
   .modal-backdrop.is-entering, which render() sets once and clears - never on the card
   itself, or every render would replay it across the whole screen. */
.completion-card {
  display: grid;
  /* Capy, the title, the rewards, the child's button, and a guest's note for the parent. Only
     the rewards give way: on a short screen they scroll inside the card, and the button that
     gets the child out stays on screen. With plain auto rows the card ran out of its own frame
     and that button was below the screen (found December 1, 2026). */
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-auto-rows: auto;
  justify-items: center;
  gap: 10px;
  text-align: center;
  max-width: 420px;
  max-height: calc(100dvh - 40px);
}
.completion-card > .modal-body { width: 100%; display: grid; justify-items: center; gap: 12px; align-content: start; }

.completion-capy {
  width: min(180px, 60%);
  height: min(190px, 17dvh);
  object-fit: contain;
  object-position: bottom;
}
/* A short screen (a phone with its browser bars showing): less air, a smaller Capy, and the
   parents' note in one line, so the rewards keep most of the card. */
@media (max-height: 720px) {
  .modal-backdrop:has(.completion-card), .save-prompt.modal-backdrop { padding: 12px; }
  .completion-card { padding: 16px 18px; gap: 8px; max-height: calc(100dvh - 24px); }
  .completion-card h2 { font-size: 1.35rem; }
  .completion-capy { height: min(110px, 15dvh); }
}

.completion-rewards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
}

.completion-reward {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fffdf6;
}

.completion-reward svg { width: 1.6em; height: 1.6em; }

.completion-card .primary-button {
  min-width: min(100%, 240px);
  /* 48px, not the 42px .primary-button defaults to. This is the one control on the
     screen and a five-year-old has to hit it; the shared default is below the floor
     docs/child-facing-ui.md sets, which is recorded in docs/OPEN-ITEMS.md. */
  min-height: 48px;
  justify-content: center;
}

/* A guest's card only: a quiet note for the parent under the child's button, on the
   frame like that button so neither scrolls away (parent.js completionSignup). */
/* The games that pay nothing end on two buttons: once more first and bigger, back under it. */
.completion-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; width: 100%; min-width: 0; }
.completion-actions .primary-button, .completion-actions .secondary-button { min-height: 52px; }
.completion-actions .secondary-button { display: inline-flex; align-items: center; gap: 8px; }
.completion-parent-note { display: grid; gap: 8px; justify-items: start; width: 100%; min-width: 0; box-sizing: border-box; padding: 12px; border: 2px dashed #b9a78f; border-radius: 14px; background: #f3ecdf; color: #4b3a31; text-align: start; }
.completion-parent-note > * { min-width: 0; margin: 0; }
.completion-parent-note strong { font-size: .95rem; }
.completion-parent-note p { font-size: .95rem; line-height: 1.5; }
.completion-parent-note button { min-height: 48px; justify-self: center; }   /* in the middle of the popup (Dana, November 30) */
/* On a phone, and on a short desktop screen, the parents' note is smaller and Capy a little
   smaller, so the rewards (the coins, the opened games, a new badge) show without scrolling
   wherever the screen allows. After the note's own rules, so these win. */
@media (max-width: 720px), (max-height: 820px) {
  .completion-card { padding: 16px 20px; gap: 8px; }
  .completion-capy { height: min(132px, 12.5dvh); }
  /* The parents' note in small running text, its button in the middle under it (Dana,
     November 30: the sign-up button sits in the middle of the popup). */
  .completion-parent-note { display: block; padding: 8px 10px; text-align: center; }
  .completion-parent-note strong, .completion-parent-note p { display: inline; font-size: .85rem; line-height: 1.4; }
  .completion-parent-note strong::after { content: ": "; }
  .completion-parent-note button { display: flex; width: fit-content; margin: 6px auto 0; }
}
/* Shortest screens: only the label and the button, the button still in the middle. */
@media (max-height: 720px) {
  .completion-capy { height: min(110px, 15dvh); }
  .completion-parent-note { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; }
  .completion-parent-note strong { justify-self: start; }
  .completion-parent-note strong::after { content: none; }
  .completion-parent-note p { display: none; }
  .completion-parent-note button { margin: 0; }
}

/* ---- Badges -------------------------------------------------------------- */
.completion-badges,
.board-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.paint-paper { min-width: 0; }
.paint-zoom-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.paint-zoom-tools .icon-button { min-width: 49px; min-height: 49px; }
.paint-zoom-tools [aria-pressed="true"] { background: var(--teal); }
.paint-viewport { position: relative; overflow: auto; max-height: 65vh; direction: ltr; padding-bottom: 16px; }
/* "One moment" while a colouring page loads stands over the paper, so nothing below the paper
   moves when the page arrives (December 2, 2026: above it, it pushed the colours 90px down on a
   phone and they jumped back up; STUDIO-PHONE-12). */
.paint-viewport > .paint-loading { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; margin: 0; padding: 12px; direction: rtl; text-align: center; background: rgba(255, 253, 247, .88); pointer-events: none; }
.paint-viewport .paint-canvas { max-width: none; }

/* Studio controls adapt in place; other colour activities retain the painted palette. */
.studio-phone-tool, .paint-zoom-tools.is-free { display: none; }
.studio-side .paint-well > svg { display: none; }
@media (max-width: 720px) {
  .lesson-shell:has(.studio-panel) { gap: 10px; }
  .lesson-shell:has(.studio-panel) .capy-guide { padding: 6px; grid-template-columns: 48px minmax(0,1fr); gap: 8px; }
  .lesson-shell:has(.studio-panel) .capy-guide > img { width: 48px; height: 64px; object-fit: contain; }
  .lesson-shell:has(.studio-panel) .speech-bubble { padding: 6px 10px; }
  .lesson-shell:has(.studio-panel) .speech-bubble strong { display: none; }
  .lesson-shell:has(.studio-panel) .speech-bubble p { margin: 2px 0; font-size: .85rem; }
  .lesson-shell:has(.studio-panel) .replay-button { min-height: 48px; padding: 4px 10px; }
  .studio-panel { display: flex; flex-direction: column; gap: 12px; padding: 0; border: 0; background: transparent; box-shadow: none; }
  .studio-panel > h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .studio-panel > .art-modes { order: -1; margin: 0; flex-wrap: nowrap; justify-content: center; }
  .studio-panel > .art-modes .art-mode { flex: 1 1 0; min-width: 0; justify-content: center; gap: 5px; padding: 6px; font-size: .85rem; }
  .studio-panel > .art-modes .art-mode span { min-width: 0; }
  .studio-panel > .action-row { order: 3; }
  .studio-panel .paint-studio { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
  .studio-panel .paint-paper, .studio-panel .studio-side { display: contents; }
  .studio-panel .paint-viewport { order: 0; width: 100%; min-width: 0; aspect-ratio: var(--paint-aspect); max-height: none; padding: 0; border: 3px solid var(--line); border-radius: 14px; background: #fffdf7; overscroll-behavior: contain; }
  .studio-panel .paint-canvas { width: var(--paint-zoom) !important; border: 0; border-radius: 0; box-shadow: none; touch-action: none !important; }
  .studio-panel .is-moving .paint-canvas { cursor: grab !important; }
  .studio-panel .is-moving .paint-viewport { border-color: #237b78; box-shadow: 0 0 0 3px #9dd6cf; }
  .studio-panel .palette-viewport { order: 1; width: 100%; margin: 0; overflow: visible; direction: rtl; }
  .studio-panel .paint-zoom-tools { order: 2; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 49px 49px; gap: 6px; margin: 10px 0 0; width: 100%; }
  .studio-panel .studio-phone-tool { display: inline-flex; min-width: 0; min-height: 49px; padding: 5px; gap: 4px; font-size: .85rem; justify-content: center; }
  .studio-panel .studio-phone-tool[aria-pressed="true"] { background: #b9e2d8; border-color: #237b78; box-shadow: inset 0 -3px 0 rgba(35,123,120,.18); }
  .studio-panel .studio-desktop-pan { display: none; }
  .studio-panel .studio-tools { order: 3; display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
  .studio-panel .studio-tools button { min-width: 0; min-height: 49px; padding: 8px; font-size: .9rem; }
}
/* The swatch grid replaces the painted palette wherever a finger needs wells the
   painted art cannot make 48px: phones, and touch screens wide enough for the
   side-by-side studio, where 11% of its 320px palette is 35px. A mouse keeps the
   painted palette beside the wider paper (OPEN-ITEMS, tablets). */
@media (max-width: 720px), (min-width: 981px) and (pointer: coarse) {
  .studio-side .palette-viewport { width: 100%; margin: 0; overflow: visible; direction: rtl; }
  .studio-panel .paint-palette {
    display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 8px;
    width: 100%; margin: 0; padding: 8px;
    border: 2px solid #785940; border-radius: 18px;
    /* Pale wood and broad diagonal grain echo palette-v3's illustrated surface.
       These decorative layers do not change the grid or its touch targets. */
    background:
      linear-gradient(155deg, transparent 12%, #fff6e838 13%, #fff6e838 22%, transparent 23%, transparent 48%, #fff6e82b 49%, #fff6e82b 59%, transparent 60%),
      repeating-linear-gradient(157deg, transparent 0 19px, #a77a4910 20px 21px, transparent 22px 42px, #fffaf024 43px 48px, transparent 49px 68px),
      linear-gradient(135deg, #f3dfbf, #e6c9a5 55%, #efdab9);
    box-shadow: inset 0 3px 0 #fff6e8b3, inset 0 -3px 0 #b58c5e40,
      0 4px 0 #b18c65, 0 6px 0 #785940, 0 10px 14px #4b322814;
  }
  .studio-panel .paint-palette > img, .studio-panel .palette-center { display: none; }
  .studio-panel .paint-palette .paint-well { position: relative; left: auto !important; top: auto !important; width: 100%; min-width: 48px; height: 50px; aspect-ratio: auto; border: 2px solid transparent; border-radius: 12px; background: transparent; transform: none; animation: none; box-shadow: none; }
  .studio-panel .paint-well > svg { display: block; width: 100%; height: 100%; }
  .studio-panel .paint-palette .paint-well.is-active { border-color: var(--ink); background: #d6ede7; box-shadow: 0 0 0 1px var(--ink); }
  /* Grid swatches have no image anchor. The shared painted-palette hover rule
     translates anchored hotspots, so it must not move these grid cells. */
  .studio-panel .paint-palette .paint-well:is(:hover, :focus-visible, :active, .is-active) { transform: none; animation: none; }
  .studio-panel .paint-palette .paint-well:hover { border-color: var(--ink); }
  .studio-panel .paint-well:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
}
@media (max-width: 350px) {
  .studio-panel .paint-palette { padding: 5px; gap: 6px; }
}

.board-badges {
  margin-block-start: 24px;
}

/* The completion card already contributes a 12px grid gap after its heading or
   rewards row, so another 12px gives it the same effective breathing room. */
.completion-badges {
  margin-block-start: 12px;
}

.completion-badge,
.board-badge {
  display: grid;
  justify-items: center;
  gap: 4px;
  max-width: 120px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.completion-badge:focus-visible,
.board-badge:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 4px;
  border-radius: 8px;
}

.completion-badge small,
.board-badge small {
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: center;
}

/* One face for every badge, image or placeholder, so swapping CapyBadges.ART_READY
   changes nothing about the layout around it. */
.badge-face {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  object-fit: contain;
  transform-origin: center;
  transition: transform 180ms ease, filter 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .completion-badge:hover .badge-face,
  .board-badge:hover .badge-face,
  .board-next:hover .badge-face {
    transform: translateY(-4px) scale(1.06);
    filter:
      drop-shadow(0 0 7px rgba(247, 190, 52, 0.78))
      drop-shadow(0 0 15px rgba(25, 154, 163, 0.48));
  }
}

.completion-badge:focus-visible .badge-face,
.board-badge:focus-visible .badge-face,
.board-next:focus-visible .badge-face {
  transform: translateY(-4px) scale(1.06);
  filter:
    drop-shadow(0 0 7px rgba(247, 190, 52, 0.78))
    drop-shadow(0 0 15px rgba(25, 154, 163, 0.48));
}

@media (prefers-reduced-motion: reduce) {
  .completion-badge .badge-face,
  .board-badge .badge-face,
  .board-next .badge-face {
    transition: none;
  }

  .completion-badge:hover .badge-face,
  .board-badge:hover .badge-face,
  .board-next:hover .badge-face,
  .completion-badge:focus-visible .badge-face,
  .board-badge:focus-visible .badge-face,
  .board-next:focus-visible .badge-face {
    transform: none;
  }
}

/* The placeholder is a rosette, not a grey box: it should read as a badge and as WHICH
   badge while being obviously unfinished. Deleted once the art lands. */
.badge-face.is-placeholder {
  border-radius: 50%;
  border: 3px dashed var(--line);
  background: radial-gradient(circle at 35% 28%, #fffdf6, #f0e4cf);
  color: var(--ink-soft);
}

.badge-face.is-placeholder[data-tier="knows"] { background: radial-gradient(circle at 35% 28%, #fffdf6, #d9f0ea); }
.badge-face.is-placeholder[data-tier="tried"] { background: radial-gradient(circle at 35% 28%, #fffdf6, #f8e6cf); }
.badge-face.is-placeholder[data-tier="made"]  { background: radial-gradient(circle at 35% 28%, #fffdf6, #efe0f2); }

.badge-face.is-placeholder svg { width: 2.2em; height: 2.2em; }

/* Opt-in, never on .completion-badge itself: render() rebuilds every node, so an
   animation declared on the element would replay across all of them on every click. */
.completion-badge.is-new .badge-face {
  animation: badge-arrive 0.5s cubic-bezier(0.22, 1.4, 0.4, 1);
}

@keyframes badge-arrive {
  0%   { transform: scale(0.3) rotate(-12deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ---- The badge board ----------------------------------------------------- */
.board-next {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 16px;
  padding-top: 16px;
  border: 0;
  border-top: 2px dashed var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.board-next:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 4px;
  border-radius: 8px;
}

/* The ring IS the progress. A conic-gradient needs no element per step, so it reads
   the same at 2-of-3 as at 60-of-100 - which pips cannot do, and a numeral cannot be
   read by the child at all. */
.board-ring {
  display: grid;
  place-items: center;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--pct) * 1%), rgba(75, 50, 40, 0.12) 0);
}

/* Not yet earned: the face inside the ring is dimmed, so "next" never reads as "won". */
.board-ring .badge-face {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background-color: #fffdf6;
  opacity: 0.55;
}

/* ---- Badges on the parent dashboard -------------------------------------- */
.badge-report {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.badge-report li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f4f1ea;
  opacity: 0.55;
}

.badge-report li.is-earned {
  opacity: 1;
  background: #e7fbf8;
}

.badge-report small {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

/* Before the first tap there is no active colour, so the card asks for one instead of
   showing a word the child has not heard. --active-paint is transparent, which hides
   the brush stroke without a second rule. */
.intro-canvas.is-waiting .intro-canvas-paper {
  opacity: 0.5;
}

.intro-waiting {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---- Colouring-page picker: the pages behind one button, chosen by picture ---- */
/* Each page used to be its own tab carrying the same generic page icon, so a child
   who cannot read saw identical buttons and had to guess. Here the artwork IS the
   control. See docs/child-facing-ui.md. */
.picker-card {
  width: min(100%, 720px);
  text-align: center;
}

.picker-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
}

/* The page being offered. Big, tappable, and the whole thing is the button. */
.picker-page {
  display: block;
  width: 100%;
  padding: 10px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
  box-shadow: 0 8px 0 rgba(75, 50, 40, 0.14);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.picker-page img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 896;   /* the box is there before the picture is, so the popup never jumps */
  border-radius: 10px;
}

.picker-page:hover { transform: translateY(-3px); box-shadow: 0 11px 0 rgba(75, 50, 40, 0.14); }
.picker-page:active { transform: translateY(2px); box-shadow: 0 4px 0 rgba(75, 50, 40, 0.16); }

/* Step to the page either side. These carried a thumbnail of their destination so the
   arrow pointed at something real; it was dropped because at the width a phone leaves
   for it the thumbnail was an illegible smudge, and an unreadable picture justifies
   the arrow no better than none. So the arrows carry the job alone and are sized for
   it - large, high-contrast, and well clear of the 48px floor. */
.picker-step {
  display: grid;
  place-items: center;
  min-width: 56px;
  min-height: 56px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform 150ms ease;
}

.picker-step svg {
  width: 52px;
  height: 52px;
  flex: none;
}

.picker-step:hover { transform: scale(1.08); }
.picker-step:active { transform: translateY(2px) scale(0.98); }

.picker-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

/* Where you are in the set. Dots, not "2 / 5" - a numeral is unreadable at this age,
   the same reason session progress is a row of stars. */
.picker-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.picker-dots span {
  width: 11px;
  height: 11px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fffdf6;
}

.picker-dots span.is-on {
  background: var(--teal);
}

@media (max-width: 720px) {
  .picker-row {
    gap: 4px;
    margin: 14px 0 10px;
  }

  /* The page keeps the full width on its own row with the arrows beneath it. Three
     across was tried and does not fit: the two step buttons ate half of a 333px card
     and left the page being chosen barely larger than a thumbnail, which inverts what
     the screen is for. */
  .picker-card { padding: 18px 12px; }

  .picker-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "page page"
      "prev next";
    gap: 10px;
  }

  .picker-page { grid-area: page; padding: 6px; border-radius: 14px; }
  .picker-row > .picker-step:first-child { grid-area: prev; justify-self: center; }
  .picker-row > .picker-step:last-child  { grid-area: next; justify-self: center; }

  .picker-name { font-size: 1rem; }
}

/* ---- Scrollbars ---------------------------------------------------------- */
/* A default grey system scrollbar inside a cream, hand-drawn card reads as a piece
   of someone else's UI showing through. These are the same ink and rounding as every
   other border in the app, sitting on a transparent track so nothing boxes them in.
   Applied to every scroller the child can reach, not only modals: the album pages,
   the zoomed colouring paper and the shop grids all had the same seam. */
.modal-body,
.paint-viewport,
.album-page,
.shop-grid {
  scrollbar-width: thin;                       /* Firefox */
  scrollbar-color: rgba(75, 50, 40, 0.34) transparent;
}

.modal-body::-webkit-scrollbar,
.paint-viewport::-webkit-scrollbar,
.album-page::-webkit-scrollbar,
.shop-grid::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.modal-body::-webkit-scrollbar-track,
.paint-viewport::-webkit-scrollbar-track,
.album-page::-webkit-scrollbar-track,
.shop-grid::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb,
.paint-viewport::-webkit-scrollbar-thumb,
.album-page::-webkit-scrollbar-thumb,
.shop-grid::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(75, 50, 40, 0.30);
  /* the transparent border is what keeps the thumb slimmer than its track without
     a second element to inset it */
  border: 3px solid transparent;
  background-clip: padding-box;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.paint-viewport::-webkit-scrollbar-thumb:hover,
.album-page::-webkit-scrollbar-thumb:hover,
.shop-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(75, 50, 40, 0.48);
  background-clip: padding-box;
}

/* The corner where two scrollbars meet, on the one scroller that has both. */
.paint-viewport::-webkit-scrollbar-corner {
  background: transparent;
}

/* A gated room object wears the same padlock as a locked island world, but every
   rule for that badge is scoped `.world-node .world-lock` and so matches nothing
   inside a room. Without its own rule the span had no positioning at all and the
   PNG rendered at its natural size: 275x359 on the bed, 65% of the object, sitting
   over the window behind it. This is the whole badge, not a width override. */
.room-object .world-lock {
  position: absolute;
  left: 50%;
  top: 58%;
  width: clamp(40px, 24%, 64px);
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
  animation: lock-bob 3.6s ease-in-out infinite;
}

.room-object .world-lock img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 6px 10px rgba(47, 35, 29, 0.32));
}

/* The garden uses the room's landscape ratio and shared shell. */
.window-panel { gap: 10px; text-align: center; padding: 0; background: transparent; border: 0; box-shadow: none; }
.window-scene { position: relative; width: 100%; aspect-ratio: var(--window-aspect); margin: 0 auto; isolation: isolate; overflow: hidden; border-radius: 10px; }
@media (min-width: 761px) {
  .window-scene { max-width: calc((100dvh - 330px) * 1.490566); }
}
.window-landscape { display: block; width: 100%; height: 100%; position: absolute; inset: 0; pointer-events: none; }
.window-hanging-cord { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.window-hanging-cord path { fill: none; stroke: #775137; stroke-width: 1.5px; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.window-prop, .window-capy { position: absolute; height: auto; pointer-events: none; transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))); }
.window-prop { z-index: 1; overflow: visible; }
.window-capy { z-index: 3; transform-origin: 50% 100%; }
.window-object { position: absolute; z-index: 2; transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))); min-width: 48px; min-height: 48px; height: var(--target-height); padding: 0; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.window-touch-icon { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.window-touch-icon svg { display: block; width: 100%; height: 100%; }
.window-object:disabled { opacity: 1; cursor: default; }
/* Transparent buttons over a picture draw nothing while they wait: the global disabled shadow
   showed as a light grey line across the window scene each time a shape was chosen (Dana,
   December 2, 2026), and along the jungle's boats and falling leaves. SCENE-01. */
.window-object:disabled, .river-boat:disabled, .catch-lane:disabled { box-shadow: none !important; }
.window-outline > *, .window-art-feedback > * { fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.window-outline > * { stroke: #654736; stroke-width: 2.5px; }
.window-art-feedback { opacity: 0; transition: opacity 140ms ease; }
.window-art-feedback > * { stroke: #fff8d9; stroke-width: 3px; filter: drop-shadow(0 0 3px #ffe49b); }
.window-painted-part.is-found .window-art-feedback, .window-painted-part.is-hinted .window-art-feedback { opacity: 1; }
.window-painted-part.is-hinted .window-art-feedback { animation: window-hint 1.3s ease-in-out infinite; }

.window-scene:has([data-object="ball"]:focus-visible) [data-art="ball"] .window-art-feedback,
.window-scene:has([data-object="house-window"]:focus-visible) [data-art="house-window"] .window-art-feedback,
.window-scene:has([data-object="house-roof"]:focus-visible) [data-art="house-roof"] .window-art-feedback,
.window-scene:has([data-object="planter"]:focus-visible) [data-art="planter"] .window-art-feedback,
.window-scene:has([data-object="heart"]:focus-visible) [data-art="heart"] .window-art-feedback,
.window-scene:has([data-object="star"]:focus-visible) [data-art="star"] .window-art-feedback { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
.window-scene:not(:has(.window-painted-part.is-hinted)):has([data-object="ball"]:hover:not(:disabled)) [data-art="ball"] .window-art-feedback,
.window-scene:not(:has(.window-painted-part.is-hinted)):has([data-object="house-window"]:hover:not(:disabled)) [data-art="house-window"] .window-art-feedback,
.window-scene:not(:has(.window-painted-part.is-hinted)):has([data-object="house-roof"]:hover:not(:disabled)) [data-art="house-roof"] .window-art-feedback,
.window-scene:not(:has(.window-painted-part.is-hinted)):has([data-object="planter"]:hover:not(:disabled)) [data-art="planter"] .window-art-feedback,
.window-scene:not(:has(.window-painted-part.is-hinted)):has([data-object="heart"]:hover:not(:disabled)) [data-art="heart"] .window-art-feedback,
.window-scene:not(:has(.window-painted-part.is-hinted)):has([data-object="star"]:hover:not(:disabled)) [data-art="star"] .window-art-feedback { opacity: .8; }
}
.window-controls { display: flex; gap: 8px; justify-content: center; min-width: 0; }
.window-controls > button { min-width: 0; min-height: 52px; width: min(100%, 360px); justify-content: center; }
.window-controls > .block-speaker { display: flex; align-items: center; gap: 10px; height: auto; padding: 12px 18px; margin: 0; border-radius: 18px; font-size: 1.1rem; line-height: 1.4; }
.window-controls > .block-speaker svg { width: 28px; height: 28px; flex: 0 0 28px; }
.window-controls > .block-speaker span { min-width: 0; }
.window-word { margin: 0; min-height: 26px; font-size: 1.15rem; }
.window-feedback { min-height: 24px; font-weight: 700; }
.window-feedback .feedback { min-height: 24px; margin-top: 0; }
.window-panel .action-row { margin-top: 0; justify-content: center; padding-top: 0; }
@keyframes window-find { 0% { opacity: 0; } 20%, 75% { opacity: 1; } 100% { opacity: .8; } }
@keyframes window-hint { 50% { opacity: .4; } }
.window-capy.is-pleased { animation: window-capy-pleased .65s ease-in-out 2; }
@keyframes window-capy-pleased { 50% { rotate: -2deg; } }
@media (prefers-reduced-motion: reduce) { .window-art-feedback, .window-capy.is-pleased { animation: none !important; transition: none; } }
@media (max-width: 720px) {
  .lesson-shell:has(.window-panel) .capy-guide { padding: 6px; }
  .lesson-shell:has(.window-panel) .capy-guide > img { width: 48px; height: 64px; object-fit: contain; }
  .lesson-shell:has(.window-panel) .speech-bubble { padding: 6px 10px; }
  .lesson-shell:has(.window-panel) .speech-bubble strong { display: none; }
  .lesson-shell:has(.window-panel) .speech-bubble p { margin: 2px 0; font-size: .95rem; }
  .window-controls > button { font-size: .95rem; padding: 6px; gap: 5px; }
}

/* ---- Capy's quilt: a form board, not a shelf ---- */
.quilt {
  width: min(100%, 400px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  margin: 0 auto 16px;
  padding: 14px;
  border: 9px solid #70ada4;
  outline: 2px dashed #e6fff2;
  outline-offset: -6px;
  border-radius: 24px 20px 28px 22px;
  background: repeating-linear-gradient(0deg, #fff9ed88 0 1px, transparent 1px 4px), #e6ead4;
  box-shadow: 0 8px 0 #518e8426;
}

/* An empty hole is a recess with the shape sunk into it. That silhouette is a
   second, silent clue to what the spoken word means - the thing a shelf never gave. */
.quilt-hole {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 8%;
  border-radius: 12px;
  border: 2px dashed #bcb89b;
  background: #fff9e9;
  box-shadow: none;
}
.quilt-hole:nth-child(3n + 2) { background: #f3e6e5; border-color: #d9b8b5; }
.quilt-hole:nth-child(3n) { background: #e5edf3; border-color: #b4cbd8; }

.quilt-hole.is-filled { box-shadow: none; }
.quilt-hole.is-landing { animation: block-land 0.34s cubic-bezier(0.22, 1.4, 0.4, 1); }
.quilt-hole.is-hovered {
  box-shadow: inset 0 0 0 3px var(--teal), inset 0 3px 6px rgba(47, 35, 29, 0.26);
}

/* The socket: the same painted patch, flattened to a shadow of itself. */
.hole-art { display: block; width: 100%; }
/* brightness(0) flattens the painted patch to a pure silhouette while keeping its
   alpha, so the socket is the SHAPE and nothing else. Greyscaling instead left the
   fabric's painted highlight in the recess, and a square socket read as a smudge. */
.hole-art img {
  display: block;
  width: 100%;
  height: auto;
  filter: brightness(0) opacity(0.16);
}

/* A patch, painted. The image carries the fabric, the shading and the stitching; the
   overlay carries the colour and multiplies over it, so one picture wears any hue.
   isolation keeps that blend inside the patch instead of reaching the page behind. */
.patch-art {
  position: relative;
  display: block;
  width: 100%;
  isolation: isolate;
}

.patch-art img { display: block; width: 100%; height: auto; }

.patch-art.is-painted::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--paint);
  mix-blend-mode: multiply;
  -webkit-mask-image: var(--patch);
  mask-image: var(--patch);
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  pointer-events: none;
}

.shape-ask { display: grid; gap: 10px; justify-items: center; width: min(100%, 350px); margin: 0 auto; }
.quilt-panel { text-align: center; gap: 10px; background: #fffdf7; }
.quilt-panel > *, .shape-ask > *, .shape-teaching > * { min-width: 0; }
.quilt-panel .block-speaker { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 18px; width: 100%; height: 58px; margin: 0; border-radius: 18px; background: #e5f3ef; border-color: #467b6b; box-shadow: 0 4px 0 #bad1c5; }
.quilt-panel .block-speaker svg { width: 28px; height: 28px; flex-shrink: 0; }
.shape-teaching { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; width: min(100%, 520px); margin: 0 auto; }
.shape-card { min-width: 0; min-height: 100px; padding: 12px; border: 2px dashed #b4cec4; border-radius: 22px; background: #fff9ed; display: grid; place-items: center; gap: 8px; cursor: pointer; }
.shape-card.is-active { background: #e6f4ed; border-color: #438878; }
.shape-card > svg { width: 24px; height: 24px; }
.shape-card .patch-art { max-width: 120px; }
.shape-name { min-height: 32px; font-size: 22px; margin: 18px 0; }
.shape-name span { display: inline-block; margin-inline-start: 12px; color: #438878; }

.patch-tray {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  border: 2px dashed #aac6bc;
  border-radius: 20px;
  background: #f5f8eb;
  box-shadow: none;
}

.patch {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  min-width: 48px;
  min-height: 48px;
  padding: 2px;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;          /* the finger drags the patch, not the page */
  transition: transform 150ms ease;
}

.patch:hover { transform: translateY(-4px) scale(1.05); }
.patch.is-dragging { opacity: 0.3; }
.patch.is-target { animation: block-pulse 1.4s ease-in-out infinite; }

/* Follows the finger. Fixed, so it is not clipped by the panel it started in. */
.patch-ghost {
  position: fixed;
  z-index: 80;
  width: 72px;
  height: 72px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

@media (max-width: 720px) {
  .quilt-panel { padding: 10px; gap: 8px; }
  .quilt { padding: 10px; gap: 8px; margin-bottom: 12px; }
  .shape-ask { display: grid; gap: 10px; max-width: 520px; margin: 0 auto; }
  .shape-ask .block-speaker { width: 100%; height: 50px; margin: 0; border-width: 2px; }
  .shape-ask .block-speaker svg { width: 2.2em; height: 2.2em; }
  .patch-tray { margin: 0; padding: 10px; gap: 10px; }
  .patch { width: 62px; height: 62px; }
  .patch-ghost { width: 62px; height: 62px; }
}
/* A short phone: the quilt narrows (its holes stay square) so the patches clear the fold. */
@media (max-width: 720px) and (max-height: 760px) {
  .quilt { width: min(100%, 250px); gap: 6px; padding: 8px; margin-bottom: 8px; }
  .shape-ask { gap: 8px; }
  .patch-tray { padding: 8px; }
  .patch { width: 56px; height: 56px; }
}
@media (max-width: 340px) and (max-height: 760px) {
  .quilt { width: min(100%, 226px); }
  .patch { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .quilt-hole.is-landing, .patch.is-target { animation: none; }
}

/* Build with Capy: the toy is the board, and every colour stays within reach. */
.build-panel > *, .build-ask > *, .build-footer > * { min-width: 0; }
.build-art { display: block; width: 100%; height: 100%; overflow: visible; color: #55453d; }
.build-panel { gap: 10px; background: #fffdf7; }
.build-scene { position: relative; isolation: isolate; width: 100%; height: 310px; border: 2px solid #d2dfd1; border-radius: 25px; background: radial-gradient(ellipse at 50% 92%, #dce9d6 0, #eff5e7 55%, #f6f9f0 100%); }
.build-scene > .build-art { width: min(100%, 430px); margin: auto; }
.build-ask { display: grid; gap: 10px; justify-items: center; }
.build-panel .block-speaker { width: min(100%, 350px); height: 58px; margin: 0; border-radius: 18px; background: #e5f3ef; border-color: #467b6b; box-shadow: 0 4px 0 #bad1c5; }
.build-panel .block-speaker svg { width: 33px; height: 33px; }
.build-panel .block-tray { width: min(100%, 350px); box-sizing: border-box; gap: 12px; padding: 10px; background: #eaf0e6; border-color: #c0cdbc; border-width: 2px; box-shadow: inset 0 3px 0 #dce5d5; }
.build-panel .tray-block { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 14px; }
.build-panel .tray-block > svg { position: relative; width: 65%; height: 65%; color: #fff; opacity: .48; }
.build-feedback { min-height: 28px; text-align: center; }
.build-feedback .feedback { margin: 0; padding: 0; background: none; border: 0; }
.build-footer { display: grid; justify-items: center; gap: 14px; margin-top: auto; }
.build-footer .progress-stars { gap: 5px; padding: 4px 8px; flex-wrap: nowrap; min-width: 0; max-width: 100%; }
.build-footer .progress-star { width: 25px; height: 25px; flex: 0 1 25px; }
.build-panel .tray-block { background: transparent; border: 0; box-shadow: none; border-radius: 6px; }
.build-panel .tray-block::before, .build-panel .tray-block::after { content: none; }
.build-panel .tray-block > svg { display: block; width: 100%; height: 100%; opacity: 1; }
.build-panel .block-tray .tray-block.is-target { border: 0; box-shadow: 0 0 0 3px #fffdf6, 0 0 0 6px var(--paint); }
.build-finish-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.build-piece.is-landing { animation: build-piece-land .5s cubic-bezier(.2,.8,.3,1.15); }
.build-art.is-complete .build-toy { transform-origin: center; }
/* ---- The finished toy comes alive (Dana, November 29, 2026) ----
   Each toy does what it is for four seconds. Every animation here reads --show-t, the place
   in the show the render hands it, so a render in the middle continues instead of restarting.
   The finished picture clips what leaves it; a board still being built must not, because its
   pieces fly in from the tray. The finished toy is a button: a tap plays the show again. */
.build-panel.is-complete .build-scene { overflow: hidden; }
.build-toy-button { position: relative; display: block; width: min(100%, 430px); height: 100%; margin: auto; padding: 0; border: 0; background: none; cursor: pointer; }
.build-toy-button > .build-art { width: 100%; height: 100%; }
.build-extra { opacity: 0; }
/* How far out of the picture a toy drives, in the drawing's own units: just past the edge, so
   the picture is not left empty for long. A phone's picture is narrower. */
.build-art.is-showing { --exit: 600px; }
@media (max-width: 720px) { .build-art.is-showing { --exit: 450px; } }
.build-art.is-showing :is(.build-toy, .build-piece, .build-extra, .build-extra > *, .build-steam circle) { animation-duration: 4s; animation-delay: var(--show-t, 0ms); animation-timing-function: ease-in-out; }
.build-art.is-showing [data-shape] .build-piece { transform-box: fill-box; transform-origin: center; }
/* Train and car: drive out to the right and come back in from the left, wheels turning. */
.build-art:is(.build-art--train, .build-art--car).is-showing .build-toy { animation-name: build-drive; }
.build-art:is(.build-art--train, .build-art--car).is-showing [data-shape="buildWheel"] .build-piece { animation-name: build-wheel-spin; animation-timing-function: linear; }
.build-art.is-showing :is(.build-steam, .build-dust, .build-smoke) circle { transform-box: fill-box; transform-origin: center; animation-name: build-puff; animation-duration: 1s; animation-iteration-count: 4; animation-delay: calc(var(--show-t, 0ms) + var(--puff) * 220ms); animation-timing-function: ease-out; }
.build-art.is-showing :is(.build-dust, .build-smoke) { opacity: 1; }
.build-art.is-showing :is(.build-dust, .build-smoke) circle { opacity: 0; }
.build-art.is-showing .build-dust circle { animation-duration: .6s; animation-iteration-count: 3; }
/* The shadow on the floor goes with the toy: it fades as the toy drives or sails away and
   comes back with it, and thins out under the rocket while it is up. */
.build-art.is-showing .build-shadow { animation-duration: 4s; animation-delay: var(--show-t, 0ms); animation-timing-function: ease-in-out; transform-box: fill-box; transform-origin: center; }
.build-art:is(.build-art--train, .build-art--car, .build-art--boat).is-showing .build-shadow { animation-name: build-shadow-away; }
.build-art--rocket.is-showing .build-shadow { animation-name: build-shadow-lift; }
@keyframes build-shadow-away { 0%, 14% { opacity: .13; } 30%, 60% { opacity: 0; } 82%, 100% { opacity: .13; } }
@keyframes build-shadow-lift { 0%, 20% { opacity: .13; transform: scaleX(1); } 38%, 68% { opacity: 0; transform: scaleX(.35); } 100% { opacity: .13; transform: scaleX(1); } }
/* Boat: waves rise under the hull, it rocks and sails out and back. */
.build-art--boat.is-showing .build-toy { animation-name: build-sail; }
.build-art--boat.is-showing .build-waves { animation-name: build-waves; animation-timing-function: linear; }
/* Rocket: shakes, lifts off on its flame, floats back down. */
.build-art--rocket.is-showing .build-toy { animation-name: build-liftoff; }
.build-art--rocket.is-showing .build-flame { transform-box: fill-box; transform-origin: 50% 0; animation-name: build-flame; }
/* Robot: dances, both arms wave, the antenna spins. */
.build-art--robot.is-showing .build-toy { animation-name: build-robot-dance; }
.build-art--robot.is-showing [data-piece="5"] .build-piece { transform-origin: 90% 10%; animation-name: build-arm-left; }
.build-art--robot.is-showing [data-piece="6"] .build-piece { transform-origin: 10% 10%; animation-name: build-arm-right; }
.build-art--robot.is-showing [data-piece="9"] .build-piece { animation-name: build-antenna; animation-timing-function: linear; }
/* House: the windows light up, smoke rises, the door swings open and shut. */
.build-art--house.is-showing .build-lights { opacity: 1; filter: blur(5px); }
.build-art--house.is-showing .build-lights circle { opacity: 0; animation-name: build-light; }
.build-art--house.is-showing .build-smoke circle { animation-iteration-count: 3; animation-duration: 1.2s; }
.build-art--house.is-showing [data-shape="buildDoor"] .build-piece { transform-origin: 0 50%; animation-name: build-door; }
@keyframes build-drive {
  0% { transform: translateX(0); } 8% { transform: translateX(-12px); animation-timing-function: ease-in; }
  46% { transform: translateX(var(--exit)); animation-timing-function: step-end; }
  46.01% { transform: translateX(calc(var(--exit) * -1)); animation-timing-function: ease-out; }
  100% { transform: translateX(0); }
}
@keyframes build-wheel-spin { 0% { transform: rotate(0); } 8% { transform: rotate(-40deg); } 100% { transform: rotate(2160deg); } }
@keyframes build-puff { 0% { opacity: 0; transform: translateY(8px) scale(.5); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px) scale(1.2); } }
@keyframes build-sail {
  0% { transform: translateX(0) rotate(0); } 8% { transform: translateX(0) rotate(-3deg); } 16% { transform: translateX(6px) rotate(3deg); animation-timing-function: ease-in; }
  48% { transform: translateX(var(--exit)) rotate(-3deg); animation-timing-function: step-end; }
  48.01% { transform: translateX(calc(var(--exit) * -1)) rotate(3deg); animation-timing-function: ease-out; }
  86% { transform: translateX(0) rotate(-2deg); } 93% { transform: translateX(0) rotate(1.5deg); } 100% { transform: translateX(0) rotate(0); }
}
@keyframes build-waves { 0% { opacity: 0; transform: translateX(0); } 8% { opacity: 1; } 90% { opacity: 1; } 100% { opacity: 0; transform: translateX(-120px); } }
@keyframes build-liftoff {
  0% { transform: translate(0, 0); } 4% { transform: translate(-3px, 0); } 8% { transform: translate(3px, 1px); } 12% { transform: translate(-3px, 0); } 16% { transform: translate(3px, 1px); }
  20% { transform: translate(0, 0); animation-timing-function: ease-in; }
  50% { transform: translate(0, -320px); } 56% { transform: translate(0, -320px); animation-timing-function: ease-out; }
  100% { transform: translate(0, 0); }
}
@keyframes build-flame {
  0% { opacity: 0; transform: scaleY(.3); } 5% { opacity: 1; transform: scaleY(.6); } 10% { transform: scaleY(1.05); } 15% { transform: scaleY(.75); } 20% { transform: scaleY(1.2); }
  28% { transform: scaleY(.9); } 36% { transform: scaleY(1.25); } 44% { transform: scaleY(1); } 50% { opacity: 1; transform: scaleY(1.2); }
  58% { opacity: 0; transform: scaleY(.3); } 100% { opacity: 0; transform: scaleY(.3); }
}
@keyframes build-robot-dance {
  0%, 100% { transform: translate(0, 0); } 8% { transform: translate(-7px, -11px); } 16% { transform: translate(-7px, 0); } 25% { transform: translate(7px, -11px); } 33% { transform: translate(7px, 0); }
  42% { transform: translate(-7px, -11px); } 50% { transform: translate(-7px, 0); } 58% { transform: translate(7px, -11px); } 66% { transform: translate(7px, 0); } 78% { transform: translate(0, -15px); } 88% { transform: translate(0, 0); }
}
@keyframes build-arm-right { 0%, 100% { transform: rotate(0); } 12%, 37%, 62% { transform: rotate(-115deg); } 25%, 50%, 75% { transform: rotate(-65deg); } 88% { transform: rotate(-115deg); } }
@keyframes build-arm-left { 0%, 100% { transform: rotate(0); } 12%, 37%, 62% { transform: rotate(65deg); } 25%, 50%, 75% { transform: rotate(115deg); } 88% { transform: rotate(65deg); } }
@keyframes build-antenna { 0% { transform: rotate(0); } 100% { transform: rotate(1440deg); } }
@keyframes build-light { 0%, 100% { opacity: 0; } 12% { opacity: .95; } 18% { opacity: .6; } 24%, 82% { opacity: .95; } }
@keyframes build-door { 0%, 28%, 82%, 100% { transform: scaleX(1); } 42%, 68% { transform: scaleX(.22); } }
@keyframes build-piece-land { 0% { opacity: .7; transform: translate(var(--from-x), var(--from-y)); } 65% { opacity: 1; transform: translateY(-6px); } 100% { transform: translateY(0); } }
@media (max-width: 720px) {
  .build-panel { padding: 10px; gap: 8px; }
  .build-scene { height: 183px; border-radius: 18px; }
  .build-panel .block-speaker { height: 50px; border-width: 2px; }
  .build-panel .block-tray { gap: 10px; padding: 8px; }
  .build-panel .tray-block { width: 54px; height: 54px; flex-basis: 54px; border-width: 2px; }
  .build-feedback { min-height: 22px; font-size: .95rem; }
  .build-feedback .feedback { min-height: 22px; line-height: 22px; }
  .lesson-shell:has(.build-panel) .capy-guide { padding: 12px; }
  .build-footer { gap: 10px; }
  .lesson-shell:has(.build-panel) .capy-guide > img { width: 52px; height: 84px; object-fit: contain; }
  .lesson-shell:has(.build-panel) .speech-bubble { padding: 10px 12px; }
  .lesson-shell:has(.build-panel) .speech-bubble strong { font-size: 1rem; }
  .lesson-shell:has(.build-panel) .speech-bubble p { margin: 4px 0; font-size: .98rem; }
}
@media (max-width: 370px) {
  .build-panel .block-tray { gap: 7px; padding: 7px; }
  .build-panel .tray-block { width: 50px; height: 50px; flex-basis: 50px; }
  .build-scene { height: 152px; }
}
@media (prefers-reduced-motion: reduce) {
  .build-piece.is-landing { animation: none; }
  /* No travel, flight or shaking: the toy glows softly for the length of its show. */
  .build-art.is-showing, .build-art.is-showing * { animation: none !important; }
  .build-art.is-showing :is(.build-extra, .build-extra circle) { opacity: 0 !important; }
  .build-art.is-showing .build-toy { filter: drop-shadow(0 0 7px rgba(255, 236, 150, .95)) drop-shadow(0 0 16px rgba(255, 226, 120, .7)); }
}

.building-piece-art { display: block; width: 100%; height: 100%; overflow: visible; }
.building-piece-art { shape-rendering: geometricPrecision; }
.building-piece-art .build-edge,
.building-piece-art .build-detail-line,
.building-piece-art .build-shine {
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.patch > svg { position: absolute; width: 16px; height: 16px; bottom: -3px; right: -3px; }

@media (max-width: 720px) {
  .lesson-shell:has(.quilt-panel) .capy-guide { padding: 8px; }
  .lesson-shell:has(.quilt-panel) .capy-guide > img { width: 52px; height: 80px; object-fit: contain; }
  .lesson-shell:has(.quilt-panel) .speech-bubble { padding: 8px 12px; }
  .lesson-shell:has(.quilt-panel) .speech-bubble p { margin: 4px 0; font-size: .95rem; }
  .lesson-shell:has(.quilt-panel) .speech-bubble strong { font-size: 1rem; }
  /* Keep adjacent 48px hit areas stationary; the outline supplies the feedback. */
  .paint-palette .paint-well:hover,
  .paint-palette .paint-well.is-active,
  .paint-palette .paint-well.is-target {
    transform: translate(-50%, -50%);
    animation: none;
  }
}
.building-piece-art .build-edge { stroke: #624a40; stroke-width: 1.4px; }
.building-piece-art .build-detail-line { stroke: #624a40; stroke-width: 1px; }
.building-piece-art .build-shine { fill: none; stroke: #fffaf0; stroke-opacity: .48; stroke-width: 1.5px; }
/* A stationary vector stays crisp; arbitrary rotation rasterized each answer
   onto a different subpixel grid, making otherwise identical pieces look uneven. */
.build-panel .tray-block { transform: none; }
.build-panel .tray-block { background: #fffdf5; box-shadow: 0 2px 0 #c4d1bf; padding: 3px; }
.build-panel .block-tray { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.build-panel .tray-block { width: 100%; height: 48px; min-width: 0; }
.build-panel .tray-block:last-child:nth-child(odd) { grid-column: 1 / -1; width: calc(50% - 4px); justify-self: center; }
@media (max-width: 720px) {
  .build-scene { height: 167px; }
  .lesson-shell:has(.build-panel) .capy-guide { padding: 8px; }
  .lesson-shell:has(.build-panel) .speech-bubble { padding: 8px 12px; }
  .lesson-shell:has(.build-panel) .speech-bubble > strong { display: none; }
}
@media (max-width: 370px) {
  .build-scene { height: 136px; }
  .lesson-shell:has(.build-panel) .capy-guide { padding: 4px; }
  .lesson-shell:has(.build-panel) .speech-bubble { padding: 4px 12px; }
}
/* A short phone (360x740, 375x667): the board gives up height before the tray is cut. */
@media (max-width: 720px) and (max-height: 760px) {
  .build-scene { height: 124px; }
}
/* Child profiles share the island's cream cards, brown outlines and teal actions. */
.profile-picker { max-width: 880px; margin: 0 auto; text-align: center; padding: 28px; }
.profile-welcome { display: flex; align-items: center; justify-content: center; gap: 28px; margin-bottom: 28px; min-width: 0; }
.profile-welcome > * { min-width: 0; }
.profile-welcome img { width: 110px; height: 145px; object-fit: contain; }
.profile-welcome h1 { margin: 0 0 12px; }
.profile-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; margin: 24px 0 30px; }
.profile-card { min-width: 0; min-height: 174px; padding: 22px 12px; border: 2px solid var(--line); border-radius: 22px; background: #fffdf6; box-shadow: 0 5px 0 #d5c7af; display: flex; flex-direction: column; align-items: center; gap: 16px; color: var(--ink); font: inherit; font-size: 24px; cursor: pointer; }
.profile-card strong { overflow-wrap: anywhere; }
.profile-card:only-child { grid-column: 1 / -1; width: min(240px, 100%); justify-self: center; }
.profile-card:hover, .profile-card:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 4px; }
.profile-avatar { position: relative; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: #c5ece5; }
.profile-avatar > svg { width: 52px; height: 52px; }
.profile-avatar > span { position: absolute; bottom: -4px; left: -4px; width: 27px; height: 27px; border: 2px solid var(--line); border-radius: 50%; background: #fffdf6; font-size: 16px; }
.profile-tone-1 .profile-avatar { background: #eed8ed; }
.profile-tone-2 .profile-avatar { background: #d7e9cb; }
.profile-tone-3 .profile-avatar { background: #d7e6fb; }
.child-settings { margin-bottom: 28px; }
.child-settings h2 { margin-top: 0; }
.child-settings label { display: flex; flex-direction: column; gap: 8px; font-weight: 700; min-width: 0; }
.child-settings input, .child-settings select { min-width: 0; width: 100%; min-height: 48px; border: 2px solid var(--line); border-radius: 10px; background: #fffdf6; color: var(--ink); padding: 10px 12px; font: inherit; }
.child-settings input:focus, .child-settings select:focus { outline: 3px solid #70d7df; outline-offset: 2px; }
.profile-count { max-width: 160px; margin: 20px 0 12px; }
.child-settings-rows { display: grid; gap: 16px; margin: 20px 0 24px; }
.child-settings-row { min-width: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(130px, .5fr); gap: 16px; align-items: center; padding: 16px; border: 1px solid #cbbfab; border-radius: 14px; }
.child-number { border-radius: 50%; background: #c5ece5; width: 36px; height: 36px; display: grid; place-items: center; }
.profile-hint { font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.profile-error { background: #fff0eb; border: 1px solid #b85c45; border-radius: 10px; padding: 14px; }
.parent-profile-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.parent-profile-tabs button { min-height: 48px; max-width: 100%; overflow-wrap: anywhere; }
.parent-profile-tabs button[aria-pressed="true"] { background: #c5ece5; }
.topbar .parent-link { display: none; }
.app-shell:has(.profile-picker, .island-layout) .topbar .parent-link { display: inline-flex; }
/* The guest's save button (index.html #guestSave): same screens as "אזור הורים". */
.topbar .guest-save { display: none; }
.app-shell:has(.profile-picker, .island-layout) .topbar .guest-save:not([hidden]) { display: inline-flex; }
.guest-save { align-items: center; justify-content: center; gap: 6px; min-width: 48px; min-height: 48px; padding: 0 12px; border: 2px solid var(--teal-dark); border-radius: 999px; background: #dcefee; color: var(--teal-dark); font-family: inherit; font-size: 0.9rem; font-weight: 700; line-height: 1; white-space: nowrap; }
.guest-save svg { width: 20px; height: 20px; flex: 0 0 auto; }
.guest-save-short { display: none; }
@media (hover: hover) and (pointer: fine) {
  .guest-save:hover { background: #c5ece5; }
}
/* Measured against the phone top bar (avatar | save, coins, "אזור הורים"): tightened, the
   short label fits from 390px (the common iPhone width), the icon alone from 350px;
   narrower, the button would sit on the avatar, so it gives way and the round-end note
   stays the way in. */
@media (max-width: 720px) {
  .guest-save { padding: 0 8px; gap: 4px; }
  .topbar-end:has(.guest-save:not([hidden])) { gap: 6px; }
  .guest-save-long { display: none; }
  .guest-save-short { display: inline; }
}
@media (max-width: 389px) {
  .guest-save-short { display: none; }
  .guest-save { padding: 0; }
}
@media (max-width: 349px) {
  .app-shell:has(.profile-picker, .island-layout) .topbar .guest-save:not([hidden]) { display: none; }
}
.island-profile-row { display: flex; margin-bottom: 12px; min-width: 0; }
.island-profile-row .profile-switch { min-height: 48px; max-width: 100%; min-width: 0; text-align: start; }
.island-profile-row .profile-switch > span { display: flex; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
.island-profile-row .profile-switch strong { overflow-wrap: anywhere; min-width: 0; }
.app-shell:has(.profile-picker) .main-nav,
.app-shell:has(.profile-picker) .coin-balance,
.app-shell:has(.profile-picker) .profile-switch { display: none; }
@media (max-width: 720px) {
  .profile-picker { padding: 18px 6px; }
  .profile-welcome { gap: 12px; margin-bottom: 18px; }
  .profile-welcome img { width: 70px; height: 100px; }
  .profile-welcome h1 { font-size: 25px; }
  .profile-welcome p { font-size: 15px; }
  .profile-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .profile-card { font-size: 21px; min-height: 162px; padding: 18px 10px; }
  .child-settings-row { grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .child-settings-row label:last-child { grid-column: 2; }
  .child-number { width: 28px; height: 28px; }
  .profile-switch { font-size: 13px; }
}
/* Animal introductions keep the picture itself as the play surface. */
button.animal-region-frame { padding: 0; border: 0; background: transparent; pointer-events: auto; cursor: pointer; }
button.animal-region-frame:focus-visible { outline: 3px solid #327b75; outline-offset: 3px; border-radius: 18px; }
.animal-entry-icon { position: absolute; right: 17%; bottom: 12%; width: 24px; height: 24px; border-radius: 50%; background: #fff7e5; padding: 3px; }
.animal-entry-icon svg { display: block; width: 100%; height: 100%; }
/* The end of an animal area's introduction: stars and the way on, under the scene. */
.animal-intro-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; margin: 10px auto 0; min-width: 0; }
.animal-intro-footer .primary-button { margin-top: 0; }
@media (max-width: 720px) { .animal-intro-footer { padding-inline: 14px; margin-bottom: 10px; } }
/* On one row the pointing hand stands between the button and the stars: leave it room. */
@media (min-width: 721px) { :is(.animal-intro-footer, .numbers-footer) .primary-button.is-next-game { margin-inline-start: 88px; } }
/* No small icons on the animal island (Dana, November 30, 2026): not beside a world's name and
   not in the circle on its picture. They stay in the markup, hidden, as on the room's objects. */
.animal-entry-icon, .animal-world-stage .animal-region-label > svg { display: none !important; }
.farm-stage { position: relative; width: 100%; min-width: 0; aspect-ratio: 3 / 2; overflow: hidden; align-self: start; border-radius: 22px; border: 0; isolation: isolate; container-type: inline-size; }
.farm-background { display: block; width: 100%; height: auto; }
.farm-animal { position: absolute; transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))); display: block; aspect-ratio: 1; min-width: 48px; min-height: 48px; padding: 0; border: 0; background: transparent; cursor: pointer; z-index: 2; color: #513e32; }
/* Artwork keeps its scene scale even when the transparent touch target grows.
   Both frames share the same foot anchor; animation stays inside that frame. */
.farm-animal-visual { position: absolute; width: var(--animal-art-width); aspect-ratio: 1; left: var(--anchor-x); top: var(--anchor-y); transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))); pointer-events: none; }
.farm-animal-art { display: block; width: 100%; height: auto; transform-origin: 50% 92%; }
.farm-animal-name { position: absolute; left: 50%; top: 94%; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; white-space: nowrap; padding: 4px 12px; border-radius: 18px; background: #fff7e9; border: 1px solid #b7aa8d; box-shadow: 0 2px 0 #745f4830; font-size: clamp(14px, 1.5vw, 20px); line-height: 1.2; }
.farm-animal:focus-visible { outline: 3px solid #367f78; border-radius: 22px; outline-offset: 2px; }
.farm-animal.is-petted .farm-animal-art { animation: farm-pet .55s ease-out; }
.farm-animal.is-petted .farm-animal-name { background: #e4f3e9; border-color: #659b8b; }
.farm-animal.is-suggested .farm-animal-name { border-color: #367f78; box-shadow: 0 0 0 3px #83c6b870; }
/* Feeding shows no name tag, so the second-miss help lights the animal itself, with the
   jungle's glow. Until November 26 the help was recorded but nothing on screen showed it.
   While it glows, no other animal may light up like it. */
.farm-stage.is-feeding .farm-animal.is-suggested .farm-animal-art { filter: drop-shadow(0 0 5px #ffdf77) drop-shadow(0 0 2px #fff6ce); }
.farm-stage.is-feeding:has(.is-suggested) .farm-animal:not(.is-suggested) { filter: none; }
@keyframes farm-pet { 0%,100% { transform: translateY(0) rotate(0); } 35% { transform: translateY(-8px) rotate(-3deg); } 65% { transform: translateY(-3px) rotate(3deg); } }
@media (max-width: 720px) { .farm-animal-name { padding: 3px 7px; } .animal-entry-icon { width: 20px; height: 20px; } }
.farm-panel { min-width: 0; align-self: start; }
.farm-menu { display:grid; gap:8px; min-width:0; margin-top:12px; }
.lesson-shell .farm-menu > .lesson-progress { margin:0; }
.farm-animal-name > svg { width:14px; height:14px; flex-shrink:0; }
.farm-animal-icon { position:absolute; width:14px; height:14px; bottom:0; right:0; opacity:.65; }
.farm-animal-icon > svg { display:block; width:100%; height:100%; }
@media (max-width:720px) {
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) { padding:12px 0 0; gap:12px; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .lesson-head { padding-inline:14px; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .lesson-card { display:contents; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .capy-guide { width:calc(100% - 28px); margin-inline:14px; padding:6px; grid-template-columns:40px minmax(0,1fr); gap:6px; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .capy-guide > img { width:40px; height:56px; object-fit:contain; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .speech-bubble { padding:6px 10px; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .speech-bubble strong { display:none; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .speech-bubble p { margin:2px 0 6px; font-size:.85rem; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .replay-button { min-height:48px; padding:4px 10px; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .lesson-main { width:100%; min-width:0; }
  .lesson-shell:has(:is(.farm-panel,.jungle-panel,.savanna-panel,.sea-panel,.numbers-panel)) .learning-nav { margin:0 14px 16px; }
  .lesson-shell:has(.farm-panel) .farm-menu { margin:0 14px 16px; }
  .lesson-shell:has(.farm-panel) .farm-menu > .lesson-progress { margin:0; }
  .farm-panel .farm-stage { aspect-ratio:1122 / 1402; border:0; border-radius:14px; }
  .farm-stage .farm-animal { min-width:56px; min-height:56px; touch-action:pan-y; }
  .farm-stage .farm-animal-name { font-size:16px; padding:4px 8px; gap:4px; }
  .farm-stage .farm-speaker-anchor { left:50%; top:10%; width:56px; }
  .farm-panel .farm-footer { margin:8px 14px 0; gap:6px; }
  .farm-panel .farm-footer .progress-stars { padding:4px 10px; gap:4px; }
  .farm-panel .farm-footer .progress-star { width:20px; height:20px; }
  .farm-panel .farm-footer .primary-button { min-height:56px; padding:8px 16px; }
  .farm-panel:has(.is-feeding) .farm-footer { flex-direction:row; margin-top:6px; }
  .farm-panel:has(.is-feeding) .farm-footer .primary-button { min-height:48px; margin-top:0; padding:6px 14px; }
  .farm-panel .farm-feeding-feedback { min-height:22px; padding-top:2px; font-size:14px; }
  .farm-panel:has(.is-complete) .farm-feeding-feedback { display:none; }
}
.farm-footer { margin-top: 12px; gap: 8px; }
.farm-panel:has(.is-feeding) .farm-footer { justify-content: center; }
.farm-feeding-feedback { min-height: 26px; text-align: center; color: #367f78; font-weight: 700; padding-top: 4px; }
.farm-animal:disabled { opacity: 1; cursor: default; transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))) !important; box-shadow: none !important; }
.farm-delivery, .farm-dish { position: absolute; transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))); pointer-events: none; }
.farm-delivery { aspect-ratio: 1; z-index: 3; transform-origin: 50% 100%; }
.farm-courier-shadow { position: absolute; width: 44%; height: 8%; left: 28%; bottom: 5%; background: #513e3230; border-radius: 50%; filter: blur(1px); }
.farm-courier-body { display: block; position: relative; width: 100%; height: 100%; transform-origin: 50% 90%; }
.farm-walk-sprite { display: block; opacity: 0; width: 100%; height: 100%; background-position:0 0; background-size:200% 200%; }
.farm-courier-idle { position: absolute; width: 70%; height: 110%; left: 15%; bottom: 8%; object-fit: contain; }
.has-animation-art .farm-delivery.has-outfit-walk.is-active .farm-courier-idle { opacity: 0; }
.has-animation-art .farm-delivery.has-outfit-walk.is-active .farm-walk-sprite { opacity: 1; }
.farm-delivery-food { position: absolute; width: 58%; height: auto; left: 53%; bottom: 23%; transform-origin: 20% 65%; }
.farm-delivery.is-finished .farm-delivery-food { visibility: hidden; }
.farm-food-stream { position: absolute; width: 22%; height: 34%; left: 91%; top: 61%; opacity: 0; }
.farm-food-stream i { position: absolute; width: 16%; height: 9%; border-radius: 45%; background: #8d603a; border: 1px solid #614633; left: calc(var(--crumb) * 16%); }
.farm-dish { z-index: 4; opacity: 0; }
.farm-dish img { display: block; width: 100%; }
.farm-dish.is-finished { opacity: 1; }
.farm-dish.is-finished img { clip-path: inset(44% 0 0); }
.farm-eating-sprite { display: block; opacity: 0; position: absolute; width: var(--animal-art-width); aspect-ratio: 1; left: var(--anchor-x); top: var(--anchor-y); transform: translate(calc(-1 * var(--anchor-x)), calc(-1 * var(--anchor-y))); background-size: 200% 100%; pointer-events: none; }
.farm-speaker-anchor { position: absolute; left: 44%; top: 13%; width: clamp(52px, 9cqw, 84px); aspect-ratio: 1; transform: translate(-50%, -50%); z-index: 5; }
.farm-speaker { min-width: 48px; min-height: 48px; }
/* One 4.6s timeline: anticipate, walk, serve, chew, return. Negative elapsed
   delay preserves the pose if the shared renderer refreshes during a delivery. */
.farm-delivery.is-active { animation: farm-route 4.6s var(--delivery-delay) linear both; }
.farm-delivery.is-active, .farm-dish.is-active { animation-delay: var(--delivery-delay) !important; }
.farm-delivery.is-active .farm-courier-body { animation: farm-body 4.6s var(--delivery-delay) linear both; }
.farm-delivery.is-active .farm-walk-sprite { animation: farm-walk 4.6s var(--delivery-delay) step-end both; }
.farm-delivery.is-active .farm-delivery-food { animation: farm-pour 4.6s var(--delivery-delay) ease-in-out both; }
.farm-delivery.is-active .farm-food-stream { animation: farm-stream 4.6s var(--delivery-delay) linear both; }
.farm-delivery.is-active .farm-food-stream i { animation: farm-crumb .24s calc(var(--crumb) * -.05s) linear infinite; }
.farm-dish.is-active { animation: farm-dish-arrive 4.6s var(--delivery-delay) linear both; }
.farm-dish.is-active img { animation: farm-food-eaten 4.6s var(--delivery-delay) linear both; }
.has-animation-art.is-delivering .is-receiving .farm-animal-visual { animation: farm-animal-idle 4.6s var(--delivery-delay) linear both; }
.has-animation-art.is-delivering .is-receiving .farm-eating-sprite { display: block; animation: farm-animal-eat 4.6s var(--delivery-delay) step-end both; }
@keyframes farm-route {
  0%,4%,100% { left: var(--delivery-home-x); top: var(--delivery-home-y); transform: translate(-50%,-100%) scale(1); }
  29%,75% { left: var(--delivery-to-x); top: var(--delivery-to-y); transform: translate(-50%,-100%) scale(var(--delivery-scale)); }
}
@keyframes farm-body {
  0% { transform: scaleX(var(--walk-facing)) scaleY(1); }
  4% { transform: scaleX(var(--walk-facing)) scaleY(.95); }
  10%,22% { transform: scaleX(var(--walk-facing)) translateY(-2%); }
  16%,28% { transform: scaleX(var(--walk-facing)); }
  29%,41%,75% { transform: scaleX(var(--capy-facing)); }
  35% { transform: scaleX(var(--capy-facing)) rotate(8deg); }
  76%,87%,99%,100% { transform: scaleX(calc(-1 * var(--walk-facing))); }
  81%,93% { transform: scaleX(calc(-1 * var(--walk-facing))) translateY(-2%); }
}
@keyframes farm-walk {
  0%,4%,16%,28%,29%,75%,76%,88%,100% { background-position: 0 0; }
  7%,19%,79%,91% { background-position: 100% 0; }
  10%,22%,82%,94% { background-position: 0 100%; }
  13%,25%,85%,97% { background-position: 100% 100%; }
}
@keyframes farm-pour {
  0%,29% { opacity: 1; transform: rotate(0); }
  35%,40% { opacity: 1; transform: translate(10%,22%) rotate(65deg); }
  43%,100% { opacity: 0; transform: translate(10%,22%) rotate(65deg); }
}
@keyframes farm-stream { 0%,34%,42%,100% { opacity: 0; } 35%,40% { opacity: 1; } }
@keyframes farm-crumb { from { transform: translateY(0); } to { transform: translateY(650%); } }
@keyframes farm-dish-arrive { 0%,32% { opacity: 0; } 40%,100% { opacity: 1; } }
@keyframes farm-food-eaten { 0%,45% { clip-path: inset(0); } 75%,100% { clip-path: inset(44% 0 0); } }
@keyframes farm-animal-idle {
  0%,39% { opacity: 1; }
  41%,74% { opacity: 0; }
  76%,100% { opacity: 1; }
}
@keyframes farm-animal-eat {
  0%,76%,100% { opacity: 0; background-position: 0 0; }
  41%,49%,57%,65%,73% { opacity: 1; background-position: 0 0; }
  45%,53%,61%,69% { opacity: 1; background-position: 100% 0; }
}
@media (max-width: 720px) {
  .lesson-shell:has(.is-feeding) .capy-guide { padding: 6px; }
  .lesson-shell:has(.is-feeding) .speech-bubble { padding: 6px 10px; }
  .lesson-shell:has(.is-feeding) .speech-bubble p { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) {
  .farm-animal-art, .farm-speaker, .farm-delivery.is-active .farm-courier-body,
  .farm-delivery.is-active .farm-walk-sprite { animation: none !important; }
  .farm-delivery.is-active { animation-timing-function: step-end; }
}

/* Finished colours have no touch hotspots: artwork can give space to Finish. */
@media (max-width: 720px) {
  .is-practice-finished .palette-viewport { margin-inline: 0; }
  .is-practice-finished .paint-palette { width: 100%; }
}
.farm-puzzle-panel, .farm-puzzle-panel * { box-sizing:border-box; min-width:0; }
.farm-puzzle-stage { position:relative; width:100%; aspect-ratio:var(--puzzle-aspect); overflow:hidden; isolation:isolate; background:#eee6d5; border-radius:22px; box-shadow:0 3px 12px #44332918; }
.puzzle-board-art { position:absolute; inset:0; width:100%; height:100%; }
.puzzle-slot { position:absolute; min-width:0; min-height:0; border:0; border-radius:0; background:transparent; padding:0; color:#827767; }
.puzzle-slot > svg { width:18px; height:18px; opacity:.3; }
.puzzle-slot:hover { background:#ffffff18; }
.puzzle-animal { position:absolute; left:var(--spot-x); top:var(--spot-y); width:var(--world-width); aspect-ratio:1; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); border:0; padding:0; background:transparent; z-index:3; }
.puzzle-animal img { width:100%; height:100%; object-fit:contain; display:block; }
.farm-puzzle-stage.is-placing .puzzle-animal { pointer-events:none; }
.puzzle-tray.is-empty { display:none; }
.puzzle-animal > span { position:absolute; bottom:5%; left:40%; background:#fffdf2; border-radius:50%; padding:4px; display:flex; }
.puzzle-animal > span svg { width:20px; height:20px; }
.puzzle-animal b { position:absolute; bottom:0; left:50%; transform:translate(-50%,100%); background:#fffdf2; border-radius:10px; padding:3px 10px; }
.puzzle-animal.is-inviting img { animation:puzzle-invite 1.8s ease-in-out infinite; }
@keyframes puzzle-invite { 50% { filter:drop-shadow(0 0 6px #38a4ac); transform:scale(1.025); } }
.puzzle-loading { position:absolute; inset:0; z-index:5; display:grid; place-items:center; background:#eee6d5dd; }
.puzzle-tray { display:grid; grid-template-columns:48px minmax(0,1fr) 48px; gap:8px; max-width:620px; margin:10px auto 0; align-items:center; direction:ltr; }
.puzzle-tray-pieces { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; }
.puzzle-tray button, .puzzle-tools button { min-height:48px; border:2px solid #d8d2be; background:#fffdf6; border-radius:14px; color:#345653; cursor:pointer; }
.puzzle-tray > button { width:48px; height:48px; padding:10px; }
.puzzle-tray > button svg { width:24px; height:24px; }
.puzzle-tray .puzzle-piece { position:relative; height:110px; padding:3px; touch-action:none; }
.puzzle-fragment { display:block; width:100%; height:100%; pointer-events:none; }
.puzzle-piece > span { position:absolute; bottom:3px; right:3px; width:14px; height:14px; pointer-events:none; }
.puzzle-piece.is-selected, .puzzle-tools [aria-pressed="true"] { border-color:#2b8f91; background:#e2f2ed; }
.farm-puzzle-panel button:disabled { opacity:.45; cursor:default; }
.puzzle-count { text-align:center; margin:8px 0; font-weight:700; }
.puzzle-tools { display:flex; justify-content:center; gap:8px; flex-wrap:wrap; margin-top:8px; }
.puzzle-tools button { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:8px 12px; }
.puzzle-tools svg { width:22px; height:22px; flex-shrink:0; }
.puzzle-drag-ghost { position:fixed; width:130px; height:130px; transform:translate(-50%,-65%); z-index:100; pointer-events:none; filter:drop-shadow(0 5px 4px #0005); }
@media (prefers-reduced-motion:reduce) { .puzzle-animal.is-inviting img { animation:none; filter:drop-shadow(0 0 5px #38a4ac); } }
@media (max-width:720px) {
  .screen:has(.farm-puzzle-panel) { padding:6px; }
  .lesson-shell:has(.farm-puzzle-panel) { gap:4px; }
  .lesson-shell:has(.farm-puzzle-panel) .capy-guide { padding:2px; grid-template-columns:48px minmax(0,1fr); gap:6px; }
  .lesson-shell:has(.farm-puzzle-panel) .capy-guide > img { width:48px; height:58px; object-fit:contain; }
  .lesson-shell:has(.farm-puzzle-panel) .speech-bubble { padding:4px 8px; }
  .lesson-shell:has(.farm-puzzle-panel) .speech-bubble strong { display:none; }
  .lesson-shell:has(.farm-puzzle-panel) .speech-bubble p { font-size:.85rem; margin:2px 0; }
  .lesson-shell:has(.farm-puzzle-panel) .replay-button { min-height:48px; margin-top:0; padding:4px 8px; }
  .farm-puzzle-stage { width:100%; margin-inline:auto; border-radius:18px; }
  .puzzle-tray { margin-top:4px; gap:5px; }
  .puzzle-tray .puzzle-piece { height:72px; }
  .puzzle-tools button { padding:6px 8px; font-size:.85rem; }
}
.jungle-panel { min-width:0; }
.jungle-stage { position:relative; width:100%; min-width:0; aspect-ratio:3 / 2; overflow:hidden; isolation:isolate; border-radius:22px; container-type:inline-size; }
.jungle-background { display:block; width:100%; height:auto; }
.jungle-animal, .jungle-capy { position:absolute; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); z-index:2; }
.jungle-animal { display:block; min-width:48px; min-height:48px; padding:0; border:0; color:#513e32; background:transparent; cursor:pointer; touch-action:pan-y; }
.jungle-art { display:block; width:100%; height:auto; mask-mode:alpha; mask-size:100% 100%; mask-repeat:no-repeat; transform-origin:var(--anchor-x) var(--anchor-y); pointer-events:none; }
.jungle-label { position:absolute; top:100%; left:50%; transform:translateX(-50%); display:flex; align-items:center; justify-content:center; gap:4px; white-space:nowrap; padding:3px 9px; border:1px solid #bdaa91; border-radius:20px; background:#fff9e9; font-size:clamp(14px,2cqw,18px); line-height:1.2; }
.jungle-label svg { width:15px; height:15px; flex:none; }
.jungle-animal[data-animal="parrot"] .jungle-label { left:100%; top:65%; }
.jungle-animal[data-animal="crocodile"] .jungle-label { top:79%; }
.jungle-animal:disabled { opacity:.5; cursor:default; }
.jungle-animal:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:20px; }
.jungle-animal.is-selected .jungle-label { background:#e4f3e9; border-color:#659b8b; }
.jungle-animal.is-selected .jungle-art { animation:jungle-greet .65s var(--reaction-delay) ease-out both; }
.jungle-capy { pointer-events:none; }
.jungle-capy img { display:block; width:100%; height:auto; }
@keyframes jungle-greet { 0%,100%{transform:rotate(0)} 35%{transform:rotate(-2deg)} 70%{transform:rotate(1deg)} }
@media(max-width:720px) {
  .jungle-stage { aspect-ratio:1122 / 1402; border-radius:14px; }
  .lesson-main:has(.jungle-panel) { padding:0; }
  .jungle-label { font-size:16px; padding:4px 8px; }
  .jungle-animal[data-animal="crocodile"] .jungle-label { font-size:14px; padding:3px 8px; }
}
@media(prefers-reduced-motion:reduce) { .jungle-animal.is-selected .jungle-art { animation:none; } }

.jungle-hide-stage { position:relative; width:100%; min-width:0; aspect-ratio:3 / 2; overflow:hidden; isolation:isolate; border-radius:22px; }
.jungle-hide-panel { width:100%; }
.jungle-hide-slot { position:absolute; aspect-ratio:1.4; transform:translate(-50%,-90%); z-index:2; }
.jungle-hide-animal { position:absolute; left:50%; top:82%; transform:translate(calc(-1 * var(--hide-anchor-x)),calc(-1 * var(--hide-anchor-y))); visibility:hidden; pointer-events:none; }
.jungle-hide-slot.is-open .jungle-hide-animal { visibility:visible; z-index:1; }
.jungle-hide-leaves { position:absolute; inset:0; background:url('assets/mvp/worlds/jungle-hide-seek-v1/bush-source-v1.png') center / 100% 100% no-repeat; mask:url('assets/mvp/worlds/jungle-hide-seek-v1/bush-mask-v1.png') center / 100% 100% no-repeat; mask-mode:luminance; transform-origin:50% 90%; pointer-events:none; }
.jungle-hide-leaves.left { clip-path:inset(0 48% 0 0); }
.jungle-hide-leaves.right { clip-path:inset(0 0 0 48%); }
.jungle-hide-slot.is-open .left { animation:jungle-leaves-left .5s var(--reveal-delay) ease-out both; }
.jungle-hide-slot.is-open .right { animation:jungle-leaves-right .5s var(--reveal-delay) ease-out both; }
.jungle-hide-hit { position:absolute; inset:0; width:100%; height:100%; min-width:48px; min-height:48px; padding:0; border:0; border-radius:35%; background:transparent; cursor:pointer; touch-action:pan-y; }
.jungle-hide-touch { position:absolute; bottom:8%; left:50%; transform:translateX(-50%); display:grid; place-items:center; width:26px; height:26px; border:1px solid #baa982; border-radius:50%; background:#fff9e9e8; color:#4a7161; pointer-events:none; }
.jungle-hide-touch svg { width:18px; height:18px; }
.jungle-hide-hit:focus-visible { outline:3px solid #387f79; outline-offset:2px; }
.jungle-hide-hit:disabled { cursor:default; }
.jungle-hide-slot.is-help .jungle-hide-animal { filter:drop-shadow(0 0 5px #ffdf77) drop-shadow(0 0 2px #fff6ce); }
.jungle-hide-animal .jungle-art { transform-origin:var(--hide-anchor-x) var(--hide-anchor-y); }
.jungle-hide-slot.is-found { z-index:3; }
.jungle-hide-slot.is-found .jungle-art { animation:jungle-hide-dance 1.8s var(--found-delay) ease-in-out both; }
.jungle-hide-sparkles { position:absolute; inset:0; z-index:2; pointer-events:none; }
.jungle-hide-sparkles i { position:absolute; top:25%; left:12%; width:9px; height:9px; border-radius:35%; background:#fff5ce; box-shadow:0 0 0 2px #d6a949; animation:jungle-hide-sparkle 1.8s var(--found-delay) ease-out both; }
.jungle-hide-sparkles i:nth-child(2) { top:6%; left:70%; width:7px; height:7px; }
.jungle-hide-sparkles i:nth-child(3) { top:53%; left:89%; width:6px; height:6px; }
@keyframes jungle-hide-dance {
  0%,100% { transform:translateY(0) rotate(0) scale(1); }
  8% { transform:translateY(0) rotate(-3deg) scale(1.06,.92); }
  20% { transform:translateY(-13%) rotate(-9deg) scale(.98,1.04); }
  31% { transform:translateY(0) rotate(5deg) scale(1.04,.96); }
  40% { transform:translateY(-3%) rotate(-7deg) scale(1); }
  51% { transform:translateY(-16%) rotate(9deg) scale(.98,1.04); }
  63% { transform:translateY(0) rotate(-5deg) scale(1.06,.94); }
  74% { transform:translateY(-5%) rotate(6deg) scale(1); }
  86% { transform:translateY(0) rotate(-3deg) scale(1.02,.98); }
}
@keyframes jungle-hide-sparkle {
  0%,100% { opacity:0; transform:translateY(0) rotate(0) scale(.3); }
  22%,58% { opacity:1; transform:translateY(-14px) rotate(100deg) scale(1); }
  85% { opacity:0; transform:translateY(-25px) rotate(180deg) scale(.5); }
}
.jungle-hide-speaker { position:absolute; z-index:4; top:5%; left:50%; translate:-50% 0; width:64px; height:64px; min-height:48px; min-width:48px; }
.jungle-hide-hint { position:absolute; z-index:4; top:6%; right:5%; display:flex; align-items:center; gap:5px; padding:8px 12px; border-radius:20px; background:#fff9e9; color:#513e32; }
.jungle-hide-hint svg { width:22px; height:22px; }
.jungle-hide-footer { display:flex; justify-content:center; align-items:center; flex-wrap:wrap; gap:10px; margin:8px auto; min-width:0; }
.jungle-hide-footer .primary-button { min-height:48px; display:flex; align-items:center; gap:8px; }
@keyframes jungle-leaves-left { to { transform:translate(-16%,0) rotate(-12deg) scale(.6); } }
@keyframes jungle-leaves-right { to { transform:translate(16%,0) rotate(12deg) scale(.6); } }
@media(max-width:720px) {
  .jungle-hide-stage { aspect-ratio:1122 / 1402; border-radius:14px; }
  .jungle-hide-speaker { width:56px; height:56px; }
  .lesson-shell:has(:is(.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) { gap:8px; }
  .lesson-shell:has(:is(.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .capy-guide { padding:2px; }
  .lesson-shell:has(:is(.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .speech-bubble { display:grid; grid-template-columns:minmax(0,1fr) 48px; align-items:center; gap:8px; }
  .lesson-shell:has(:is(.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .speech-bubble p { margin:0; }
  .lesson-shell:has(:is(.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .replay-button { width:48px; height:48px; min-width:48px; padding:0; justify-content:center; }
  .lesson-shell:has(:is(.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .replay-button span { display:none; }
  .jungle-hide-footer .primary-button { margin-top:0; padding:6px 14px; }
  .jungle-hide-footer { margin:6px auto; }
  .jungle-hide-hint { font-size:15px; padding:6px 8px; }
}
@media(prefers-reduced-motion:reduce) {
  .jungle-hide-slot.is-open .left { animation:none; transform:translate(-16%,0) rotate(-12deg) scale(.6); }
  .jungle-hide-slot.is-open .right { animation:none; transform:translate(16%,0) rotate(12deg) scale(.6); }
  .jungle-hide-slot.is-found .jungle-art { animation:none; }
  .jungle-hide-sparkles { display:none; }
  .jungle-hide-slot.is-found .jungle-hide-animal { filter:drop-shadow(0 0 6px #fff5ce); }
}

.savanna-panel { min-width:0; }
.savanna-stage { position:relative; width:100%; min-width:0; aspect-ratio:3 / 2; overflow:hidden; isolation:isolate; border-radius:22px; container-type:inline-size; }
.savanna-background { display:block; width:100%; height:auto; }
.savanna-animal, .savanna-capy { position:absolute; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); z-index:2; }
.savanna-animal { display:block; min-width:48px; min-height:48px; padding:0; border:0; color:#513e32; background:transparent; cursor:pointer; touch-action:pan-y; }
.savanna-art { display:block; width:100%; height:auto; mask-mode:luminance; mask-size:100% 100%; mask-repeat:no-repeat; transform-origin:var(--anchor-x) var(--anchor-y); pointer-events:none; }
.savanna-label { position:absolute; top:100%; left:50%; transform:translateX(-50%); display:flex; align-items:center; justify-content:center; gap:4px; white-space:nowrap; padding:3px 9px; border:1px solid #bdaa91; border-radius:20px; background:#fff9e9; font-size:clamp(14px,2cqw,18px); line-height:1.2; }
.savanna-label svg { width:15px; height:15px; flex:none; }
/* The shared disabled style drops every transform; an animal stands on its anchor even while it waits. */
.savanna-animal:disabled { opacity:.5; cursor:default; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))) !important; box-shadow:none !important; }
.savanna-animal:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:20px; }
.savanna-animal.is-selected .savanna-label { background:#e4f3e9; border-color:#659b8b; }
.savanna-animal.is-selected .savanna-art { animation:savanna-greet .65s var(--reaction-delay) ease-out both; }
.savanna-capy { pointer-events:none; }
.savanna-capy img { display:block; width:100%; height:auto; }
@keyframes savanna-greet { 0%,100%{transform:rotate(0)} 35%{transform:rotate(-2deg)} 70%{transform:rotate(1deg)} }
@media(max-width:720px) {
  .savanna-stage { aspect-ratio:1121 / 1403; border-radius:14px; }
  .lesson-main:has(.savanna-panel) { padding:0; }
  .savanna-label { font-size:clamp(14px,2cqw,18px); padding:3px 8px; }
}
@media(prefers-reduced-motion:reduce) { .savanna-animal.is-selected .savanna-art { animation:none; } }

.savanna-animal[data-animal="hippo"] { aspect-ratio:2.5; }
.savanna-animal[data-animal="hippo"] .savanna-crop { position:absolute; inset:0; overflow:hidden; border-radius:0 0 45% 20%; }
.savanna-animal[data-animal="hippo"] .savanna-label { font-size:clamp(13px,2cqw,16px); }
.savanna-capy.is-listening img { animation:savanna-greet .65s var(--reaction-delay) ease-out both; transform-origin:bottom center; }
@media(prefers-reduced-motion:reduce) { .savanna-capy.is-listening img { animation:none; } }

/* The sea's introduction: the animals swim in open water, anchored at their middle, with
   their name tag below; Capy's submarine rests on the sand and is the scene's tappable Capy. */
.sea-panel { min-width:0; }
.sea-stage { position:relative; width:100%; min-width:0; aspect-ratio:3 / 2; overflow:hidden; isolation:isolate; border-radius:22px; container-type:inline-size; }
.sea-background { display:block; width:100%; height:auto; }
.sea-animal, .sea-capy { position:absolute; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); z-index:2; }
.sea-animal { display:block; min-width:48px; min-height:48px; padding:0; border:0; color:#513e32; background:transparent; cursor:pointer; touch-action:pan-y; }
.sea-art { display:block; width:100%; height:auto; transform-origin:50% 50%; pointer-events:none; }
.sea-label { position:absolute; top:100%; left:50%; transform:translateX(-50%); display:flex; align-items:center; justify-content:center; gap:4px; white-space:nowrap; padding:3px 9px; border:1px solid #bdaa91; border-radius:20px; background:#fff9e9; font-size:clamp(14px,2cqw,18px); line-height:1.2; }
.sea-label svg { width:15px; height:15px; flex:none; }
/* The shared disabled style drops every transform; an animal keeps its anchor while its picture loads. */
.sea-animal:disabled { opacity:.5; cursor:default; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))) !important; box-shadow:none !important; }
.sea-animal:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:20px; }
.sea-animal.is-selected .sea-label { background:#e4f3e9; border-color:#659b8b; }
.sea-animal.is-selected .sea-art { animation:sea-greet .65s var(--reaction-delay) ease-out both; }
.sea-capy img { transform-origin:50% 100%; }
@keyframes sea-greet { 0%,100% { transform:translateY(0) rotate(0); } 35% { transform:translateY(-4%) rotate(-3deg); } 70% { transform:translateY(1%) rotate(2deg); } }
@media(max-width:720px) {
  .sea-stage { aspect-ratio:1122 / 1402; border-radius:14px; }
  .lesson-main:has(.sea-panel) { padding:0; }
  .sea-label { font-size:16px; padding:4px 8px; }
}
@media(prefers-reduced-motion:reduce) { .sea-animal.is-selected .sea-art { animation:none; } }

/* The sea's memory game: a grid of shells on the sea floor, Capy's submarine in the water
   above them. Shells keep their size while a pair is judged (disabled only to hold taps). */
.sea-menu { display:grid; gap:8px; min-width:0; margin-top:12px; }
.lesson-shell .sea-menu > .lesson-progress { margin:0; }
.sea-memory-board { --gap:8px; position:absolute; z-index:3; left:6%; right:6%; bottom:4%; display:flex; flex-wrap:wrap; justify-content:center; gap:var(--gap); }
.sea-memory-board > .sea-shell { flex:0 0 min(15cqw,150px,calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols))); min-width:0; }
.sea-shell { position:relative; display:block; min-width:48px; min-height:48px; padding:0; border:0; background:transparent; cursor:pointer; touch-action:manipulation; }
.sea-shell-art { display:block; width:100%; height:auto; transform-origin:50% 90%; pointer-events:none; }
.sea-shell-animal { position:absolute; left:50%; top:58%; width:var(--animal-size,74%); height:auto; transform:translate(-50%,-50%); pointer-events:none; filter:drop-shadow(0 2px 2px #0002); }
.sea-shell b { position:absolute; left:50%; bottom:2%; transform:translateX(-50%); padding:1px 7px; border:1px solid #bdaa91; border-radius:14px; background:#fff9e9; color:#513e32; font-size:clamp(12px,1.6cqw,16px); line-height:1.2; white-space:nowrap; pointer-events:none; }
.sea-memory-stage[aria-busy="false"] .sea-shell:disabled { opacity:1; cursor:default; }
.sea-shell:disabled { opacity:.5; box-shadow:none !important; }
.sea-shell:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:16px; }
.sea-shell.is-matched b { background:#e4f3e9; border-color:#659b8b; }
.sea-shell.is-new .sea-shell-animal { animation:sea-shell-bob .8s var(--bob-delay) ease-out both; }
/* When the board is finished the last pair bobs, then every animal rises once. Both are timed
   from the last match (--bob-delay), so a re-render never restarts them. */
.sea-memory-board.is-finished .sea-shell-animal { animation:sea-shell-rise .9s calc(var(--bob-delay) + .8s) ease-out forwards; }
.sea-memory-board.is-finished .sea-shell.is-new .sea-shell-animal { animation:sea-shell-bob .8s var(--bob-delay) ease-out both, sea-shell-rise .9s calc(var(--bob-delay) + .8s) ease-out forwards; }
.sea-memory-footer { display:flex; justify-content:center; margin:8px auto; min-width:0; }
.sea-memory-footer .primary-button { min-height:48px; display:flex; align-items:center; gap:8px; }
@keyframes sea-shell-bob { 0%,100% { transform:translate(-50%,-50%); } 40% { transform:translate(-50%,-62%) rotate(-4deg); } 70% { transform:translate(-50%,-48%) rotate(3deg); } }
@keyframes sea-shell-rise { from { transform:translate(-50%,-50%); } to { transform:translate(-50%,-64%); } }
@media(max-width:720px) {
  .lesson-shell:has(.sea-panel) .sea-menu { margin:0 14px 16px; }
  .lesson-shell:has(.sea-panel) .sea-menu > .lesson-progress { margin:0; }
  .sea-memory-board { --gap:6px; left:3%; right:3%; bottom:3%; }
  .sea-memory-board > .sea-shell { flex-basis:calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols)); }
}
/* A found pair sparkles once its name is said (Dana, November 29): both shells pulse with a
   strong gold glow and eight gold stars pop out around them, timed by --sparkle-delay. */
.sea-shell.is-sparkling .sea-shell-art { animation:shell-glow 1.6s var(--sparkle-delay) ease-out both; }
.shell-sparkles { position:absolute; inset:-14%; z-index:3; pointer-events:none; filter:drop-shadow(0 0 4px #fff3b0) drop-shadow(0 0 2px #c98a17); }
.shell-sparkles i { position:absolute; width:18px; height:18px; clip-path:polygon(50% 0,61% 39%,100% 50%,61% 61%,50% 100%,39% 61%,0 50%,39% 39%); background:radial-gradient(circle,#fff 0 22%,#ffe066 40%,#f2b632 100%); animation:shell-star 1.5s var(--sparkle-delay) ease-out both; }
.shell-sparkles i:nth-child(1) { top:4%; left:12%; }
.shell-sparkles i:nth-child(2) { top:0; left:48%; width:22px; height:22px; animation-delay:calc(var(--sparkle-delay) + 90ms); }
.shell-sparkles i:nth-child(3) { top:8%; left:82%; width:14px; height:14px; animation-delay:calc(var(--sparkle-delay) + 180ms); }
.shell-sparkles i:nth-child(4) { top:44%; left:92%; width:16px; height:16px; animation-delay:calc(var(--sparkle-delay) + 60ms); }
.shell-sparkles i:nth-child(5) { top:84%; left:80%; width:20px; height:20px; animation-delay:calc(var(--sparkle-delay) + 240ms); }
.shell-sparkles i:nth-child(6) { top:88%; left:36%; width:14px; height:14px; animation-delay:calc(var(--sparkle-delay) + 140ms); }
.shell-sparkles i:nth-child(7) { top:62%; left:0; width:18px; height:18px; animation-delay:calc(var(--sparkle-delay) + 200ms); }
.shell-sparkles i:nth-child(8) { top:30%; left:2%; width:12px; height:12px; animation-delay:calc(var(--sparkle-delay) + 300ms); }
@keyframes shell-star { 0% { opacity:0; scale:0; rotate:0deg; } 25% { opacity:1; scale:1.25; } 55% { opacity:1; scale:.9; rotate:90deg; } 75% { opacity:1; scale:1.1; } 100% { opacity:0; scale:.4; rotate:180deg; } }
@keyframes shell-glow { 0%,100% { scale:1; filter:drop-shadow(0 0 0 #ffd35c00); } 25% { scale:1.12; filter:drop-shadow(0 0 10px #ffd35c) drop-shadow(0 0 22px #ffe9a8); } 60% { scale:1.04; filter:drop-shadow(0 0 8px #ffd35c) drop-shadow(0 0 18px #ffe9a8); } }
@media(prefers-reduced-motion:reduce) { .shell-sparkles { display:none; } .sea-shell.is-sparkling .sea-shell-art { animation:none; filter:drop-shadow(0 0 6px #ffe08a); } }
@media(prefers-reduced-motion:reduce) { .sea-shell.is-new .sea-shell-animal, .sea-memory-board.is-finished .sea-shell-animal, .sea-memory-board.is-finished .sea-shell.is-new .sea-shell-animal { animation:none; } }

/* The mud bath (savanna practice): mud over each animal, clipped by the animal's own mask;
   the same sponge cue on every animal; a bucket beside Capy; speaker, hint and footer as
   in jungle hide-and-seek. */
.savanna-wash-panel { width:100%; }
.savanna-wash-stage .savanna-crop { position:relative; display:block; }
.savanna-mud { position:absolute; left:0; top:0; display:block; width:100%; height:auto; mask-mode:luminance; mask-size:100% 100%; mask-repeat:no-repeat; transform-origin:var(--anchor-x) var(--anchor-y); pointer-events:none; }
.savanna-wash-stage[aria-busy="false"] .savanna-animal:disabled { opacity:1; cursor:default; }
.savanna-wash-touch { position:absolute; bottom:8%; left:50%; transform:translateX(-50%); z-index:3; display:grid; place-items:center; width:26px; height:26px; border:1px solid #baa982; border-radius:50%; background:#fff9e9e8; pointer-events:none; }
.savanna-wash-touch svg { width:18px; height:18px; animation:savanna-rock 1.6s var(--rock-delay, 0s) ease-in-out infinite; transform-origin:50% 70%; }
/* While the right animal glows, no other animal may light up like it. */
.savanna-wash-stage:has(.is-help) .savanna-animal:not(.is-help) { filter:none; }
.savanna-bucket { position:absolute; z-index:2; display:block; height:auto; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); pointer-events:none; }
.savanna-wash-speaker { position:absolute; z-index:4; top:5%; left:50%; translate:-50% 0; width:64px; height:64px; min-height:48px; min-width:48px; }
.savanna-wash-hint { position:absolute; z-index:4; top:6%; right:5%; display:flex; align-items:center; gap:5px; padding:8px 12px; border-radius:20px; background:#fff9e9; color:#513e32; }
.savanna-wash-hint svg { width:22px; height:22px; }
.savanna-wash-footer { display:flex; justify-content:center; align-items:center; flex-wrap:wrap; gap:10px; margin:8px auto; min-width:0; }
.savanna-wash-footer .primary-button { min-height:48px; display:flex; align-items:center; gap:8px; }
.savanna-wash-stage .savanna-animal.is-clean .savanna-mud { animation:savanna-mud-off .55s var(--wash-delay) ease forwards; }
.savanna-wash-stage .savanna-animal.is-clean .savanna-crop { animation:savanna-shake-off .6s calc(var(--wash-delay) + 450ms) ease-in-out both; transform-origin:var(--anchor-x) var(--anchor-y); }
.savanna-wash-stage .savanna-animal.is-back .savanna-mud { animation:savanna-mud-on .4s var(--back-delay) ease both; }
.savanna-wash-stage .savanna-animal.is-back .savanna-crop { animation:savanna-hop .55s var(--back-delay) ease-out both; transform-origin:var(--anchor-x) var(--anchor-y); }
.savanna-wash-stage .savanna-animal.is-refused .savanna-crop { animation:savanna-head-shake .7s var(--refuse-delay) ease-in-out both; transform-origin:var(--anchor-x) var(--anchor-y); }
/* The jungle's help glow, one layer stronger: the savanna's starters are smaller on a phone. */
.savanna-wash-stage .savanna-animal.is-help .savanna-crop { filter:drop-shadow(0 0 6px #ffdf77) drop-shadow(0 0 3px #ffdf77) drop-shadow(0 0 2px #fff6ce); }
.savanna-foam, .savanna-bubbles { position:absolute; inset:0; z-index:3; pointer-events:none; }
.savanna-foam i, .savanna-bubbles i { position:absolute; width:16px; height:16px; margin:-8px 0 0 -8px; border:1px solid #9fc4c0; border-radius:50%; background:radial-gradient(circle at 35% 35%, #fff, #e9f5f4 60%, #cfe6e4); }
.savanna-foam i:nth-child(1) { left:46%; top:44%; } .savanna-foam i:nth-child(2) { left:56%; top:50%; width:12px; height:12px; } .savanna-foam i:nth-child(3) { left:40%; top:54%; width:10px; height:10px; }
.savanna-bubbles i { animation:savanna-rise 1.5s var(--wash-delay) ease-out both; }
.savanna-bubbles i:nth-child(1) { left:30%; top:55%; } .savanna-bubbles i:nth-child(2) { left:48%; top:45%; animation-delay:calc(var(--wash-delay) + 120ms); }
.savanna-bubbles i:nth-child(3) { left:62%; top:58%; animation-delay:calc(var(--wash-delay) + 240ms); } .savanna-bubbles i:nth-child(4) { left:40%; top:35%; animation-delay:calc(var(--wash-delay) + 360ms); }
.savanna-bubbles i:nth-child(5) { left:70%; top:42%; animation-delay:calc(var(--wash-delay) + 480ms); } .savanna-bubbles i:nth-child(6) { left:54%; top:62%; animation-delay:calc(var(--wash-delay) + 600ms); }
.savanna-sponge { position:absolute; z-index:5; width:44px; height:44px; margin:-22px 0 0 -22px; pointer-events:none; filter:drop-shadow(0 2px 2px #0003); }
.savanna-sponge svg { width:100%; height:100%; }
@keyframes savanna-rock { 0%,100% { transform:rotate(-12deg) translateX(-2px); } 50% { transform:rotate(12deg) translateX(2px); } }
@keyframes savanna-mud-off { from { opacity:1; } to { opacity:0; } }
@keyframes savanna-mud-on { from { opacity:0; } to { opacity:1; } }
@keyframes savanna-shake-off { 0%,100% { transform:rotate(0); } 20% { transform:rotate(-2.5deg); } 40% { transform:rotate(2.5deg); } 60% { transform:rotate(-1.5deg); } 80% { transform:rotate(1deg); } }
@keyframes savanna-hop { 0% { transform:translateY(0); } 40% { transform:translateY(-7%); } 70% { transform:translateY(1%); } 100% { transform:translateY(0); } }
@keyframes savanna-head-shake { 0%,100% { transform:rotate(0); } 15% { transform:rotate(-3deg); } 35% { transform:rotate(3deg); } 55% { transform:rotate(-2deg); } 75% { transform:rotate(1.5deg); } }
@keyframes savanna-rise { 0% { transform:translateY(0) scale(.4); opacity:0; } 15% { opacity:1; } 100% { transform:translateY(-80px) scale(1.15); opacity:0; } }
@media(prefers-reduced-motion:reduce) {
  .savanna-wash-stage .savanna-animal:is(.is-clean, .is-back, .is-refused) :is(.savanna-crop, .savanna-mud), .savanna-wash-touch svg { animation:none; }
  .savanna-wash-stage .savanna-animal.is-clean .savanna-mud { opacity:0; }
  .savanna-bubbles { display:none; }
}
@media(max-width:720px) {
  .savanna-wash-speaker { width:56px; height:56px; }
  .savanna-wash-touch { width:22px; height:22px; }
  .savanna-wash-touch svg { width:15px; height:15px; }
  .savanna-wash-footer .primary-button { margin-top:0; padding:6px 14px; }
  .savanna-wash-footer { margin:6px auto; }
  .savanna-wash-hint { font-size:15px; padding:6px 8px; }
}

/* The dive (sea practice): steer Capy's submarine to the animal that was named and hold
   it there. The submarine is positioned by its middle; it moves with the finger, and a
   tap on an animal sails it there (sea-travel, resumed across re-renders by a negative
   delay). Animals found swim in a line behind it. The hold ring is the same for every
   animal, so it gives nothing away; the help glow follows the painted outline. */
.sea-dive-panel { width:100%; }
.sea-dive-stage[aria-busy="false"] .sea-animal:disabled { opacity:1; cursor:default; }
.sea-sub { position:absolute; z-index:4; transform:translate(-50%,-50%); pointer-events:none; }
.sea-sub.faces-right { transform:translate(-50%,-50%) scaleX(-1); }
.sea-sub.is-travelling { animation:sea-travel .7s var(--travel-delay) ease-in-out both; }
.sea-sub-handle { position:relative; display:block; width:100%; min-width:64px; min-height:64px; padding:0; border:0; background:transparent; cursor:grab; touch-action:none; pointer-events:auto; -webkit-tap-highlight-color:transparent; }
.sea-sub.is-steering .sea-sub-handle { cursor:grabbing; }
.sea-sub-handle img { display:block; width:100%; height:auto; pointer-events:none; transition:scale 80ms ease; }
.sea-sub-handle:active img, .sea-sub.is-steering .sea-sub-handle img { scale:.97; filter:drop-shadow(0 0 6px #fffdf2) drop-shadow(0 0 2px #fffdf2); }
.sea-sub-handle:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:24px; }
.sea-sub-handle:disabled { cursor:default; }
.sea-steer-cue { position:absolute; left:42%; top:52%; z-index:2; display:grid; place-items:center; width:34px; height:34px; margin:-17px 0 0 -17px; border:1px solid #baa982; border-radius:50%; background:#fff9e9e8; pointer-events:none; }
.sea-steer-cue svg { width:24px; height:24px; animation:savanna-rock 1.6s ease-in-out infinite; transform-origin:50% 70%; }
.sea-train { position:absolute; inset:0; pointer-events:none; }
.sea-follower { position:absolute; left:calc(84% + var(--i) * 40%); top:34%; width:38%; height:auto; animation:sea-bob 1.8s calc(var(--i) * -.3s) ease-in-out infinite; }
.sea-hold-ring { position:absolute; left:50%; top:50%; z-index:3; width:58px; height:58px; margin:-29px 0 0 -29px; border:4px solid #fff9e9e6; border-radius:50%; box-shadow:0 0 0 1px #8fb9b5; pointer-events:none; }
.sea-hold-ring::after { content:""; position:absolute; inset:3px; border-radius:50%; background:#fff9e9a8; transform:scale(0); animation:sea-hold .4s var(--hold-delay) linear forwards; }
.sea-dive-stage .sea-animal.is-found .sea-art { animation:sea-loop 1.1s var(--found-delay) ease-in-out both; }
.sea-dive-stage .sea-animal.is-refused .sea-art { animation:sea-turn-away .9s var(--refuse-delay) ease-in-out both; }
.sea-dive-stage .sea-animal.is-help .sea-art { filter:drop-shadow(0 0 6px #ffdf77) drop-shadow(0 0 3px #ffdf77) drop-shadow(0 0 2px #fff6ce); }
.sea-bubbles { position:absolute; inset:0; z-index:3; pointer-events:none; }
.sea-bubbles i { position:absolute; width:14px; height:14px; margin:-7px 0 0 -7px; border:1px solid #9fc4c0; border-radius:50%; background:radial-gradient(circle at 35% 35%, #fff, #e9f5f4 60%, #cfe6e4); animation:savanna-rise 1.2s var(--refuse-delay) ease-out both; }
.sea-bubbles i:nth-child(1) { left:30%; top:45%; } .sea-bubbles i:nth-child(2) { left:38%; top:38%; width:10px; height:10px; animation-delay:calc(var(--refuse-delay) + 150ms); }
.sea-bubbles i:nth-child(3) { left:26%; top:34%; width:8px; height:8px; animation-delay:calc(var(--refuse-delay) + 300ms); } .sea-bubbles i:nth-child(4) { left:34%; top:28%; width:12px; height:12px; animation-delay:calc(var(--refuse-delay) + 450ms); }
.sea-dive-speaker { position:absolute; z-index:5; top:4%; left:50%; translate:-50% 0; width:64px; height:64px; min-height:48px; min-width:48px; }
.sea-dive-hint { position:absolute; z-index:5; top:5%; left:4%; display:flex; align-items:center; gap:5px; padding:8px 12px; border-radius:20px; background:#fff9e9; color:#513e32; }
.sea-dive-hint svg { width:22px; height:22px; }
.sea-dive-footer { display:flex; justify-content:center; align-items:center; flex-wrap:wrap; gap:10px; margin:8px auto; min-width:0; }
.sea-dive-footer .primary-button { min-height:48px; display:flex; align-items:center; gap:8px; }
@keyframes sea-travel { from { left:var(--from-x); top:var(--from-y); } to { left:var(--to-x); top:var(--to-y); } }
@keyframes sea-hold { to { transform:scale(1); } }
@keyframes sea-bob { 0%,100% { translate:0 0; } 50% { translate:0 -8%; } }
@keyframes sea-loop { 0% { transform:translateY(0) rotate(0); } 50% { transform:translateY(-14%) rotate(-180deg); } 100% { transform:translateY(0) rotate(-360deg); } }
@keyframes sea-turn-away { 0%,100% { transform:scaleX(1); } 30%,70% { transform:scaleX(-1); } }
@media(max-width:720px) {
  .sea-dive-speaker { width:56px; height:56px; }
  .sea-dive-footer .primary-button { margin-top:0; padding:6px 14px; }
  .sea-dive-footer { margin:6px auto; }
  .sea-dive-hint { font-size:15px; padding:6px 8px; }
  .sea-steer-cue { width:28px; height:28px; margin:-14px 0 0 -14px; }
  .sea-steer-cue svg { width:19px; height:19px; }
}
@media(prefers-reduced-motion:reduce) {
  .sea-sub.is-travelling, .sea-follower, .sea-steer-cue svg, .sea-hold-ring::after,
  .sea-dive-stage .sea-animal:is(.is-found, .is-refused) .sea-art { animation:none; }
  .sea-hold-ring::after { transform:scale(1); }
  .sea-bubbles { display:none; }
}

/* Every stage answers the pointer (AGENTS.md, docs/game-screen-layout.md). A map of
   areas lifts the hovered one like a world on the outer island; a scene grows the
   hovered object from where it stands, with the room's white halo. Hover needs a real
   mouse; a touch screen has no hover and would keep a tapped object raised, so it gets
   the press instead: at the touch, the object settles to 97% and lights up, within
   80ms. Only the artwork moves. The button is the hit area and stays put, or the
   pointer would slip off its bottom edge and the object would bounce. `translate` and
   `scale` are separate from `transform`, so they add to the anchor transforms and the
   greet, pet and leaf animations instead of replacing them. The state is set on the
   button as --stage-lift, --stage-grow and --stage-speed, and the artwork reads them.
   A new scene puts .scene-target on each tappable button and .scene-lift on its art. */
.scene-target, .animal-region-frame, .jungle-hide-slot {
  --stage-halo: drop-shadow(0 0 6px rgba(255, 255, 255, 1)) drop-shadow(0 0 14px rgba(255, 255, 255, .9));
  transition: filter var(--stage-speed, 180ms) ease;
}
.animal-region-frame { --stage-halo: drop-shadow(0 0 6px rgba(255, 255, 255, .95)) drop-shadow(0 16px 14px rgba(47, 35, 29, .22)); }
/* The press below replaces the browser's grey tap rectangle. */
.scene-target, .animal-region-frame, .animal-region-label, .jungle-hide-hit,
.world-node, .room-object { -webkit-tap-highlight-color: transparent; }
.scene-lift, .animal-region-frame > img, .jungle-hide-leaves, .jungle-hide-animal { scale: var(--stage-grow, 1); }
.animal-region-frame > :is(img, .animal-entry-icon) { translate: 0 var(--stage-lift, 0px); }
.scene-lift, .animal-region-frame > :is(img, .animal-entry-icon), .jungle-hide-leaves, .jungle-hide-animal {
  transition: translate var(--stage-speed, 180ms) ease, scale var(--stage-speed, 180ms) ease;
}
.animal-region-frame > img { transform-origin: 50% 90%; }
.jungle-hide-animal { transform-origin: var(--hide-anchor-x) var(--hide-anchor-y); }

/* An active game in a scene with many objects glows softly, so the child knows what to tap
   (Dana, November 30). The glow is on the artwork, so the white hover halo on the button
   still adds to it; scenery never carries it. A warm breath, never the hint's gold ring. */
.scene-glow .scene-lift { filter: drop-shadow(0 0 5px rgba(255, 248, 205, .95)) drop-shadow(0 0 14px rgba(255, 240, 160, .75)); animation: scene-glow 2.6s ease-in-out infinite; }
@keyframes scene-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 248, 205, .7)) drop-shadow(0 0 9px rgba(255, 240, 160, .4)); }
  50% { filter: drop-shadow(0 0 7px rgba(255, 248, 205, 1)) drop-shadow(0 0 18px rgba(255, 240, 160, .85)); }
}
@media (prefers-reduced-motion: reduce) { .scene-glow .scene-lift { animation: none; } }

/* Lit: keyboard focus everywhere, hover only with a mouse. */
.animal-region-frame:focus-visible { --stage-lift: -8px; --stage-grow: 1.03; filter: var(--stage-halo); }
.scene-target:enabled:focus-visible { --stage-grow: 1.08; filter: var(--stage-halo); }
.jungle-hide-slot:has(> .jungle-hide-hit:enabled:focus-visible) { --stage-grow: 1.08; }
@media (hover: hover) and (pointer: fine) {
  /* A region's name is its own button, layered above the region. Hovering the name
     counts as hovering the region, so crossing it does not drop the region back. */
  .animal-region-frame:hover,
  .animal-world-stage:has([data-region-tag="farm"] .animal-region-label:hover) [data-animal-region="farm"],
  .animal-world-stage:has([data-region-tag="jungle"] .animal-region-label:hover) [data-animal-region="jungle"],
  .animal-world-stage:has([data-region-tag="savanna"] .animal-region-label:hover) [data-animal-region="savanna"],
  .animal-world-stage:has([data-region-tag="sea"] .animal-region-label:hover) [data-animal-region="sea"] {
    --stage-lift: -8px; --stage-grow: 1.03; filter: var(--stage-halo);
  }
  .scene-target:enabled:hover { --stage-grow: 1.08; filter: var(--stage-halo); }
  .jungle-hide-slot:has(> .jungle-hide-hit:enabled:hover) { --stage-grow: 1.08; }
}

/* Pressed: every input, after the lit rules so it wins while hovered. Pressing a
   region's name presses the region. */
.animal-region-frame:active,
.animal-world-stage:has([data-region-tag="farm"] .animal-region-label:active) [data-animal-region="farm"],
.animal-world-stage:has([data-region-tag="jungle"] .animal-region-label:active) [data-animal-region="jungle"],
.animal-world-stage:has([data-region-tag="savanna"] .animal-region-label:active) [data-animal-region="savanna"],
.animal-world-stage:has([data-region-tag="sea"] .animal-region-label:active) [data-animal-region="sea"] {
  --stage-lift: 0px; --stage-grow: .97; --stage-speed: 80ms; filter: var(--stage-halo);
}
.scene-target:enabled:active { --stage-grow: .97; --stage-speed: 80ms; filter: var(--stage-halo); }
.jungle-hide-slot:has(> .jungle-hide-hit:enabled:active) { --stage-grow: .97; --stage-speed: 80ms; }

/* The bushes are answer choices. The halo is held back while a hint glows, so no
   other bush looks like the answer. */
.jungle-hide-stage:not(:has(.is-help)) .jungle-hide-slot:has(> .jungle-hide-hit:enabled:is(:focus-visible, :active)) { filter: var(--stage-halo); }
@media (hover: hover) and (pointer: fine) {
  .jungle-hide-stage:not(:has(.is-help)) .jungle-hide-slot:has(> .jungle-hide-hit:enabled:hover) { filter: var(--stage-halo); }
}
@media (prefers-reduced-motion: reduce) {
  .scene-lift, .animal-region-frame > :is(img, .animal-entry-icon), .jungle-hide-leaves, .jungle-hide-animal { translate: none !important; scale: none !important; }
}

/* Capy is tappable wherever he stands (app.js tapCapy): he dances and says his name.
   He answers the pointer like every stage target, and the dance moves the picture with
   `translate` and `rotate`, apart from the transforms that place, walk and bob him.
   `:where()` keeps these picture rules weaker than each scene's own sizing. */
button.capy-tap { padding: 0; border: 0; background: none; cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent; }
button.capy-tap.is-walking { pointer-events: none; cursor: default; }
/* At least 48px to tap, without growing the picture. */
button.capy-tap::before { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 48px); height: max(100%, 48px); transform: translate(-50%, -50%); }
:where(button.capy-tap) img { display: block; width: 100%; height: auto; transform-origin: 50% 100%; scale: var(--stage-grow, 1); transition: scale var(--stage-speed, 180ms) ease; }
.room-capy > img { height: 100%; object-fit: contain; }
button.capy-tap:focus-visible { --stage-grow: 1.08; outline: 3px solid #367f78; outline-offset: 2px; border-radius: 16px; }
@media (hover: hover) and (pointer: fine) {
  button.capy-tap:not(.is-walking):hover { --stage-grow: 1.08; filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 14px rgba(255, 255, 255, .9)); }
}
button.capy-tap:not(.is-walking):active { --stage-grow: .97; --stage-speed: 80ms; filter: drop-shadow(0 0 6px #fff) drop-shadow(0 0 14px rgba(255, 255, 255, .9)); }
@keyframes capy-dance {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  12% { translate: 0 -12%; rotate: -7deg; }
  25% { translate: 0 0; rotate: 0deg; }
  37% { translate: 0 -9%; rotate: 7deg; }
  50% { translate: 0 0; rotate: 0deg; }
  62% { translate: 0 -12%; rotate: -7deg; }
  75% { translate: 0 0; rotate: 0deg; }
  87% { translate: 0 -5%; rotate: 5deg; }
}
button.capy-tap.is-dancing img { animation: capy-dance 1.3s var(--dance-delay, 0ms) ease-in-out both; }
/* The big Capy at the side is a button too: it lies over his picture, in the same grid cell,
   so the picture stays where every layout rule sizes it. A tap makes him dance and say the
   instructions again. */
.capy-guide > .guide-capy-tap, .capy-guide > img, .sidebar-capy > .guide-capy-tap, .sidebar-capy > img { grid-row: 1; grid-column: 1; }
.guide-capy-tap { position: relative; z-index: 1; align-self: stretch; justify-self: stretch; min-width: 48px; min-height: 48px; margin: 0; padding: 0; border: 0; border-radius: 16px; background: transparent; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.guide-capy-tap .room-object-icon { display: none; }
.guide-capy-tap:focus-visible { outline: 3px solid #367f78; outline-offset: 2px; }
.capy-guide.is-dancing > img, .sidebar-capy.is-dancing > img { animation: capy-dance 1.3s var(--dance-delay, 0ms) ease-in-out both; }
@media (prefers-reduced-motion: reduce) { .capy-guide.is-dancing > img, .sidebar-capy.is-dancing > img { animation: none; } }
@media (prefers-reduced-motion: reduce) {
  button.capy-tap.is-dancing img { animation: none; }
  :where(button.capy-tap) img { scale: none; }
}

/* Parent account: one column on phones, no nested scrolling. */
.cloud-account { margin-block-end: 24px; display: grid; gap: 14px; min-width: 0; }
.cloud-account > *, .cloud-fields > *, .cloud-actions > * { min-width: 0; }
.cloud-account h2, .cloud-account p { margin: 0; }
.cloud-account label { display: grid; gap: 8px; }
.cloud-account input, .cloud-account select { box-sizing: border-box; width: 100%; min-width: 0; min-height: 48px; font: inherit; padding: 10px 12px; border: 2px solid #cbd7cd; border-radius: 12px; background: #fff; }
.cloud-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cloud-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.cloud-account button { min-height: 48px; }
.cloud-account bdi { overflow-wrap: anywhere; }
/* A guest's game: what moves at sign-up, and the reminder to keep this page open. */
.cloud-guest-move { display: grid; gap: 4px; padding: 12px 14px; border: 2px solid var(--teal-dark); border-radius: 14px; background: #dcefee; }
.cloud-guest-move p { margin: 0; }
.cloud-account .cloud-guest-keep-open { padding: 10px 12px; border-radius: 12px; background: var(--cream); line-height: 1.55; }
/* The signed-out card's steps: confirm the email, ask for a reset link, choose a new password. */
.cloud-account .cloud-step { margin: 0; font-size: 1.2rem; line-height: 1.35; color: var(--teal-dark); }
.cloud-account .cloud-steps { margin: 0; padding-inline-start: 1.4em; display: grid; gap: 6px; line-height: 1.5; }
.cloud-account .cloud-address { font-weight: 700; overflow-wrap: anywhere; text-align: start; }
.cloud-fields.is-single { grid-template-columns: minmax(0, 1fr); max-width: 420px; }
.parent-card .cloud-message { margin: 0; padding: 10px 12px; border-radius: 12px; background: #dcefee; color: var(--teal-dark); font-weight: 700; line-height: 1.5; }
.cloud-account .cloud-forgot { justify-self: start; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 4px; border: 0; background: none; color: var(--teal-dark); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.cloud-account .cloud-forgot svg { width: 22px; height: 22px; flex: 0 0 auto; }
.cloud-account .cloud-forgot:focus-visible { outline: 3px solid var(--teal-dark); outline-offset: 2px; border-radius: 10px; }
@media (max-width: 720px) {
  .cloud-fields { grid-template-columns: minmax(0, 1fr); }
  .cloud-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .cloud-account button { width: 100%; }
}

/* Capy's room games on a phone (Dana, November 28, 2026): the animal worlds' layout. A
   compact instruction line with a round replay speaker, the board edge to edge, no card
   around it. tools/e2e/tests/room-games-phone.spec.cjs holds the sizes. */
@media (max-width:720px) {
  .screen:has(.lesson-panel) { padding:0; }
  .lesson-shell:has(.lesson-panel) { padding:12px 0 0; gap:10px; }
  .lesson-shell:has(.lesson-panel) .lesson-head { padding-inline:14px; }
  .lesson-shell:has(.lesson-panel) .lesson-card { display:contents; }
  .lesson-shell:has(.lesson-panel) .capy-guide { width:calc(100% - 28px); margin-inline:14px; padding:2px; grid-template-columns:40px minmax(0,1fr); gap:6px; }
  .lesson-shell:has(.lesson-panel) .capy-guide > img { width:40px; height:56px; object-fit:contain; }
  .lesson-shell:has(.lesson-panel) .speech-bubble { display:grid; grid-template-columns:minmax(0,1fr) 48px; align-items:center; gap:8px; padding:6px 10px; }
  .lesson-shell:has(.lesson-panel) .speech-bubble > strong { display:none; }
  .lesson-shell:has(.lesson-panel) .speech-bubble p { margin:0; font-size:.85rem; }
  .lesson-shell:has(.lesson-panel) .replay-button { width:48px; height:48px; min-width:48px; padding:0; justify-content:center; }
  .lesson-shell:has(.lesson-panel) .replay-button span { display:none; }
  .lesson-shell:has(.lesson-panel) .lesson-main { width:100%; min-width:0; padding:0; }
  .lesson-shell:has(.lesson-panel) .learning-nav { margin:0 14px 16px; }
  .lesson-shell .lesson-panel { padding:4px 0 12px; border:0; border-radius:0; background:transparent; box-shadow:none; }

  /* Colours: the cropped palette across the screen, centred, with 15% wells (about 56px
     at 390, apart from each other). The big colour sample under it goes: the tapped
     colour's name sits in one short line instead. */
  .palette-lesson .palette-viewport { width:100%; margin:0; overflow:visible; direction:ltr; }
  .palette-lesson .paint-palette { width:100%; max-width:none; margin:0 auto; justify-self:center; }
  .palette-lesson .paint-palette .paint-well { left:var(--px) !important; top:var(--py) !important; width:15%; }
  .palette-lesson .palette-center { left:43.8%; top:50.7%; width:22%; }
  .palette-intro-panel { background:transparent; overflow:visible; }
  .palette-lesson { grid-template-columns:minmax(0,1fr); gap:8px; }
  .palette-lesson .intro-canvas { min-height:0; height:auto; margin:0 14px; padding:8px 12px; border-width:2px; }
  .palette-lesson .intro-canvas-paper { display:none; }
  .palette-lesson .intro-canvas strong { display:flex; align-items:center; justify-content:center; gap:10px; margin:0; font-size:1.1rem; }
  .palette-lesson .intro-canvas:not(.is-waiting) strong::before { content:""; width:28px; height:28px; border:2px solid var(--line); border-radius:50%; background:var(--active-paint); flex:none; }
}

@media (max-width:720px) {
  /* Building on a phone: the toy across the screen, a tall speaker, chunky blocks. */
  .lesson-shell .build-panel { padding:4px 0 12px; gap:10px; background:transparent; }
  .lesson-shell .build-scene { height:auto; aspect-ratio:360 / 250; border-radius:0; border-inline:0; }
  .lesson-shell .build-scene > .build-art { width:100%; height:100%; }
  .lesson-shell .build-ask { padding-inline:14px; }
  .lesson-shell .build-panel .block-speaker { width:100%; height:60px; }
  /* One row of up to four blocks, so the answer stays above the fold (CORE-11). */
  .lesson-shell .build-panel .block-tray { width:100%; display:flex; justify-content:center; gap:8px; padding:8px; }
  .lesson-shell .build-panel .tray-block { flex:1 1 0; max-width:110px; width:auto; height:72px; min-height:72px; padding:6px; }
  .lesson-shell .build-footer { padding-inline:14px; }
}

@media (max-width:720px) {
  /* Quilt and window on a phone: a taller speaker; the window's shapes get a 56px tap
     area around them (the picture stays as drawn; the hit box grows, centred). */
  .lesson-shell .shape-ask { padding-inline:14px; }
  .lesson-shell .shape-ask .block-speaker { height:60px; }
  .lesson-shell .quilt-panel .patch-tray { margin-inline:14px; }
  .lesson-shell .window-object { min-width:56px; min-height:56px; }
  .lesson-shell .window-controls { padding-inline:14px; }
}
@media (max-width:720px) {
  /* Painting on a phone is one column (Dana, December 2, 2026: the free drawing / colouring page
     choice goes back above the paper, "הלייאוט של הכפתורים לא נראה טוב בטלפון, לא מסודר
     מספיק"): the choice, the paper, the colours, the paper's tools, the save row. Every row
     stands between the same two 12px margins and its buttons fill it; every button has the
     same height and corner. The paper takes the margins too (12px keeps it nearly edge to edge,
     ROOMPHONE), which also keeps the colours on the first screen of a 430px phone once the
     choice sits above (STUDIO-PHONE-01, -09). The studio-side wrapper is display:contents, so its own padding never reached the colours or
     the save row: the margins are on the rows themselves. */
  .lesson-shell .studio-panel { gap:10px; }
  .lesson-shell .studio-panel > .art-modes { order:-2; }
  .lesson-shell .studio-panel > .paint-studio { order:-1; }
  .lesson-shell .studio-panel > .art-modes,
  .lesson-shell .studio-panel > .action-row,
  .lesson-shell .studio-panel .paint-viewport,
  .lesson-shell .studio-panel .palette-viewport,
  .lesson-shell .studio-panel .paint-zoom-tools,
  .lesson-shell .studio-panel .studio-tools { width:auto; align-self:stretch; margin-inline:12px; padding-inline:0; box-sizing:border-box; }
  .lesson-shell .studio-panel .paint-zoom-tools { margin-top:4px; }
  .lesson-shell .studio-panel :is(.art-modes, .paint-zoom-tools, .studio-tools) button { min-height:48px; border-radius:12px; }
  .lesson-shell .studio-panel .paint-zoom-tools .icon-button { width:auto; height:auto; padding:0; justify-content:center; }   /* the magnifier in the middle (STUDIO-PHONE-11) */
  /* The palette picture has its own transparent background since v2 (December 1, 2026): blended
     over the page, its not-quite-white paper showed as a pale box around the palette. */
  .lesson-shell .studio-panel .paint-palette .paint-well { height:56px; }
}
@media (max-width:350px) {
  /* A small phone: narrower margins and a tighter colour grid keep every colour 56px wide. */
  .lesson-shell .studio-panel > .art-modes,
  .lesson-shell .studio-panel > .action-row,
  .lesson-shell .studio-panel .paint-viewport,
  .lesson-shell .studio-panel .palette-viewport,
  .lesson-shell .studio-panel .paint-zoom-tools,
  .lesson-shell .studio-panel .studio-tools { margin-inline:8px; }
  .lesson-shell .studio-panel .paint-palette { padding:3px; gap:4px; }
}


/* The island's welcome, in a small speech bubble under Capy in the sidebar. */
.sidebar-capy-says { margin:8px 0 0; padding:6px 10px; border:2px solid var(--line); border-radius:14px; background:#fffdf6; color:var(--ink); font-size:.95rem; line-height:1.4; text-align:center; }
@media (max-width:720px) {
  .sidebar-capy { grid-template-columns:clamp(80px,24vw,100px) minmax(0,1fr); gap:8px; align-items:center; }
  .sidebar-capy img { width:clamp(80px,24vw,100px); height:clamp(104px,32vw,130px); object-fit:contain; object-position:center bottom; }
  .sidebar-capy-says { margin:0; font-size:.88rem; }
}

/* Every place says what it is, in one short line under its title (Dana, November 28, 2026). */
.place-intro { margin:4px 0 10px; color:var(--ink-soft); font-size:1rem; line-height:1.45; text-align:center; flex-basis:100%; }

/* The shop's one-line explanation sits under the title, across the whole head. */
.shop-head { flex-wrap:wrap; }
.shop-head > .place-intro { order:3; flex:1 1 100%; margin:2px 0 0; }

@media (max-width:720px) {
  /* The sticker album on a phone (Dana, November 28, 2026: it looked terrible): the stickers
     come first, wrapping in rows right under the instruction (no sideways scrolling); then the pages,
     less tall. Positions are kept in percent of the page, so nothing moves on the artwork. */
  .view-frame:has(> .album-book) > .album-hint,
  .modal-body:has(> .album-book) > .album-hint { order:0; margin:0; }
  .view-frame:has(> .album-book), .modal-body:has(> .album-book) { display:flex; flex-direction:column; gap:12px; }
  .view-frame:has(> .album-book) > .album-tray,
  .modal-body:has(> .album-book) > .album-tray { order:1; flex-wrap:wrap; justify-content:center; margin:0; padding:8px; gap:8px; min-height:0; width:100%; box-sizing:border-box; }
  .album-tray > .tray-sticker { flex:0 0 auto; min-width:72px; min-height:72px; }
  .album-tray > .tray-empty { margin:0; text-align:center; width:100%; }
  .view-frame:has(> .album-book) > .album-book,
  .modal-body:has(> .album-book) > .album-book { order:2; width:100%; }
  .album-page { aspect-ratio:4 / 3; }
  .album-sticker { width:14%; min-width:44px; }
  .view-frame:has(> .album-book) > :not(.album-hint, .album-tray, .album-book, .shop-head),
  .modal-body:has(> .album-book) > :not(.album-hint, .album-tray, .album-book) { order:3; }
}
.shop-head.is-centered > .place-intro { grid-column:1 / -1; grid-row:2; text-align:center; }
/* The way back to the island on the shops, the album and the songs (Dana, December 2, 2026):
   the room's button in the room's place. On a desktop it stands in the head's first column,
   as in .view-title.is-centered; on a phone it is the room's round arrow at the same edge,
   with an equal empty column on the other side so the title stays centred (SHOPBACK-01). */
.shop-head.is-centered > .ghost-button { grid-column:1; grid-row:1; justify-self:start; }
/* Every way back shows where it goes (backButton() in app.js; a playtest on December 2, 2026: a
   child in a room game could not find the way back to the room). A desktop and a tablet show
   the arrow, the place's picture and its name, 52px high. On a phone it stays the 48px round
   button it was, so the head keeps its height to the pixel (the studio's last colour sat 2px
   above the fold at 430px): the place's picture fills it and the arrow sits on its corner as a
   badge, and the gaps beside the title shrink from 8px to 4px so the badge has room. The name
   stays for screen readers (BACKPIC-01). */
.ghost-button.back-button { min-height:52px; padding:2px 16px 2px 10px; gap:4px; }
.ghost-button.back-button > svg { width:26px; height:26px; }
.back-button > .back-place { display:inline-flex; }
.back-button > .back-place svg { width:32px; height:32px; }
@media (max-width:720px) {
  .ghost-button.back-button { position:relative; width:48px; min-width:48px; height:48px; min-height:48px; padding:0; justify-content:center; border-radius:50%; }
  .ghost-button.back-button > .back-place svg { width:32px; height:32px; }
  .ghost-button.back-button > svg { position:absolute; inset-block-end:-4px; inset-inline-start:-3px; width:20px; height:20px; }
  .ghost-button.back-button > .back-label { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
}
/* The songs screen centres its column, and its head would shrink to the title. */
.songs-view > .shop-head { align-self:stretch; }
@media (max-width:720px) {
  .shop-head.is-centered:has(> .ghost-button) { display:grid; grid-template-columns:48px minmax(0, 1fr) 48px; gap:6px 4px; align-items:center; }
  .shop-head.is-centered:has(> .ghost-button) > h1 { grid-column:2; grid-row:1; min-width:0; text-align:center; }
  .shop-head.is-centered > .ghost-button { grid-column:3; grid-row:1; justify-self:end; }
  .shop-head.is-centered:has(> .ghost-button) > .coin-balance { grid-column:1 / -1; grid-row:2; justify-self:center; }
  .shop-head.is-centered:has(> .ghost-button) > .place-intro { grid-column:1 / -1; grid-row:3; width:100%; }
}
@media (max-width:720px) {
  .modal-card.is-wide:has(.album-book) { width:calc(100vw - 24px); max-width:calc(100vw - 24px); box-sizing:border-box; }
  .modal-body:has(> .album-book), .modal-body:has(> .album-book) > * { min-width:0; max-width:100%; }
}

/* The memory board on the sea-floor picture (Dana approved it November 28): exactly --cols
   shells per row, centred, lying on the sand. The picture is drawn a little larger from its
   bottom edge so the sand is deep enough for two or three rows. */
.sea-memory-stage .sea-background { transform:scale(1.45); transform-origin:50% 100%; }
.sea-memory-board { --shell:min(14cqw,140px); left:0; right:0; bottom:2%; margin-inline:auto; max-width:94%;
  width:calc(var(--cols) * var(--shell) + (var(--cols) - 1) * var(--gap)); }
.sea-memory-board > .sea-shell { flex:0 0 min(var(--shell), calc((100% - (var(--cols) - 1) * var(--gap)) / var(--cols))); min-width:0; }
@media (max-width:720px) {
  /* Dana, November 29: the shells were too small on a phone (72px). The picture is drawn larger
     from its bottom edge, as on a desktop, so the sand holds three rows of 86px shells; three
     pairs get 104px. */
  .sea-memory-stage .sea-background { transform:scale(1.45); }
  .sea-memory-board { --shell:min(104px, 27cqw); left:0; right:0; bottom:2%; max-width:96%; }
  .sea-memory-board[style*="--cols:4"] { --shell:min(86px, 22.5cqw); }
}
@media (max-width:720px) {
  /* The memory game gets the practice screens' compact instruction: text and a round speaker. */
  .lesson-shell:has(.sea-memory-panel) { gap:8px; }
  .lesson-shell:has(.sea-memory-panel) .capy-guide { padding:2px; }
  .lesson-shell:has(.sea-memory-panel) .speech-bubble { display:grid; grid-template-columns:minmax(0,1fr) 48px; align-items:center; gap:8px; }
  .lesson-shell:has(.sea-memory-panel) .speech-bubble p { margin:0; }
  .lesson-shell:has(.sea-memory-panel) .replay-button { width:48px; height:48px; min-width:48px; padding:0; justify-content:center; }
  .lesson-shell:has(.sea-memory-panel) .replay-button span { display:none; }
}

/* ---- Capy's songs (songs.js, November 29, 2026) ---- */
/* A fourth button in the top bar. On a phone the nav row becomes four equal quarters;
   the labels are short enough, and the icon sits above the label so each quarter keeps
   a 48px target without squeezing the text. */
@media (max-width: 720px) {
  .main-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .main-nav button { flex-direction: column; gap: 0; padding: 4px 2px; font-size: 0.78rem; line-height: 1.1; }
  .main-nav button svg { width: 1.7em; height: 1.7em; }
}
/* At 320px "הַחֶדֶר שֶׁל קָפִּי" wraps to two lines; a smaller icon and type keep the bar
   from pushing the game boards below it down. */
@media (max-width: 360px) {
  .main-nav { gap: 4px; }
  .main-nav button { padding: 2px 1px; font-size: 0.72rem; line-height: 1.05; }
  .main-nav button svg { width: 1.45em; height: 1.45em; }
}
.songs-view { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.song-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 18px;
  width: 100%; max-width: 980px;
}
.song-card {
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  flex: 0 1 calc((100% - 36px) / 3); min-width: 0;
  padding: 10px; border: 3px solid var(--line); border-radius: 20px;
  background: #fff; color: var(--ink); cursor: pointer;
  box-shadow: 0 6px 0 rgba(75, 50, 40, 0.12);
  transition: transform 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.song-card img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; background: #e9f4f1; }
/* Bold like the title (700). At 800 the browser drew Rubik's heaviest cut, 900, and the
   letters and their dots crowded into each other (Dana, November 30, 2026). */
.song-name { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; font-size: 1.15rem; font-weight: 700; }
.song-name svg { width: 1.6em; height: 1.6em; flex: none; }
/* "More songs soon": the size of a song card, drawn as an empty place waiting for one. */
.song-soon { display: flex; flex-direction: column; gap: 8px; align-items: stretch; flex: 0 1 calc((100% - 36px) / 3); min-width: 0; padding: 10px; border: 3px dashed #b9a893; border-radius: 20px; background: rgba(255, 255, 255, 0.55); color: var(--ink-soft); }
.song-soon-art { display: flex; align-items: center; justify-content: center; gap: 8%; aspect-ratio: 16 / 9; border-radius: 12px; background: #e9f4f1; }
.song-soon-art svg { width: 18%; height: auto; }
.song-soon-art svg:nth-child(1) { transform: translateY(12%) rotate(-10deg); opacity: .55; }
.song-soon-art svg:nth-child(2) { width: 24%; transform: translateY(-8%); }
.song-soon-art svg:nth-child(3) { transform: translateY(14%) rotate(10deg); opacity: .55; }
@media (hover: hover) and (pointer: fine) {
  .song-card:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 10px 0 rgba(75, 50, 40, 0.13), 0 0 0 6px rgba(255, 255, 255, 0.9); }
}
.song-card:focus-visible { outline: none; box-shadow: 0 6px 0 rgba(75, 50, 40, 0.12), 0 0 0 5px #2f83e6; }
.song-card:active { transform: scale(0.97); transition-duration: 80ms; }
@media (max-width: 720px) {
  .song-grid { gap: 12px; }
  .song-card, .song-soon { flex-basis: calc((100% - 12px) / 2); padding: 7px; border-radius: 16px; }
  .song-name { font-size: 1rem; min-height: 36px; }
}

/* The player: the video is the whole card. Wide on a computer, the tall Shorts cut on a
   phone held upright, both sized to the window so the controls never fall below it. */
.modal-card.song-player { width: auto; max-width: 96vw; max-height: 96vh; padding: 18px; gap: 10px; align-items: center; }
.song-player h2 { text-align: center; }
.song-player .modal-body { overflow: hidden; display: flex; justify-content: center; }
.song-video { display: block; border-radius: 14px; background: #1d2b2a; }
/* The window minus the backdrop's 20px sides and the card's padding and border. */
.song-video.is-wide { width: min(calc(100vw - 90px), 1100px, calc((96vh - 120px) * 16 / 9)); aspect-ratio: 16 / 9; }
.song-video.is-tall { height: min(calc(100dvh - 130px), calc((100vw - 76px) * 16 / 9)); aspect-ratio: 9 / 16; }
.song-failed { margin: 20px 10px; font-size: 1.15rem; text-align: center; }
@media (max-width: 720px) {
  .modal-card.song-player { padding: 12px; border-radius: 20px; }
  .song-player .modal-close { top: 6px; inset-inline-start: 6px; }
}

/* ---- Capy beside his bubble on a phone (Dana, November 29, 2026: "on the phone Capy is
   too small") ---- */
/* Screen by screen the phone guide had shrunk Capy to 40-52px to save height, which read
   as a speck next to a wide bubble. One shared size for every game and hub: about the
   height of a two-line bubble, so the row barely grows. !important because each screen
   set its own size with :has() selectors of several classes; this rule replaces them all. */
@media (max-width: 720px) {
  .lesson-shell .capy-guide { grid-template-columns: clamp(80px, 24vw, 100px) minmax(0, 1fr) !important; gap: 6px !important; align-items: end !important; }
  .lesson-shell .capy-guide > img { width: clamp(80px, 24vw, 100px) !important; height: clamp(104px, 32vw, 130px) !important; object-fit: contain; object-position: center bottom; }
  .lesson-shell .capy-guide > .speech-bubble { align-self: center; }
}
/* The narrowest phones (320px) give back 4px, so the building tray stays above a 740px fold. */
@media (max-width: 360px) {
  .lesson-shell .capy-guide > img { height: 100px !important; }
}
/* Capy's room, the numbers jungle, the jungle introduction and the full-screen practice boards (the dive, hide-and-seek, the mud bath, feeding, the memory
   board) end with their Finish button at the bottom of the phone, so Capy is medium there. */
@media (max-width: 720px) {
  .lesson-shell:has(:is(.room-hub,.numbers-panel,.jungle-panel,.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.sea-memory-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .capy-guide { grid-template-columns: 60px minmax(0, 1fr) !important; }
  .lesson-shell:has(:is(.room-hub,.numbers-panel,.jungle-panel,.jungle-hide-panel,.savanna-wash-panel,.sea-dive-panel,.sea-memory-panel,.farm-puzzle-panel,.farm-stage.is-feeding)) .capy-guide > img { width: 60px !important; height: 74px !important; }
}
/* Even line breaks in every bubble, so a word is never left alone on the last line
   ("לָלֶכֶת." under two full lines read as a broken bubble). */
.speech-bubble p, .sidebar-capy-says { text-wrap: balance; }

/* ---- Area titles centred on a phone (Dana, November 29, 2026) ---- */
/* The back button's label took half the row, so a title could not sit in the middle.
   On a phone it becomes a round arrow button (the label stays for screen readers), with
   an equal empty column on the other side so the title is centred on the screen. In RTL
   column 1 is the right edge, column 3 the left, where the back button always sat. */
@media (max-width: 720px) {
  .view-title.is-centered.lesson-head { grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 4px; }
  .view-title.is-centered.lesson-head > div { grid-column: 2; grid-row: 1; min-width: 0; text-align: center; }
  .view-title.is-centered.lesson-head h1 { text-align: center; }
  .view-title.is-centered.lesson-head .ghost-button { grid-column: 3; grid-row: 1; justify-self: end; }
  .shop-head.is-centered { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
  .shop-head.is-centered h1 { flex: none; text-align: center; }
  .shop-head.is-centered > * { max-width: 100%; }
  .shop-head.is-centered > .place-intro { flex: none; width: 100%; }
}

/* The numbers jungle (world-numbers.js): the opening scene and the numbers game.
   Placement is anchored like the sea's: left/top is the anchor point, translate pulls the box
   back by its anchor. Hover and press come from .scene-target / .scene-lift. */
/* A short desktop screen (a laptop 768 high): every game board gives up size alike, so the
   whole picture, the stars under it and the finish button fit without scrolling. 286px is
   what stands above and below the board; on a screen 900 high nothing changes. Only where
   the board stands beside Capy (above 1080px): stacked in one column, on a tablet or a phone,
   the page scrolls by design and the board's size follows the width. */
@media (min-width: 1081px) {
  :is(.farm-stage, .jungle-stage, .jungle-hide-stage, .savanna-stage, .sea-stage, .numbers-stage) { max-width: max(540px, calc((100dvh - 286px) * 1.5)); margin-inline: auto; }
}
.numbers-panel { min-width:0; }
.numbers-stage { position:relative; width:100%; min-width:0; aspect-ratio:3 / 2; overflow:hidden; isolation:isolate; border-radius:22px; container-type:inline-size; }
.numbers-background { display:block; width:100%; height:auto; }
.numbers-tree, .numbers-dock, .numbers-capy { position:absolute; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); }
.numbers-dock { z-index:1; display:block; min-width:48px; min-height:48px; padding:0; border:0; background:transparent; cursor:pointer; touch-action:manipulation; }
.numbers-dock > img { display:block; width:100%; height:auto; transform-origin:50% 60%; pointer-events:none; }
.numbers-dock.is-refused .scene-lift { animation:numbers-wobble .5s var(--react, 0ms) ease-in-out both; }
.numbers-dock .world-lock { position:absolute; left:50%; top:38%; width:clamp(30px,22%,56px); translate:-50% -50%; pointer-events:none; }
.numbers-dock .world-lock img { display:block; width:100%; height:auto; }
.world-games-nav .step-pill .world-lock { width:26px; margin-inline-start:auto; }
.world-games-nav .step-pill .world-lock img { display:block; width:100%; height:auto; }
/* The boats: three lanes on the river, sailing right to left by a CSS animation whose negative
   delay is how long they have sailed, so a redraw continues each boat where it was. A boat is
   a button: only its artwork lifts on hover, and the hint is the gold ring, never the halo. */
.river-boat { position:absolute; z-index:3; left:calc(100% + var(--half)); display:block; min-width:72px; min-height:48px; padding:0; border:0; background:transparent; cursor:pointer; touch-action:manipulation; translate:-50% -100%;
  animation:boat-sail var(--cross) linear var(--at) infinite; animation-play-state:var(--sailing, paused); }
@keyframes boat-sail { from { left:calc(100% + var(--half)); } to { left:calc(0% - var(--half)); } }
.river-boat:disabled { cursor:default; opacity:1; filter:none; }   /* a stopped boat is still a boat, not a greyed control */
.boat-art { position:relative; display:block; transform-origin:50% 100%; animation:boat-bob 2.8s ease-in-out infinite; animation-play-state:var(--sailing, paused); }   /* a waiting boat lies still */
@keyframes boat-bob { 0%,100% { translate:0 0; rotate:-1.2deg; } 50% { translate:0 -3%; rotate:1.2deg; } }
.boat-hull { position:relative; display:block; width:100%; height:auto; pointer-events:none; }
.boat-load { position:absolute; inset:0; z-index:1; pointer-events:none; }
.boat-fruit { position:absolute; height:auto; translate:-50% 0; filter:drop-shadow(0 2px 2px #0003); }
.river-boat.is-help .boat-art { filter:drop-shadow(0 0 0 #0000) drop-shadow(0 0 6px #f6d36b) drop-shadow(0 0 12px #e3a92b); }
.river-boat.is-refused .boat-art { animation:numbers-wobble .5s var(--react, 0ms) ease-in-out both; }
.river-boat.is-found .boat-art { animation:numbers-bounce .7s ease-out both; }
.river-boat:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:16px; }
.flying-coconut.is-from-boat { animation-name:boats-fly; }
@keyframes boats-fly { from { left:var(--from-x); top:var(--from-y); } 55% { top:calc(var(--from-y) - 12%); } to { left:var(--to-x); top:var(--to-y); } }
.boats-cue { position:absolute; z-index:4; top:4%; inset-inline-start:calc(3% + clamp(52px,9cqw,76px) + 8px); width:clamp(44px,8cqw,68px); pointer-events:none; }
.boats-cue svg { display:block; width:100%; height:auto; overflow:visible; }
@media (prefers-reduced-motion: reduce) { .boat-art, .river-boat.is-refused .boat-art, .river-boat.is-found .boat-art { animation:none; } }
/* Catching in the basket: a lane is a tall button with its leaf falling inside it by a CSS
   animation whose delay is how long the leaves have fallen. Only the leaf lifts on hover; the
   hint is the gold ring, never the halo. The basket slides from where it stood. */
.numbers-catch-stage { touch-action:pan-y; }
/* The board has the animal games' shape on a phone (4:5); its near-square picture fills it, losing only jungle at the sides. */
.numbers-catch-stage > picture { position:absolute; inset:0; }
.numbers-catch-stage .numbers-background { width:100%; height:100%; object-fit:cover; }
.catch-lane { position:absolute; z-index:3; top:0; bottom:0; min-width:48px; padding:0; border:0; background:transparent; cursor:pointer; touch-action:pan-y; translate:-50% 0; -webkit-tap-highlight-color:transparent; }
.catch-lane:disabled { cursor:default; opacity:1; filter:none; }
.catch-lane:focus-visible { outline:3px solid #367f78; outline-offset:-3px; border-radius:16px; }
.catch-fall { position:absolute; left:0; width:100%; top:-22%; translate:0 -50%; animation:catch-fall var(--fall) linear var(--at) infinite backwards; animation-play-state:var(--falling, paused); pointer-events:none; }
@keyframes catch-fall { from { top:-22%; opacity:1; } 84% { opacity:1; } 96% { opacity:0; } to { top:104%; opacity:0; } }   /* an uncaught leaf melts into the grass */
.catch-leaf { position:relative; display:block; transform-origin:50% 50%; animation:catch-sway 3.2s ease-in-out infinite; animation-play-state:var(--falling, paused); }
@keyframes catch-sway { 0%,100% { translate:-7% 0; rotate:-4deg; } 50% { translate:7% 0; rotate:4deg; } }
.catch-leaf-img { display:block; width:100%; height:auto; filter:drop-shadow(0 3px 3px #0002); }
.catch-digit { position:absolute; left:50%; top:46%; width:38%; height:auto; translate:-50% -50%; overflow:visible; filter:drop-shadow(0 2px 2px #0003); }
.catch-lane.is-help .catch-leaf { filter:drop-shadow(0 0 0 #0000) drop-shadow(0 0 6px #f6d36b) drop-shadow(0 0 12px #e3a92b); }
.catch-lane.is-refused .catch-leaf { animation:catch-hop .5s var(--react, 0ms) ease-out both; }
@keyframes catch-hop { 0%,100% { translate:0 0; rotate:0deg; } 35% { translate:0 -38%; rotate:-10deg; } 70% { translate:0 -8%; rotate:8deg; } }
.catch-lane.is-found .catch-leaf { animation:catch-drop .6s ease-in both; }
@keyframes catch-drop { from { scale:1; translate:0 0; opacity:1; } to { scale:.35; translate:0 60%; opacity:0; } }
.catch-basket { position:absolute; z-index:4; translate:-50% -100%; pointer-events:none; animation:catch-slide .26s var(--slid, 0ms) ease-out both; }
@keyframes catch-slide { from { margin-left:var(--slide); } to { margin-left:0; } }
.catch-basket.is-glad { animation:numbers-bounce .7s ease-out both; }
.catch-basket-back { display:block; width:100%; height:auto; }
.catch-basket-front { position:absolute; inset:0; width:100%; height:100%; }
.catch-piled { position:absolute; width:62%; translate:-50% 0; }
.catch-piled .catch-leaf-img { filter:none; }
.catch-garland { position:absolute; inset:0; z-index:2; pointer-events:none; }
.catch-garland::before { content:""; position:absolute; left:4%; right:4%; top:3%; height:9%; border-bottom:3px solid #8a6a4a; border-radius:0 0 50% 50% / 0 0 100% 100%; opacity:.8; }
.catch-hung { position:absolute; width:13%; transform-origin:50% 0; animation:catch-hang .5s ease-out both; }
@keyframes catch-hang { from { opacity:0; translate:0 -30%; } to { opacity:1; translate:0 0; } }
.catch-cue { aspect-ratio:1; border-radius:14px; background:#fffaf0; border:2px solid #5b4636; box-sizing:border-box; }
.numbers-catch { position:absolute; z-index:2; display:block; min-width:48px; min-height:48px; padding:0; border:0; background:transparent; cursor:pointer; touch-action:manipulation; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); }
.catch-prop { position:relative; display:block; padding-top:34%; transform-origin:50% 100%; pointer-events:none; }
.catch-prop-leaf { position:absolute; left:6%; top:0; width:88%; rotate:-6deg; }
.catch-prop-basket { display:block; width:100%; height:auto; }
.numbers-catch.is-refused .scene-lift { animation:numbers-wobble .5s var(--react, 0ms) ease-in-out both; }
.numbers-catch .world-lock { position:absolute; left:50%; top:62%; width:clamp(30px,34%,56px); translate:-50% -50%; pointer-events:none; }
.numbers-catch .world-lock img { display:block; width:100%; height:auto; }
@media (prefers-reduced-motion: reduce) { .catch-leaf, .catch-lane.is-refused .catch-leaf, .catch-lane.is-found .catch-leaf, .catch-basket, .catch-basket.is-glad, .catch-hung { animation:none; } }
.numbers-tree { z-index:2; display:block; min-width:48px; min-height:48px; padding:0; border:0; background:transparent; cursor:pointer; touch-action:manipulation; }
.numbers-tree > img { display:block; width:100%; height:auto; transform-origin:50% 100%; pointer-events:none; }
.numbers-capy { z-index:3; min-width:48px; min-height:48px; padding:0; border:0; background:transparent; }
.numbers-capy img { display:block; width:100%; height:auto; transform-origin:50% 100%; }
/* The counting board's tree and basket, cut out of its picture and placed exactly where it painted
   them (tools/cut-count-tree.py); the background is the plate, the picture with the tree filled
   in, so the tree can grow on hover with nothing behind it. The coconuts sit inside the tree's
   art and grow with it. */
.count-tree, .count-basket { position:absolute; transform:translate(calc(-1 * var(--anchor-x)),calc(-1 * var(--anchor-y))); }
.count-tree { z-index:2; display:block; padding:0; border:0; background:transparent; touch-action:manipulation; }
button.count-tree { cursor:pointer; }
.count-tree-art { position:relative; display:block; }
.count-tree-img { display:block; width:100%; height:auto; pointer-events:none; }
.count-basket { z-index:3; height:auto; pointer-events:none; }
/* Practice: the basket's front wall is drawn once more over the collected coconuts, cut along
   the inside of its rim, so they sit in the basket and not on it (Dana, November 30). */
.count-basket-front { z-index:5; clip-path:polygon(0.0% 23.3%,10.1% 26.4%,20.2% 31.8%,34.4% 36.4%,49.8% 38.8%,64.8% 36.4%,79.8% 31.8%,89.9% 26.4%,100.0% 23.3%,100.0% 100.0%,0.0% 100.0%); }
.count-basket-front.is-phone { clip-path:polygon(0.0% 24.7%,8.6% 28.4%,21.4% 33.3%,35.0% 37.0%,49.8% 38.3%,64.6% 37.0%,78.6% 33.3%,91.4% 28.4%,100.0% 24.7%,100.0% 100.0%,0.0% 100.0%); }
/* Introduction: one coconut per counted number. */
.tree-coconut { position:absolute; width:clamp(40px,6.5cqw,80px); height:auto; transform:translate(-50%,-50%); animation:numbers-pop .45s var(--pop) cubic-bezier(.3,1.6,.6,1) both; filter:drop-shadow(0 2px 2px #0002); }
.count-tree:focus-visible, .number-face:focus-visible, .numbers-tree:focus-visible, .number-choice:focus-visible { outline:3px solid #367f78; outline-offset:2px; border-radius:16px; }
/* Practice: each card is its coconuts with a small number with eyes in the top corner on the
   right (Dana, November 29), under the picture. The hint is a warm gold ring, never the white
   hover halo, so hovering never looks like help. */
.number-choices { display:flex; justify-content:center; gap:10px; margin:10px auto 0; min-width:0; }
.number-choice { position:relative; flex:1 1 0; max-width:170px; min-width:48px; min-height:48px; aspect-ratio:1.2; padding:0; border:2px solid #e2d5c3; border-radius:18px; background:#fff9ec; cursor:pointer; touch-action:manipulation; box-shadow:0 4px 0 rgba(75,50,40,.12); }
.number-choice:disabled { cursor:default; }
/* Desktop: the cards stand in a column on the right side of the picture, under the speaker and
   clear of Capy and the basket, so a full-size picture and its answers fit one screen. */
.numbers-stage > .number-choices { position:absolute; z-index:5; right:2%; top:17%; bottom:3%; width:17%; margin:0; flex-direction:column; justify-content:center; gap:1.33cqw; }
.numbers-stage > .number-choices .number-choice { flex:0 0 auto; width:100%; max-width:none; }
.choice-art { position:absolute; inset:0; display:block; transform-origin:50% 100%; pointer-events:none; }
.choice-nuts { position:absolute; left:8%; right:8%; top:26%; bottom:5%; }
.choice-coconut { position:absolute; height:auto; transform:translate(-50%,-50%); pointer-events:none; }
.choice-face { position:absolute; top:3%; right:3%; width:22%; height:auto; overflow:visible; }
.number-choice.is-found .choice-nuts { animation:choice-nuts-leave .25s var(--react) ease-in both; }
@keyframes choice-nuts-leave { to { opacity:0; scale:.85; } }
/* The right answer's coconuts fly from above its card into Capy's basket, and stay there. */
.basket-coconut, .flying-coconut { position:absolute; z-index:4; height:auto; transform:translate(-50%,-50%); pointer-events:none; filter:drop-shadow(0 2px 2px #0002); }
.flying-coconut { z-index:6; animation:numbers-fly .7s var(--fly, 0ms) cubic-bezier(.3,.7,.4,1) both; }
@keyframes numbers-fly { from { left:var(--from-x); top:var(--from-y, 104%); } 60% { top:calc(var(--to-y) - 14%); } to { left:var(--to-x); top:var(--to-y); } }
.number-choice.is-help { border-color:#e3a92b; box-shadow:0 0 0 4px #f6d36b, 0 4px 0 rgba(75,50,40,.12); }
.number-choice.is-found { border-color:#5aa86b; background:#eef8ef; animation:numbers-bounce .7s var(--react) ease-out both; }
.number-choice.is-refused { animation:numbers-wobble .5s var(--react) ease-in-out both; }
/* The speaker stands out on the jungle picture (Dana, December 2, 2026: "יותר בולט"): bigger, and
   warm yellow, the colour of the main buttons, instead of white against the sky. */
.numbers-speaker { position:absolute; z-index:4; top:4%; inset-inline-start:3%; width:clamp(64px,12cqw,96px); height:clamp(64px,12cqw,96px); background:#f3c73f; border-width:3px; box-shadow:0 5px 0 rgba(75,50,40,.22), 0 0 0 5px rgba(255,248,220,.75); }
.numbers-speaker:disabled { background:#f6e3a6; }
.numbers-speaker svg { width:56%; height:56%; }
/* Desktop: the picture is only as tall as the screen allows, so the numbers and the answer cards
   under it stay in view without scrolling (a 1280x900 window cut the groups off; the cards with
   their corner digit are 22px taller than the old groups). */
/* Every numbers game is as wide as the animal island's games on desktop (Dana, December 1, 2026).
   The tree game used to give up width to keep its cards on a short screen; she chose one size. */

.numbers-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:10px; margin:10px auto 0; min-width:0; }
.numbers-footer .primary-button { min-height:48px; display:flex; align-items:center; gap:8px; }
/* After the count the numbers are the controls, so they sit in a row under the picture, not on
   it (on it, they covered Capy's grass): one row of ten, two rows of five on a phone. */
.number-face-row { direction:ltr; display:grid; grid-template-columns:repeat(10, minmax(0, 1fr)); gap:6px; width:min(100%, 860px); margin:10px auto 0; min-width:0; }
.number-face { position:relative; min-width:48px; min-height:48px; aspect-ratio:1; padding:0; border:0; background:transparent; cursor:pointer; touch-action:manipulation; }
.number-face .scene-lift { display:block; width:100%; height:100%; transform-origin:50% 100%; }
.number-face svg, .count-face svg { display:block; width:100%; height:100%; overflow:visible; }
/* A number with eyes: the digit, outlined like the old bouncing digit, two eyes over its top. */
.number-face-digit { font:900 104px Rubik, sans-serif; stroke:#4b322e; stroke-width:9px; stroke-linejoin:round; paint-order:stroke fill; }
.number-face.is-dancing svg { animation:number-face-dance .6s var(--dance, 0ms) ease-in-out both; }
@keyframes number-face-dance { 0%,100% { translate:0 0; rotate:0deg; } 20% { translate:0 -22%; rotate:-8deg; } 40% { translate:0 0; rotate:6deg; } 60% { translate:0 -10%; rotate:-4deg; } 80% { translate:0 0; rotate:2deg; } }
/* A counted number beside its coconut: pops in, dances, and goes (0.9s, NUMBER_FACE_MS). */
.count-face { position:absolute; z-index:3; width:clamp(44px,7.5cqw,96px); aspect-ratio:120 / 122; transform:translate(-50%,-50%); pointer-events:none; animation:count-face-life .9s var(--life, 0ms) ease-out both; }
@keyframes count-face-life { 0% { scale:.3; opacity:0; } 15% { scale:1.1; opacity:1; } 25% { scale:1; translate:0 0; rotate:0deg; } 40% { translate:0 -14%; rotate:-8deg; } 55% { translate:0 0; rotate:6deg; } 70% { translate:0 -6%; rotate:0deg; opacity:1; } 100% { translate:0 0; scale:.8; opacity:0; } }
@keyframes count-face-fade { 0% { opacity:0; } 20%, 70% { opacity:1; } 100% { opacity:0; } }
@keyframes numbers-pop { from { scale:0; opacity:0; } to { scale:1; opacity:1; } }
@keyframes numbers-wobble { 0%,100% { rotate:0deg; } 25% { rotate:-9deg; } 75% { rotate:9deg; } }
@keyframes numbers-bounce { 0%,100% { translate:0 0; } 40% { translate:0 -18%; } 70% { translate:0 4%; } }
@media(max-width:720px) {
  .numbers-stage { aspect-ratio:1122 / 1402; border-radius:14px; }
  .numbers-stage.numbers-count-stage { aspect-ratio:1122 / 1060; }
  /* The boats' board has the same shape as every other game on a phone (Dana, December 1, 2026).
     Its tall river picture fills it, giving up sky at the top so the water and the bank stay. */
  .numbers-boats-stage > picture { position:absolute; inset:0; }
  .numbers-boats-stage .numbers-background { width:100%; height:100%; object-fit:cover; object-position:50% 70%; }
  /* Stars over the button, so the pointing hand beside the button never lies on them. */
  .numbers-footer { flex-direction:column; }
  /* The row of numbers and the answer cards stay above the fold because the instruction is
     compact here, as in the other practice games: the replay button is its round icon beside
     the text. The board keeps its full width (a first fix shrank the board instead, and on a
     real phone, where the browser's bars take height, the game came out small; Dana, November 30). */
  .lesson-shell:has(.numbers-lesson-stage) { gap:8px; }
  .lesson-shell:has(.numbers-lesson-stage) .capy-guide { padding:2px; }
  .lesson-shell:has(.numbers-lesson-stage) .speech-bubble { display:grid; grid-template-columns:minmax(0,1fr) 48px; align-items:center; gap:8px; }
  .lesson-shell:has(.numbers-lesson-stage) .speech-bubble strong { grid-column:1 / -1; }
  .lesson-shell:has(.numbers-lesson-stage) .speech-bubble p { margin:0; }
  .lesson-shell:has(.numbers-lesson-stage) .replay-button { width:48px; height:48px; min-width:48px; margin-top:0; padding:0; justify-content:center; }
  .lesson-shell:has(.numbers-lesson-stage) .replay-button span { display:none; }
  .lesson-main:has(.numbers-panel) { padding:0; }
  .lesson-shell:has(.numbers-panel) .world-games-nav { margin:0 14px 16px; }
  .number-face-row { grid-template-columns:repeat(5, minmax(0, 1fr)); width:min(100%, 300px); padding-inline:14px; }
  .number-choices, .numbers-footer { padding-inline:14px; }
}
@media(prefers-reduced-motion:reduce) {
  .tree-coconut, .number-choice.is-found, .number-choice.is-refused, .number-face.is-dancing svg { animation:none; }
  .count-face { animation-name:count-face-fade; }
  .flying-coconut { display:none; }
  .number-choice.is-found .choice-nuts { animation:none; }
}

/* Capy's speech bubble never touches the edge of its card on a phone (Dana, December 1, 2026:
   it sat 4px from the edge in most games). One rule for every screen, after the compact
   layouts above, which set their own padding. */
@media (max-width: 720px) {
  .lesson-shell .capy-guide { padding-inline-end: 12px !important; }
}
/* The colour game's palette keeps clear of the screen's edges on a phone (Dana, December 1,
   2026: the wood touched both sides). Not under 351px wide, where the wells need every pixel
   to stay 48px. */
@media (min-width: 351px) and (max-width: 720px) {
  .palette-lesson .palette-viewport { width: auto; margin: 0 8px; }   /* 8px: at 390 the wells stay 56px */
}
/* Colour practice on a phone: the stars sit close under the palette (Dana, December 1, 2026:
   the room kept for the feedback word left a 58px hole). The word still has its own line, so
   nothing jumps when it appears. */
@media (max-width: 720px) {
  .lesson-panel:has(.palette-lesson) > .feedback { margin-top: 2px; min-height: 24px; }
  .lesson-panel:has(.palette-lesson) > .action-row { padding-top: 4px; }
}
/* The closet on a phone (Dana, December 1, 2026: Capy's tall picture left the clothes a whole
   scroll away). Capy is a short row that stays in view while the clothes scroll under him, so
   the child sees him change, and the clothes stand two to a row. */
@media (max-width: 720px) {
  .wardrobe-layout { gap: 10px; margin-top: 4px; }
  .wardrobe-capy { position: sticky; top: 0; z-index: 2; grid-template-columns: auto minmax(0, 1fr); align-items: center; justify-items: start; gap: 12px; padding: 6px 12px; border-width: 2px; border-radius: 16px; box-shadow: 0 4px 0 rgba(75, 50, 40, 0.1); }
  .wardrobe-capy img { width: auto; height: 150px; max-width: none; }
  .wardrobe-capy p { text-align: start; }
  .wardrobe-capy .shop-way { grid-column: 1 / -1; }
  .wardrobe-layout .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .wardrobe-layout .shop-item { padding: 8px; min-width: 0; }
  .wardrobe-layout .shop-item .primary-button, .wardrobe-layout .shop-item .secondary-button { min-height: 48px; padding-inline: 8px; }
}
