:root {
  --sky-top: #7ec8ff;
  --sky-mid: #b8e4ff;
  --sky-bottom: #fff6d8;
  --grass: #7bc96f;
  --coral: #ff7a59;
  --sunny: #ffd166;
  --ink: #2b2d42;
  --ink-soft: #4a4e69;
  --card: #ffffff;
  --shadow: 0 12px 28px rgba(43, 45, 66, 0.18);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --touch: 72px;
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 42%, var(--sky-bottom) 100%);
}

body.child-world {
  overflow-x: hidden;
}

.sky-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  filter: blur(0.2px);
  animation: drift 28s linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 999px;
}

.cloud-a {
  width: 120px;
  height: 40px;
  top: 8%;
  left: -10%;
}

.cloud-a::before {
  width: 50px;
  height: 50px;
  top: -24px;
  left: 18px;
}

.cloud-a::after {
  width: 70px;
  height: 70px;
  top: -34px;
  left: 48px;
}

.cloud-b {
  width: 160px;
  height: 48px;
  top: 18%;
  left: 60%;
  animation-duration: 36s;
  animation-delay: -8s;
}

.cloud-b::before {
  width: 60px;
  height: 60px;
  top: -28px;
  left: 24px;
}

.cloud-b::after {
  width: 80px;
  height: 80px;
  top: -40px;
  left: 60px;
}

.hill {
  position: absolute;
  bottom: -40px;
  width: 70vw;
  height: 180px;
  background: radial-gradient(circle at 50% 0%, #9be28f 0%, var(--grass) 70%);
  border-radius: 50% 50% 0 0;
  opacity: 0.55;
}

.hill-left {
  left: -20vw;
}

.hill-right {
  right: -15vw;
  height: 220px;
  opacity: 0.4;
}

@keyframes drift {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(120vw);
  }
}

.child-shell {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 6.5rem;
}

.child-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.greeting-block h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0;
  line-height: 1.15;
}

.greeting-block p {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 1.05rem;
}

.avatar-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 0.45rem 0.85rem 0.45rem 0.45rem;
  box-shadow: var(--shadow);
}

.avatar-face {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffe08a, #ffb347);
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08);
}

.star-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 800;
  color: #9a6b00;
}

.hero-prompt {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  text-align: center;
  margin: 0.5rem 0 1.25rem;
}

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

.world-card {
  appearance: none;
  border: 0;
  text-decoration: none;
  color: inherit;
  background: var(--card);
  border-radius: var(--radius-xl);
  min-height: 170px;
  padding: 1rem 0.85rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  transform: perspective(800px) rotateX(0) translateY(0);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.world-card::after {
  content: "";
  position: absolute;
  inset: auto 12% -18px;
  height: 28px;
  background: rgba(43, 45, 66, 0.12);
  filter: blur(10px);
  border-radius: 50%;
  z-index: 0;
}

.world-card:hover,
.world-card:focus-visible {
  transform: perspective(800px) rotateX(6deg) translateY(-8px) scale(1.03);
  box-shadow: 0 18px 34px rgba(43, 45, 66, 0.22);
  outline: none;
}

.world-card:active {
  transform: perspective(800px) translateY(2px) scale(0.98);
}

.world-icon {
  font-size: 2.6rem;
  line-height: 1;
  position: relative;
  z-index: 1;
  animation: bob 2.8s ease-in-out infinite;
}

.world-card:nth-child(2n) .world-icon {
  animation-delay: -0.6s;
}

.world-card:nth-child(3n) .world-icon {
  animation-delay: -1.2s;
}

.world-label {
  font-family: var(--font-display);
  font-size: 1.05rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

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

.adventure-strip {
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.adventure-strip h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.star-row {
  display: flex;
  gap: 0.35rem;
  font-size: 1.4rem;
}

.mascot-bubble {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 1rem 0 1.25rem;
}

.mascot {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffd166, #ff9f1c);
  display: grid;
  place-items: center;
  font-size: 2rem;
  box-shadow: var(--shadow);
  animation: bob 3s ease-in-out infinite;
}

.bubble {
  background: #fff;
  border-radius: 22px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
  font-weight: 700;
  position: relative;
}

.bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 22px;
  border: 8px solid transparent;
  border-right-color: #fff;
}

.child-nav {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 1.25rem));
  background: rgba(255, 255, 255, 0.96);
  border-radius: 28px;
  box-shadow: 0 10px 30px rgba(43, 45, 66, 0.2);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.15rem;
  padding: 0.45rem;
  z-index: 20;
}

.child-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  text-align: center;
  border-radius: 20px;
  padding: 0.45rem 0.2rem;
  font-weight: 800;
  font-size: 0.72rem;
}

.child-nav a span {
  display: block;
  font-size: 1.35rem;
  line-height: 1.2;
}

.child-nav a.active,
.child-nav a:hover {
  background: #e8f6ff;
  color: var(--ink);
}

.toy-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(180deg, #ff9a76 0%, var(--coral) 100%);
  border-radius: 18px;
  min-height: var(--touch);
  padding: 0.75rem 1.4rem;
  box-shadow: 0 8px 0 #d4573a, 0 12px 20px rgba(212, 87, 58, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.toy-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #d4573a, 0 4px 10px rgba(212, 87, 58, 0.25);
}

.toy-btn.secondary {
  background: linear-gradient(180deg, #6ec6ff 0%, #3aa0e8 100%);
  box-shadow: 0 8px 0 #2a7fb8, 0 12px 20px rgba(42, 127, 184, 0.35);
}

.toy-btn.secondary:active {
  box-shadow: 0 2px 0 #2a7fb8, 0 4px 10px rgba(42, 127, 184, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  .cloud,
  .world-icon,
  .mascot {
    animation: none !important;
  }

  .world-card {
    transition: none;
  }
}

@media (max-width: 480px) {
  .worlds-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* —— Phase 2 shared —— */
.page-head { text-align: center; margin-bottom: 1rem; }
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0.4rem 0;
}
.page-head p { margin: 0; font-weight: 700; color: var(--ink-soft); }
.back-pill {
  display: inline-flex;
  align-items: center;
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.mascot-bubble.compact { margin: 0.5rem 0 1rem; }
.mascot-bubble.compact .mascot { width: 56px; height: 56px; font-size: 1.6rem; }
.strip-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.mini-link { font-weight: 800; color: #1c5fc4; text-decoration: none; }
.today-tasks { display: grid; gap: 0.45rem; margin: 0.75rem 0; }
.today-task {
  display: flex; align-items: center; gap: 0.55rem;
  background: #f3f8ff; border-radius: 14px; padding: 0.55rem 0.75rem; font-weight: 800;
}
.today-task.done { background: #e8f8ee; }
.today-task .check { margin-left: auto; color: #059669; }
.star-row .dim, .lesson-stars .dim, .big-star.dim { opacity: 0.35; }
.toast-success {
  background: #ecfdf5; color: #047857; font-weight: 800;
  border-radius: 16px; padding: 0.75rem 1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.empty-state {
  text-align: center; background: rgba(255,255,255,.92);
  border-radius: var(--radius-xl); padding: 2rem 1.25rem; box-shadow: var(--shadow);
}
.empty-art { font-size: 3rem; margin-bottom: 0.5rem; }
.empty-state h2 { font-family: var(--font-display); margin: 0.25rem 0; }
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1rem; }

/* Adventure map */
.map-page .child-shell { max-width: 640px; }
.adventure-map { position: relative; padding: 0.5rem 0 1rem; }
.map-path {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}
.map-nodes {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 1.1rem; position: relative; z-index: 1;
}
.map-node { display: flex; }
.map-node.side-left { justify-content: flex-start; padding-left: 4%; }
.map-node.side-right { justify-content: flex-end; padding-right: 4%; }
.node-btn {
  width: min(240px, 78vw);
  min-height: 88px;
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.2rem; text-decoration: none; color: inherit;
  transform: perspective(700px) rotateX(0);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 0; padding: 0.75rem;
}
.node-btn:not(.is-static):hover,
.node-btn:not(.is-static):focus-visible {
  transform: perspective(700px) rotateX(5deg) translateY(-6px) scale(1.03);
}
.status-available .node-btn {
  animation: pulse-glow 2s ease-in-out infinite;
  border: 3px solid #ffd166;
}
.status-locked .node-btn { opacity: 0.72; filter: grayscale(0.25); }
.status-completed .node-btn { border: 3px solid #7bc96f; }
.node-icon { font-size: 1.8rem; }
.node-title { font-family: var(--font-display); font-weight: 700; text-align: center; }
.node-stars, .node-lock { font-size: 0.95rem; }
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 12px 28px rgba(43,45,66,.18), 0 0 0 0 rgba(255,209,102,.5); }
  50% { box-shadow: 0 14px 30px rgba(43,45,66,.2), 0 0 0 8px rgba(255,209,102,.15); }
}

/* World / lessons */
.world-hero-icon { font-size: 3rem; line-height: 1; animation: bob 2.8s ease-in-out infinite; }
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
}
.lesson-card, .story-card {
  background: #fff; border-radius: var(--radius-lg); padding: 1rem 0.85rem;
  box-shadow: var(--shadow); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 0.35rem; min-height: 140px;
  transition: transform 0.18s ease;
}
.lesson-card:hover, .story-card:hover { transform: translateY(-6px) scale(1.02); }
.lesson-card.status-locked { opacity: 0.7; }
.lesson-badge { font-size: 1.6rem; }
.lesson-title { font-family: var(--font-display); font-size: 1.05rem; text-transform: capitalize; }
.lesson-hint, .activity-meta { font-size: 0.85rem; color: var(--ink-soft); font-weight: 700; }
.activity-list { display: grid; gap: 0.75rem; }
.activity-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem; align-items: center;
  background: #fff; border-radius: 20px; padding: 0.85rem 1rem; text-decoration: none; color: inherit;
  box-shadow: var(--shadow);
}
.activity-emoji { font-size: 1.8rem; }
.activity-name { font-family: var(--font-display); text-transform: capitalize; }
.activity-go {
  width: 44px; height: 44px; border-radius: 50%; background: #ff7a59; color: #fff;
  display: grid; place-items: center; font-weight: 800;
}

/* Play stage */
.play-stage {
  background: rgba(255,255,255,.94); border-radius: 28px; padding: 1.25rem;
  box-shadow: var(--shadow); text-align: center;
}
.letter-hero, .count-hero, .sound-play {
  font-size: clamp(4rem, 18vw, 7rem); line-height: 1;
  font-family: var(--font-display); color: #e76f51;
  text-shadow: 0 8px 0 rgba(0,0,0,.08);
  animation: bob 2.4s ease-in-out infinite;
}
.sound-play {
  width: 120px; height: 120px; border-radius: 50%; border: 0; background: #fff3cd;
  box-shadow: var(--shadow); margin: 0 auto; display: grid; place-items: center; cursor: pointer;
}
.play-caption { font-family: var(--font-display); font-size: 1.35rem; margin: 0.75rem 0 1rem; }
.object-row, .choice-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0.75rem;
}
.object-btn, .choice-card, .carrot-item {
  border: 0; background: #f8fbff; border-radius: 20px; padding: 0.9rem 0.5rem;
  box-shadow: 0 6px 0 rgba(43,45,66,.08); cursor: pointer; font: inherit;
  min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.35rem;
}
.object-btn span, .choice-emoji { font-size: 2rem; }
.choice-letter { font-family: var(--font-display); font-size: 2.4rem; }
.choice-card.is-correct { background: #d8f3dc; box-shadow: 0 6px 0 #74c69d; }
.choice-card.is-almost { animation: shake 0.4s ease; background: #fff3cd; }
.drop-zone {
  min-height: 110px; border: 3px dashed #90caf9; border-radius: 22px;
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; justify-content: center;
  margin: 0.75rem auto; background: #e3f2fd; max-width: 360px; padding: 0.75rem;
}
.drop-hint { font-weight: 800; color: #547fa8; }
.carrot-tray { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin-top: 0.75rem; }
.carrot-item { min-width: 64px; min-height: 64px; font-size: 1.8rem; }
.count-readout { font-family: var(--font-display); font-size: 2rem; margin: 0.5rem 0; }
.complete-btn { margin-top: 1rem; }
.try-again-toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: #fff; border-radius: 999px; padding: 0.7rem 1.1rem; font-weight: 800;
  box-shadow: var(--shadow); z-index: 30;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Celebration */
.celebration-stage { text-align: center; position: relative; overflow: hidden; padding: 1rem 0 2rem; }
.celebration-stage h1 { font-family: var(--font-display); font-size: 2.4rem; margin: 0.5rem 0; }
.trophy-bounce { font-size: 4rem; animation: bob 1.2s ease-in-out infinite; }
.star-fly { display: flex; justify-content: center; gap: 0.5rem; font-size: 2.4rem; margin: 0.75rem 0 1rem; }
.big-star.lit { animation: pop-in 0.45s ease backwards; }
.big-star.lit:nth-child(2) { animation-delay: 0.12s; }
.big-star.lit:nth-child(3) { animation-delay: 0.24s; }
@keyframes pop-in {
  from { transform: scale(0) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.confetti-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece {
  position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px;
  animation: confetti-fall 2.8s linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.2; }
}

/* Games / stories / rewards / me */
.type-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; justify-content: center; }
.type-chip {
  background: rgba(255,255,255,.9); border-radius: 999px; padding: 0.4rem 0.75rem;
  font-weight: 800; box-shadow: var(--shadow); display: inline-flex; gap: 0.35rem; align-items: center;
}
.story-cover { font-size: 2.4rem; }
.story-modes { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.8rem; font-weight: 800; color: var(--ink-soft); }
.story-mode-toggle { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.75rem; flex-wrap: wrap; }
.chip {
  background: rgba(255,255,255,.9); border-radius: 999px; padding: 0.45rem 0.85rem;
  text-decoration: none; color: var(--ink); font-weight: 800; box-shadow: var(--shadow);
}
.chip.on { background: #ffd166; }
.story-book { min-height: 280px; }
.story-page {
  display: none; background: #fff; border-radius: 28px; padding: 1.5rem 1rem;
  box-shadow: var(--shadow); text-align: center;
}
.story-page.active { display: block; animation: pop-in 0.35s ease; }
.story-art { font-size: 4.5rem; margin-bottom: 0.75rem; }
.story-text { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.4; }
.story-controls {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1rem;
}
.page-indicator { font-weight: 800; }
.reward-bank {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-bottom: 1.25rem;
}
.bank-item {
  background: #fff; border-radius: 20px; padding: 0.9rem 0.5rem; text-align: center; box-shadow: var(--shadow);
}
.bank-item span { font-size: 1.5rem; display: block; }
.bank-item strong { font-size: 1.4rem; display: block; font-family: var(--font-display); }
.section-block {
  background: rgba(255,255,255,.92); border-radius: 24px; padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.section-block h2 { font-family: var(--font-display); margin: 0 0 0.75rem; }
.cat-title { margin: 0.75rem 0 0.4rem; color: var(--ink-soft); }
.badge-grid, .sticker-shelf, .pet-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.65rem;
}
.badge-card, .pet-card {
  background: #f8fbff; border-radius: 18px; padding: 0.75rem 0.5rem; text-align: center; font-weight: 800;
  position: relative;
}
.badge-card.locked { opacity: 0.55; filter: grayscale(0.4); }
.badge-icon, .pet-emoji { font-size: 1.8rem; display: block; }
.sticker {
  aspect-ratio: 1; border-radius: 18px; background: #fff8e7; display: grid; place-items: center;
  font-size: 1.8rem; box-shadow: inset 0 0 0 2px rgba(0,0,0,.04);
}
.sticker.ghost { opacity: 0.35; filter: grayscale(1); }
.me-hero {
  display: flex; gap: 1rem; align-items: center; background: #fff; border-radius: 24px;
  padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.avatar-preview {
  width: 96px; height: 112px; border-radius: 24px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.skin-fair { background: #ffe0bd; }
.skin-warm { background: #f1c27d; }
.skin-deep { background: #8d5524; }
.av-face { font-size: 2rem; z-index: 1; margin-bottom: 0.2rem; }
.av-hair {
  position: absolute; top: 8px; width: 54px; height: 28px; border-radius: 20px 20px 8px 8px; background: #3d2914;
}
.hair-curly { border-radius: 50%; height: 36px; }
.hair-long { height: 40px; width: 60px; }
.hair-bun::after {
  content: ""; position: absolute; top: -10px; left: 16px; width: 22px; height: 22px;
  border-radius: 50%; background: #3d2914;
}
.av-shirt {
  width: 70px; height: 34px; border-radius: 12px 12px 0 0;
}
.shirt-yellow { background: #ffd166; }
.shirt-blue { background: #4cc9f0; }
.shirt-green { background: #7bc96f; }
.shirt-coral { background: #ff7a59; }
.avatar-form {
  display: grid; gap: 0.75rem;
}
.avatar-form label { font-weight: 800; display: grid; gap: 0.35rem; }
.avatar-form select, .avatar-form input {
  border: 2px solid #e5e7eb; border-radius: 12px; padding: 0.65rem; font: inherit; background: #fff;
}
.pet-card { cursor: pointer; border: 3px solid transparent; }
.pet-card.selected, .pet-card:has(input:checked) { border-color: #ffd166; background: #fff8e1; }
.pet-card input { position: absolute; opacity: 0; }
.me-links { display: grid; gap: 0.75rem; margin-top: 0.5rem; }

/* World scenery tints */
.scenery-jungle .sky-decor .hill { background: radial-gradient(circle at 50% 0%, #8fd694, #2a9d8f); }
.scenery-alphabet-island .sky-decor { filter: hue-rotate(-10deg); }
.scenery-number-castle .sky-decor { filter: hue-rotate(20deg); }
.scenery-rainbow-hills .hill-left { opacity: 0.7; }
.scenery-treasure .child-shell { background: linear-gradient(180deg, transparent, rgba(255,209,102,.15)); }

/* Phase 4 game engines */
.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.match-col { display: grid; gap: 0.65rem; }
.match-tile {
  min-height: 84px; border: 0; border-radius: 20px; background: #f8fbff;
  box-shadow: 0 6px 0 rgba(43,45,66,.08); font-size: 2rem; cursor: pointer;
}
.match-tile.selected { outline: 3px solid #ffd166; transform: scale(1.04); }
.match-tile.matched { background: #d8f3dc; box-shadow: 0 6px 0 #74c69d; opacity: 0.85; }
.match-status { font-weight: 800; color: var(--ink-soft); margin-top: 0.75rem; }

.sort-board { display: grid; gap: 1rem; }
.zone-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; }
.sort-zone {
  min-height: 140px; border-radius: 22px; background: #eef8ff; border: 3px dashed #90caf9; padding: 0.65rem;
}
.zone-label { font-weight: 800; margin-bottom: 0.4rem; }
.zone-items { display: flex; flex-wrap: wrap; gap: 0.35rem; min-height: 60px; }
.drag-tray { display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center; }
.drag-item {
  border: 0; border-radius: 18px; background: #fff; min-width: 96px; min-height: 88px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.25rem; cursor: pointer;
}
.drag-item.selected { outline: 3px solid #ff7a59; }
.drag-item span { font-size: 1.7rem; }

.memory-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 0.65rem;
  max-width: 420px;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1; border: 0; border-radius: 18px; background: #3aa0e8; color: #fff;
  box-shadow: var(--shadow); position: relative; cursor: pointer;
  transform-style: preserve-3d; transition: transform 0.35s ease;
}
.memory-card.flipped, .memory-card.matched {
  background: #fff; color: var(--ink); transform: rotateY(180deg);
}
.memory-back, .memory-front {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.8rem;
  backface-visibility: hidden;
}
.memory-front { transform: rotateY(180deg); }
.memory-card.matched { outline: 3px solid #7bc96f; }

.balloon-sky {
  position: relative; height: 320px; overflow: hidden; border-radius: 24px;
  background: linear-gradient(180deg, #7ec8ff, #e8f6ff);
}
.balloon-layer { position: absolute; inset: 0; }
.balloon {
  position: absolute; bottom: -40px; width: 72px; height: 88px; border: 0; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  color: #fff; font-family: var(--font-display); font-size: 1.5rem; font-weight: 800;
  box-shadow: inset -8px -10px 0 rgba(0,0,0,.08); cursor: pointer;
  animation: float-up linear forwards;
}
.balloon::after {
  content: ""; position: absolute; left: 50%; bottom: -18px; width: 2px; height: 18px; background: rgba(0,0,0,.25);
}
.balloon.popped { animation: pop 0.35s ease forwards; }
@keyframes float-up {
  from { transform: translateY(0) rotate(-4deg); }
  to { transform: translateY(-380px) rotate(4deg); }
}
@keyframes pop {
  to { transform: scale(1.4); opacity: 0; }
}

.puzzle-preview { font-size: 3rem; margin-bottom: 0.5rem; }
.puzzle-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 0.45rem;
  max-width: 360px;
  margin: 0 auto 0.75rem;
}
.puzzle-tile {
  aspect-ratio: 1; border: 0; border-radius: 16px; cursor: pointer;
  background: hsl(200 70% calc(var(--shade, 0.7) * 100%));
  box-shadow: var(--shadow); position: relative; color: #fff;
}
.puzzle-tile.selected { outline: 3px solid #ffd166; }
.puzzle-emoji { font-size: 1.8rem; filter: grayscale(0.15); opacity: calc(0.45 + var(--shade, 0.5)); }
.puzzle-num {
  position: absolute; right: 8px; bottom: 6px; font-weight: 800; font-size: 0.9rem;
}

.shadow-hero { margin-bottom: 0.75rem; }
.shadow-object { font-size: 4rem; }
.shadow-choice .shadow-silhouette {
  font-size: 2.4rem; filter: brightness(0) opacity(0.75);
}
.shadow-choice.is-correct .shadow-silhouette { filter: none; }

@media (prefers-reduced-motion: reduce) {
  .balloon, .memory-card { animation: none !important; transition: none !important; }
}

/* Phase 5 — Tracing */
.trace-wrap { display: grid; gap: 0.75rem; }
.trace-toolbar { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.trace-tool { min-height: 52px !important; padding: 0.55rem 1rem !important; font-size: 1rem !important; }
.trace-canvas-shell {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fffdf7;
  touch-action: none;
}
#trace-canvas {
  width: 100%;
  height: min(58vh, 420px);
  display: block;
  cursor: crosshair;
  touch-action: none;
}
#trace-canvas.trace-complete {
  animation: pop-in 0.45s ease;
  box-shadow: inset 0 0 0 4px #7bc96f;
}
.trace-hint {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(255,255,255,.92);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--ink-soft);
  pointer-events: none;
}
.start-dot { color: #7bc96f; }
.trace-progress { text-align: center; }
.trace-bar {
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(43,45,66,.08);
  margin-bottom: 0.35rem;
}
.trace-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7bc96f, #ffd166);
  border-radius: inherit;
  transition: width 0.2s ease;
}
.engine-tracing .play-stage { padding-bottom: 1rem; }

/* Phase 6 — Story Land */
.story-card.theme-garden { background: linear-gradient(180deg, #fff, #e8f8ee); }
.story-card.theme-jungle { background: linear-gradient(180deg, #fff, #e7f6ef); }
.story-card.theme-home { background: linear-gradient(180deg, #fff, #fff4e8); }
.story-card.theme-school { background: linear-gradient(180deg, #fff, #eaf4ff); }
.story-card.theme-festival { background: linear-gradient(180deg, #fff, #ffe8f1); }
.story-card.theme-rain { background: linear-gradient(180deg, #fff, #e8f1ff); }

.story-reader .story-book { min-height: 340px; }
.story-page {
  position: relative;
  overflow: hidden;
}
.story-page.enter-right { animation: page-in 0.35s ease; }
@keyframes page-in {
  from { opacity: 0; transform: translateX(24px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
.story-art.tap-target {
  appearance: none;
  border: 0;
  background: transparent;
  width: 100%;
  cursor: pointer;
  position: relative;
  padding: 0.5rem;
}
.art-emoji {
  display: inline-block;
  font-size: 4.5rem;
  line-height: 1;
  filter: drop-shadow(0 8px 0 rgba(0,0,0,.06));
}
.sparkle {
  position: absolute;
  right: 18%;
  top: 12%;
  opacity: 0;
  font-size: 1.4rem;
  pointer-events: none;
}
.tap-cue {
  margin: 0.15rem 0 0.75rem;
  font-weight: 800;
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.fx-bounce .art-emoji { animation: bob 0.55s ease; }
.fx-spin .art-emoji { animation: spin-once 0.7s ease; }
.fx-sparkle .art-emoji { animation: bob 0.45s ease; }
.fx-sparkle .sparkle { animation: spark 0.8s ease; }
.fx-fly .art-emoji { animation: fly-across 0.9s ease; }
.fx-wiggle .art-emoji { animation: wiggle 0.55s ease; }
@keyframes spin-once {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}
@keyframes spark {
  0% { opacity: 0; transform: scale(0.4); }
  40% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: translateY(-18px) scale(0.8); }
}
@keyframes fly-across {
  0% { transform: translateX(0); }
  50% { transform: translateX(40px) translateY(-10px); }
  100% { transform: translateX(0); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
.moral-card .moral-text {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0.35rem 0 0.75rem;
}
.theme-rain .sky-decor { filter: saturate(0.85) hue-rotate(10deg); }
.theme-festival .sky-decor { filter: hue-rotate(-20deg) saturate(1.2); }

@media (prefers-reduced-motion: reduce) {
  .story-page.enter-right,
  .fx-bounce .art-emoji,
  .fx-spin .art-emoji,
  .fx-fly .art-emoji,
  .fx-wiggle .art-emoji,
  .fx-sparkle .sparkle { animation: none !important; }
}

/* Phase 7 — Gamification */
.bonus-row { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; margin: 0.75rem 0; }
.bonus-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  background: linear-gradient(180deg, #fff7d6, #ffe8a3);
  box-shadow: 0 4px 0 rgba(0,0,0,.08);
}
.bonus-chip.streak { background: linear-gradient(180deg, #ffe8d6, #ffc4a3); }
.bonus-chip.sticker { background: linear-gradient(180deg, #e8fff4, #c5f5df); }
.bonus-chip.badge { background: linear-gradient(180deg, #e8f0ff, #c9dbff); }
.daily-strip { margin-bottom: 1.25rem; }
.claim-form { margin-top: 0.75rem; text-align: center; }
.treasure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.85rem;
}
.treasure-card {
  display: block;
  text-align: center;
  text-decoration: none;
  color: inherit;
  padding: 1rem 0.75rem;
  border-radius: 1.25rem;
  background: linear-gradient(180deg, #fff, #fff4d8);
  box-shadow: 0 8px 0 rgba(0,0,0,.06);
  transition: transform 0.2s ease;
}
.treasure-card:hover { transform: translateY(-4px); }
.treasure-card.status-locked { opacity: 0.55; pointer-events: none; filter: grayscale(0.4); }
.treasure-card.status-opened { background: linear-gradient(180deg, #fff, #e8fff4); }
.treasure-emoji { font-size: 2.4rem; margin-bottom: 0.35rem; }
.loot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin: 1rem 0;
}
.loot-item {
  padding: 0.65rem 1rem;
  border-radius: 1rem;
  background: #fff;
  font-weight: 800;
  box-shadow: 0 6px 0 rgba(0,0,0,.06);
}
.chest-bounce { font-size: 4.5rem; }
.map-node.status-available .node-btn { animation: soft-glow 1.6s ease-in-out infinite; }
@keyframes soft-glow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .map-node.status-available .node-btn { animation: none; }
}

/* Phase 9 — a11y */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 1000;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  box-shadow: var(--shadow);
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0.75rem;
  outline: 3px solid #2f80ed;
  outline-offset: 2px;
}
.child-nav a:focus-visible,
.toy-btn:focus-visible,
.back-pill:focus-visible,
.chip:focus-visible,
a.story-card:focus-visible,
a.lesson-card:focus-visible,
a.treasure-card:focus-visible {
  outline: 3px solid #2f80ed;
  outline-offset: 3px;
}
.world-card:focus-visible {
  outline: 3px solid #2f80ed;
  outline-offset: 4px;
  box-shadow: var(--shadow);
}
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}


