/* ==========================================================================
   Bao the Sheep — kid-friendly game styles
   ========================================================================== */

:root {
  --sky-top: #5ec8f2;
  --sky-bottom: #c9f0ff;
  --ink: #23314f;
  --ink-soft: #55627f;
  --paper: #ffffff;
  --paper-soft: #f4f8ff;
  --shadow: rgba(35, 49, 79, 0.18);

  --green: #2fbf71;
  --green-dark: #1f9455;
  --red: #ff5a5f;
  --red-dark: #d63c41;
  --yellow: #ffcd3c;
  --yellow-dark: #e0a800;
  --purple: #8b5cf6;
  --purple-dark: #6d3fe0;
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --gray: #b8c2d6;
  --gray-dark: #8f9ab2;

  --radius: 26px;
  --radius-sm: 16px;
  --font: "Baloo 2", "Nunito", "Comic Sans MS", "Chalkboard SE", "Segoe UI", system-ui, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;

  /* Per-screen accent; screens override this with the submodule color. */
  --accent: var(--purple);
  --accent-dark: var(--purple-dark);
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.35;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 65%, #e8fbe6 100%) fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

button { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
.emoji { font-family: var(--emoji); line-height: 1; }

/* ---------- Decorative drifting clouds ---------- */
.sky-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud {
  position: absolute; width: 180px; height: 60px; background: #fff; border-radius: 60px; opacity: .75;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 80px; height: 80px; top: -40px; left: 28px; }
.cloud::after { width: 100px; height: 100px; top: -55px; left: 72px; }
.c1 { top: 14%; animation-duration: 70s; animation-delay: -10s; }
.c2 { top: 42%; transform: scale(.7); animation-duration: 95s; animation-delay: -50s; opacity: .55; }
.c3 { top: 72%; transform: scale(.9); animation-duration: 80s; animation-delay: -30s; opacity: .5; }
@keyframes drift { from { left: -240px; } to { left: 110vw; } }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
}
.brand {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper); padding: 6px 18px 6px 10px; border-radius: 999px;
  box-shadow: 0 4px 0 var(--shadow);
}
.brand-icon { display: block; width: 36px; height: 36px; }
/* Plain description in index.html (for web filters and no-JavaScript visitors); hidden once the app runs. */
.site-about { max-width: 720px; margin: 24px auto; padding: 20px 24px; background: var(--paper); border-radius: 20px;
  box-shadow: 0 4px 0 var(--shadow); line-height: 1.5; }
.site-about h1 { font-size: 28px; margin: 0 0 8px; }
.site-about h2 { font-size: 22px; margin: 18px 0 6px; }
.js .site-about { display: none; }
.brand-text { font-weight: 800; font-size: 24px; color: var(--green-dark); letter-spacing: .3px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.star-counter {
  display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 24px;
  background: var(--paper); padding: 4px 16px; border-radius: 999px; box-shadow: 0 4px 0 var(--shadow);
}
.star-counter.bump { animation: bump .5s ease; }
.star-icon { font-family: var(--emoji); }
.parent-btn {
  position: relative; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--paper); box-shadow: 0 4px 0 var(--shadow); font-size: 22px; font-family: var(--emoji);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.parent-ring {
  position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(var(--purple) calc(var(--hold, 0) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 25px, #000 26px);
          mask: radial-gradient(circle, transparent 25px, #000 26px);
}

/* ---------- Screens ---------- */
#app { position: relative; z-index: 1; outline: none; }
.screen {
  max-width: 1040px; margin: 0 auto; padding: 8px 16px 64px;
  animation: screen-in .35s ease both;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.screen-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 18px; }
.screen-title {
  font-size: clamp(26px, 5vw, 38px); font-weight: 800; color: var(--accent-dark);
  background: var(--paper); padding: 4px 24px; border-radius: 999px; box-shadow: 0 5px 0 var(--shadow);
}
.back-btn {
  flex: none; width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--paper); box-shadow: 0 5px 0 var(--shadow); font-size: 30px; font-weight: 800;
  display: grid; place-items: center; color: var(--ink);
}
.back-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }

/* ---------- Mascot + speech bubble ---------- */
.mascot-row { display: flex; align-items: flex-end; gap: 14px; margin: 4px 0 22px; }
.mascot { flex: none; width: 112px; height: auto; filter: drop-shadow(0 6px 0 rgba(0,0,0,.12)); }
.mascot.small { width: 84px; }
.mascot.happy { animation: hop .6s ease 2; }
.mascot.think { animation: tilt 1.6s ease-in-out infinite; }
.lid { transform-box: fill-box; transform-origin: center top; animation: blink 5s infinite; transform: scaleY(0); }
.actor:nth-child(odd) .lid, .cast-tile:nth-child(odd) .lid { animation-delay: -2.1s; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22px) rotate(-4deg); } }
@keyframes tilt { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

.bubble {
  position: relative; background: var(--paper); border-radius: var(--radius); padding: 14px 20px;
  font-size: clamp(20px, 3.4vw, 26px); font-weight: 700; box-shadow: 0 5px 0 var(--shadow);
  margin-bottom: 26px; max-width: 640px;
}
.bubble::before {
  content: ""; position: absolute; left: -14px; bottom: 18px; width: 28px; height: 28px;
  background: var(--paper); transform: rotate(45deg); border-radius: 4px;
}
.bubble .say-btn { margin-left: 8px; vertical-align: middle; }

/* ---------- Cards (modules & submodules) ---------- */
.card-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}
.card {
  --c: var(--purple); --cd: var(--purple-dark);
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 26px 20px 22px; border-radius: var(--radius); border: 0; cursor: pointer;
  background: var(--c); color: #fff; box-shadow: 0 9px 0 var(--cd), 0 14px 24px var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease; animation: pop-in .45s ease both;
}
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
.card:hover { transform: translateY(-3px); }
.card:active { transform: translateY(7px); box-shadow: 0 2px 0 var(--cd), 0 4px 10px var(--shadow); }
.card-icon {
  font-family: var(--emoji); font-size: 70px; line-height: 1; width: 112px; height: 112px;
  display: grid; place-items: center; background: rgba(255,255,255,.25); border-radius: 50%;
}
.card-icon.word { font-family: var(--font); font-weight: 800; font-size: 40px; }
.card-title { font-size: 34px; font-weight: 800; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
.card-sub { font-size: 19px; font-weight: 600; opacity: .95; }
.card-stars { margin-top: 6px; background: rgba(0,0,0,.15); padding: 2px 14px; border-radius: 999px; font-weight: 800; }
.card.locked { --c: var(--gray); --cd: var(--gray-dark); cursor: default; }
.card.locked:hover { transform: none; }
.card.locked:active { transform: none; box-shadow: 0 9px 0 var(--cd), 0 14px 24px var(--shadow); }
.card.locked .card-icon { filter: grayscale(.7); opacity: .8; }
.ribbon {
  position: absolute; top: 14px; right: -6px; background: var(--yellow); color: var(--ink);
  font-size: 15px; font-weight: 800; padding: 3px 12px; border-radius: 8px 0 0 8px; box-shadow: 0 3px 0 var(--yellow-dark);
}

/* ---------- Submodule level map ---------- */
.map { position: relative; display: flex; flex-direction: column; align-items: center; gap: 30px; padding: 10px 0 20px; }
.map-node {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: pop-in .45s ease both;
}
.map-node:nth-child(odd)  { translate: -70px 0; }
.map-node:nth-child(even) { translate: 70px 0; }
.map::before {
  content: ""; position: absolute; top: 70px; bottom: 90px; left: 50%; width: 10px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.95) 0 18px, transparent 18px 32px); border-radius: 10px;
}
.node-btn {
  position: relative; width: 132px; height: 132px; border-radius: 50%; border: 6px solid #fff; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 9px 0 var(--accent-dark), 0 14px 22px var(--shadow);
  font-size: 58px; font-family: var(--emoji); display: grid; place-items: center;
  transition: transform .12s ease;
}
.node-btn:active { transform: translateY(7px); box-shadow: 0 2px 0 var(--accent-dark); }
.node-btn .num { font-family: var(--font); font-weight: 800; font-size: 60px; text-shadow: 0 3px 0 rgba(0,0,0,.18); }
.node-btn.locked { background: var(--gray); box-shadow: 0 9px 0 var(--gray-dark); cursor: default; }
.node-btn.locked:active { transform: none; }
.node-btn.done { background: var(--yellow); box-shadow: 0 9px 0 var(--yellow-dark), 0 14px 22px var(--shadow); }
.node-label {
  background: var(--paper); border-radius: 999px; padding: 4px 18px; font-weight: 800; font-size: 22px;
  box-shadow: 0 4px 0 var(--shadow); white-space: nowrap;
}
.node-sub { font-size: 16px; font-weight: 700; color: var(--ink-soft); background: rgba(255,255,255,.7); padding: 0 12px; border-radius: 999px; }
.node-stars { font-family: var(--emoji); font-size: 26px; letter-spacing: 2px; min-height: 30px; }
.node-stars .off { filter: grayscale(1); opacity: .35; }
.start-tag {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  background: var(--green); color: #fff; font-weight: 800; font-size: 18px; padding: 2px 14px; border-radius: 999px;
  box-shadow: 0 4px 0 var(--green-dark); animation: nudge 1.2s ease-in-out infinite; white-space: nowrap; z-index: 2;
}
.lock-badge { position: absolute; bottom: -4px; right: -4px; font-size: 34px; font-family: var(--emoji); }
@keyframes nudge { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -7px); } }

/* ---------- Buttons ---------- */
.btn {
  --c: var(--green); --cd: var(--green-dark);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 64px; padding: 10px 30px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--c); color: #fff; font-size: 26px; font-weight: 800;
  box-shadow: 0 7px 0 var(--cd), 0 10px 18px var(--shadow); transition: transform .1s ease;
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--cd); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.secondary { --c: var(--paper); --cd: #cfd8ea; color: var(--ink); text-shadow: none; }
.btn.accent { --c: var(--accent); --cd: var(--accent-dark); }
.btn.yellow { --c: var(--yellow); --cd: var(--yellow-dark); color: var(--ink); text-shadow: none; }
.btn .emoji { font-size: 30px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 22px; }

.say-btn {
  width: 52px; height: 52px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--yellow); box-shadow: 0 4px 0 var(--yellow-dark); font-size: 26px; font-family: var(--emoji);
  display: inline-grid; place-items: center;
}
.say-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--yellow-dark); }
.say-btn.speaking { animation: pulse 1s ease-in-out infinite; }

/* ---------- Picture scenes ---------- */
.scene {
  position: relative; width: 100%; aspect-ratio: 16 / 10; overflow: hidden;
  border-radius: var(--radius); border: 6px solid #fff; background: #bfe9ff;
  box-shadow: 0 8px 0 var(--shadow); container-type: inline-size;
}
.scene.compact { aspect-ratio: 16 / 9; }
.scene-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.actor {
  position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%);
  font-size: calc(var(--s, 18) * 1cqw); font-family: var(--emoji); line-height: 1;
  transform: translate(-50%, -50%) rotate(calc(var(--r, 0) * 1deg)) scaleX(var(--flip, 1));
  user-select: none; pointer-events: none; z-index: var(--z, 2);
}
.actor > span { display: inline-block; }
.actor.text { font-family: var(--font); font-weight: 800; color: var(--ink); font-size: calc(var(--s, 6) * 1cqw); }
.anim-bob > span    { animation: a-bob 2.2s ease-in-out infinite; }
.anim-bounce > span { animation: a-bounce 1s ease-in-out infinite; }
.anim-wiggle > span { animation: a-wiggle 1.4s ease-in-out infinite; }
.anim-shiver > span { animation: a-shiver .25s linear infinite; }
.anim-pulse > span  { animation: pulse 1.6s ease-in-out infinite; }
.anim-spin > span   { animation: a-spin 10s linear infinite; }
.anim-float > span  { animation: a-float 3s ease-in-out infinite; }
.anim-sway > span   { animation: a-sway 2.6s ease-in-out infinite; transform-origin: bottom center; }
.anim-fall > span   { animation: a-fall 2.4s ease-in infinite; }
.anim-zzz > span    { animation: a-zzz 2.4s ease-out infinite; }
@keyframes a-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6%); } }
@keyframes a-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-22%); } 60% { transform: translateY(0) scale(1.05, .95); } }
@keyframes a-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes a-shiver { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3%); } 75% { transform: translateX(3%); } }
@keyframes a-spin { to { transform: rotate(360deg); } }
@keyframes a-float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(4%, -8%); } }
@keyframes a-sway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes a-fall { 0% { transform: translateY(-40%) rotate(0); opacity: 0; } 15% { opacity: 1; } 80% { transform: translateY(60%) rotate(25deg); opacity: 1; } 100% { transform: translateY(60%) rotate(25deg); opacity: 0; } }
@keyframes a-zzz { 0% { transform: translate(0, 0) scale(.6); opacity: 0; } 30% { opacity: 1; } 100% { transform: translate(40%, -70%) scale(1.1); opacity: 0; } }

/* Animated bits inside the SVG backdrops */
.scene-bg .sun-rays { transform-box: fill-box; transform-origin: center; animation: a-spin 24s linear infinite; }
.scene-bg .svg-cloud { animation: svg-drift 14s ease-in-out infinite alternate; }
.scene-bg .twinkle { animation: twinkle 2.4s ease-in-out infinite; }
.scene-bg .twinkle:nth-child(even) { animation-delay: -1.2s; }
@keyframes svg-drift { from { translate: -4px 0; } to { translate: 5px 0; } }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* Thought / speech bubbles inside scenes */
.actor.thought, .actor.speech { font-size: calc(var(--s, 12) * 1cqw); }
.actor.thought > span, .actor.speech > span {
  position: relative; display: grid; place-items: center; min-width: 1.6em; height: 1.6em; padding: 0 .25em;
  background: #fff; border-radius: 50%; box-shadow: 0 .06em 0 rgba(0,0,0,.15);
}
.actor.speech > span { border-radius: .5em; font-family: var(--font); font-weight: 800; font-size: .55em; padding: 0 .5em; height: 2em; color: var(--ink); white-space: nowrap; }
.actor.thought > span::before, .actor.thought > span::after {
  content: ""; position: absolute; background: #fff; border-radius: 50%;
}
.actor.thought > span::before { width: .32em; height: .32em; bottom: -.28em; left: 18%; }
.actor.thought > span::after  { width: .18em; height: .18em; bottom: -.5em; left: 8%; }
.actor.thought.right > span::before { left: auto; right: 18%; }
.actor.thought.right > span::after  { left: auto; right: 8%; }
.actor.speech > span::after {
  content: ""; position: absolute; bottom: -.35em; left: 22%; border: .2em solid transparent; border-top-color: #fff; border-bottom: 0;
}

/* Weather overlays */
.weather { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.weather .drop {
  position: absolute; top: -12%; width: .5cqw; height: 4cqw; border-radius: 1cqw;
  background: linear-gradient(rgba(255,255,255,0), rgba(120,170,255,.9)); animation: rain linear infinite;
}
.weather .flake {
  position: absolute; top: -8%; width: 1.4cqw; height: 1.4cqw; border-radius: 50%; background: #fff;
  box-shadow: 0 0 .6cqw rgba(255,255,255,.9); animation: snow linear infinite;
}
.weather .gust {
  position: absolute; height: .5cqw; border-radius: 1cqw; background: rgba(255,255,255,.8); animation: wind linear infinite;
}
@keyframes rain { to { transform: translate(-3cqw, 120cqw); } }
@keyframes snow { 0% { transform: translate(0, 0); } 50% { transform: translate(2.5cqw, 35cqw); } 100% { transform: translate(-1cqw, 70cqw); } }
@keyframes wind { from { transform: translateX(-30cqw); opacity: 0; } 20% { opacity: 1; } to { transform: translateX(130cqw); opacity: 0; } }

/* ---------- Lesson player ---------- */
.lesson { max-width: 820px; margin: 0 auto; }
.slide {
  background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: 0 9px 0 var(--shadow);
  animation: slide-in .35s ease both;
}
.slide.back { animation-name: slide-in-back; }
@keyframes slide-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes slide-in-back { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
.slide-title { font-size: clamp(28px, 5vw, 40px); font-weight: 800; color: var(--accent-dark); margin: 4px 4px 12px; text-align: center; }
.slide-text {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  font-size: clamp(22px, 4vw, 30px); font-weight: 700; text-align: center; margin: 16px 6px 6px;
}
.slide-text strong, .hl { color: var(--accent-dark); }
.big-word {
  display: inline-block; background: var(--accent); color: #fff; padding: 0 .4em; border-radius: .3em;
  box-shadow: 0 .12em 0 var(--accent-dark); margin: 0 .1em;
}
/* Story slides: Bao narrates, the cast say their lines (name tag in the character's color). */
.story-lines { display: grid; gap: 10px; margin: 16px 4px 4px; font-size: clamp(20px, 3.6vw, 27px); font-weight: 700; line-height: 1.35; }
.story-line { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); transition: background .2s, box-shadow .2s; }
.story-line.cast { background: #fffaf0; border-left: 7px solid var(--who); }
.story-line .who { display: flex; align-items: center; gap: 6px; font-weight: 800; color: #4a5571; font-size: .8em; margin-bottom: 2px; }
.story-line .who-pic svg { width: 1.9em; height: auto; display: block; }
.story-line.reading { background: #fff3c4; box-shadow: 0 0 0 3px var(--yellow); }
.slide-title.reading { color: var(--accent); }
.story-say { display: flex; justify-content: center; }
.light-beams { animation: beams 3.2s ease-in-out infinite; transform-origin: 50% 0; }
@keyframes beams { 0%, 100% { opacity: .85; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .light-beams { animation: none; } }

.reveal-box { margin-top: 14px; text-align: center; }
.reveal-answer {
  display: inline-flex; align-items: center; gap: 12px; font-size: clamp(22px, 4vw, 30px); font-weight: 800;
  background: #eafff2; color: var(--green-dark); border: 4px dashed var(--green); border-radius: var(--radius-sm);
  padding: 10px 22px; animation: pop-in .4s ease both;
}
.lesson-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 22px; }
.dots { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.dot { width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,.6); border: 3px solid #fff; }
.dot.on { background: var(--accent); transform: scale(1.25); }
.dot.seen { background: var(--accent); opacity: .55; }
.round-btn {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: var(--accent); color: #fff; font-size: 40px; font-weight: 800;
  box-shadow: 0 7px 0 var(--accent-dark); display: grid; place-items: center;
}
.round-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--accent-dark); }
.round-btn[disabled] { visibility: hidden; }
.round-btn.go { background: var(--green); box-shadow: 0 7px 0 var(--green-dark); animation: pulse 1.4s ease-in-out infinite; }

/* ---------- Quiz ---------- */
.quiz { max-width: 900px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.quiz-progress {
  flex: 1; display: flex; gap: 6px; background: rgba(255,255,255,.55); padding: 8px; border-radius: 999px;
}
.quiz-progress .pip { flex: 1; height: 18px; border-radius: 999px; background: rgba(255,255,255,.9); transition: background .3s; }
.quiz-progress .pip.now { background: var(--yellow); animation: pulse 1.2s ease-in-out infinite; }
.quiz-progress .pip.ok { background: var(--green); }
.quiz-progress .pip.retry { background: #ffb347; }
.q-card { background: var(--paper); border-radius: var(--radius); padding: 18px; box-shadow: 0 9px 0 var(--shadow); animation: slide-in .35s ease both; }
.q-prompt {
  display: flex; align-items: center; gap: 14px; justify-content: center; text-align: center;
  font-size: clamp(24px, 4.4vw, 34px); font-weight: 800; margin: 0 4px 14px;
}
.q-sub { text-align: center; font-size: 22px; font-weight: 700; color: var(--ink-soft); margin: -6px 0 12px; }
.q-layout { display: grid; gap: 18px; }
@media (min-width: 820px) {
  .q-layout.side { grid-template-columns: 1.15fr 1fr; align-items: center; }
}

.options { display: grid; gap: 14px; grid-template-columns: 1fr; }
.options.n2 { grid-template-columns: repeat(2, 1fr); }
.options.n3 { grid-template-columns: repeat(3, 1fr); }
.options.n4 { grid-template-columns: repeat(2, 1fr); }
.q-layout.side .options:not(.yesno) { grid-template-columns: 1fr; }
.options.text-only { grid-template-columns: 1fr; }
@media (max-width: 560px) { .options.n3 { grid-template-columns: 1fr; } }

.option {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 110px; padding: 14px 12px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--paper-soft); border: 4px solid #d9e3f5; box-shadow: 0 6px 0 #d9e3f5;
  font-size: clamp(19px, 3vw, 24px); font-weight: 700; text-align: center; transition: transform .1s ease, background .2s;
}
.option:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9e3f5; }
.option .pic { font-family: var(--emoji); font-size: clamp(44px, 9vw, 64px); line-height: 1.05; }
.options.text-only .option, .option.row { flex-direction: row; justify-content: flex-start; text-align: left; min-height: 76px; gap: 16px; padding: 12px 20px; }
.options.text-only .option .pic, .option.row .pic { font-size: 44px; }
.option.reading { border-color: var(--yellow); box-shadow: 0 6px 0 var(--yellow-dark); background: #fff8dc; }
.option.correct {
  background: #e3fbec; border-color: var(--green); box-shadow: 0 6px 0 var(--green-dark); animation: pop .4s ease;
}
.option.correct::after, .option.wrong::after {
  position: absolute; top: -14px; right: -10px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 26px; font-weight: 800; border: 4px solid #fff;
}
.option.correct::after { content: "✓"; background: var(--green); }
.option.wrong { background: #ffecec; border-color: var(--red); box-shadow: 0 6px 0 var(--red-dark); animation: shake .45s ease; opacity: .7; }
.option.wrong::after { content: "✕"; background: var(--red); }
.option.dim { opacity: .45; }
.options.locked .option { pointer-events: none; }

.yesno { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.yesno .option { min-height: 130px; }
.yesno .option .pic { font-size: 64px; }
.because-card {
  display: flex; align-items: center; gap: 14px; justify-content: center; text-align: center;
  background: #fff6e8; border: 4px dashed #ffb347; border-radius: var(--radius-sm);
  font-size: clamp(22px, 4vw, 30px); font-weight: 800; padding: 12px 16px; margin: 4px 0 16px;
}

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.match-col { display: flex; flex-direction: column; gap: 14px; }
.match-col h4 { margin: 0; text-align: center; font-size: 20px; color: var(--ink-soft); }
.match .option { min-height: 96px; }
.match .option.selected { border-color: var(--blue); box-shadow: 0 6px 0 var(--blue-dark); background: #eaf2ff; transform: scale(1.03); }
.match .option.paired { pointer-events: none; }

/* Feedback panel */
.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap;
  padding: 16px max(16px, env(safe-area-inset-left)) calc(16px + env(safe-area-inset-bottom));
  background: #e3fbec; border-top: 6px solid var(--green); box-shadow: 0 -8px 24px var(--shadow);
  animation: rise .35s cubic-bezier(.2, 1.4, .4, 1) both;
}
.feedback.try { background: #fff1e0; border-top-color: #ffb347; }
.feedback-text { display: flex; align-items: center; gap: 14px; max-width: 640px; }
.feedback-text .big { font-size: clamp(28px, 5vw, 38px); font-weight: 800; color: var(--green-dark); line-height: 1.05; }
.feedback.try .feedback-text .big { color: #c96a00; }
.feedback-text .small { font-size: clamp(18px, 3vw, 22px); font-weight: 700; color: var(--ink); }
.feedback .mascot { width: 78px; }
@keyframes rise { from { transform: translateY(110%); } to { transform: none; } }
.quiz.has-feedback { padding-bottom: 150px; }

/* ---------- Results ---------- */
.results { max-width: 720px; margin: 0 auto; text-align: center; background: var(--paper); border-radius: var(--radius); padding: 26px 20px 30px; box-shadow: 0 9px 0 var(--shadow); animation: pop-in .45s ease both; }
.results h2 { font-size: clamp(34px, 7vw, 52px); color: var(--accent-dark); }
.result-stars { display: flex; justify-content: center; gap: 10px; margin: 18px 0 8px; }
.result-stars span { font-family: var(--emoji); font-size: clamp(64px, 14vw, 100px); opacity: 0; transform: scale(.2); }
.result-stars span.in { animation: star-in .6s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.result-stars span.off { filter: grayscale(1); }
.result-stars span.off.in { animation-name: star-in-off; }
.results p { font-size: 24px; font-weight: 700; margin: 8px 0; }
@keyframes star-in { from { opacity: 0; transform: scale(.2) rotate(-90deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes star-in-off { from { opacity: 0; transform: scale(.2); } to { opacity: .3; transform: scale(.85); } }

/* ---------- Parents panel ---------- */
.panel { max-width: 720px; margin: 0 auto; background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: 0 9px 0 var(--shadow); }
.panel h2 { font-size: 32px; margin-bottom: 6px; }
.panel .hint { color: var(--ink-soft); font-size: 18px; margin: 0 0 14px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 2px solid #eef2fa; font-weight: 700; }
.field label { flex: 1; }
.field small { display: block; font-weight: 500; color: var(--ink-soft); font-size: 16px; }
.field input[type="text"] { font: inherit; font-size: 22px; padding: 8px 14px; border-radius: 14px; border: 3px solid #d9e3f5; width: min(260px, 48vw); }
.field input[type="range"] { width: min(220px, 40vw); accent-color: var(--purple); }
.field select { font: inherit; font-size: 18px; padding: 6px 10px; border-radius: 12px; border: 3px solid #d9e3f5; max-width: 52vw; }
.switch { position: relative; width: 70px; height: 40px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--gray); cursor: pointer; transition: background .2s; }
.switch span::before { content: ""; position: absolute; width: 30px; height: 30px; left: 5px; top: 5px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(30px); }
.switch input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn.danger { --c: var(--red); --cd: var(--red-dark); font-size: 20px; min-height: 52px; }

/* ---------- Misc ---------- */
.empty { text-align: center; background: var(--paper); border-radius: var(--radius); padding: 30px; box-shadow: 0 9px 0 var(--shadow); }
.empty .emoji { font-size: 80px; }
.noscript { text-align: center; font-size: 24px; background: #fff; margin: 40px auto; padding: 20px; max-width: 600px; border-radius: 20px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

@keyframes pop-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.3); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-7px); } 80% { transform: translateX(7px); } }

:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

@media (max-width: 640px) {
  body { font-size: 18px; }
  .brand-text { font-size: 20px; }
  .brand-icon { width: 30px; height: 30px; }
  .mascot { width: 84px; }
  .map-node:nth-child(odd)  { translate: -40px 0; }
  .map-node:nth-child(even) { translate: 40px 0; }
  .node-btn { width: 112px; height: 112px; font-size: 48px; }
  .option { min-height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .cloud { display: none; }
}

/* ---------- Quiz extras ---------- */
.q-hint { text-align: center; font-weight: 800; color: #c96a00; font-size: clamp(19px, 3vw, 23px); min-height: 1.4em; margin: -4px 0 10px; }
.q-hint:empty { min-height: 0; margin: 0; }
.option .pic-scene .scene { border-width: 3px; box-shadow: none; border-radius: 12px; }
.results .mascot { width: 120px; margin: 0 auto; }
.quiz-top .mascot { width: 70px; }
.screen-head .mascot { width: 76px; }

/* Keep pictures inside the screen height so the text and buttons stay visible. */
.slide .scene, .q-card > .q-layout > .scene, .q-card > div > .scene { width: min(100%, calc(50vh * 1.6)); margin: 0 auto; }
.q-layout.side > .scene { width: 100%; }

/* Cast characters in scenes: anchored at their feet */
.actor.char { transform: translate(-50%, -100%) rotate(calc(var(--r, 0) * 1deg)) scaleX(var(--flip, 1)); font-size: calc(var(--s, 24) * 1cqw); z-index: var(--z, 3); }
.actor.char > span { display: block; width: 1em; }
.actor.char svg, .mascot svg, .pic-char svg { display: block; width: 100%; height: auto; overflow: visible; }
.pic-char { display: block; width: clamp(70px, 14vw, 104px); }
.options.text-only .pic-char, .option.row .pic-char { width: 64px; flex: none; }
.fx-zzz { animation: fx-zzz 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: left bottom; }
@keyframes fx-zzz { 0%, 100% { opacity: .35; transform: translateY(2px); } 50% { opacity: 1; transform: translateY(-3px); } }

/* Character sheet */
.cast-card { max-width: 1040px; margin-bottom: 22px; }
.cast-card h2 small { font-size: 17px; color: var(--ink-soft); font-weight: 700; }
.cast-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.cast-tile { margin: 0; width: 96px; text-align: center; background: var(--paper-soft); border-radius: 14px; padding: 18px 6px 4px; }
.cast-pic { width: 76px; margin: 0 auto; }
.cast-pic svg { display: block; width: 100%; height: auto; overflow: visible; }
.cast-tile figcaption { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* Play mode */
.node-btn.play { background: linear-gradient(135deg, #ff5a5f, #ffcd3c 35%, #2fbf71 60%, #3b82f6 80%, #8b5cf6); box-shadow: 0 9px 0 #6d3fe0, 0 14px 22px var(--shadow); }
.node-btn.play.locked { background: var(--gray); box-shadow: 0 9px 0 var(--gray-dark); }
.quiz-progress.counter { position: relative; height: 38px; padding: 0; overflow: hidden; align-items: center; justify-content: center; }
.quiz-count-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); opacity: .35; transition: width .3s; }
.quiz-count-text { position: relative; font-weight: 800; font-size: 20px; white-space: pre; }

/* Talking activities */
.talk { display: grid; gap: 16px; }
.say-card {
  display: flex; align-items: center; justify-content: center; gap: 16px; text-align: center;
  font-size: clamp(26px, 5vw, 40px); font-weight: 800; color: var(--ink);
  background: #fff8e1; border: 4px dashed #ffcd3c; border-radius: var(--radius-sm); padding: 14px 20px;
}
.say-card .pic { font-family: var(--emoji); font-size: 1.5em; }
.say-card .pic-char { width: 90px; }
.say-card.correct { background: #e3fbec; border-color: var(--green); border-style: solid; animation: pop .4s ease; }
.say-card.reading, .say-card.speaking { border-color: var(--yellow-dark); }
.mic-area { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.mic-btn {
  --level: 0; position: relative; width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); box-shadow: 0 7px 0 var(--accent-dark); display: grid; place-items: center;
}
.mic-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--accent-dark); }
.mic-icon { position: relative; font-family: var(--emoji); font-size: 44px; z-index: 1; }
.mic-level {
  position: absolute; inset: -8px; border-radius: 50%; border: 6px solid var(--accent);
  opacity: 0; transform: scale(calc(1 + var(--level) * .45)); transition: transform .08s linear;
}
.mic-btn.listening .mic-level { opacity: .55; }
.mic-btn.listening { animation: pulse 1.4s ease-in-out infinite; }
.mic-btn.loading { opacity: .7; }
.mic-btn.loading .mic-icon { animation: a-wiggle 1s ease-in-out infinite; }
.mic-btn.off { display: none; }
.mic-text { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.mic-status { font-weight: 800; font-size: clamp(18px, 3vw, 22px); color: var(--ink-soft); min-height: 1.3em; }
.said-btn { min-height: 52px; font-size: 20px; padding: 6px 20px; }
.said-btn.nudge { --c: var(--green); --cd: var(--green-dark); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
