/* ==========================================================================
   FDP QUEST — Visuals, Pip, video player, transitions & micro-interactions
   ========================================================================== */

/* ---------- Pip the MathBot (SVG) ---------- */
.pip-bot { padding: 4px; overflow: visible; }
.pip-bot .pip-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pip-eyes { transform-origin: 60px 56px; animation: blink 4.5s infinite; }
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
.pip-bulb { animation: bulb 2s ease-in-out infinite; transform-origin: 60px 8px; }
@keyframes bulb {
  0%, 100% { fill: #facc15; }
  50% { fill: #fde68a; }
}
.pip-mouth { transform-origin: 60px 72px; transition: transform 0.1s; }
body.pip-talking .pip-mouth { animation: talk 0.22s ease-in-out infinite alternate; }
body.pip-talking .pip-bulb { animation-duration: 0.5s; fill: #4ade80; }
@keyframes talk {
  from { transform: scaleY(0.6) scaleX(0.9); }
  to { transform: scaleY(2.6) scaleX(0.75); }
}
body.pip-talking .pip-banner .pip-bot { animation: bob 0.9s ease-in-out infinite; }

/* ---------- Stacked fractions & tappable numbers ---------- */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  line-height: 1;
  font-size: 0.82em;
  margin: 0 0.12em;
  font-variant-numeric: lining-nums;
}
.frac .fn { padding: 0 0.2em 0.08em; border-bottom: 0.11em solid currentColor; }
.frac .fd { padding: 0.08em 0.2em 0; }
.sayable {
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: underline dotted rgba(124, 58, 237, 0.45);
  text-underline-offset: 3px;
}
.frac.sayable { text-decoration: none; padding: 1px 2px; }
.sayable:hover { background: rgba(124, 58, 237, 0.12); }
.say-pulse { animation: sayPulse 0.6s ease; }
@keyframes sayPulse {
  0% { box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.55); background: rgba(124, 58, 237, 0.2); }
  100% { box-shadow: 0 0 0 12px rgba(124, 58, 237, 0); }
}
.say-tip {
  position: fixed;
  z-index: 2500;
  transform: translate(-50%, -100%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 9px 14px;
  border-radius: 14px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.18s, transform 0.25s cubic-bezier(.3, 1.6, .5, 1);
}
.say-tip::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: var(--ink); transform: translateX(-50%) rotate(45deg); }
.say-tip span { opacity: 0.75; font-weight: 700; }
.say-tip strong { color: #fde68a; }
.say-tip.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }

/* ---------- Welcome floating numbers ---------- */
#screenWelcome { position: relative; overflow: hidden; }
.welcome-bg { position: absolute; inset: 0; pointer-events: none; }
.welcome-bg span {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.6rem;
  color: rgba(124, 58, 237, 0.12);
  animation: floatNum 9s ease-in-out infinite;
}
.welcome-bg span:nth-child(1) { left: 6%; top: 12%; }
.welcome-bg span:nth-child(2) { right: 8%; top: 18%; animation-delay: -2s; color: rgba(236, 72, 153, 0.14); }
.welcome-bg span:nth-child(3) { left: 10%; bottom: 14%; animation-delay: -4s; color: rgba(22, 163, 74, 0.14); }
.welcome-bg span:nth-child(4) { right: 12%; bottom: 10%; animation-delay: -1s; color: rgba(245, 158, 11, 0.18); }
.welcome-bg span:nth-child(5) { left: 44%; top: 4%; animation-delay: -6s; }
.welcome-bg span:nth-child(6) { left: 3%; top: 50%; animation-delay: -3s; color: rgba(14, 165, 233, 0.16); }
.welcome-bg span:nth-child(7) { right: 4%; top: 52%; animation-delay: -5s; }
.welcome-bg span:nth-child(8) { left: 40%; bottom: 3%; animation-delay: -7s; color: rgba(22, 163, 74, 0.14); }
@keyframes floatNum {
  0%, 100% { transform: translateY(0) rotate(-6deg); }
  50% { transform: translateY(-24px) rotate(6deg); }
}
.welcome-card { position: relative; z-index: 1; }

/* ---------- Circle wipe transition ---------- */
.wipe {
  position: fixed;
  inset: 0;
  z-index: 2800;
  pointer-events: none;
  background: var(--zone-bg, linear-gradient(135deg, #7c3aed, #ec4899));
  background: linear-gradient(135deg, var(--zone), var(--zone-deep));
  clip-path: circle(0 at var(--cx, 50%) var(--cy, 50%));
  opacity: 1;
  visibility: hidden;
}
.wipe.expand { visibility: visible; clip-path: circle(150% at var(--cx) var(--cy)); transition: clip-path 0.55s cubic-bezier(.6, 0, .3, 1); }
.wipe.fade { opacity: 0; transition: opacity 0.4s ease 0.05s; }

/* ---------- Level chip ---------- */
.level-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-radius: var(--r-full);
  padding: 5px 14px 5px 5px;
  box-shadow: inset 0 0 0 2px #fcd34d;
}
.lv-badge {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, #a78bfa, #6d28d9);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 3px 0 #4c1d95;
}
.lv-badge small { font-size: 0.55rem; font-weight: 900; letter-spacing: 0.1em; opacity: 0.85; }
.lv-badge strong { font-family: var(--font-display); font-size: 1.25rem; }
.lv-info { min-width: 120px; }
.lv-title { font-family: var(--font-display); font-weight: 600; color: #78350f; font-size: 0.98rem; line-height: 1.1; }
.lv-track { height: 8px; background: rgba(255, 255, 255, 0.8); border-radius: 99px; overflow: hidden; margin: 3px 0 2px; }
.lv-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #8b5cf6, #ec4899); transition: width 0.8s cubic-bezier(.3, 1.3, .5, 1); }
.lv-xp { font-size: 0.72rem; font-weight: 900; color: #92400e; }
.level-chip.bump { animation: chipBump 0.6s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes chipBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.level-chip-mini { padding-right: 10px; }
.level-chip-mini .lv-badge { width: 38px; height: 38px; }
.level-chip-mini .lv-info { min-width: 70px; }
.level-chip-mini .lv-xp { font-size: 0.66rem; }

.map-header { display: grid; grid-template-columns: auto auto 1fr; grid-template-areas: "chip level stats" "prog prog prog"; row-gap: 10px; }
.map-header .explorer-chip { grid-area: chip; }
.map-header .level-chip { grid-area: level; }
.map-header .header-stats { grid-area: stats; justify-self: end; }
.map-header .journey-progress { grid-area: prog; max-width: none; margin: 0; }
@media (max-width: 900px) {
  .map-header { grid-template-columns: 1fr auto; grid-template-areas: "chip stats" "level level" "prog prog"; }
  .map-header .level-chip { justify-self: start; }
}

/* XP float */
.xp-float {
  position: fixed;
  z-index: 2600;
  transform: translate(-50%, 0);
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: #7c3aed;
  text-shadow: 0 2px 0 #fff, 0 0 12px rgba(255, 255, 255, 0.9);
  animation: xpUp 1.25s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes xpUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -12px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}

/* ---------- Lesson progress (focus mode) ---------- */
.lesson-topbar { flex-wrap: wrap; }
.lesson-progress { flex-basis: 100%; display: flex; align-items: center; gap: 10px; }
.lp-track { flex: 1; height: 10px; background: #eceaf6; border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06); }
.lp-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--zone), #facc15);
  transition: width 0.6s cubic-bezier(.3, 1.2, .5, 1);
  position: relative;
}
.lp-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 2.2s infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to { transform: translateX(100%); }
}
.lp-label { font-weight: 900; color: var(--zone-deep); min-width: 42px; text-align: right; font-size: 0.9rem; }
@media (max-width: 720px) {
  .level-chip-mini .lv-info { display: none; }
  .level-chip-mini { padding: 3px; }
  #btnFullscreen { display: none; }
}

/* ---------- Guided auto-advance sheet ---------- */
.advance-sheet {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 900;
  transform: translate(-50%, 160%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: var(--r-xl);
  padding: 12px 14px 12px 18px;
  box-shadow: 0 18px 50px rgba(38, 33, 74, 0.28), inset 0 0 0 3px var(--zone-soft);
  width: min(560px, calc(100vw - 24px));
  transition: transform 0.45s cubic-bezier(.3, 1.4, .5, 1);
}
.advance-sheet.show { transform: translate(-50%, 0); }
.adv-burst { font-size: 2rem; animation: popIn 0.6s ease; }
.adv-text { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.adv-text strong { font-family: var(--font-display); font-size: 1.2rem; color: var(--zone-deep); }
.adv-text span { color: var(--ink-soft); font-weight: 800; }
.adv-go { position: relative; padding-left: 44px; }
.adv-ring { position: absolute; left: 8px; top: 50%; width: 28px; height: 28px; transform: translateY(-50%) rotate(-90deg); }
.adv-ring circle { fill: none; stroke: rgba(255, 255, 255, 0.95); stroke-width: 4; stroke-dasharray: 94.25; stroke-dashoffset: 0; }
.advance-sheet.show .adv-ring circle { animation: ring var(--secs, 6s) linear forwards; }
@keyframes ring { to { stroke-dashoffset: 94.25; } }
@media (max-width: 600px) {
  .advance-sheet { flex-wrap: wrap; }
  .advance-sheet .adv-go { flex: 1; }
}

/* ---------- Stop preview sheet ---------- */
.sheet-overlay { align-items: flex-end; }
@media (min-width: 700px) { .sheet-overlay { align-items: center; } }
.stop-sheet { max-width: 520px; padding: 0; overflow: hidden auto; animation: sheetUp 0.5s cubic-bezier(.3, 1.3, .5, 1); }
@keyframes sheetUp {
  from { transform: translateY(80px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.sheet-hero {
  position: relative;
  text-align: center;
  padding: 28px 20px 22px;
  background: linear-gradient(160deg, var(--zone), var(--zone-deep));
  color: #fff;
  overflow: hidden;
}
.sheet-scenery span {
  position: absolute;
  font-size: 30px;
  opacity: 0.35;
  animation: drift 6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -1s);
}
.sheet-scenery span:nth-child(1) { left: 6%; top: 14%; }
.sheet-scenery span:nth-child(2) { right: 8%; top: 10%; }
.sheet-scenery span:nth-child(3) { left: 12%; bottom: 12%; }
.sheet-scenery span:nth-child(4) { right: 12%; bottom: 16%; }
.sheet-scenery span:nth-child(5) { left: 30%; top: 4%; font-size: 22px; }
.sheet-scenery span:nth-child(6) { right: 30%; bottom: 4%; font-size: 22px; }
.sheet-badge {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #fff;
  font-size: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.18), 0 0 0 8px rgba(255, 255, 255, 0.25);
  animation: badgeIn 0.8s cubic-bezier(.3, 1.6, .5, 1), bob 3s ease-in-out 0.8s infinite;
}
.sheet-kicker { position: relative; font-weight: 900; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.9; }
.stop-sheet h2 { position: relative; color: #fff; font-size: 1.8rem; margin: 2px 0 6px; }
.sheet-stars { position: relative; font-size: 1.6rem; letter-spacing: 4px; color: rgba(255, 255, 255, 0.35); }
.sheet-stars .on { color: #fde047; text-shadow: 0 2px 0 #b45309; }
.sheet-body { padding: 18px 22px 6px; }
.sheet-desc { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.sheet-progress { margin: 14px 0; }
.sp2-row { display: flex; justify-content: space-between; font-weight: 900; color: var(--ink-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.sp2-row strong { color: var(--zone-deep); }
.sheet-stations { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ss-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: #f7f6fc;
  animation: stageIn 0.4s both;
  animation-delay: calc(var(--i) * 70ms);
}
.ss-item[data-jump] { cursor: pointer; }
.ss-item[data-jump]:hover { background: var(--zone-soft); }
.ss-item div { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.ss-item small { color: var(--ink-soft); font-weight: 700; }
.ss-icon { width: 40px; height: 40px; border-radius: 50%; background: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; box-shadow: inset 0 0 0 2px var(--line); flex-shrink: 0; font-weight: 900; }
.ss-item.is-done .ss-icon { background: var(--go); color: #fff; box-shadow: none; }
.ss-item.is-current { background: var(--zone-soft); box-shadow: inset 0 0 0 2px var(--zone); }
.ss-item.is-current .ss-icon { background: var(--zone); color: #fff; box-shadow: none; }
.ss-item.is-locked { opacity: 0.55; }
.ss-tag { font-size: 0.75rem; font-weight: 900; padding: 3px 10px; border-radius: 99px; background: var(--go-soft); color: var(--go-deep); }
.ss-tag.ss-next { background: var(--zone); color: #fff; animation: chipBounce2 1.2s ease-in-out infinite; }
@keyframes chipBounce2 { 50% { transform: translateY(-3px); } }
.sheet-reward { margin: 14px 0 4px; padding: 10px 14px; border-radius: var(--r-md); background: var(--cream); box-shadow: inset 0 0 0 2px #fdecc8; font-weight: 700; }
.sheet-reward span { font-size: 0.75rem; font-weight: 900; text-transform: uppercase; color: #b45309; margin-right: 6px; }
.sheet-actions { padding: 14px 22px 22px; }
.sheet-start { width: 100%; animation: glowBtn 2s ease-in-out infinite; }
@keyframes glowBtn {
  0%, 100% { box-shadow: 0 5px 0 var(--go-deep), 0 0 0 0 rgba(22, 163, 74, 0.45); }
  50% { box-shadow: 0 5px 0 var(--go-deep), 0 0 0 12px rgba(22, 163, 74, 0); }
}

/* ---------- Level-up modal ---------- */
.level-card { text-align: center; max-width: 420px; overflow: hidden; }
.level-burst {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(160deg, #a78bfa, #6d28d9);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 0 #4c1d95, 0 0 0 10px #fff, 0 0 50px rgba(167, 139, 250, 0.8);
  animation: badgeIn 0.9s cubic-bezier(.3, 1.6, .5, 1);
}
.level-burst span { font-weight: 900; letter-spacing: 0.2em; font-size: 0.8rem; }
.level-burst strong { font-family: var(--font-display); font-size: 4rem; line-height: 1; }
.celebrate-xp { position: relative; margin-top: 10px; font-weight: 900; color: #7c3aed; animation: popIn 0.6s ease 1.2s both; }

/* ---------- Tools on questions ---------- */
.q-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tool-btn {
  position: relative;
  overflow: hidden;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  font-size: 0.88rem;
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: #f3f1fb;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.12s;
}
.tool-btn:hover { transform: translateY(-2px); }
.tool-help { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #78350f; box-shadow: 0 3px 0 #f59e0b; }
.tool-help::before { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.7) 50%, transparent 70%); transform: translateX(-100%); animation: sheen 3s ease-in-out infinite; }
@keyframes sheen { 60%, 100% { transform: translateX(100%); } }
.link-btn { display: inline-block; margin-top: 8px; border: none; background: none; font: inherit; font-weight: 900; color: #b45309; text-decoration: underline; cursor: pointer; }
.step-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.step-top .step-header-tag { margin-bottom: 0; }
.quiz-card-top { gap: 10px; flex-wrap: wrap; }
.q-help { margin-top: 16px; }
.q-opt-btn, .option-btn { position: relative; overflow: hidden; animation: optIn 0.4s both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes optIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.q-opt-btn.correct, .option-btn.selected-correct { animation: popIn 0.4s ease; }

/* ---------- Ripple ---------- */
.btn, .icon-btn, .avatar-opt, .station-pill, .pp-btn, .say-card { position: relative; overflow: hidden; }
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  transform: scale(0);
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
}
.btn-ghost .ripple, .q-opt-btn .ripple, .option-btn .ripple, .icon-btn .ripple, .say-card .ripple, .avatar-opt .ripple, .station-pill .ripple { background: rgba(124, 58, 237, 0.18); }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- Pip's typing bubble ---------- */
#pipSpeech.typing::after { content: "▍"; color: var(--zone); animation: caret 0.6s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* ---------- Story extras ---------- */
.story-video { margin-bottom: 20px; }
.ff-say { font-size: 0.85rem; font-weight: 800; background: rgba(255, 255, 255, 0.22); padding: 2px 10px; border-radius: 99px; }
.ff-main .frac { font-size: 1.05em; }
.fb-main .frac, .fb-mid .frac { font-size: 0.9em; }
.say-panel { margin-top: 22px; border-radius: var(--r-lg); padding: 16px; background: linear-gradient(135deg, #eff6ff, #f5f3ff); box-shadow: inset 0 0 0 2px #dbeafe; }
.say-head h4 { font-size: 1.2rem; color: #1e3a8a; }
.say-head p { color: var(--ink-soft); font-weight: 700; font-size: 0.92rem; margin: 2px 0 12px; }
.say-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.say-card {
  border: none;
  cursor: pointer;
  background: #fff;
  border-radius: var(--r-md);
  padding: 12px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font: inherit;
  color: var(--ink);
  box-shadow: 0 4px 0 #dbeafe, inset 0 0 0 2px #dbeafe;
  transition: transform 0.15s;
}
.say-card:hover { transform: translateY(-3px) rotate(-1deg); }
.say-token { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; color: #1d4ed8; }
.say-words { font-weight: 800; font-size: 0.88rem; color: var(--ink-soft); text-align: center; }
.say-icon { font-size: 0.9rem; opacity: 0.7; }

/* ==========================================================================
   PIP PLAYER (video-style explainer)
   ========================================================================== */
.pp { border-radius: var(--r-lg); overflow: hidden; background: #1e1b4b; box-shadow: var(--shadow-md); animation: stageIn 0.4s ease; }
.pp-screen {
  position: relative;
  aspect-ratio: 16 / 8;
  min-height: 230px;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.85), transparent 45%),
    linear-gradient(160deg, var(--zone-soft), #fff 55%, var(--zone-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.pp-compact .pp-screen { aspect-ratio: 16 / 7.5; min-height: 210px; }
.pp-topline { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; z-index: 2; }
.pp-title { font-weight: 900; font-size: 0.82rem; color: var(--zone-deep); background: rgba(255, 255, 255, 0.85); padding: 4px 10px; border-radius: 99px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-count { font-weight: 900; font-size: 0.8rem; background: var(--zone); color: #fff; padding: 4px 10px; border-radius: 99px; }
.pp-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 40px 70px 14px 14px; }
.pp-scene { animation: sceneIn 0.55s cubic-bezier(.2, .9, .3, 1.2); display: flex; align-items: center; justify-content: center; width: 100%; }
@keyframes sceneIn {
  from { opacity: 0; transform: translateX(30px) scale(0.92); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
.pp-pip { position: absolute; right: 10px; bottom: 6px; width: 70px; height: 70px; z-index: 2; }
.pp-pip .pip-bot { width: 70px; height: 70px; }
.pp-end {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(30, 27, 75, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  animation: fadeIn 0.3s ease;
}
.pp-end-badge { width: 70px; height: 70px; border-radius: 50%; background: var(--go); display: flex; align-items: center; justify-content: center; font-size: 2.2rem; font-weight: 900; box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.25); animation: badgeIn 0.6s cubic-bezier(.3, 1.6, .5, 1); }
.pp-end-text { font-family: var(--font-display); font-size: 1.4rem; }
.pp-caption {
  background: #fff;
  padding: 14px 18px;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--ink);
  min-height: 64px;
  border-top: 3px solid var(--zone-soft);
  animation: fadeIn 0.3s ease;
}
.pp-step-n { display: inline-block; background: var(--zone); color: #fff; font-size: 0.75rem; font-weight: 900; padding: 2px 9px; border-radius: 99px; margin-right: 6px; vertical-align: middle; }
.pp-controls { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: #1e1b4b; }
.pp-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}
.pp-btn:hover { background: rgba(255, 255, 255, 0.25); transform: scale(1.06); }
.pp-play { width: 46px; height: 46px; background: #facc15; color: #1e1b4b; font-size: 1.1rem; box-shadow: 0 3px 0 #b45309; }
.pp-play:hover { background: #fde047; }
.pp-segs { flex: 1; display: flex; gap: 4px; padding: 0 6px; }
.pp-seg { flex: 1; height: 8px; border: none; border-radius: 99px; background: rgba(255, 255, 255, 0.2); padding: 0; cursor: pointer; overflow: hidden; }
.pp-seg span { display: block; height: 100%; width: 0; background: #facc15; border-radius: inherit; }
.pp-seg.is-current { background: rgba(255, 255, 255, 0.32); }
@media (max-width: 600px) {
  .pp-screen { aspect-ratio: auto; min-height: 250px; }
  .pp-stage { padding: 40px 10px 64px; }
  .pp-pip { width: 54px; height: 54px; }
  .pp-pip .pip-bot { width: 54px; height: 54px; }
  .pp-caption { font-size: 1rem; }
  .pp-btn { width: 34px; height: 34px; }
  .pp-play { width: 42px; height: 42px; }
}

/* ==========================================================================
   VISUALS (inside the player)
   ========================================================================== */
.viz { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 100%; }
.viz-label { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; color: var(--ink); text-align: center; display: flex; flex-direction: column; align-items: center; animation: fadeIn 0.6s ease 0.4s both; }
.viz-label small { font-family: var(--font-body); font-size: 0.85rem; color: var(--ink-soft); font-weight: 800; }

/* pie */
.viz-pie { width: 150px; height: 150px; filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.08)); }
.viz-pie .slice { fill: #fff; stroke: var(--zone-deep); stroke-width: 2.5; }
.viz-pie .slice.on { fill: var(--zone); animation: sliceOn 0.5s both; animation-delay: calc(0.25s + var(--i) * 0.18s); transform-origin: 80px 80px; }
@keyframes sliceOn {
  from { fill: #fff; transform: scale(0.85); }
  60% { transform: scale(1.06); }
  to { transform: scale(1); }
}
/* bar */
.viz-bar { display: grid; grid-template-columns: repeat(var(--d), 1fr); gap: 4px; width: min(420px, 80vw); height: 58px; padding: 5px; background: #fff; border-radius: 12px; box-shadow: inset 0 0 0 3px var(--zone-deep); }
.viz-bar span { background: #eeedf7; border-radius: 6px; }
.viz-bar span.on { background: var(--zone); animation: cellOn 0.4s both; animation-delay: calc(0.2s + var(--i) * 0.1s); }
@keyframes cellOn { from { background: #eeedf7; transform: scaleY(0.4); } to { transform: none; } }
/* 100 grid */
.viz-grid100 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; width: 150px; padding: 4px; background: #fff; border-radius: 8px; box-shadow: inset 0 0 0 2px var(--zone-deep); }
.viz-grid100 span { aspect-ratio: 1; background: #eeedf7; border-radius: 2px; }
.viz-grid100 span.on { background: var(--zone); animation: cellOn 0.25s both; animation-delay: calc(0.15s + var(--i) * 12ms); }

/* place value */
.pv-table { display: grid; gap: 4px; }
.pv-row { display: grid; grid-template-columns: repeat(var(--cols), auto); gap: 4px; justify-content: center; }
.pv-h, .pv-d { width: 52px; text-align: center; border-radius: 8px; }
.pv-h { font-weight: 900; font-size: 0.8rem; color: var(--ink-soft); background: rgba(255, 255, 255, 0.85); padding: 3px 0; }
.pv-d { font-family: var(--font-display); font-size: 2rem; font-weight: 600; background: #fff; box-shadow: inset 0 0 0 2px var(--line); height: 54px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pv-d.is-hl { background: #fef3c7; box-shadow: inset 0 0 0 3px #f59e0b; color: #b45309; animation: hlPulse 1.2s ease 0.3s 2; }
@keyframes hlPulse { 50% { transform: scale(1.15); } }
.pv-pt { width: 14px; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--coral); font-weight: 900; }
.shift-arrow { text-align: center; font-weight: 900; color: var(--zone-deep); background: var(--zone-soft); border-radius: 99px; padding: 3px 12px; margin: 4px auto; font-size: 0.9rem; }
.pv-after .pv-d b { display: block; }
.pv-after .pv-d b.slide { animation: digitSlide 1s cubic-bezier(.5, 0, .2, 1) 0.6s both; color: var(--go-deep); }
.pv-after .pv-d b.ghost0 { animation: popIn 0.5s ease 1.5s both; color: #7c3aed; }
@keyframes digitSlide {
  from { transform: translateX(calc(var(--from) * 56px)); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
@media (max-width: 600px) {
  .pv-h, .pv-d { width: 38px; }
  .pv-d { font-size: 1.5rem; height: 44px; }
  @keyframes digitSlide { from { transform: translateX(calc(var(--from) * 42px)); opacity: 0.4; } to { transform: none; opacity: 1; } }
}

/* number line */
.viz-nl svg { width: min(470px, 86vw); height: auto; overflow: visible; }
.viz-nl .axis { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.viz-nl line { stroke: var(--ink); stroke-width: 2.5; }
.viz-nl line.mid { stroke: #f59e0b; stroke-width: 3; stroke-dasharray: 4 3; }
.viz-nl text { font-family: var(--font-display); font-weight: 600; font-size: 17px; fill: var(--ink); }
.viz-nl .mid-t { fill: #b45309; font-size: 13px; }
.viz-nl .mid-s { fill: #b45309; font-size: 11px; font-weight: 800; }
.viz-nl .target { fill: var(--go); opacity: 0; animation: targetIn 0.5s ease 1.6s forwards; }
@keyframes targetIn { from { opacity: 0; r: 2; } to { opacity: 0.45; } }
.viz-nl .marker { transform: translate(var(--x), 70px); animation: markerIn 1s cubic-bezier(.3, 1.3, .5, 1) 0.2s both; }
.viz-nl .marker path { fill: var(--coral); }
.viz-nl .marker text { fill: var(--coral); font-size: 18px; }
@keyframes markerIn { from { transform: translate(30px, 70px); opacity: 0; } to { transform: translate(var(--x), 70px); opacity: 1; } }
.viz-nl .hop { fill: none; stroke: var(--go); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 0.8s ease 1.2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* bus stop */
.viz-bs { font-family: var(--font-display); font-size: 2.3rem; font-weight: 600; align-items: flex-start; }
.bs-roof, .bs-num { display: grid; grid-template-columns: repeat(var(--n), 44px); text-align: center; }
.bs-roof { margin-left: 58px; border-bottom: 5px solid var(--ink); color: var(--go-deep); min-height: 1.3em; }
.bs-roof i { color: #cbd5e1; font-style: normal; }
.bs-c { position: relative; }
.bs-c.pop { animation: popIn 0.6s ease; }
.bs-body { display: flex; }
.bs-div { width: 58px; text-align: center; border-right: 5px solid var(--ink); color: var(--coral); }
.bs-carry { position: absolute; left: 0; top: 2px; font-size: 0.42em; color: var(--coral); animation: popIn 0.5s ease; }
@media (max-width: 600px) {
  .viz-bs { font-size: 1.8rem; }
  .bs-roof, .bs-num { grid-template-columns: repeat(var(--n), 34px); }
  .bs-roof { margin-left: 44px; }
  .bs-div { width: 44px; }
}

/* column multiplication */
.viz-col { font-family: var(--font-display); font-weight: 600; font-size: 2rem; align-items: stretch; }
.col-row { display: grid; grid-template-columns: repeat(var(--w), 38px); text-align: center; }
.col-carry { font-size: 0.55em; color: var(--coral); min-height: 1em; }
.col-c.op { color: var(--zone-deep); }
.col-line { height: 4px; background: var(--ink); border-radius: 2px; margin: 2px 0; }
.col-res .on { color: var(--go-deep); animation: popIn 0.5s ease; }
.col-res .off { color: #cbd5e1; }
.viz-col .viz-label { font-size: 1.1rem; }

/* compare with ghost zeros */
.viz-cmp { gap: 6px; }
.cmp-row {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.9rem;
  background: #fff;
  border-radius: 12px;
  padding: 2px 18px;
  box-shadow: inset 0 0 0 2px var(--line);
  animation: stageIn 0.4s both;
  animation-delay: calc(var(--i) * 120ms);
  position: relative;
}
.cmp-int { min-width: 1.4ch; text-align: right; }
.cmp-pt { color: var(--coral); }
.cmp-dec { letter-spacing: 2px; min-width: 3.4ch; }
.cmp-dec .ghost { color: #a78bfa; animation: ghostIn 0.6s ease 0.8s both; }
@keyframes ghostIn { from { opacity: 0; transform: translateY(-8px); display: inline-block; } to { opacity: 1; } }
.cmp-row.is-best { box-shadow: inset 0 0 0 3px var(--go); background: var(--go-soft); color: var(--go-deep); }
.cmp-crown { position: absolute; right: -12px; top: -16px; font-size: 1.4rem; animation: popIn 0.6s ease 0.9s both; }

/* coins */
.coin-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 380px; }
.vcoin {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 0.9rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15), 0 3px 0 rgba(0, 0, 0, 0.15);
  animation: coinDrop 0.5s cubic-bezier(.3, 1.6, .5, 1) both;
  animation-delay: calc(0.1s + var(--i) * 0.1s);
}
@keyframes coinDrop { from { transform: translateY(-40px) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
.c-L2 { background: radial-gradient(circle at 35% 30%, #fff7cc, #d4a017); color: #5b3b00; box-shadow: inset 0 0 0 5px #cbd5e1, 0 3px 0 rgba(0, 0, 0, 0.2); }
.c-L1 { background: radial-gradient(circle at 35% 30%, #fef9c3, #facc15); color: #713f12; }
.c-50p, .c-20p { background: radial-gradient(circle at 35% 30%, #fff, #cbd5e1); color: #334155; border-radius: 28%; }
.c-10p, .c-5p { background: radial-gradient(circle at 35% 30%, #fff, #94a3b8); color: #1e293b; }
.c-5p { width: 42px; height: 42px; }
.c-2p, .c-1p { background: radial-gradient(circle at 35% 30%, #ffedd5, #ea8a4b); color: #7c2d12; }
.c-1p { width: 42px; height: 42px; }

/* big text / emoji */
.viz-big {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 6vw, 3.2rem);
  color: var(--zone-deep);
  text-align: center;
  animation: bigIn 0.7s cubic-bezier(.3, 1.6, .5, 1);
  line-height: 1.25;
}
.viz-big.is-long { font-size: clamp(1.3rem, 3.6vw, 2rem); }
@keyframes bigIn { from { transform: scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
.viz-emoji { font-size: 5.5rem; animation: bigIn 0.7s cubic-bezier(.3, 1.6, .5, 1), bob 3s ease-in-out 0.7s infinite; }

/* UK say-it line inside labs */
.say-line {
  display: block;
  width: 100%;
  margin-top: 14px;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: center;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  color: var(--ink-soft);
  font-weight: 700;
  box-shadow: inset 0 0 0 2px #dbeafe;
}
.say-line strong { color: #1d4ed8; }

.stop-sheet .modal-close { z-index: 5; background: rgba(255, 255, 255, 0.9); }
.sheet-actions { position: sticky; bottom: 0; background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 30%); padding-top: 22px; }
.stop-sheet { max-height: 94vh; }

.pp-count { white-space: nowrap; flex-shrink: 0; }
.lesson-kicker { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .pip-banner .speech-bubble { font-size: 0.95rem; padding: 10px 14px; }
  .lesson-topbar .btn-ghost { padding: 9px 12px; }
}

.pp-stage { overflow: hidden; }
.pp-scene .viz { flex-shrink: 0; }
.pp-segs { min-width: 60px; }
@media (max-width: 600px) {
  .pp-stage { padding: 40px 8px 60px; }
}
.pp-scene .viz { max-width: none; }

/* aspect-ratio + min-height would force a min-width (overflow on phones): use a fluid height instead */
.pp-screen, .pp-compact .pp-screen { aspect-ratio: auto; min-height: 0; height: clamp(240px, 40vw, 340px); }
.pp-compact .pp-screen { height: clamp(230px, 36vw, 300px); }
.pp, .q-help, .story-video { min-width: 0; max-width: 100%; }
@media (max-width: 420px) {
  .station-flag { display: none; }
  .station-track { padding: 0 10px; }
}
.level-card .modal-actions { justify-content: center; position: relative; }

/* flow: 1/2 = 1 ÷ 2 = 0.5 */
.viz-flow { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; }
.flow-box {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #fff; border-radius: 16px; padding: 10px 16px; min-width: 90px;
  box-shadow: inset 0 0 0 3px var(--zone), 0 5px 0 var(--zone-soft);
  animation: bigIn 0.6s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--i) * 0.55s);
}
.flow-val { font-family: var(--font-display); font-weight: 600; font-size: 2.1rem; color: var(--zone-deep); line-height: 1.1; }
.flow-box small { font-weight: 800; font-size: 0.78rem; color: var(--ink-soft); text-align: center; max-width: 150px; }
.flow-eq { font-family: var(--font-display); font-size: 2rem; color: var(--sun); font-weight: 700; animation: popIn 0.4s both; animation-delay: calc(var(--i) * 0.55s - 0.2s); }
/* people sharing */
.viz-people { display: flex; gap: 6px; font-size: 1.9rem; margin-top: -4px; }
.viz-people span { animation: coinDrop 0.5s both; animation-delay: calc(0.3s + var(--i) * 0.12s); }
/* caption with explanation */
.pp-cap-head { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--zone-deep); }
.pp-cap-say { margin-top: 6px; font-weight: 700; color: var(--ink); font-size: 1.02rem; line-height: 1.45; }
@media (max-width: 600px) { .flow-val { font-size: 1.6rem; } .flow-box { min-width: 70px; padding: 8px 10px; } .pp-cap-say { font-size: 0.95rem; } }
/* say-it alternatives */
.say-alt { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-align: center; line-height: 1.3; }
.say-tip small { display: block; font-weight: 700; opacity: 0.8; font-size: 0.8rem; margin-top: 2px; white-space: normal; max-width: 280px; }
.say-tip { white-space: normal; text-align: center; max-width: 320px; }
.ff-alt { font-size: 0.72rem; opacity: 0.85; font-weight: 700; }
/* fact explainer under the flip cards */
.fact-explain { margin-top: 16px; scroll-margin-top: 140px; }
.fact-explain:empty { display: none; }
.fb-play { font-size: 0.78rem; font-weight: 900; color: var(--zone-deep); background: var(--zone-soft); padding: 3px 10px; border-radius: 99px; margin-top: 4px; }

/* ---------- English visuals ---------- */
.viz-sentence { max-width: 100%; }
.sx-line { font-family: var(--font-display); font-size: 1.7rem; font-weight: 500; line-height: 2.6; text-align: center; color: var(--ink); }
.sx-part { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; margin: 0 2px; animation: bigIn 0.6s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--i) * 0.35s); }
.sx-t { background: color-mix(in srgb, var(--c) 18%, #fff); color: var(--c); border-radius: 10px; padding: 0 8px; line-height: 1.5; box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--c) 35%, #fff); font-weight: 600; }
.sx-part small { font-family: var(--font-body); font-size: 0.72rem; font-weight: 900; color: var(--c); line-height: 1.2; text-transform: uppercase; letter-spacing: 0.04em; }
.viz-word { gap: 6px; }
.wb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wb-part { display: flex; flex-direction: column; align-items: center; background: #fff; border-radius: 14px; padding: 8px 14px; box-shadow: inset 0 0 0 3px var(--zone), 0 4px 0 var(--zone-soft); animation: bigIn 0.5s both; animation-delay: calc(var(--i) * 0.4s); }
.wb-part span { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; color: var(--zone-deep); }
.wb-part small { font-size: 0.72rem; font-weight: 900; color: var(--ink-soft); text-transform: uppercase; }
.wb-plus, .wb-eq { font-family: var(--font-display); font-size: 1.8rem; color: var(--sun); font-weight: 700; }
.wb-whole { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; color: var(--go-deep); animation: popIn 0.6s ease 1.2s both; }
.viz-quote blockquote { font-family: Georgia, 'Times New Roman', serif; font-size: 1.35rem; line-height: 1.5; color: var(--ink); background: #fffdf5; border-left: 6px solid var(--zone); padding: 14px 18px; border-radius: 12px; max-width: 520px; box-shadow: var(--shadow-sm); }
.viz-quote cite { font-weight: 800; color: var(--ink-soft); font-size: 0.85rem; }

/* ---------- Data-driven labs ---------- */
.qf-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.qf-count { font-weight: 900; color: var(--zone-deep); background: var(--zone-soft); padding: 4px 12px; border-radius: 99px; }
.qf-streak { font-weight: 900; font-size: 1.1rem; }
.qf-q { font-family: var(--font-display); font-size: 1.5rem; text-align: center; margin: 10px 0 16px; }
.qf-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.qf-opt { border: none; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.1rem; padding: 14px; border-radius: var(--r-md); background: #fff; color: var(--ink); box-shadow: inset 0 0 0 3px var(--line), 0 4px 0 var(--line); }
.qf-opt.ok { background: var(--go-soft); box-shadow: inset 0 0 0 3px var(--go); animation: popIn 0.4s ease; }
.qf-opt.no { background: var(--coral-soft); opacity: 0.6; animation: shake 0.4s ease; }
.qf-fb { margin-top: 12px; text-align: center; font-weight: 800; min-height: 1.5em; }
.ws-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 18px; min-height: 48px; }
.ws-word { border: none; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.05rem; padding: 10px 16px; border-radius: 99px; background: #fff; color: var(--ink); box-shadow: inset 0 0 0 3px var(--line), 0 3px 0 var(--line); }
.ws-word.sel { box-shadow: inset 0 0 0 3px var(--zone), 0 3px 0 var(--zone-deep); transform: translateY(-3px); }
.ws-word.placed { background: var(--go-soft); box-shadow: inset 0 0 0 2px var(--go); cursor: default; }
.ws-buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.ws-bucket { background: var(--zone-soft); border-radius: var(--r-lg); padding: 12px; min-height: 120px; cursor: pointer; border: 3px dashed var(--zone); }
.ws-bucket-title { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; color: var(--zone-deep); text-align: center; margin-bottom: 8px; }
.ws-bucket-words { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.sb { text-align: center; }
.sb-play { margin: 8px auto 12px; }
.sb-sentence { font-size: 1.15rem; font-weight: 700; color: var(--ink-soft); min-height: 1.6em; }
.sb-row { display: flex; gap: 10px; max-width: 460px; margin: 12px auto 0; }
.sb-input { font-family: var(--font-display); font-size: 1.5rem; text-align: center; letter-spacing: 0.06em; }
