/* ==========================================================================
   FDP QUEST — Fractions, Decimals & Percentages
   Playful journey theme for Year 6 SATs (Year 4 cognitive accessibility):
   big targets, high contrast, one thing at a time, lots of feedback.
   ========================================================================== */

:root {
  --ink: #26214a;
  --ink-soft: #5b5683;
  --muted: #8a86a8;
  --line: #e6e3f5;
  --paper: #ffffff;
  --cream: #fffaf0;
  --sky-1: #dff3ff;
  --sky-2: #f3ecff;

  --violet: #7c3aed;
  --violet-deep: #5b21b6;
  --violet-soft: #ede9fe;
  --go: #16a34a;
  --go-deep: #15803d;
  --go-soft: #dcfce7;
  --sun: #f59e0b;
  --sun-soft: #fef3c7;
  --gold: #fbbf24;
  --coral: #ef4444;
  --coral-soft: #fee2e2;
  --sea: #0ea5e9;
  --sea-soft: #e0f2fe;
  --pink: #ec4899;

  /* zone theme (overridden per land) */
  --zone: #7c3aed;
  --zone-deep: #5b21b6;
  --zone-soft: #ede9fe;
  --zone-bg: linear-gradient(180deg, #f5f3ff, #ede9fe);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-full: 999px;

  --shadow-sm: 0 2px 6px rgba(38, 33, 74, 0.08);
  --shadow-md: 0 8px 24px rgba(38, 33, 74, 0.10);
  --shadow-lg: 0 18px 50px rgba(38, 33, 74, 0.18);
  --press: 0 5px 0 rgba(38, 33, 74, 0.18);

  --font-display: "Fredoka", ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.theme-forest, .zone-forest { --zone: #16a34a; --zone-deep: #166534; --zone-soft: #dcfce7; --zone-bg: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%); }
.theme-factory, .zone-factory { --zone: #2563eb; --zone-deep: #1e3a8a; --zone-soft: #dbeafe; --zone-bg: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%); }
.theme-ridge, .zone-ridge { --zone: #ea580c; --zone-deep: #9a3412; --zone-soft: #ffedd5; --zone-bg: linear-gradient(180deg, #fff7ed 0%, #fed7aa 100%); }
.theme-fair, .zone-fair { --zone: #db2777; --zone-deep: #9d174d; --zone-soft: #fce7f3; --zone-bg: linear-gradient(180deg, #fdf2f8 0%, #fbcfe8 100%); }
.theme-castle, .zone-castle { --zone: #7c3aed; --zone-deep: #4c1d95; --zone-soft: #ede9fe; --zone-bg: linear-gradient(180deg, #f5f3ff 0%, #ddd6fe 100%); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 60%, #fff 100%) fixed;
  background-color: var(--sky-1);
  line-height: 1.5;
  font-size: 17px;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; }
button { font-family: inherit; }
[hidden] { display: none !important; }

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

/* ==========================================================================
   SCREENS
   ========================================================================== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; animation: screenIn 0.4s ease; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ==========================================================================
   BUTTONS & COMMON
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--violet);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 11px 20px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--violet-deep);
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s, filter 0.15s;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--violet-deep); }
.btn:disabled { background: #d6d3e6; color: #8f8ba8; box-shadow: 0 4px 0 #bdb9d3; cursor: not-allowed; transform: none; filter: none; }
.btn small { font-weight: 700; opacity: 0.85; font-size: 0.75rem; }

.btn-sm { padding: 7px 13px; font-size: 0.88rem; border-radius: var(--r-sm); box-shadow: 0 3px 0 var(--violet-deep); }
.btn-lg { padding: 14px 26px; font-size: 1.1rem; }
.btn-xl { padding: 18px 34px; font-size: 1.3rem; border-radius: var(--r-lg); font-family: var(--font-display); font-weight: 600; }

.btn-go { background: var(--go); box-shadow: 0 5px 0 var(--go-deep); }
.btn-go:active { box-shadow: 0 1px 0 var(--go-deep); }

.btn-ghost, .btn-outline {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--line), inset 0 0 0 2px var(--line);
}
.btn-ghost:active, .btn-outline:active { box-shadow: inset 0 0 0 2px var(--line); }
.btn-outline.active, .btn.active { background: var(--violet); color: #fff; box-shadow: 0 3px 0 var(--violet-deep); }

.btn-danger-ghost { background: #fff; color: var(--coral); box-shadow: 0 3px 0 var(--coral-soft), inset 0 0 0 2px var(--coral-soft); }

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--r-full);
  border: none;
  background: #fff;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line), inset 0 0 0 2px var(--line);
  transition: transform 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { transform: scale(1.07); }
.icon-btn.is-off { opacity: 0.6; }
.icon-btn-soft { width: 40px; height: 40px; font-size: 1.1rem; background: var(--zone-soft); box-shadow: none; }

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-full);
  font-weight: 900;
  font-size: 1rem;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--line);
}
.stat-pill .stat-of { color: var(--muted); font-weight: 800; font-size: 0.85rem; }
.stars-pill { background: var(--sun-soft); color: #92400e; box-shadow: inset 0 0 0 2px #fde68a; }
.badges-pill { background: var(--violet-soft); color: var(--violet-deep); box-shadow: inset 0 0 0 2px #ddd6fe; }

.muted { color: var(--ink-soft); font-weight: 600; }

.pip-bot {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #e0e7ff 70%);
  box-shadow: 0 0 0 4px #fff, 0 6px 14px rgba(38, 33, 74, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  animation: bob 3s ease-in-out infinite;
}
.pip-bot-lg { width: 96px; height: 96px; font-size: 60px; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}

.speech-bubble {
  position: relative;
  background: #fff;
  border-radius: var(--r-lg);
  padding: 14px 18px;
  font-weight: 700;
  box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--line);
  color: var(--ink);
}
.speech-bubble-left::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 22px;
  width: 18px;
  height: 18px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: -2px 2px 0 var(--line);
}

.text-input {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 3px solid var(--line);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--violet); outline: none; }

.field-label { display: block; font-weight: 900; color: var(--ink-soft); margin: 18px 0 8px; font-size: 0.95rem; }

.shake { animation: shake 0.45s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.avatar-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 8px; }
.avatar-opt {
  width: 100%;
  aspect-ratio: 1;
  font-size: 32px;
  border-radius: var(--r-md);
  border: none;
  background: #fff;
  cursor: pointer;
  box-shadow: inset 0 0 0 3px var(--line);
  transition: transform 0.12s, box-shadow 0.12s;
}
.avatar-opt:hover { transform: translateY(-3px) rotate(-4deg); }
.avatar-opt.selected { box-shadow: inset 0 0 0 4px var(--violet), 0 6px 14px rgba(124, 58, 237, 0.25); background: var(--violet-soft); transform: scale(1.06); }

/* ==========================================================================
   WELCOME SCREEN
   ========================================================================== */
#screenWelcome.active { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }

.welcome-card {
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: var(--r-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: left;
}
.welcome-pip { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.welcome-pip .speech-bubble { flex: 1; font-size: 1.05rem; }

.welcome-title {
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 700;
  color: var(--violet-deep);
  letter-spacing: -1px;
  text-align: center;
}
.welcome-title span {
  background: linear-gradient(90deg, #f59e0b, #ec4899, #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome-sub { text-align: center; color: var(--ink-soft); font-weight: 800; letter-spacing: 1px; margin-bottom: 18px; }

.how-it-works {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 8px 0 6px;
}
.how-it-works li {
  background: var(--cream);
  border-radius: var(--r-md);
  padding: 10px 6px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: inset 0 0 0 2px #fdecc8;
}
.hiw-icon { font-size: 1.6rem; }

#btnStartJourney { width: 100%; margin-top: 24px; }

@media (max-width: 480px) {
  .how-it-works { grid-template-columns: repeat(2, 1fr); }
  .welcome-card { padding: 24px 18px; }
}

/* ==========================================================================
   MAP SCREEN
   ========================================================================== */
.map-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 0 var(--line);
  flex-wrap: wrap;
}
.explorer-chip { display: flex; align-items: center; gap: 12px; min-width: 0; }
.explorer-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--sun-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--gold);
  flex-shrink: 0;
}
.explorer-hello { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; color: var(--violet-deep); }
.explorer-sub { font-size: 0.9rem; color: var(--ink-soft); font-weight: 700; }

.journey-progress { flex: 1; min-width: 160px; max-width: 360px; margin-left: auto; }
.jp-label { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 900; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.jp-label strong { color: var(--go-deep); }
.jp-track { height: 14px; border-radius: var(--r-full); background: #eceaf6; overflow: hidden; box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.06); }
.jp-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #facc15, #f97316, #ec4899, #8b5cf6);
  background-size: 400px 100%;
  transition: width 1s cubic-bezier(.2, .8, .2, 1);
}

.header-stats { display: flex; align-items: center; gap: 8px; }

@media (max-width: 900px) {
  .map-header { gap: 10px; padding: 10px 14px; }
  .journey-progress { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .header-stats { margin-left: auto; }
  .explorer-hello { font-size: 1.1rem; }
}

.map-scroll { padding: 24px 16px 80px; }
.map-world {
  position: relative;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.map-path-svg { position: absolute; inset: 0; pointer-events: none; z-index: 1; overflow: visible; }
.trail-base { fill: none; stroke: rgba(255, 255, 255, 0.9); stroke-width: 22; stroke-linecap: round; }
.trail-dash { fill: none; stroke: #c9c3e3; stroke-width: 5; stroke-dasharray: 2 14; stroke-linecap: round; }
.trail-done { fill: none; stroke: var(--gold); stroke-width: 9; stroke-linecap: round; filter: drop-shadow(0 2px 0 #d97706); }

.zone {
  position: relative;
  border-radius: var(--r-xl);
  background: var(--zone-bg);
  padding: 20px 18px 28px;
  box-shadow: var(--shadow-md), inset 0 0 0 3px rgba(255, 255, 255, 0.7);
  overflow: hidden;
}
/* No filter/opacity on .zone itself: that would create a stacking context and push the land under the trail */
.zone-locked .zone-scenery { filter: grayscale(0.7); opacity: 0.7; }
.zone-locked .zone-emoji { filter: grayscale(0.6); }

.zone-scenery { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.zone-scenery span {
  position: absolute;
  font-size: 34px;
  opacity: 0.55;
  animation: drift 6s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.8s);
}
.zone-scenery span:nth-child(1) { left: 4%; top: 30%; }
.zone-scenery span:nth-child(2) { right: 5%; top: 24%; }
.zone-scenery span:nth-child(3) { left: 8%; top: 62%; font-size: 40px; }
.zone-scenery span:nth-child(4) { right: 9%; top: 55%; }
.zone-scenery span:nth-child(5) { left: 3%; bottom: 6%; }
.zone-scenery span:nth-child(6) { right: 3%; bottom: 10%; font-size: 40px; }
.zone-scenery span:nth-child(7) { left: 44%; bottom: 2%; font-size: 26px; }
.zone-scenery span:nth-child(8) { right: 30%; top: 40%; font-size: 24px; }

@keyframes drift {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

.zone-sign {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: var(--r-lg);
  padding: 12px 16px;
  box-shadow: 0 5px 0 var(--zone), var(--shadow-sm);
  max-width: 560px;
  margin: 0 auto 8px;
}
.zone-emoji {
  font-size: 34px;
  width: 58px;
  height: 58px;
  border-radius: var(--r-md);
  background: var(--zone-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.zone-sign-text { flex: 1; min-width: 0; }
.zone-kicker { font-size: 0.75rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--zone); }
.zone-sign h3 { font-size: 1.35rem; color: var(--zone-deep); }
.zone-sign p { font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.zone-progress {
  flex-shrink: 0;
  font-weight: 900;
  color: var(--zone-deep);
  background: var(--zone-soft);
  border-radius: var(--r-full);
  padding: 6px 12px;
  font-size: 0.95rem;
}
.zone-progress.is-done { background: var(--sun-soft); color: #92400e; }
.zone-reward-chip { white-space: nowrap; }

.zone-nodes { position: relative; z-index: 2; padding-top: 30px; }
.node-slot { position: relative; height: 158px; }

.map-node {
  position: absolute;
  left: var(--x);
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  width: 170px;
}

.node-orb {
  position: relative;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  box-shadow: 0 7px 0 var(--zone-deep), 0 10px 20px rgba(38, 33, 74, 0.2);
  transition: transform 0.18s cubic-bezier(.3, 1.6, .5, 1);
}
/* progress ring */
.node-orb::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.85) 0);
  z-index: -1;
}
.node-icon { font-size: 42px; line-height: 1; }
.node-lock {
  position: absolute;
  right: -6px;
  bottom: -4px;
  font-size: 22px;
  display: none;
  background: #fff;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.map-node:hover .node-orb { transform: translateY(-4px) scale(1.05); }
.map-node:active .node-orb { transform: translateY(3px); box-shadow: 0 3px 0 var(--zone-deep); }

.node-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--r-md);
  padding: 5px 10px 4px;
  box-shadow: var(--shadow-sm);
  max-width: 170px;
  line-height: 1.2;
}
.node-num { font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--zone); }
.node-title { font-size: 0.86rem; font-weight: 800; text-align: center; color: var(--ink); }
.node-stars { font-size: 0.95rem; color: var(--gold); letter-spacing: 1px; text-shadow: 0 1px 0 #d97706; }
.node-stars .dim { color: #dedbe9; text-shadow: none; }

.node-chip {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translate(-50%, -100%);
  background: var(--go);
  color: #fff;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 4px 12px;
  border-radius: var(--r-full);
  box-shadow: 0 3px 0 var(--go-deep);
  white-space: nowrap;
}

/* node states */
.state-locked { cursor: not-allowed; }
.state-locked .node-orb { background: #eeedf5; box-shadow: 0 7px 0 #c9c6db; }
.state-locked .node-icon { filter: grayscale(1); opacity: 0.45; }
.state-locked .node-lock { display: flex; }
.state-locked .node-label { opacity: 0.75; }

.state-done .node-orb { background: linear-gradient(160deg, #fff7d6, #fde68a); }
.state-done .node-chip { background: var(--sun); box-shadow: 0 3px 0 #b45309; }

.state-current .node-orb { animation: glow 1.8s ease-in-out infinite; }
.state-current .node-chip { animation: chipBounce 1.2s ease-in-out infinite; }

@keyframes glow {
  0%, 100% { box-shadow: 0 7px 0 var(--zone-deep), 0 0 0 0 rgba(250, 204, 21, 0.7); }
  50% { box-shadow: 0 7px 0 var(--zone-deep), 0 0 0 16px rgba(250, 204, 21, 0); }
}
@keyframes chipBounce {
  0%, 100% { transform: translate(-50%, -100%); }
  50% { transform: translate(-50%, -125%); }
}

.just-unlocked .node-orb { animation: unlockPop 0.8s cubic-bezier(.3, 1.6, .5, 1), glow 1.8s ease-in-out 0.8s infinite; }
@keyframes unlockPop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.node-castle .node-orb { width: 112px; height: 112px; }
.node-castle .node-icon { font-size: 60px; }
.zone-castle .node-slot { height: 200px; }

/* explorer token that walks the path */
.map-token {
  position: absolute;
  z-index: 4;
  width: 50px;
  height: 50px;
  margin-left: 38px;
  margin-top: -62px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: #fff;
  border-radius: 50% 50% 50% 8px;
  box-shadow: 0 0 0 3px var(--gold), var(--shadow-md);
  animation: bob 2.4s ease-in-out infinite;
}
.map-token.moving { transition: left 1.1s cubic-bezier(.45, 0, .2, 1), top 1.1s cubic-bezier(.45, 0, .2, 1); }

@media (max-width: 600px) {
  .map-header { position: static; }
  .node-slot { height: 182px; }
  .map-node { width: 140px; }
  .node-label { max-width: 140px; }
  .node-orb { width: 74px; height: 74px; }
  .node-icon { font-size: 36px; }
  .zone-sign { gap: 10px; padding: 10px 12px; }
  .zone-emoji { width: 46px; height: 46px; font-size: 28px; }
  .zone-sign h3 { font-size: 1.1rem; }
  .zone-sign p { display: none; }
  .zone-scenery span { font-size: 24px; }
  .map-token { width: 42px; height: 42px; font-size: 24px; margin-left: 30px; margin-top: -52px; }
}

/* ==========================================================================
   LESSON SCREEN
   ========================================================================== */
#screenLesson { background: var(--zone-bg); background-attachment: fixed; }

.lesson-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 0 var(--line);
}
.lesson-heading { flex: 1; min-width: 0; }
.lesson-kicker { font-size: 0.78rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.07em; color: var(--zone); }
.lesson-title { font-size: 1.35rem; color: var(--zone-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-topbar-right { display: flex; gap: 8px; align-items: center; }

/* station track */
.station-track {
  max-width: 980px;
  margin: 18px auto 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 0;
}
.station-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 8px;
  border-radius: var(--r-full);
  border: none;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 4px 0 #dcd8ec;
  color: var(--ink);
  flex-shrink: 0;
  transition: transform 0.12s;
}
.station-pill:hover { transform: translateY(-2px); }
.sp-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: var(--zone-soft);
  font-weight: 900;
}
.sp-label { display: flex; flex-direction: column; text-align: left; font-weight: 900; font-size: 0.92rem; line-height: 1.15; }
.sp-label small { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.station-pill.is-done .sp-icon { background: var(--go); color: #fff; }
.station-pill.is-current { box-shadow: 0 4px 0 var(--zone-deep), 0 0 0 3px var(--zone); }
.station-pill.is-current .sp-icon { background: var(--zone); color: #fff; }
.station-pill.is-locked { opacity: 0.55; cursor: not-allowed; }
.station-pill.is-locked:hover { transform: none; }

.station-link { flex: 1; height: 6px; min-width: 10px; background: repeating-linear-gradient(90deg, #cfcbe4 0 8px, transparent 8px 14px); border-radius: 3px; margin: 0 4px; }
.station-link.is-done { background: var(--go); }
.station-flag {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 0 #dcd8ec;
  flex-shrink: 0;
}
.station-flag.is-done { background: var(--sun-soft); box-shadow: 0 4px 0 var(--sun); animation: unlockPop 0.7s ease; }

@media (max-width: 720px) {
  .sp-label { display: none; }
  .station-pill { padding: 6px; }
  .station-pill.is-current .sp-label { display: flex; }
  .station-pill.is-current .sp-label small { display: none; }
  .station-flag { width: 38px; height: 38px; font-size: 1.1rem; }
  .station-link { min-width: 6px; margin: 0 2px; }
  .lesson-title { font-size: 1.1rem; }
  .lesson-topbar { padding: 8px 12px; gap: 8px; }
  .lesson-topbar .stars-pill { display: none; }
}

.lesson-body { max-width: 980px; margin: 0 auto; padding: 18px 16px 60px; }

.pip-banner { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.pip-banner .speech-bubble { flex: 1; font-size: 1.05rem; }

.station-stage {
  background: #fff;
  border-radius: var(--r-xl);
  padding: 26px;
  box-shadow: var(--shadow-md);
  min-height: 300px;
}
.stage-enter { animation: stageIn 0.4s cubic-bezier(.2, .8, .2, 1); }
@keyframes stageIn {
  from { opacity: 0; transform: translateY(14px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.station-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.station-hint { font-weight: 800; color: var(--ink-soft); background: rgba(255, 255, 255, 0.8); padding: 10px 16px; border-radius: var(--r-full); }
.station-hint.is-done { color: var(--go-deep); background: var(--go-soft); }
.pulse-once { animation: pulseOnce 1.1s ease; }
@keyframes pulseOnce {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); }
  60% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

@media (max-width: 600px) {
  .station-stage { padding: 18px 14px; border-radius: var(--r-lg); }
  .pip-banner .pip-bot { width: 46px; height: 46px; font-size: 28px; }
  .station-footer .btn { width: 100%; }
}

/* ---------- Station 1: Story ---------- */
.story-card {
  display: flex;
  gap: 22px;
  align-items: center;
  background: var(--zone-soft);
  border-radius: var(--r-lg);
  padding: 20px;
}
.story-scene {
  position: relative;
  width: 130px;
  height: 130px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 0 var(--zone);
}
.scene-main { font-size: 70px; animation: bob 3s ease-in-out infinite; }
.scene-side { position: absolute; left: -10px; bottom: 0; font-size: 34px; }
.scene-side-r { left: auto; right: -12px; top: 4px; bottom: auto; }
.story-headline { font-size: 1.6rem; color: var(--zone-deep); margin-bottom: 6px; }
.story-intro { font-size: 1.12rem; font-weight: 700; color: var(--ink); }

.golden-rule {
  position: relative;
  margin: 22px 0;
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  border-radius: var(--r-lg);
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: inset 0 0 0 3px #fcd34d;
}
.gr-label {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--sun);
  color: #fff;
  font-weight: 900;
  font-size: 0.85rem;
  padding: 4px 14px;
  border-radius: var(--r-full);
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.golden-rule p { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; color: #78350f; }

.flip-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.flip-heading h4 { font-size: 1.15rem; color: var(--ink); }
.flip-count { background: var(--zone-soft); color: var(--zone-deep); font-weight: 900; padding: 4px 12px; border-radius: var(--r-full); }
.flip-count.is-done { background: var(--go); color: #fff; }

.flip-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.flip-card {
  background: none;
  border: none;
  perspective: 900px;
  cursor: pointer;
  min-height: 150px;
}
.flip-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 150px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.3, 1.3, .5, 1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px;
  text-align: center;
}
.flip-front {
  background: linear-gradient(150deg, var(--zone), var(--zone-deep));
  color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
}
.ff-main { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; }
.ff-tap { font-size: 0.8rem; opacity: 0.85; background: rgba(255, 255, 255, 0.2); padding: 2px 10px; border-radius: var(--r-full); }
.flip-back {
  background: #fff;
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 3px var(--zone), 0 6px 0 var(--zone-soft);
}
.fb-mid { font-size: 0.95rem; color: var(--ink-soft); font-weight: 800; }
.fb-main { font-family: var(--font-display); font-size: 1.45rem; color: var(--go-deep); font-weight: 600; line-height: 1.15; }
.fb-note { font-size: 0.85rem; color: var(--muted); font-weight: 700; }

.pip-tip {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 22px;
  background: var(--go-soft);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  color: #14532d;
}
.pip-tip-icon { font-size: 1.8rem; }
.pip-tip p { font-weight: 700; }

@media (max-width: 600px) {
  .story-card { flex-direction: column; text-align: center; }
  .story-scene { width: 104px; height: 104px; }
  .scene-main { font-size: 56px; }
  .golden-rule p { font-size: 1.1rem; }
}

/* ---------- Station 2: Lab ---------- */
.lab-intro {
  background: var(--zone-soft);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  margin-bottom: 18px;
}
.lab-intro h3 { color: var(--zone-deep); font-size: 1.3rem; }
.lab-intro p { color: var(--ink-soft); font-weight: 700; }

.explore-meter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  background: var(--cream);
  border-radius: var(--r-full);
  padding: 10px 16px;
  box-shadow: inset 0 0 0 2px #fdecc8;
}
.em-label { font-weight: 900; color: #92400e; white-space: nowrap; }
.em-track { flex: 1; height: 14px; background: #fff; border-radius: var(--r-full); overflow: hidden; box-shadow: inset 0 0 0 2px #fdecc8; }
.em-fill { height: 100%; background: linear-gradient(90deg, #facc15, #f97316); border-radius: inherit; transition: width 0.4s cubic-bezier(.3, 1.4, .5, 1); }
.em-count { font-weight: 900; color: #92400e; min-width: 54px; text-align: right; }
.explore-meter.is-done { background: var(--go-soft); box-shadow: inset 0 0 0 2px #86efac; }
.explore-meter.is-done .em-fill { background: var(--go); }
.explore-meter.is-done .em-label, .explore-meter.is-done .em-count { color: var(--go-deep); }

/* ---------- Station 3: Trainer ---------- */
.trainer-q {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--zone-soft);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.trainer-q-icon { font-size: 2rem; }
.trainer-q p { font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; color: var(--zone-deep); }

.step-dots { display: flex; align-items: center; justify-content: center; margin: 18px 0 6px; }
.step-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  background: #efedf8;
  color: var(--muted);
  transition: all 0.25s;
}
.step-dot.is-current { background: var(--zone); color: #fff; transform: scale(1.15); }
.step-dot.is-done { background: var(--go); color: #fff; }
.step-dot-link { width: 34px; height: 4px; background: #e6e3f5; border-radius: 2px; }

.trainer-step-box {
  border-radius: var(--r-lg);
  padding: 20px;
  margin-top: 16px;
  box-shadow: inset 0 0 0 3px var(--line);
  animation: stageIn 0.4s ease;
}
.trainer-step-box.is-solved { box-shadow: inset 0 0 0 3px #86efac; background: #fbfffc; }
.step-header-tag {
  display: inline-block;
  background: var(--zone-soft);
  color: var(--zone-deep);
  font-weight: 900;
  padding: 3px 12px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.step-prompt { font-size: 1.15rem; font-weight: 800; }
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 14px 0 0; }
.option-btn {
  background: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 15px 14px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--line), 0 4px 0 var(--line);
  transition: transform 0.1s, box-shadow 0.1s;
}
.option-btn:hover:not(:disabled) { box-shadow: inset 0 0 0 3px var(--zone), 0 4px 0 var(--zone-soft); transform: translateY(-2px); }
.option-btn:disabled { cursor: default; opacity: 0.55; }
.option-btn.selected-correct { background: var(--go-soft); box-shadow: inset 0 0 0 3px var(--go), 0 4px 0 #86efac; color: #14532d; opacity: 1; animation: popIn 0.4s ease; }
.option-btn.selected-incorrect { background: var(--coral-soft); box-shadow: inset 0 0 0 3px #fca5a5; color: #991b1b; animation: shake 0.4s ease; }

@keyframes popIn {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.step-feedback { margin-top: 14px; padding: 12px 16px; border-radius: var(--r-md); font-weight: 800; }
.feedback-success { background: var(--go-soft); color: #14532d; }
.feedback-retry { background: #fff7ed; color: #9a3412; }
.trainer-finish {
  margin-top: 18px;
  text-align: center;
  background: linear-gradient(90deg, #fef3c7, #dcfce7);
  border-radius: var(--r-lg);
  padding: 16px;
  font-size: 1.1rem;
  animation: popIn 0.5s ease;
}

/* ---------- Station 4: Challenge quiz ---------- */
.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.quiz-head h3 { font-size: 1.4rem; color: var(--zone-deep); }
.quiz-dots { display: flex; gap: 8px; flex-wrap: wrap; }
.quiz-dot { width: 18px; height: 18px; border-radius: 50%; background: #e9e6f5; transition: all 0.25s; }
.quiz-dot.is-current { background: var(--zone); transform: scale(1.25); box-shadow: 0 0 0 4px var(--zone-soft); }
.quiz-dot.is-done { background: var(--gold); box-shadow: 0 2px 0 #d97706; }
.quiz-dot.is-retry { background: #a7f3d0; }

.quiz-card { border-radius: var(--r-lg); padding: 22px; box-shadow: inset 0 0 0 3px var(--line); }
.quiz-card-top { display: flex; justify-content: space-between; align-items: center; }
.q-badge { background: var(--zone-soft); color: var(--zone-deep); font-weight: 900; padding: 4px 12px; border-radius: var(--r-full); font-size: 0.85rem; }
.q-body { display: flex; align-items: center; gap: 16px; margin: 16px 0 18px; }
.q-emoji {
  font-size: 46px;
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  border-radius: var(--r-lg);
  background: var(--zone-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-text { font-family: var(--font-display); font-size: 1.4rem; font-weight: 500; color: var(--ink); }

.q-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 600px) {
  .q-options { grid-template-columns: 1fr; }
  .q-text { font-size: 1.2rem; }
  .q-emoji { width: 60px; height: 60px; font-size: 36px; }
}
.q-opt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--line), 0 4px 0 var(--line);
  transition: transform 0.1s, box-shadow 0.12s;
}
.q-opt-btn:hover:not(:disabled) { box-shadow: inset 0 0 0 3px var(--zone), 0 4px 0 var(--zone-soft); transform: translateY(-2px); }
.q-opt-btn:disabled { cursor: default; opacity: 0.5; }
.q-letter {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--zone-soft);
  color: var(--zone-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.q-opt-btn.correct { background: var(--go-soft); box-shadow: inset 0 0 0 3px var(--go), 0 4px 0 #86efac; color: #14532d; opacity: 1; animation: popIn 0.4s ease; }
.q-opt-btn.correct .q-letter { background: var(--go); color: #fff; }
.q-opt-btn.wrong { background: var(--coral-soft); box-shadow: inset 0 0 0 3px #fca5a5; color: #991b1b; animation: shake 0.4s ease; }
.q-opt-btn.wrong .q-letter { background: #fca5a5; color: #fff; }

.q-feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-md); font-weight: 700; animation: stageIn 0.3s ease; }
.q-feedback.is-correct { background: var(--go-soft); color: #14532d; }
.q-feedback.is-wrong { background: #fff7ed; color: #9a3412; }
.q-next-row { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 33, 74, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: #fff;
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 30px 26px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.45s cubic-bezier(.3, 1.4, .5, 1);
}
@keyframes modalIn {
  from { transform: translateY(30px) scale(0.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-card h2 { font-size: 1.7rem; color: var(--violet-deep); }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f3f1fb;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  color: var(--ink-soft);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* celebration */
.celebrate-card { text-align: center; max-width: 480px; overflow: hidden; }
.celebrate-rays {
  position: absolute;
  top: -160px;
  left: 50%;
  width: 520px;
  height: 520px;
  margin-left: -260px;
  background: repeating-conic-gradient(from 0deg, rgba(250, 204, 21, 0.18) 0 12deg, transparent 12deg 24deg);
  border-radius: 50%;
  animation: spin 18s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.celebrate-badge {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(160deg, #fff7d6, #fcd34d);
  box-shadow: 0 8px 0 #d97706, 0 0 0 8px #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  animation: badgeIn 0.9s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes badgeIn {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0); }
}
.celebrate-card h2 { position: relative; font-size: 2rem; }
.celebrate-sub { position: relative; color: var(--ink-soft); font-weight: 800; }
.celebrate-stars { position: relative; display: flex; justify-content: center; gap: 10px; margin: 14px 0; }
.big-star { font-size: 58px; line-height: 1; color: #e7e4f2; }
.big-star.earned { color: var(--gold); text-shadow: 0 4px 0 #d97706; animation: starIn 0.6s cubic-bezier(.3, 1.8, .5, 1) both; animation-delay: var(--d); }
@keyframes starIn {
  0% { transform: scale(0) rotate(-90deg); color: #e7e4f2; text-shadow: none; }
  100% { transform: scale(1) rotate(0); }
}
.badge-unlock {
  position: relative;
  display: inline-block;
  background: var(--violet-soft);
  color: var(--violet-deep);
  padding: 10px 18px;
  border-radius: var(--r-full);
  font-weight: 800;
}
.zone-reward {
  position: relative;
  margin-top: 14px;
  background: linear-gradient(90deg, #fef3c7, #fce7f3);
  border-radius: var(--r-lg);
  padding: 14px;
  font-weight: 800;
  animation: popIn 0.6s ease 0.8s both;
}
.celebrate-card .modal-actions { justify-content: center; position: relative; }

/* trophy room */
.trophy-card { max-width: 760px; }
.sticker-book { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin: 18px 0 24px; }
.sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 8px;
  border-radius: var(--r-lg);
  text-align: center;
  background: #f6f5fb;
  box-shadow: inset 0 0 0 2px dashed var(--line);
  border: 2px dashed #d9d5ea;
}
.sticker.earned { background: linear-gradient(160deg, #fff, #fef9e7); border: 2px solid #fcd34d; box-shadow: 0 4px 0 #fde68a; }
.sticker.crown.earned { background: linear-gradient(160deg, #f5f3ff, #fde68a); border-color: var(--violet); }
.sticker-icon { font-size: 40px; }
.sticker.locked .sticker-icon { filter: grayscale(1); opacity: 0.4; }
.sticker-title { font-weight: 900; font-size: 0.85rem; line-height: 1.2; }
.sticker-meta { font-size: 0.75rem; color: var(--muted); font-weight: 800; }
.sticker.earned .sticker-meta { color: #b45309; }

.certificate { border-radius: var(--r-lg); padding: 10px; background: repeating-linear-gradient(45deg, #fcd34d 0 10px, #fbbf24 10px 20px); }
.cert-inner { background: var(--cream); border-radius: var(--r-md); padding: 26px 20px; text-align: center; border: 3px double #d97706; }
.cert-seal { font-size: 46px; }
.cert-heading { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: #92400e; }
.cert-name { font-family: var(--font-display); font-size: 2rem; color: var(--violet-deep); border-bottom: 3px dashed #d97706; display: inline-block; padding: 2px 22px; margin: 8px 0; }
.cert-topic { font-family: var(--font-display); font-size: 1.3rem; color: var(--violet); margin: 4px 0 10px; }
.cert-meta { font-size: 0.9rem; color: #92400e; }
.certificate.is-champion .cert-seal::after { content: " 👑"; }

/* settings */
.settings-card { max-width: 520px; }
.toggle-list { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f7f6fc;
  border-radius: var(--r-md);
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 800;
}
.toggle-row small { display: block; color: var(--muted); font-weight: 700; }
.toggle-row input { width: 26px; height: 26px; accent-color: var(--violet); cursor: pointer; flex-shrink: 0; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 140%);
  background: var(--ink);
  color: #fff;
  padding: 13px 22px;
  border-radius: var(--r-full);
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  transition: transform 0.35s cubic-bezier(.3, 1.4, .5, 1), opacity 0.25s;
  max-width: calc(100vw - 32px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

#confettiCanvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 3000; }

/* ==========================================================================
   LAB MANIPULATIVES (shared)
   ========================================================================== */
.lab-card {
  background: #fbfaff;
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: inset 0 0 0 3px var(--line);
}
.lab-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.lab-banner,
.machine-banner, .ticket-header, .factory-header, .fruit-stall-banner, .roller-coaster-title,
.wizard-header, .fdp-title, .fair-header {
  font-family: var(--font-display);
  font-weight: 600;
  text-align: center;
  padding: 12px;
  border-radius: var(--r-md);
  letter-spacing: 0.5px;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(90deg, var(--zone), var(--zone-deep));
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  margin-bottom: 6px;
}
.machine-banner { background: linear-gradient(90deg, #312e81, #1e1b4b); color: #c7d2fe; }
.wizard-header { background: linear-gradient(90deg, #4c1d95, #1e1b4b); color: #fde68a; }
.fair-header { background: linear-gradient(90deg, #ec4899, #f59e0b); }
.fruit-stall-banner { background: linear-gradient(90deg, #16a34a, #f59e0b); }

.form-input, .form-select, .form-range { font: inherit; padding: 9px 12px; border-radius: var(--r-sm); border: 3px solid var(--line); font-size: 1.05rem; background: #fff; color: var(--ink); }
.form-input:focus, .form-select:focus { border-color: var(--zone); outline: none; }
.form-range { padding: 0; border: none; width: 100%; accent-color: var(--zone); height: 28px; }

.readout-deck { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 18px; }
.readout-box { background: #fff; border-radius: var(--r-md); padding: 14px; text-align: center; box-shadow: inset 0 0 0 3px var(--line); }
.readout-box.highlight-box { background: var(--zone-soft); box-shadow: inset 0 0 0 3px var(--zone); }
.readout-label { display: block; font-size: 0.78rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.readout-val { font-family: var(--font-display); font-size: 1.8rem; font-weight: 600; color: var(--zone-deep); }

/* fraction bar / 100 grid */
.visual-display-area { margin: 6px 0; }
.fraction-bar-10 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; height: 84px; background: #fff; padding: 8px; border-radius: var(--r-md); box-shadow: inset 0 0 0 3px var(--line); }
.fraction-grid-100, .fdp-interactive-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  max-width: 440px;
  margin: 0 auto;
  background: #fff;
  padding: 8px;
  border-radius: var(--r-md);
  box-shadow: inset 0 0 0 3px var(--line);
}
.grid-cell { background: #eeedf7; border-radius: 5px; cursor: pointer; transition: background 0.15s, transform 0.1s; min-height: 32px; aspect-ratio: auto; }
.fraction-grid-100 .grid-cell, .fdp-interactive-grid .grid-cell { aspect-ratio: 1; min-height: 0; }
.grid-cell:hover { background: #d9d4f5; transform: scale(1.06); }
.grid-cell.shaded { background: var(--zone); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }

/* word problem detective */
.story-detective-box { background: #fff; border-radius: var(--r-md); padding: 16px 18px; box-shadow: inset 0 0 0 3px var(--line); }
.story-text { font-size: 1.15rem; font-weight: 700; }
.clue-tag { background: #fef08a; padding: 1px 8px; border-radius: 6px; font-weight: 900; box-shadow: 0 2px 0 #facc15; }
.basket-visualizer { margin-top: 18px; display: flex; justify-content: center; }
.basket-frame {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 600px;
  padding: 10px;
  background: #d6a76b;
  border-radius: 14px 14px 40px 40px;
  box-shadow: inset 0 -6px 0 #b07d43, 0 6px 0 #8a5a2b;
}
.basket-section {
  min-height: 90px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 900;
  padding: 4px;
  transition: background 0.3s, transform 0.3s;
}
.basket-section.empty { background: rgba(255, 255, 255, 0.55); color: #8a5a2b; }
.basket-section.filled { background: #fb7185; color: #fff; animation: popIn 0.4s ease; box-shadow: inset 0 -4px 0 #e11d48; }

/* piggy bank */
.piggy-stage { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 20px; background: #fdf2f8; border-radius: var(--r-md); box-shadow: inset 0 0 0 3px #fbcfe8; }
.piggy-icon { font-size: 72px; transition: transform 0.3s cubic-bezier(.3, 1.8, .5, 1); }
.piggy-bounce { transform: scale(1.25) rotate(-10deg); }
.piggy-balance { display: flex; flex-direction: column; }
.balance-title { font-size: 0.85rem; font-weight: 900; color: #db2777; text-transform: uppercase; letter-spacing: 0.05em; }
.balance-amount { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; color: #9d174d; }
.coin-dispenser { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.coin-btn {
  border: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1.1;
  transition: transform 0.1s;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15), 0 5px 0 rgba(0, 0, 0, 0.2);
}
.coin-btn small { display: block; font-size: 0.68rem; font-weight: 800; }
.coin-btn:hover { transform: translateY(-3px) rotate(-6deg); }
.coin-btn:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15); }
.coin-pound { background: radial-gradient(circle at 35% 30%, #fef9c3, #facc15); color: #713f12; }
.coin-50p { background: radial-gradient(circle at 35% 30%, #fff, #cbd5e1); color: #334155; border-radius: 30%; }
.coin-10p { background: radial-gradient(circle at 35% 30%, #fff, #94a3b8); color: #1e293b; }
.coin-1p { background: radial-gradient(circle at 35% 30%, #ffedd5, #ea8a4b); color: #7c2d12; width: 76px; height: 76px; }
.ml-auto { margin-left: auto; }

.place-value-chart { display: flex; background: #fff; border-radius: var(--r-md); overflow: hidden; text-align: center; box-shadow: inset 0 0 0 3px var(--line); }
.pv-col { flex: 1; padding: 14px 8px; }
.pv-ones { background: #fefce8; }
.pv-tenths { background: #f1f5f9; }
.pv-hundredths { background: #fff7ed; }
.pv-header { font-size: 0.85rem; font-weight: 900; color: var(--ink-soft); margin-bottom: 4px; }
.pv-count { font-family: var(--font-display); font-size: 2.4rem; font-weight: 600; color: var(--zone-deep); }
.pv-dot { font-size: 3rem; font-weight: 900; display: flex; align-items: center; padding: 0 6px; color: var(--coral); background: #fff; }

/* monster scales */
.monster-select-row { display: flex; align-items: flex-end; justify-content: center; gap: 16px; flex-wrap: wrap; }
.monster-select-row label { display: block; font-weight: 900; color: var(--ink-soft); margin-bottom: 4px; }
.vs-badge { font-family: var(--font-display); font-size: 1.3rem; background: var(--coral); color: #fff; width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 0 #b91c1c; }
.scales-container { display: flex; align-items: center; justify-content: space-around; padding: 34px 10px; background: #fff; border-radius: var(--r-md); min-height: 210px; box-shadow: inset 0 0 0 3px var(--line); }
.scale-pan { padding: 16px; background: #f8f7fd; border-radius: var(--r-md); text-align: center; min-width: 150px; transition: transform 0.6s cubic-bezier(.3, 1.4, .5, 1); box-shadow: inset 0 0 0 3px var(--line), 0 5px 0 var(--line); }
.pan-down { transform: translateY(26px); box-shadow: inset 0 0 0 3px var(--go), 0 5px 0 #86efac; }
.pan-up { transform: translateY(-26px); box-shadow: inset 0 0 0 3px var(--sun), 0 5px 0 #fde68a; }
.pan-monster { font-size: 52px; }
.pan-weight { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; }
.ghost-zero-badge { display: inline-block; background: var(--violet-soft); color: var(--violet-deep); font-size: 0.8rem; font-weight: 900; padding: 4px 8px; border-radius: 6px; margin-top: 6px; }
.scale-fulcrum { font-size: 3.2rem; }
.scales-verdict { text-align: center; font-weight: 900; font-size: 1.1rem; background: var(--go-soft); color: #14532d; padding: 12px; border-radius: var(--r-md); }

/* function machine */
.machine-input-row { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; font-weight: 900; }
.machine-input-row .form-input { width: 160px; font-family: var(--font-display); font-size: 1.4rem; }
.operation-buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.btn-op { flex-direction: column; gap: 0; min-width: 110px; font-size: 1.3rem; }
.btn-op-mul { background: #059669; box-shadow: 0 5px 0 #065f46; }
.btn-op-div { background: #d97706; box-shadow: 0 5px 0 #92400e; }
.conveyor-track { background: #1e1b4b; color: #fff; padding: 20px; border-radius: var(--r-md); text-align: center; background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 20px, transparent 20px 40px); }
.track-header { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: #a5b4fc; font-weight: 900; }
.track-display { margin-top: 6px; }
.track-num { font-family: var(--font-display); font-size: 3rem; font-weight: 600; letter-spacing: 3px; color: #fde047; display: inline-block; }
.slide-pulse { animation: slidePop 0.45s ease; }
@keyframes slidePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); color: #4ade80; }
  100% { transform: scale(1); }
}
.explanation-pill, .bus-explanation, .hill-verdict-box, .wizard-feedback {
  background: #fff;
  border-radius: var(--r-md);
  padding: 13px 16px;
  font-weight: 800;
  text-align: center;
  box-shadow: inset 0 0 0 3px var(--zone-soft);
}

/* dominoes */
.domino-arena { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px; }
.domino-col { display: flex; flex-direction: column; gap: 10px; }
.domino-card {
  background: #fff;
  border-radius: var(--r-md);
  padding: 16px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: inset 0 0 0 3px var(--line), 0 4px 0 var(--line);
  transition: transform 0.12s, box-shadow 0.12s;
}
.domino-card:hover { transform: translateY(-2px); }
.domino-card.answer-card { background: #fffbeb; }
.domino-card.selected { box-shadow: inset 0 0 0 4px var(--zone), 0 4px 0 var(--zone-soft); transform: scale(1.04); }
.domino-card.matched { background: var(--go-soft); box-shadow: inset 0 0 0 3px var(--go); color: #14532d; cursor: default; opacity: 0.8; }
#dominoStatus { font-weight: 900; font-size: 1.1rem; }

/* bus ticket till */
.ticket-config-row { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.ticket-config-row label { display: block; font-weight: 900; color: var(--ink-soft); margin-bottom: 4px; }
.multiplication-grid { min-height: 20px; }
.step-card { background: #fff; border-radius: var(--r-md); padding: 18px; box-shadow: inset 0 0 0 3px var(--line); animation: stageIn 0.4s ease; }
.step-card h4 { font-size: 1.25rem; color: var(--zone-deep); margin-bottom: 8px; }
.styled-steps-list { padding-left: 22px; display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.total-receipt-box { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; background: #fefce8; border: 2px dashed #ca8a04; border-radius: var(--r-md); padding: 12px 16px; font-weight: 900; }
.total-big { font-family: var(--font-display); font-size: 2rem; color: #854d0e; }

/* factory */
.factory-sliders { background: #fff; border-radius: var(--r-md); padding: 16px; box-shadow: inset 0 0 0 3px var(--line); }
.slider-group label { font-weight: 800; }
.paper-roll-visual { background: #e2e8f0; border-radius: var(--r-md); padding: 12px; overflow: hidden; position: relative; }
.conveyor-belt-anim {
  white-space: nowrap;
  font-size: 2rem;
  animation: belt var(--belt-speed, 4s) linear infinite;
  display: inline-block;
}
@keyframes belt {
  from { transform: translateX(-30%); }
  to { transform: translateX(30%); }
}
.paper-strip { height: 22px; margin-top: 8px; border-radius: 4px; background: repeating-linear-gradient(45deg, #f472b6 0 10px, #fbcfe8 10px 20px); transition: width 0.4s ease; max-width: 100%; }

/* bus stop division */
.bus-stop-frame { margin: 22px auto; width: fit-content; font-family: var(--font-display); font-size: 2.2rem; font-weight: 600; }
.bus-row { display: grid; grid-auto-flow: column; grid-auto-columns: 46px; text-align: center; }
.bus-stop-roof { border-bottom: 5px solid var(--ink); color: var(--zone-deep); margin-left: 58px; }
.bus-stop-body { display: flex; }
.bus-divisor { width: 58px; text-align: center; border-right: 5px solid var(--ink); color: var(--coral); }
.bus-dividend { color: var(--ink); }
.bus-cell { position: relative; min-height: 1.3em; }
.bus-cell.is-blank { color: #d4d0e6; }
.bus-cell.is-new { animation: popIn 0.5s ease; color: var(--go-deep); }
.bus-carry { position: absolute; top: -2px; left: -2px; font-size: 0.9rem; color: var(--coral); }
.stepper-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* fruit stall */
.fruit-picker, .item-selector-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.fruit-btn, .item-stall-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  min-width: 110px;
  box-shadow: inset 0 0 0 3px var(--line), 0 4px 0 var(--line);
  transition: transform 0.12s;
  color: var(--ink);
}
.fruit-btn:hover, .item-stall-btn:hover { transform: translateY(-2px); }
.fruit-btn.active, .item-stall-btn.active { box-shadow: inset 0 0 0 4px var(--zone), 0 4px 0 var(--zone-soft); background: var(--zone-soft); }
.fruit-emoji, .item-emoji { font-size: 2rem; }
.fruit-display-card { background: #fff; border-radius: var(--r-md); padding: 18px; box-shadow: inset 0 0 0 3px var(--line); }
.fruit-info-grid { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.fruit-big-icon { font-size: 80px; }
.fruit-details { flex: 1; min-width: 200px; }
.fruit-details h3 { font-size: 1.3rem; color: var(--zone-deep); }
.division-text { font-family: var(--font-display); font-size: 1.2rem; color: var(--ink-soft); margin: 4px 0; }
.unit-price-pill { display: inline-block; background: var(--go-soft); color: #14532d; padding: 8px 16px; border-radius: var(--r-full); font-weight: 900; margin-top: 6px; }
.unit-price-pill span { font-family: var(--font-display); font-size: 1.4rem; }

/* roller coaster */
.roller-hill-stage { position: relative; background: linear-gradient(180deg, #e0f2fe, #fff); border-radius: var(--r-md); padding: 20px 10px 10px; overflow: hidden; }
.hill-track-svg { position: relative; width: 100%; max-width: 520px; margin: 0 auto; }
.hill-svg { width: 100%; height: auto; display: block; }
.coaster-cart { position: absolute; transform: translate(-50%, -80%); background: #fff; padding: 4px 10px; border-radius: var(--r-full); box-shadow: var(--shadow-md), inset 0 0 0 3px var(--zone); font-weight: 900; font-size: 1.05rem; transition: left 0.5s cubic-bezier(.4, 0, .2, 1), top 0.5s cubic-bezier(.4, 0, .2, 1); white-space: nowrap; }
.slider-control-center { max-width: 520px; margin: 0 auto; text-align: center; font-weight: 900; }

/* wizard maze */
.wizard-riddle-box { text-align: center; background: #faf5ff; border-radius: var(--r-md); padding: 16px; box-shadow: inset 0 0 0 3px #e9d5ff; }
.wizard-riddle-box h3 { font-size: 1.6rem; color: #6b21a8; }
.maze-doors-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.maze-door-btn {
  width: 130px;
  padding: 16px 10px;
  border: none;
  cursor: pointer;
  background: linear-gradient(180deg, #92400e, #78350f);
  color: #fef3c7;
  border-radius: 60px 60px 12px 12px;
  box-shadow: 0 6px 0 #451a03;
  transition: transform 0.15s;
}
.maze-door-btn:hover { transform: translateY(-4px); }
.maze-door-btn.door-wrong { animation: shake 0.4s ease; filter: grayscale(0.6) brightness(0.8); }
.maze-door-btn.door-unlocked { background: linear-gradient(180deg, #facc15, #f59e0b); color: #451a03; box-shadow: 0 6px 0 #b45309, 0 0 30px rgba(250, 204, 21, 0.7); }
.door-icon { font-size: 2.6rem; }
.door-val { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }
.maze-progress { text-align: center; font-weight: 900; color: #6b21a8; margin-top: 10px; }

/* fdp chameleon */
.quick-presets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* summer fair */
.discount-buttons-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn-discount { flex-direction: column; gap: 0; background: var(--pink); box-shadow: 0 5px 0 #9d174d; min-width: 110px; font-size: 1.15rem; }
.btn-discount.active { background: #9d174d; box-shadow: 0 2px 0 #500724; transform: translateY(3px); }
.stall-ticket { background: #fff; border-radius: var(--r-md); overflow: hidden; box-shadow: inset 0 0 0 3px #fbcfe8; animation: stageIn 0.35s ease; }
.ticket-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; background: #fdf2f8; flex-wrap: wrap; }
.ticket-name { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; }
.ticket-badge { background: var(--pink); color: #fff; padding: 4px 12px; border-radius: var(--r-full); font-weight: 900; }
.ticket-math { padding: 14px 16px; font-weight: 700; }
.ticket-math hr { border: none; border-top: 2px dashed #fbcfe8; margin: 10px 0; }
.new-price-banner { font-weight: 900; font-size: 1.1rem; display: flex; justify-content: space-between; align-items: center; }
.new-price-banner span { font-family: var(--font-display); font-size: 2rem; color: #9d174d; }

/* utilities used by labs */
.text-center { text-align: center; }
.text-muted { color: var(--ink-soft); font-weight: 700; }
.text-sm { font-size: 0.88rem; }
.text-green { color: var(--go-deep); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 20px; }

@media (max-width: 600px) {
  .lab-card { padding: 14px; }
  .scales-container { flex-direction: column; gap: 20px; }
  .pan-down, .pan-up { transform: none; }
  .domino-card { font-size: 1.1rem; padding: 12px 8px; }
  .basket-section { min-height: 70px; font-size: 0.7rem; }
  .coin-btn { width: 78px; height: 78px; font-size: 1rem; }
  .bus-stop-frame { font-size: 1.7rem; }
  .bus-row { grid-auto-columns: 36px; }
  .bus-stop-roof { margin-left: 46px; }
  .bus-divisor { width: 46px; }
}

/* ==========================================================================
   MOTION & PRINT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  #certificate, #certificate * { visibility: visible; }
  #certificate { position: fixed; inset: 40px; }
  .modal-overlay { background: none; backdrop-filter: none; }
}

/* ==========================================================================
   HOME — choose subject and year
   ========================================================================== */
.home-body { max-width: 1000px; margin: 0 auto; padding: 22px 16px 60px; }
.home-pip { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.home-pip .speech-bubble { flex: 1; font-size: 1.05rem; }
.subject-tabs { display: flex; gap: 12px; justify-content: center; margin-bottom: 22px; }
.subject-tab {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 600;
  padding: 14px 28px; border: none; border-radius: var(--r-full); cursor: pointer;
  background: #fff; color: var(--ink-soft); box-shadow: 0 4px 0 var(--line), inset 0 0 0 3px var(--line);
  transition: transform 0.15s, background 0.2s;
}
.subject-tab span { font-size: 1.6rem; }
.subject-tab:hover { transform: translateY(-2px); }
.subject-tab.is-active { background: var(--violet); color: #fff; box-shadow: 0 5px 0 var(--violet-deep); }
.year-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.year-card {
  position: relative; overflow: hidden; text-align: left; cursor: pointer; border: none; font: inherit; color: var(--ink);
  display: flex; flex-direction: column; gap: 6px; padding: 22px 20px 18px; border-radius: var(--r-xl);
  background: var(--zone-bg); box-shadow: 0 8px 0 var(--zone-deep), var(--shadow-md);
  transition: transform 0.18s cubic-bezier(.3, 1.5, .5, 1);
  animation: stageIn 0.45s both; animation-delay: calc(var(--i) * 90ms);
}
.year-card:hover { transform: translateY(-5px) rotate(-0.5deg); }
.year-card:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--zone-deep); }
.year-card.is-soon { filter: saturate(0.6); }
.yc-emoji { font-size: 3rem; line-height: 1; animation: bob 3s ease-in-out infinite; }
.yc-year { font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8rem; color: var(--zone); }
.yc-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; color: var(--zone-deep); line-height: 1.1; }
.yc-tag { font-size: 0.92rem; color: var(--ink-soft); font-weight: 700; min-height: 2.6em; }
.yc-progress { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.yc-track { flex: 1; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.8); overflow: hidden; }
.yc-fill { display: block; height: 100%; background: var(--zone); border-radius: inherit; }
.yc-meta { font-size: 0.82rem; font-weight: 800; color: var(--ink-soft); }
.yc-go {
  align-self: flex-start; margin-top: 6px; background: var(--zone); color: #fff; font-weight: 900;
  padding: 8px 18px; border-radius: var(--r-full); box-shadow: 0 4px 0 var(--zone-deep);
}
.year-card.is-soon .yc-go { background: #fff; color: var(--ink-soft); box-shadow: 0 3px 0 var(--line); }
.home-note { margin-top: 22px; text-align: center; color: var(--ink-soft); font-weight: 700; font-size: 0.9rem; }
.btn-home { padding: 8px 12px; font-size: 1.2rem; }
.state-soon .node-orb { background: repeating-linear-gradient(45deg, #fff7d6 0 10px, #fff 10px 20px); box-shadow: 0 7px 0 #e5d9a8; }
.state-soon .node-icon { filter: none; opacity: 0.9; }
.state-soon .node-label { opacity: 0.9; }
@media (max-width: 600px) {
  .subject-tab { padding: 12px 18px; font-size: 1.1rem; }
  .yc-title { font-size: 1.35rem; }
}

/* ==========================================================================
   HOME MODE TABS · SATs PAPERS · TEST PLAYER · REVIEW · MTC
   ========================================================================== */
.mode-tabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; background: rgba(255,255,255,.7); padding: 6px; border-radius: var(--r-full); width: fit-content; margin-left: auto; margin-right: auto; box-shadow: inset 0 0 0 2px var(--line); }
.mode-tab { border: none; cursor: pointer; font: inherit; font-weight: 900; font-size: 1rem; padding: 10px 18px; border-radius: var(--r-full); background: transparent; color: var(--ink-soft); }
.mode-tab.is-active { background: var(--ink); color: #fff; box-shadow: 0 3px 0 #000; }
.paper-subjects { flex-wrap: wrap; }
.paper-subjects .subject-tab { font-size: 1.05rem; padding: 10px 18px; }
.paper-years { display: flex; flex-direction: column; gap: 14px; }
.paper-year { background: #fff; border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--line); animation: stageIn .4s both; animation-delay: calc(var(--i) * 60ms); }
.py-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.py-year { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--violet-deep); }
.py-tag { font-size: .75rem; font-weight: 900; background: var(--sun-soft); color: #92400e; padding: 3px 10px; border-radius: 99px; }
.py-papers { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.paper-btn { border: none; cursor: pointer; font: inherit; text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: var(--r-md); background: var(--violet-soft); color: var(--ink); box-shadow: 0 4px 0 #ddd6fe; transition: transform .12s; }
.paper-btn:hover { transform: translateY(-2px); }
.paper-btn strong { font-size: 1rem; }
.paper-btn span { font-size: .8rem; font-weight: 800; }
.paper-btn.is-soon { background: #f4f3f9; box-shadow: 0 4px 0 #e6e3f5; }
.pp-soon { color: var(--muted); } .pp-prog { color: #b45309; } .pp-best { color: var(--go-deep); } .pp-new { color: var(--ink-soft); }

.test-topbar { flex-wrap: wrap; }
.test-timer { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; background: var(--violet-soft); color: var(--violet-deep); padding: 6px 14px; border-radius: 99px; }
.test-timer.is-low { background: var(--coral-soft); color: #b91c1c; animation: pulseOnce 1s infinite; }
.test-view-tabs { display: none; gap: 8px; justify-content: center; padding: 10px; }
.test-view-tabs button { border: none; font: inherit; font-weight: 900; padding: 8px 18px; border-radius: 99px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); cursor: pointer; }
.test-view-tabs button.is-active { background: var(--violet); color: #fff; box-shadow: none; }
.test-body { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 16px; max-width: 1400px; margin: 0 auto; padding: 14px; height: calc(100vh - 130px); }
.test-body.is-dictation { grid-template-columns: minmax(0, 760px); justify-content: center; }
.test-body.is-dictation .test-paper { display: none; }
.test-body.is-view-only { grid-template-columns: 1fr; }
.test-paper { overflow: auto; background: #e9e7f2; border-radius: var(--r-lg); padding: 10px; position: relative; }
.tp-tools { position: sticky; top: 0; z-index: 2; display: flex; gap: 8px; align-items: center; justify-content: flex-end; font-weight: 800; color: var(--ink-soft); }
.tp-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tp-page { margin: 0; background: #fff; box-shadow: var(--shadow-md); border-radius: 6px; overflow: hidden; width: calc(100% * var(--zoom)); max-width: none; }
.tp-page img { display: block; width: 100%; height: auto; }
.tp-page figcaption { font-size: .75rem; font-weight: 800; color: var(--muted); padding: 4px 10px; background: #faf9fe; }
.test-answers { overflow: auto; background: #fff; border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow-md); }
.test-note { padding: 20px; font-weight: 800; text-align: center; color: var(--ink-soft); }
.as-head { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; color: var(--violet-deep); margin-bottom: 10px; }
.as-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.as-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-md); background: #faf9fe; }
.as-row.as-spell { grid-template-columns: 34px 44px 1fr; }
.as-row.as-spell .as-input { grid-column: 1 / -1; }
.as-n { width: 36px; height: 36px; border-radius: 50%; background: var(--violet-soft); color: var(--violet-deep); font-weight: 900; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.as-label { grid-column: 2 / 3; font-weight: 700; font-size: .9rem; color: var(--ink-soft); }
.as-input { padding: 10px 12px; font-size: 1.15rem; }
.as-marks { font-size: .75rem; font-weight: 900; color: var(--muted); }
.as-sentence { font-weight: 700; }
.as-gap { color: var(--violet); font-weight: 900; letter-spacing: 1px; }
.as-choice { display: flex; flex-wrap: wrap; gap: 6px; }
.as-choice button { border: none; cursor: pointer; font: inherit; font-weight: 800; padding: 8px 12px; border-radius: 10px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); }
.as-choice button.is-on { background: var(--violet); color: #fff; box-shadow: none; }
.as-finish { margin: 16px auto 4px; display: flex; }
.test-start { text-align: center; padding: 20px 10px; }
.ts-emoji { font-size: 3.4rem; }
.test-start h3 { font-size: 1.5rem; color: var(--violet-deep); margin: 6px 0; }
.test-start p { font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; }
.ts-tip { background: var(--sun-soft); color: #78350f !important; padding: 8px 12px; border-radius: 12px; display: inline-block; }
.ts-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; margin-top: 12px; }
.rs-banner { display: flex; gap: 16px; align-items: center; background: linear-gradient(135deg, #f5f3ff, #fef3c7); border-radius: var(--r-lg); padding: 14px; margin-bottom: 12px; }
.rs-score { width: 104px; height: 104px; flex-shrink: 0; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 6px 0 var(--violet-deep), 0 0 0 6px var(--violet-soft); animation: badgeIn .8s cubic-bezier(.3,1.6,.5,1); }
.rs-score strong { font-family: var(--font-display); font-size: 2.4rem; color: var(--violet-deep); line-height: 1; }
.rs-score span { font-weight: 900; color: var(--ink-soft); }
.rs-text h3 { font-size: 1.4rem; color: var(--violet-deep); }
.rs-text p { font-weight: 700; color: var(--ink-soft); }
.rs-help { font-size: .82rem; }
.rs-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.rs-row { display: grid; grid-template-columns: 40px 28px 1fr auto; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; background: #faf9fe; }
.rs-row.is-right { background: var(--go-soft); } .rs-row.is-wrong { background: #fff1f2; } .rs-row.is-part { background: var(--sun-soft); } .rs-row.is-pending { background: #eff6ff; }
.rs-body { display: flex; flex-direction: column; font-size: .88rem; font-weight: 700; }
.rs-right { color: var(--ink-soft); }
.rs-marks { display: flex; align-items: center; gap: 4px; font-weight: 800; }
.rs-adj { width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer; background: #fff; box-shadow: inset 0 0 0 2px var(--line); font-weight: 900; }
.rs-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .test-view-tabs { display: flex; }
  .test-body { grid-template-columns: 1fr; height: auto; }
  .test-body[data-view="paper"] .test-answers, .test-body[data-view="answers"] .test-paper { display: none; }
  .test-body.is-dictation .test-answers { display: block; }
  .test-paper, .test-answers { max-height: none; }
}
.btn-review { padding: 8px 14px; font-size: .95rem; }
.btn-review.has-due { box-shadow: 0 3px 0 var(--sun), inset 0 0 0 2px var(--sun); animation: chipBounce2 1.6s ease-in-out infinite; }
.review-count { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--coral); color: #fff; font-size: .78rem; align-items: center; justify-content: center; }

/* Times Tables Check */
.mtc-intro { text-align: center; background: #fff; border-radius: var(--r-xl); padding: 26px 18px; box-shadow: var(--shadow-md); }
.mtc-big { font-size: 4rem; animation: bob 3s ease-in-out infinite; }
.mtc-intro h3 { font-size: 1.6rem; color: var(--violet-deep); }
.mtc-intro p { font-weight: 700; color: var(--ink-soft); }
.mtc-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 16px 0; }
.mtc-hist { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.mh-item { background: var(--violet-soft); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; font-weight: 800; }
.mh-item.is-good { background: var(--go-soft); }
.mh-item strong { font-family: var(--font-display); font-size: 1.3rem; }
.mh-item span { font-size: .75rem; color: var(--ink-soft); }
.mh-tricky span { display: inline-block; background: var(--sun-soft); padding: 2px 8px; border-radius: 8px; margin: 2px; font-weight: 800; }
.mh-empty { font-size: .9rem; }
#screenMtc.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #312e81, #1e1b4b); }
.mtc-stage { width: 100%; max-width: 520px; padding: 16px; }
.mtc-card { position: relative; background: #fff; border-radius: var(--r-xl); padding: 24px 20px; text-align: center; box-shadow: var(--shadow-lg); animation: modalIn .35s ease; }
.mtc-card h2 { color: var(--violet-deep); font-size: 1.7rem; margin: 6px 0; }
.mtc-card p { font-weight: 700; color: var(--ink-soft); margin-bottom: 12px; }
.mtc-exit { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: none; background: #f3f1fb; font-weight: 900; cursor: pointer; }
.mtc-count { font-weight: 900; background: var(--violet-soft); color: var(--violet-deep); padding: 4px 12px; border-radius: 99px; }
.mtc-count.is-practice { background: var(--sun-soft); color: #92400e; }
.mtc-q { font-family: var(--font-display); font-size: 3.6rem; font-weight: 700; color: var(--ink); margin: 16px 0 6px; animation: bigIn .4s ease; }
.mtc-answer { font-family: var(--font-display); font-size: 3rem; font-weight: 700; color: var(--violet); min-height: 1.3em; border-bottom: 4px dashed var(--line); width: 160px; margin: 0 auto 14px; }
.mtc-bar { height: 12px; border-radius: 99px; background: #eceaf6; overflow: hidden; margin: 0 auto 10px; max-width: 360px; }
.mtc-bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #22c55e, #facc15, #ef4444); transform-origin: left; }
.mtc-bar-fill.run { animation: mtcDrain var(--secs) linear forwards; }
@keyframes mtcDrain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.mtc-feedback { min-height: 1.6em; font-weight: 900; font-size: 1.1rem; }
.mtc-feedback.is-ok { color: var(--go-deep); } .mtc-feedback.is-no { color: #b91c1c; }
.mtc-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 300px; margin: 10px auto 0; }
.mtc-pad button { border: none; cursor: pointer; font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; padding: 12px 0; border-radius: 14px; background: #f3f1fb; box-shadow: 0 4px 0 #ddd8f0; }
.mtc-pad button:active { transform: translateY(3px); box-shadow: 0 1px 0 #ddd8f0; }
.mtc-pad .is-enter { background: var(--go); color: #fff; box-shadow: 0 4px 0 var(--go-deep); }
.mtc-pad .is-del { background: #fff1f2; }
.mtc-score { width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--violet-soft); box-shadow: 0 6px 0 var(--violet-deep); animation: badgeIn .8s cubic-bezier(.3,1.6,.5,1); }
.mtc-score strong { font-family: var(--font-display); font-size: 3rem; color: var(--violet-deep); line-height: 1; }
.mtc-wrong { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
.mtc-wrong span { background: var(--sun-soft); padding: 6px 10px; border-radius: 10px; font-weight: 800; }

.ms-overlay { position: fixed; inset: 0; z-index: 1500; background: rgba(38,33,74,.7); display: none; align-items: center; justify-content: center; padding: 16px; }
.ms-overlay.open { display: flex; }
.ms-card { background: #fff; border-radius: var(--r-lg); max-width: 900px; width: 100%; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.ms-bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.ms-img { overflow: auto; padding: 10px; background: #eceaf6; }
.ms-img img { width: 100%; display: block; background: #fff; }
.rs-ms { margin-top: 2px; text-align: left; padding: 0; font-size: .82rem; }
.as-sayset { display: inline-flex; gap: 4px; }
.as-row.as-spell { grid-template-columns: 34px auto 1fr; }
.as-say-word { font-size: .9rem; }
.as-row.is-playing { box-shadow: inset 0 0 0 2px var(--violet); background: var(--violet-soft); }
.as-row.is-playing .as-say:first-child { animation: pulseOnce 1s infinite; }
