:root {
  --ink: #2b2250; --line: #2b2250; --card: #fff; --muted: #5d5a85;
  --yellow: #ffd23f; --pink: #ff5fa2; --green: #3ddc84; --purple: #8b5cf6;
  --orange: #ff9f43; --blue: #3fa9ff; --red: #ff5a5f; --mint: #3ddc84; --lav: #efe7ff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font-family: "Nunito", system-ui, sans-serif;
  background: repeating-linear-gradient(135deg, #fff4da 0 18px, #ffe6ef 18px 36px, #e3f9f1 36px 54px, #e4edff 54px 72px) fixed;
  overflow-x: hidden;
}
.carnival-scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.tent { position:absolute; bottom:-10px; font-size:clamp(5rem,13vw,11rem); filter:drop-shadow(0 6px 0 #43284c33); opacity:.8; }.tent-left{left:-18px}.tent-right{right:-16px}
.balloon{position:absolute;font-size:clamp(2.8rem,6vw,5.8rem);animation:balloon-float 5s ease-in-out infinite}.balloon-one{left:8vw;top:8vh}.balloon-two{right:9vw;top:18vh;animation-delay:-1.8s}.balloon-three{left:18vw;bottom:10vh;animation-delay:-3.3s}
.confetti-dot{position:absolute;width:16px;height:16px;border-radius:4px;background:#ff5fa2;animation:confetti-dance 3.3s ease-in-out infinite}.dot-one{left:4vw;top:42vh}.dot-two{right:5vw;top:58vh;background:#8b5cf6;animation-delay:-1s}.dot-three{right:17vw;top:7vh;background:#ffd23f;animation-delay:-2.2s}
@keyframes balloon-float{50%{transform:translateY(-26px) rotate(7deg)}}@keyframes confetti-dance{50%{transform:translateY(24px) rotate(160deg)}}
.floaties { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.floaties span { position: absolute; bottom: -3rem; font: 800 2rem "Baloo 2", sans-serif; color: #fff; opacity: .55; animation: drift linear infinite; }
@keyframes drift { to { transform: translateY(-115vh) rotate(40deg); } }
.shell { position: relative; z-index: 1; width: min(720px, calc(100% - 28px)); margin: 0 auto; padding: 14px 0 24px; }

/* sticker look shared by cards and buttons */
.stat, .game, .panel, .hero-card, .world-btn, .back-link, .sound-btn, .chip, .gate, .start-btn, .champion-card {
  border: 3px solid var(--line);
}

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.back-link, .sound-btn { padding: 7px 16px; border-radius: 999px; background: #fff; color: var(--ink); text-decoration: none; font: 800 .9rem "Nunito", sans-serif; cursor: pointer; box-shadow: 0 4px 0 var(--line); transition: transform .1s, box-shadow .1s; }
.back-link:hover, .sound-btn:hover { background: var(--yellow); }
.back-link:active, .sound-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

.hero { text-align: center; margin: 14px 0 16px; }
.hero h1 { margin: 0; font: 800 clamp(2.35rem, 9vw, 3.8rem)/1 "Baloo 2", sans-serif; color: #ff7b3d; -webkit-text-stroke: 3px #3c2957; paint-order: stroke fill; text-shadow: 0 5px 0 #3c2957; letter-spacing: .02em; }
.hero h1 em { font-style: normal; display: inline-block; color: #8b5cf6; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) scale(1.05); } }
.hero p { margin: 10px auto 0; display: inline-block; padding: 6px 16px; border-radius: 999px; background: #fff; border: 3px solid var(--line); font-weight: 800; font-size: .95rem; }
.label { margin: 0 0 10px; font: 800 1.1rem "Baloo 2", sans-serif; color: var(--ink); }
.label-sub { font: 700 .85rem "Nunito", sans-serif; color: var(--muted); }

/* score strip */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { padding: 6px 4px; text-align: center; background: #fff; border-radius: 16px; box-shadow: 0 4px 0 var(--line); }
.stat-k { display: block; font: 800 .7rem "Nunito", sans-serif; color: var(--muted); }
.stat b { display: block; font: 800 1.2rem/1.25 "Baloo 2", sans-serif; }
#energy { letter-spacing: .05em; }
#coins { color: #c47a00; }
#combo { color: var(--purple); }
#ratingTotal { color: #e08a00; }
.stat.bump b { animation: pop .4s ease-out; }

/* main game card */
.game { position: relative; padding: 16px; background: #fffdf8; border-radius: 28px; box-shadow: 0 8px 0 var(--line), 0 14px 35px #7f4b7540; }
.game::before { content: ""; position: absolute; inset: 8px; pointer-events: none; border: 2px dashed #ff9f4366; border-radius: 22px; }
.game.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-8px) rotate(-.6deg); } 40% { transform: translateX(8px) rotate(.6deg); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.game-head { display: flex; align-items: center; gap: 10px; }
.level-pill { flex: 1; min-width: 0; padding: 6px 14px; border: 3px solid var(--line); border-radius: 999px; background: var(--yellow); color: var(--ink); font: 800 .95rem "Nunito", sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
select { font: 800 .9rem "Nunito", sans-serif; padding: 6px 8px; border-radius: 12px; border: 3px solid var(--line); background: #fff; color: var(--ink); }
.timer { min-width: 4.2em; padding: 3px 10px; text-align: center; border: 3px solid var(--line); border-radius: 999px; background: #d9ffe9; font: 800 1.15rem "Baloo 2", sans-serif; color: #158a4c; }
.timer.low { background: #ffe0e0; color: var(--red); animation: tick .5s ease-in-out infinite; }
@keyframes tick { 50% { transform: scale(1.1); } }
.timebar { height: 16px; margin: 10px 0 12px; background: #eef; border: 3px solid var(--line); border-radius: 999px; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--green); transition: width 1s linear; }
.timebar i.low { background: var(--red); }

.coach-row { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.avatar { flex: none; width: 60px; height: 60px; object-fit: contain; border: 3px solid var(--line); border-radius: 50%; background: #fff3c4; animation: bob 2s ease-in-out infinite; }
.avatar.happy { animation: hero-cheer .7s ease-in-out 2; } .avatar.oops { animation: hero-oops .42s ease-in-out 2; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(3deg); } }
@keyframes hero-cheer { 50% { transform: translateY(-12px) rotate(-12deg) scale(1.12); } } @keyframes hero-oops { 25% { transform: translateX(-6px) rotate(-8deg); } 75% { transform: translateX(6px) rotate(8deg); } }
.coach { position: relative; margin: 0; padding: 9px 14px; border: 3px solid var(--line); border-radius: 18px; background: var(--lav); font-weight: 800; font-size: .92rem; line-height: 1.3; }
.coach::before { content: ""; position: absolute; left: -10px; top: 50%; width: 14px; height: 14px; margin-top: -7px; background: var(--lav); border-left: 3px solid var(--line); border-bottom: 3px solid var(--line); transform: rotate(45deg); }

.mission-title { margin: 14px 0 6px; text-align: center; }
.mission-title { font: 800 .9rem "Nunito", sans-serif; letter-spacing: .1em; color: var(--pink); }
.question { margin: 0; padding: 20px 12px; min-height: 120px; display: grid; place-items: center; text-align: center; background: linear-gradient(135deg,#fff1bd,#ffe1ef); border: 3px solid var(--line); border-radius: 22px; box-shadow: inset 0 -7px 0 #ff9f4366; font: 800 clamp(1.35rem, 5.4vw, 2rem)/1.38 "Baloo 2", sans-serif; color: var(--ink); overflow-wrap: anywhere; }
.pick-label { margin: 14px 0 8px; text-align: center; font: 800 1.05rem "Baloo 2", sans-serif; color: var(--muted); }

.answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gate { position: relative; padding: 22px 6px 19px; border-radius: 50% 50% 20px 20px; background: var(--c); color: #fff; font: 800 clamp(1.8rem, 8vw, 2.8rem)/1 "Baloo 2", sans-serif; text-shadow: 0 3px 0 rgba(0,0,0,.28); cursor: pointer; box-shadow: 0 7px 0 var(--line); transition: transform .1s, box-shadow .1s; }
.gate:hover:not(:disabled) { transform: translateY(-4px) rotate(-1.5deg); box-shadow: 0 11px 0 var(--line); }
.gate:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 2px 0 var(--line); }
.gate:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }
.gate:disabled { cursor: default; }
.gate.right { background: var(--green); animation: pop .45s ease-out; }
.gate.blocked { background: #c9c7dc; color: #8a87a8; text-shadow: none; box-shadow: none; transform: translateY(6px) rotate(2deg); text-decoration: line-through; }
.gate small { position: absolute; top: 6px; left: 12px; font: 800 .75rem "Nunito", sans-serif; opacity: .85; text-shadow: none; }
@keyframes pop { 40% { transform: scale(1.14) rotate(-3deg); } 70% { transform: scale(.96); } }

.feedback { margin: 12px 0 0; min-height: 1.7em; text-align: center; font: 800 1.45rem "Baloo 2", sans-serif; color: #158a4c; animation: pop .4s ease-out; }
.feedback.bad { color: var(--red); }
.message { margin: 0; min-height: 1.4em; text-align: center; font-weight: 800; color: var(--muted); }

.steps-wrap { margin-top: 10px; text-align: center; }
.steps { display: flex; justify-content: center; gap: 10px; }
.steps i { width: 36px; height: 36px; border: 3px solid var(--line); border-radius: 50%; background: #fff; display: grid; place-items: center; font-style: normal; font-size: 1.1rem; transition: background .2s; }
.steps i::before { content: "☆"; color: #bbb; }
.steps i.on { background: var(--yellow); animation: pop .4s ease-out; }
.steps i.on::before { content: "⭐"; }
.progress-note { margin: 8px 0 0; font-weight: 800; font-size: .88rem; color: var(--ink); }
.run-stars { margin: 4px 0 0; text-align: center; font-weight: 700; font-size: .82rem; color: var(--muted); }

/* burst of emojis on a right answer */
.burst { position: absolute; z-index: 6; left: 0; top: 0; font-size: 1.7rem; pointer-events: none; animation: burst .95s ease-out forwards; }
@keyframes burst { from { opacity: 1; transform: translate(0, 0) scale(.5); } to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1.3); } }

/* start screen */
.start-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(255,249,214,.97); border-radius: 24px; }
.start-overlay[hidden] { display: none; }
.start-card { text-align: center; }
.start-emoji { font-size: 3.4rem; line-height: 1; animation: bob 1.6s ease-in-out infinite; }
.start-kicker { margin: 6px 0 0; display: inline-block; padding: 3px 14px; border: 3px solid var(--line); border-radius: 999px; background: var(--yellow); font: 800 .85rem "Nunito", sans-serif; }
.start-card h2 { margin: 8px 0 6px; font: 800 clamp(1.8rem, 7vw, 2.5rem)/1.1 "Baloo 2", sans-serif; color: var(--purple); }
.start-note { margin: 0 0 18px; font-weight: 700; color: var(--muted); line-height: 1.4; }
.start-btn { padding: 14px 42px; border-radius: 999px; background: var(--green); color: #fff; font: 800 1.6rem "Baloo 2", sans-serif; text-shadow: 0 3px 0 rgba(0,0,0,.25); cursor: pointer; box-shadow: 0 7px 0 var(--line); animation: tick 1.2s ease-in-out infinite; }
.start-btn:hover { background: #2fcf77; }
.start-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--line); animation: none; }
.start-btn:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }

/* secondary panels */
.panel { margin-top: 16px; padding: 14px; background: #fff; border-radius: 24px; box-shadow: 0 6px 0 var(--line); }

.hero-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hero-card { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 16px; background: #fff; color: var(--ink); font: 800 .88rem/1.2 "Nunito", sans-serif; text-align: left; cursor: pointer; box-shadow: 0 4px 0 var(--line); transition: transform .1s; }
.hero-card:hover { transform: translateY(-2px); }
.hero-card img { flex: none; width: 46px; height: 46px; object-fit: contain; }
.hero-card[aria-pressed="true"] { background: var(--yellow); }

.world-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.world-btn { padding: 8px 2px 6px; border-radius: 16px; background: var(--lav); color: var(--ink); font: 800 .75rem/1.2 "Nunito", sans-serif; cursor: pointer; box-shadow: 0 4px 0 var(--line); transition: transform .1s; }
.world-btn:hover:not(:disabled) { transform: translateY(-3px); }
.world-btn .num { display: block; font: 800 1.45rem/1.1 "Baloo 2", sans-serif; color: var(--purple); }
.world-btn .nm { display: block; font-size: .64rem; color: var(--muted); min-height: 1.6em; padding: 0 2px; }
.world-btn .rate { display: block; font-size: .7rem; letter-spacing: .04em; color: #e08a00; }
.world-btn.done { background: #d9ffe9; }
.world-btn.active { background: var(--yellow); }
.world-btn:disabled { background: #e6e4f0; color: #9a97b5; cursor: not-allowed; box-shadow: 0 2px 0 #b9b6d0; border-color: #b9b6d0; }
.world-btn:disabled .num { color: #9a97b5; }
.world-btn:disabled .rate { display: none; }

/* calculator */
.calc summary { cursor: pointer; font: 800 1.1rem "Baloo 2", sans-serif; }
.calc[open] summary { margin-bottom: 12px; }
.calc-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc-inputs label { font-weight: 800; font-size: .85rem; }
.calc-inputs input { display: block; width: 100%; margin-top: 3px; padding: 8px; font: 800 1.1rem "Nunito", sans-serif; text-align: center; border: 3px solid var(--line); border-radius: 14px; color: var(--ink); }
.answer-label { text-align: center; margin-top: 10px; font-weight: 800; font-size: .85rem; color: var(--muted); }
.answer { text-align: center; font: 800 2rem "Baloo 2", sans-serif; color: var(--pink); word-break: break-all; }
.scoreline { display: flex; justify-content: center; font-weight: 800; color: var(--purple); }
.cheer { margin: 4px 0 8px; text-align: center; font-weight: 700; color: var(--muted); }
.calc-controls { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-weight: 800; font-size: .9rem; }
.chip { min-width: 52px; padding: 7px 14px; border-radius: 14px; font: 800 .95rem "Nunito", sans-serif; cursor: pointer; color: var(--ink); box-shadow: 0 3px 0 var(--line); }
.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.chip.yellow { background: var(--yellow); } .chip.mint { background: var(--green); } .chip.red { background: var(--red); color: #fff; }
.keys { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-top: 10px; }
.keys button { padding: 11px 2px; border: 3px solid var(--line); border-radius: 14px; color: #fff; font: 800 1rem "Nunito", sans-serif; text-shadow: 0 2px 0 rgba(0,0,0,.25); cursor: pointer; background: var(--c); box-shadow: 0 4px 0 var(--line); transition: transform .1s; }
.keys button:hover { transform: translateY(-2px); background: var(--yellow); color: var(--ink); text-shadow: none; }
.keys button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.tip { margin: 10px 0 0; text-align: center; font-size: .85rem; color: var(--muted); }

/* dialogs */
.champion { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(43,34,80,.8); overflow: hidden; }
.champion[hidden] { display: none; }
.champion::before, .champion::after { content: "🎉 ⭐ 🎈 ✨ 🎉 ⭐ 🎈 ✨ 🎉 ⭐ 🎈 ✨ 🎉 ⭐ 🎈 ✨"; position: absolute; left: 0; right: 0; top: -2.5rem; text-align: center; font-size: 1.8rem; letter-spacing: .6rem; white-space: nowrap; animation: fall 4s linear infinite; }
.champion::after { animation-delay: -2s; }
@keyframes fall { to { transform: translateY(110vh); } }
.champion-card { position: relative; z-index: 1; width: min(440px, 100%); padding: 26px 22px; text-align: center; background: #fff; border-radius: 28px; box-shadow: 0 10px 0 var(--line); animation: pop .5s ease-out; }
.trophy { font-size: 4.5rem; line-height: 1; animation: bob 1.4s ease-in-out infinite; }
.champion-card h2 { margin: 6px 0 0; font: 800 2.6rem "Baloo 2", sans-serif; color: var(--purple); }
.champion-lead { margin: 4px 0; font-weight: 800; font-size: 1.1rem; }
.champion-sub { margin: 0 0 8px; font-weight: 800; color: var(--pink); }
.champion-stats { margin: 0 0 16px; font-weight: 800; color: #c47a00; }
.champion-card .chip { padding: 10px 26px; font-size: 1.05rem; }
.big-stars { font-size: 2.6rem; letter-spacing: .15em; color: var(--yellow); text-shadow: 0 3px 0 var(--line); line-height: 1.2; margin: 4px 0; }
.level-tip { color: var(--ink); font-size: .9rem; }
.modal-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.champion-card .modal-actions .chip { padding: 10px 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; background: var(--red); color: #fff; border: 3px solid var(--line); border-radius: 16px; font-weight: 800; box-shadow: 0 5px 0 var(--line); z-index: 30; }
footer { position: relative; z-index: 1; text-align: center; padding: 6px 0 20px; font-weight: 800; font-size: .85rem; color: var(--muted); }
footer span { color: var(--pink); }

@media (max-width: 520px) {
  .tent { opacity: .34; } .balloon { opacity: .55; }
  .keys { grid-template-columns: repeat(4, 1fr); }
  .world-row { grid-template-columns: repeat(3, 1fr); }
  .hero-cards { grid-template-columns: 1fr; }
  .stat b { font-size: 1.05rem; }
  .answers { gap: 8px; }
  .steps i { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .burst { display: none; }
}
