:root {
  --ink: #f4ecff;
  --muted: rgba(244, 236, 255, 0.78);
  --violet: #c084fc;
  --cyan: #67e8f9;
  --navy: #0b0520;
  --card: rgba(18, 8, 42, 0.78);
  --accent: #4ade80;
  --accent-dark: #166534;
  --coral: #fb7185;
  --sun: #fbbf24;
  --blue: #67e8f9;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --font: "Nunito", system-ui, sans-serif;
}

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

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--navy);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* Kids read uppercase only — apply to all game UI text */
  text-transform: uppercase;
}

a { color: inherit; text-decoration: none; }
button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #0b0520;
}

.hero-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 12% 68%;
  filter: saturate(1.05) brightness(0.72);
  transform: scale(1.04);
}

.scene picture { position: absolute; inset: 0; display: block; }

.mist {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(11, 5, 32, 0.55) 0%, rgba(11, 5, 32, 0.35) 45%, rgba(11, 5, 32, 0.5) 100%),
    linear-gradient(180deg, rgba(11, 5, 32, 0.35) 0%, transparent 18%, transparent 55%, rgba(11, 5, 32, 0.78) 100%);
}

.top, main {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 0;
  max-width: 720px;
  margin: 0 auto;
}

.back,
.nav-home {
  appearance: none;
  border: 1px solid rgba(192, 132, 252, 0.45);
  background: rgba(12, 6, 36, 0.72);
  backdrop-filter: blur(10px);
  font-weight: 800;
  font-size: 14px;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}

.nav-home { margin-bottom: 10px; }

.stars-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(12, 6, 36, 0.78);
  border: 1px solid rgba(251, 191, 36, 0.55);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.18);
  backdrop-filter: blur(10px);
}

.star-icon { color: var(--sun); font-size: 20px; text-shadow: 0 0 10px rgba(251, 191, 36, 0.7); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 18px 48px;
}

.view { animation: pop 0.35s ease; }
.hidden { display: none !important; }

@keyframes pop {
  0% { transform: scale(0.94); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes bounce-in {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.brand {
  font-weight: 800;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  line-height: 1.05;
  margin-top: 18px;
  text-shadow: 0 0 22px rgba(103, 232, 249, 0.35);
}

.hero-title {
  font-size: clamp(1.25rem, 4vw, 1.7rem);
  font-weight: 800;
  margin-top: 8px;
  color: #fff;
}

.hero-sub {
  margin-top: 8px;
  font-size: 1.02rem;
  color: var(--muted);
  max-width: 30ch;
  font-weight: 700;
}

.menu {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.menu-card {
  appearance: none;
  border: 1px solid rgba(192, 132, 252, 0.4);
  cursor: pointer;
  text-align: left;
  background: var(--card);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow), 0 0 28px rgba(124, 58, 237, 0.18);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 16px;
  row-gap: 2px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.menu-card:hover {
  transform: translateY(-3px);
  border-color: rgba(103, 232, 249, 0.55);
  box-shadow: var(--shadow), 0 0 36px rgba(103, 232, 249, 0.22);
}
.menu-card:active { transform: translateY(1px); }

.menu-orb {
  grid-row: 1 / span 2;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  align-self: center;
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow:
    inset -3px -3px 8px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(255, 255, 255, 0.2);
}

.menu-orb.syl {
  background: radial-gradient(circle at 30% 28%, #ecfeff, #22d3ee 48%, #0e7490);
}
.menu-orb.train-orb {
  background: radial-gradient(circle at 30% 28%, #fef9c3, #facc15 48%, #a16207);
}
.menu-orb.math-orb {
  background: radial-gradient(circle at 30% 28%, #fff7ed, #fb923c 48%, #9a3412);
}
.menu-orb.draw-orb {
  background: radial-gradient(circle at 30% 28%, #fce7f3, #e879f9 48%, #86198f);
}

.menu-label {
  font-size: 1.45rem;
  font-weight: 800;
}

.menu-hint {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.98rem;
}

.game-title {
  font-size: clamp(1.55rem, 5vw, 2rem);
  font-weight: 800;
  text-shadow: 0 0 16px rgba(192, 132, 252, 0.35);
}

.game-sub {
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
  margin-bottom: 16px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.progress-track {
  flex: 1;
  height: 14px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(192, 132, 252, 0.35);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4ade80, #67e8f9);
  border-radius: inherit;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.55);
}

.progress-label {
  font-weight: 800;
  min-width: 4.5ch;
  text-align: right;
}

.word-stage,
.orchard {
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(192, 132, 252, 0.35);
  border-radius: var(--radius);
  padding: 20px 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.word-stage { text-align: center; }

.word-picture {
  appearance: none;
  border: 2px solid rgba(192, 132, 252, 0.45);
  background: rgba(255, 255, 255, 0.1);
  width: min(42vw, 168px);
  height: min(42vw, 168px);
  border-radius: 28px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(124, 58, 237, 0.25);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.word-picture:active { transform: scale(0.97); }
.word-picture:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.word-emoji {
  font-size: clamp(4.2rem, 18vw, 6.2rem);
  line-height: 1;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
  user-select: none;
}

.speak-btn {
  appearance: none;
  border: 1px solid rgba(103, 232, 249, 0.45);
  background: rgba(103, 232, 249, 0.12);
  color: var(--cyan);
  font-weight: 800;
  font-size: 15px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  margin-bottom: 12px;
}

.built {
  min-height: 64px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: clamp(1.65rem, 6.5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.built .slot {
  min-width: 2.2ch;
  padding: 8px 12px;
  background: rgba(74, 222, 128, 0.1);
  border: 2px dashed rgba(74, 222, 128, 0.45);
  border-radius: 14px;
  color: #bbf7d0;
}

.built .slot.filled {
  background: rgba(74, 222, 128, 0.22);
  border-style: solid;
  border-color: var(--accent);
  animation: bounce-in 0.28s ease;
}

.target-hint {
  margin-top: 10px;
  font-weight: 800;
  color: var(--muted);
  font-size: 1.05rem;
  min-height: 1.4em;
}

.syllable-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.syl-btn,
.num-btn {
  appearance: none;
  border: 1px solid rgba(192, 132, 252, 0.4);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  border-radius: 18px;
  background: rgba(18, 8, 42, 0.88);
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, opacity 0.12s ease, border-color 0.12s ease;
}

.syl-btn {
  font-size: clamp(1.45rem, 5.5vw, 1.85rem);
  padding: 16px 20px;
  min-width: 78px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 4px solid rgba(103, 232, 249, 0.65);
}

.syl-btn:active { transform: scale(0.96); }
.syl-btn.used {
  opacity: 0.28;
  pointer-events: none;
  transform: scale(0.92);
}

.game-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 22px;
  border-radius: 16px;
  min-width: 130px;
}

.btn.primary {
  background: linear-gradient(180deg, #4ade80, #16a34a);
  color: #fff;
  box-shadow: 0 6px 0 #14532d, 0 0 20px rgba(74, 222, 128, 0.35);
}
.btn.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 #14532d; }

.btn.ghost {
  background: rgba(12, 6, 36, 0.72);
  color: var(--ink);
  border: 1px solid rgba(192, 132, 252, 0.4);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}

.feedback {
  text-align: center;
  font-weight: 800;
  font-size: 1.3rem;
  margin: 12px 0 4px;
  min-height: 1.5em;
}

.feedback.ok { color: #86efac; animation: bounce-in 0.35s ease; }
.feedback.bad { color: var(--coral); animation: shake 0.35s ease; }

.orchard {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 110px;
}

.apple {
  font-size: 2rem;
  line-height: 1;
  animation: bounce-in 0.35s ease both;
}
.apple.gone {
  opacity: 0.22;
  filter: grayscale(0.6);
  transform: scale(0.85);
}
.apple.added {
  outline: 3px solid rgba(74, 222, 128, 0.55);
  border-radius: 50%;
}

.math-equation {
  text-align: center;
  font-size: clamp(2.6rem, 12vw, 4rem);
  font-weight: 800;
  margin: 8px 0 18px;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: #fff;
  text-shadow:
    0 0 3px rgba(0, 0, 0, 1),
    0 2px 0 rgba(0, 0, 0, 0.55),
    0 0 22px rgba(103, 232, 249, 0.45);
  background: rgba(12, 6, 36, 0.55);
  border: 1px solid rgba(103, 232, 249, 0.35);
  border-radius: 22px;
  padding: 14px 12px;
}

.word-picture-sm {
  width: min(28vw, 112px);
  height: min(28vw, 112px);
  border-radius: 22px;
  margin-bottom: 8px;
}
.word-picture-sm .word-emoji {
  font-size: clamp(2.6rem, 12vw, 3.6rem);
}

.train-stage { padding-bottom: 12px; }

.train-scene {
  position: relative;
  margin: 10px 0 6px;
  padding-top: 28px;
}

.train-dock {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
}

.train-dock-flag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.92);
  color: #422006;
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.35);
}

.train-rail {
  position: relative;
  overflow: hidden;
  height: 108px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, transparent 72%, rgba(255, 255, 255, 0.12) 72%, rgba(255, 255, 255, 0.12) 78%, transparent 78%),
    rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(250, 204, 21, 0.28);
}

.train-rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  bottom: 10px;
  width: 3px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, rgba(250, 204, 21, 0.75), transparent);
  z-index: 1;
  pointer-events: none;
}

.train-convoy {
  position: absolute;
  left: 50%;
  bottom: 18px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  will-change: transform;
  transition: transform 0.55s cubic-bezier(0.22, 0.9, 0.3, 1);
}

.train-engine {
  font-size: 2.8rem;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
  animation: train-chug 0.45s ease-in-out infinite alternate;
}

@keyframes train-chug {
  from { transform: translateY(0); }
  to { transform: translateY(-3px); }
}

.train-car {
  width: 64px;
  min-height: 62px;
  padding: 8px 6px 12px;
  border-radius: 12px 12px 8px 8px;
  border: 3px dashed rgba(250, 204, 21, 0.45);
  background: rgba(250, 204, 21, 0.1);
  color: #fef9c3;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}

.train-car::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -6px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.train-car.active {
  border-style: solid;
  border-color: #fde047;
  background: rgba(250, 204, 21, 0.28);
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.45);
  transform: translateY(-4px);
}

.train-car.filled {
  border-style: solid;
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.22);
  color: #bbf7d0;
}

.train-car.miss {
  animation: shake 0.35s ease;
  border-color: var(--coral);
}

.train-timer {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.35);
  overflow: hidden;
  margin: 8px auto 0;
  max-width: 280px;
}

.train-timer-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #facc15, #fb923c);
  transform: scaleX(1);
}

.train-timer-fill.running {
  transition: transform linear;
}

@media (prefers-reduced-motion: reduce) {
  .train-engine { animation: none; }
  .train-convoy { transition: none; }
  .train-timer-fill.running { transition: none; }
}

/* ——— Magical worlds studio ——— */
#view-draw {
  max-width: 920px;
  padding-bottom: 24px;
}

.world-nav { margin-bottom: 6px; }

.world-studio {
  display: grid;
  gap: 12px;
  position: relative;
}

.world-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 4px 2px;
  width: 100%;
}

.world-card {
  appearance: none;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 0.85;
  padding: 6px 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 2px;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}
.world-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.05), rgba(0,0,0,0.45));
  pointer-events: none;
}
.world-card .world-emoji,
.world-card .world-name {
  position: relative;
  z-index: 1;
}
.world-card .world-emoji { font-size: 1.85rem; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
.world-card .world-name {
  font-size: 0.62rem;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
  line-height: 1.15;
  text-align: center;
}
.world-card.active {
  border-color: #fde68a;
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 14px 28px rgba(253, 230, 138, 0.35), 0 0 0 3px rgba(253, 230, 138, 0.25);
}
.world-card:active { transform: scale(0.96); }

.world-card[data-world="antarctica"] { background: linear-gradient(160deg, #e0f2fe, #7dd3fc 40%, #0369a1 78%, #f8fafc); }
.world-card[data-world="forest"] { background: linear-gradient(160deg, #bbf7d0, #4ade80 35%, #166534 70%, #854d0e); }
.world-card[data-world="ocean"] { background: linear-gradient(160deg, #a5f3fc, #22d3ee 30%, #0369a1 65%, #083344); }
.world-card[data-world="space"] { background: linear-gradient(160deg, #312e81, #4c1d95 40%, #0f172a 75%, #fbbf24); }
.world-card[data-world="dino"] { background: linear-gradient(160deg, #fde68a, #86efac 35%, #15803d 70%, #7f1d1d); }
.world-card[data-world="castle"] { background: linear-gradient(160deg, #ddd6fe, #f9a8d4 40%, #86efac 75%, #be123c); }
.world-card[data-world="candy"] { background: linear-gradient(160deg, #fbcfe8, #fde68a 40%, #fda4af 75%, #c084fc); }
.world-card[data-world="farm"] { background: linear-gradient(160deg, #bae6fd, #fef08a 40%, #86efac 70%, #dc2626); }

.world-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 640;
  max-height: min(58vh, 520px);
  margin: 0 auto;
  border-radius: 28px;
  overflow: hidden;
  border: 3px solid rgba(253, 230, 138, 0.55);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(192, 132, 252, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  touch-action: none;
  background: #0c0820;
}

.world-stage canvas,
.world-stickers,
.world-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#world-bg { z-index: 1; }
#world-paint {
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
}
.world-stickers {
  z-index: 3;
  pointer-events: none;
}
#world-fx {
  z-index: 4;
  pointer-events: none;
}
.world-sky {
  z-index: 5;
  pointer-events: none;
  transition: background 0.55s ease, opacity 0.55s ease, box-shadow 0.55s ease;
  opacity: 0;
}
.world-sky.night {
  opacity: 1;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.62), rgba(30, 27, 75, 0.32) 55%, rgba(15, 23, 42, 0.2));
}
.world-sky.dusk {
  opacity: 1;
  background: linear-gradient(180deg, rgba(251, 146, 60, 0.38), rgba(192, 132, 252, 0.22) 45%, rgba(244, 114, 182, 0.12));
}
.world-sky.wx-rain {
  opacity: 1;
  background: linear-gradient(180deg, rgba(30, 64, 175, 0.35), rgba(51, 65, 85, 0.22) 60%, rgba(30, 58, 138, 0.18));
}
.world-sky.wx-snow {
  opacity: 1;
  background: linear-gradient(180deg, rgba(186, 230, 253, 0.4), rgba(241, 245, 249, 0.22) 55%, rgba(148, 163, 184, 0.12));
}
.world-sky.wx-wind {
  opacity: 1;
  background: linear-gradient(180deg, rgba(253, 230, 138, 0.18), rgba(255, 255, 255, 0.08) 50%, transparent);
}
.world-sky.wx-storm {
  opacity: 1;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.55), rgba(30, 41, 59, 0.4) 50%, rgba(15, 23, 42, 0.28));
}
.world-sky.wx-magic {
  opacity: 1;
  background: linear-gradient(180deg, rgba(126, 34, 206, 0.35), rgba(219, 39, 119, 0.18) 50%, rgba(56, 189, 248, 0.12));
}
.world-sky.night.wx-rain,
.world-sky.night.wx-storm {
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.72), rgba(30, 27, 75, 0.45) 55%, rgba(15, 23, 42, 0.35));
}

.world-sticker {
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 64px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.28));
  transition: filter 0.2s ease;
  z-index: 3;
}
.world-sticker-face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 48px;
  line-height: 1;
  transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1));
  transform-origin: center center;
}
.world-sticker.selected {
  filter: drop-shadow(0 0 10px rgba(253, 230, 138, 0.85)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  z-index: 6;
}
.world-sticker.dragging { cursor: grabbing; z-index: 7; }

.world-studio.alive .world-sticker-face {
  animation: sticker-bob 2.4s ease-in-out infinite;
}
.world-studio.alive .world-sticker:nth-child(3n) .world-sticker-face {
  animation-name: sticker-sway;
  animation-duration: 3.2s;
}
.world-studio.alive .world-sticker:nth-child(4n) .world-sticker-face {
  animation-name: sticker-twinkle;
  animation-duration: 1.8s;
}
.world-studio.alive .world-sticker:nth-child(5n) .world-sticker-face {
  animation-name: sticker-spin-soft;
  animation-duration: 4.5s;
}

@keyframes sticker-bob {
  0%, 100% { transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1)) translateY(0); }
  50% { transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1)) translateY(-10px); }
}
@keyframes sticker-sway {
  0%, 100% { transform: rotate(calc(var(--rot, 0deg) - 6deg)) scale(var(--scale, 1)); }
  50% { transform: rotate(calc(var(--rot, 0deg) + 6deg)) scale(var(--scale, 1)); }
}
@keyframes sticker-twinkle {
  0%, 100% { transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1)); filter: drop-shadow(0 0 4px rgba(255,255,255,0.3)); }
  50% { transform: rotate(var(--rot, 0deg)) scale(calc(var(--scale, 1) * 1.12)); filter: drop-shadow(0 0 14px rgba(253,230,138,0.9)); }
}
@keyframes sticker-spin-soft {
  0% { transform: rotate(var(--rot, 0deg)) scale(var(--scale, 1)); }
  100% { transform: rotate(calc(var(--rot, 0deg) + 360deg)) scale(var(--scale, 1)); }
}

.sticker-handles {
  position: absolute;
  z-index: 8;
  display: flex;
  gap: 6px;
  transform: translate(-50%, -120%);
  pointer-events: auto;
}
.sticker-handles.hidden { display: none; }
.handle-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(15, 8, 40, 0.82);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.handle-btn:active { transform: scale(0.92); }

.world-dock {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(251, 191, 36, 0.18), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(56, 189, 248, 0.16), transparent 45%),
    rgba(12, 6, 36, 0.78);
  border: 1px solid rgba(253, 230, 138, 0.28);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.dock-row {
  display: grid;
  gap: 6px;
  width: 100%;
}

#world-brushes {
  grid-template-columns: repeat(9, minmax(0, 1fr));
}
.brush-btn.brush-clear {
  background: rgba(148, 163, 184, 0.22);
  border-color: rgba(226, 232, 240, 0.45);
}
.brush-btn.brush-clear.active {
  border-color: #86efac;
  background: rgba(134, 239, 172, 0.22);
  box-shadow: 0 0 14px rgba(134, 239, 172, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.stickers-dock {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  overflow: visible;
  max-height: none;
  padding: 0;
}

.brush-btn,
.bank-sticker,
.mood-btn {
  appearance: none;
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: clamp(1.05rem, 4.6vw, 1.55rem);
  line-height: 1;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.brush-btn:active,
.bank-sticker:active,
.mood-btn:active { transform: scale(0.94); }
.brush-btn.active,
.bank-sticker.active,
.mood-btn.active {
  border-color: #fde68a;
  background: rgba(253, 230, 138, 0.22);
  box-shadow: 0 0 18px rgba(253, 230, 138, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.mood-dock {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.mood-group {
  display: grid;
  gap: 6px;
  width: 100%;
}
#world-time {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
#world-weather {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.mood-btn {
  aspect-ratio: 1.15;
  border-radius: 14px;
}

.dock-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.world-action {
  appearance: none;
  width: 64px;
  height: 64px;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(18, 8, 42, 0.85);
  color: #fff;
  font-size: 1.7rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
}
.world-action.save {
  background: linear-gradient(160deg, #34d399, #059669);
  border-color: rgba(167, 243, 208, 0.7);
}
.world-action.life {
  width: auto;
  min-width: 72px;
  padding: 0 18px;
  background: linear-gradient(160deg, #fbbf24, #f97316 55%, #db2777);
  border-color: rgba(254, 240, 138, 0.85);
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.4), 0 8px 18px rgba(0, 0, 0, 0.28);
  animation: life-pulse 1.8s ease-in-out infinite;
}
@keyframes life-pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(251, 191, 36, 0.35), 0 8px 18px rgba(0, 0, 0, 0.28); }
  50% { box-shadow: 0 0 32px rgba(251, 191, 36, 0.65), 0 8px 18px rgba(0, 0, 0, 0.28); }
}

.world-wake {
  appearance: none;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 40;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.65);
  background: linear-gradient(160deg, #c084fc, #7c3aed);
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.45);
}
.world-wake.hidden { display: none; }

.world-studio.alive .world-picker,
.world-studio.alive .world-dock,
.world-studio.alive .sticker-handles,
#view-draw.alive .world-nav {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.world-studio.alive .world-stage {
  max-height: min(78vh, 640px);
  border-color: rgba(253, 230, 138, 0.85);
  box-shadow: 0 0 48px rgba(251, 191, 36, 0.35), 0 20px 50px rgba(0, 0, 0, 0.4);
}

@media (max-width: 560px) {
  .world-card { border-radius: 14px; }
  .world-card .world-emoji { font-size: 1.35rem; }
  .world-card .world-name { font-size: 0.52rem; }
  .brush-btn, .bank-sticker, .mood-btn { font-size: clamp(1rem, 4.2vw, 1.35rem); }
  .world-action { width: 56px; height: 56px; font-size: 1.45rem; }
  .world-action.life { min-width: 64px; }
  .world-dock { padding: 10px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .world-studio.alive .world-sticker-face,
  .world-action.life { animation: none; }
}

.answer-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
}

.num-btn {
  font-size: 1.4rem;
  padding: 14px 0;
  border-bottom: 4px solid rgba(251, 146, 60, 0.55);
}
.num-btn:active { transform: translateY(2px); }
.num-btn.correct-flash {
  background: rgba(74, 222, 128, 0.28);
  border-color: var(--accent);
  color: #bbf7d0;
}
.num-btn.wrong-flash {
  background: rgba(251, 113, 133, 0.22);
  color: var(--coral);
  animation: shake 0.3s ease;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 3, 24, 0.72);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: pop 0.25s ease;
  backdrop-filter: blur(6px);
}

.overlay-card {
  background: rgba(18, 8, 42, 0.94);
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 28px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: var(--shadow), 0 0 40px rgba(124, 58, 237, 0.3);
  max-width: 360px;
  width: 100%;
}

.overlay-stars {
  font-size: 2.4rem;
  color: var(--sun);
  letter-spacing: 4px;
  animation: bounce-in 0.45s ease;
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.55);
}

.overlay-card h2 {
  font-size: 2rem;
  margin-top: 6px;
  font-weight: 800;
}

.overlay-card p {
  margin-top: 6px;
  font-weight: 700;
  color: var(--muted);
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

@media (min-width: 560px) {
  .menu { grid-template-columns: 1fr 1fr; }
  .overlay-actions { flex-direction: row; justify-content: center; }
}

@media (max-width: 820px) {
  .hero-art { object-position: 8% 72%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
