:root {
  --world-night: #2f2257;
  --world-plum: #6d3f8c;
  --world-lavender: #c5a5dc;
  --world-moon: #ffd875;
  --world-ink: #342448;
  --world-cream: #fff5dc;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif; color: var(--world-ink); background: var(--world-night); }
button { font: inherit; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 5px solid #fff7bf; outline-offset: 4px; }
button:active { transform: scale(.96) translateY(2px); }
[hidden] { display: none !important; }

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 100%;
  overflow: hidden;
  isolation: isolate;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.world-background, .opening-story-art { position: absolute; inset: 0; z-index: -2; }
.world-background img, .opening-story-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.screen { position: absolute; inset: 0; display: none; }
.screen.is-active { display: block; }
.opening-screen { z-index: 20; background: #35235f; }
.opening-story-art { z-index: 0; }
.opening-screen::after { content: ""; position: absolute; z-index: 1; inset: 0; background: linear-gradient(180deg, rgba(25,15,55,.02) 58%, rgba(35,20,55,.32)); pointer-events: none; }
.image-button, .icon-button, .guide-button, .check-button, .wood-action { background: transparent; padding: 0; }
.touch-target { min-width: 80px; min-height: 80px; }
.play-button { position: absolute; z-index: 2; width: clamp(88px, 10vw, 122px); aspect-ratio: 1; left: 50%; bottom: max(4.5vh, calc(env(safe-area-inset-bottom) + 20px)); transform: translateX(-50%); filter: drop-shadow(0 10px 12px rgba(54,32,15,.32)); }
.play-button:active { transform: translateX(-50%) scale(.95); }
.play-button img, .icon-button img, .wood-action img, .check-button img { width: 100%; height: 100%; object-fit: contain; display: block; }

.play-screen { padding: clamp(8px, 1.4vw, 18px); }
.top-hud {
  position: relative;
  z-index: 8;
  height: clamp(94px, 12vh, 104px);
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(330px, 1fr);
  align-items: start;
  gap: 16px;
  pointer-events: none;
}
.top-hud > * { pointer-events: auto; }
.round-stars, .level-path, .hud-controls {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 3px solid rgba(255,215,116,.76);
  border-radius: 28px;
  background: rgba(255,248,226,.9);
  box-shadow: 0 7px 0 rgba(91,55,38,.4), 0 12px 25px rgba(54,31,74,.2);
}
.round-stars { min-width: 248px; justify-content: space-between; }
.round-token-track { display: flex; align-items: center; gap: 3px; }
.round-token-track img { width: clamp(23px, 2.3vw, 31px); height: clamp(23px, 2.3vw, 31px); object-fit: contain; transition: transform .2s ease, filter .2s ease; }
.round-token-track img.is-arriving { animation: progress-star-arrive .6s cubic-bezier(.2,.85,.3,1); }
.round-count { min-width: 58px; padding: 6px 9px; border: 2px solid rgba(158,99,58,.45); border-radius: 999px; color: #553450; background: linear-gradient(180deg,#fff9e8,#f5dfba); box-shadow: inset 0 2px rgba(255,255,255,.8),0 3px 0 rgba(111,67,43,.26); font-size: clamp(15px,1.6vw,21px); line-height: 1; text-align: center; white-space: nowrap; }
.round-count.is-counting { animation: count-kiss .58s ease; }
.level-path { justify-content: center; gap: 7px; }
.level-dot { width: 30px; height: 30px; border-radius: 50%; background: #d8c5aa; border: 4px solid #9f7044; box-shadow: inset 0 3px rgba(255,255,255,.55); }
.level-dot.is-complete { background: var(--wm-gold); }
.level-dot.is-current { transform: scale(1.22); background: #fff4bb; box-shadow: 0 0 0 5px rgba(255,216,117,.36), inset 0 3px rgba(255,255,255,.75); }
.hud-controls { justify-self: end; padding: 4px 7px; gap: 5px; }
.icon-button { width: 80px; height: 80px; min-width: 80px; min-height: 80px; filter: drop-shadow(0 4px 3px rgba(82,46,27,.24)); }

.game-layout {
  position: absolute;
  inset: clamp(112px, 14vh, 124px) clamp(16px, 2.5vw, 40px) clamp(18px, 2.5vh, 26px);
  display: grid;
  grid-template-columns: minmax(155px, .78fr) minmax(510px, 2.4fr) minmax(180px, .9fr);
  align-items: center;
  gap: clamp(12px, 2vw, 30px);
}
.hero-zone, .guide-zone { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero-character { width: min(100%, 300px); max-height: 70vh; object-fit: contain; filter: drop-shadow(0 15px 16px rgba(47,30,72,.3)); transform-origin: 50% 90%; }
.hero-character.is-happy { animation: hero-hop .75s cubic-bezier(.2,.8,.25,1); }
.hero-character.is-oops { animation: gentle-wobble .58s ease-in-out; }
.hero-aura { position: absolute; width: 80%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,218,114,.35), transparent 68%); opacity: .55; }

.game-board {
  position: relative;
  height: min(650px, calc(100vh - 132px));
  min-height: 500px;
  display: grid;
  grid-template-rows: minmax(300px, 1fr) 166px;
  gap: 15px;
  align-items: center;
  justify-items: center;
  padding: 0 16px 60px;
  border: 0;
  border-radius: 54px;
  background: transparent;
  box-shadow: none;
}
.game-board::before { content: ""; position: absolute; z-index: -1; inset: -26px -34px 10px; border-radius: 50%; background: radial-gradient(ellipse at 50% 44%, rgba(245,199,112,.22), rgba(112,65,139,.12) 44%, transparent 72%); filter: blur(9px); pointer-events: none; }
.game-board::after { content: ""; position: absolute; z-index: -1; left: 12%; right: 12%; bottom: 19px; height: 82px; border-radius: 50%; background: rgba(22,11,35,.42); filter: blur(18px); pointer-events: none; }
.game-board.is-correct { animation: board-success .72s ease; }
.game-board.is-wrong { animation: board-retry .55s ease; }
.moon-stage {
  position: relative;
  z-index: 2;
  width: min(100%, 620px);
  height: 100%;
  min-height: 235px;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 10px solid transparent;
  border-radius: 52px 52px 42px 42px;
  background:
    radial-gradient(ellipse at 50% 110%, rgba(126,76,150,.7) 0 5%, rgba(70,40,104,.66) 36%, rgba(26,14,52,.98) 82%),
    linear-gradient(180deg,#50316f,#25143f) padding-box,
    linear-gradient(145deg,#fff4bf 0%,#e1b85f 9%,#9a5e39 26%,#4b2939 42%,#7e4935 60%,#cf9448 78%,#ffdfa0 91%,#fff7ca 100%) border-box;
  box-shadow:
    0 0 0 3px rgba(70,39,54,.92),
    0 0 0 7px rgba(235,186,92,.56),
    inset 0 0 0 3px rgba(255,244,192,.22),
    inset 0 0 0 9px rgba(42,23,66,.72),
    inset 0 -34px 65px rgba(10,5,29,.5),
    0 9px 0 #48263a,
    0 18px 28px rgba(17,8,31,.48),
    0 0 30px rgba(255,210,105,.22);
}
.moon-stage::before { content: ""; position: absolute; inset: 0; opacity: .64; background-image: radial-gradient(circle,#fff7ce 0 1.4px,transparent 2.4px),radial-gradient(circle,#dcb7f2 0 1px,transparent 2px),radial-gradient(circle,#fff 0 1px,transparent 2px),linear-gradient(118deg,transparent 48%,rgba(240,205,255,.08) 49% 50%,transparent 51%); background-size: 97px 83px,139px 117px,179px 151px,221px 183px; background-position: 14px 9px,58px 37px,20px 82px,31px 18px; }
.moon-stage::after { content: ""; position: absolute; inset: 15px; border: 1px solid rgba(255,231,162,.23); border-radius: 33px 33px 26px 26px; box-shadow: inset 0 0 0 2px rgba(185,135,216,.08),inset 0 0 34px rgba(218,180,255,.1); pointer-events: none; }
.moon-stage[data-material="potion"] { background: radial-gradient(ellipse at 50% 108%,rgba(188,75,173,.36),rgba(67,31,103,.72) 45%,rgba(24,12,49,.98) 82%),linear-gradient(180deg,#57306f,#24133f) padding-box,linear-gradient(145deg,#fff4bf 0%,#e1b85f 9%,#9a5e39 26%,#4b2939 42%,#7e4935 60%,#cf9448 78%,#ffdfa0 91%,#fff7ca 100%) border-box; }
.moon-stage[data-material="crystal"] { background: radial-gradient(ellipse at 50% 108%,rgba(116,80,185,.48),rgba(53,33,98,.72) 44%,rgba(20,13,49,.98) 82%),linear-gradient(180deg,#4a3678,#21143f) padding-box,linear-gradient(145deg,#fff4bf 0%,#e1b85f 9%,#9a5e39 26%,#4b2939 42%,#7e4935 60%,#cf9448 78%,#ffdfa0 91%,#fff7ca 100%) border-box; }
.moon-stage[data-material="eye"] { background: radial-gradient(ellipse at 50% 108%,rgba(104,61,134,.54),rgba(45,27,78,.76) 46%,rgba(18,10,39,.99) 84%),linear-gradient(180deg,#41265f,#1d1035) padding-box,linear-gradient(145deg,#fff4bf 0%,#e1b85f 9%,#9a5e39 26%,#4b2939 42%,#7e4935 60%,#cf9448 78%,#ffdfa0 91%,#fff7ca 100%) border-box; }
.stage-gem { position: absolute; z-index: 7; top: 16px; width: 29px; height: 29px; border: 3px solid #f8d983; border-radius: 50% 8px 50% 8px; background: radial-gradient(circle at 30% 24%,#fff6e4 0 8%,#c890df 22%,#7b4fa0 54%,#382451 100%); box-shadow: 0 0 0 3px rgba(82,43,55,.8),0 0 16px rgba(224,178,255,.72),inset 4px 4px 5px rgba(255,255,255,.34); transform: rotate(45deg); }
.stage-gem-left { left: 18px; } .stage-gem-right { right: 18px; }
.moon-cluster { position: relative; z-index: 2; width: 78%; height: 82%; display: grid; place-items: center; transition: opacity .18s ease, transform .18s ease; }
.moon-cluster.is-hidden { opacity: 0; transform: scale(.88); }
.count-object { position: absolute; display: block; transform-origin: 50% 60%; }
.moonlight { width: clamp(58px, 8vmin, 90px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fffbd8 0 12%, #ffe38d 34%, #f3b94d 70%, #c87a29 100%); box-shadow: 0 0 12px #fff8bd, 0 0 28px #ffd86c, 0 0 55px rgba(239,170,66,.72); }
.moon-light { width: clamp(72px,9.5vmin,106px); height: auto; object-fit: contain; filter: drop-shadow(0 0 10px rgba(255,190,241,.72)) drop-shadow(0 0 24px rgba(156,111,255,.55)) drop-shadow(0 10px 8px rgba(15,5,30,.34)); }
.moonlight.eye-light::after { content: ""; position: absolute; inset: 18% 30%; border-radius: 50%; background: #3f285e; box-shadow: inset 0 0 0 5px #e8b8ff; }
.potion-light { width: clamp(64px,8.5vmin,92px); height: auto; object-fit: contain; filter: drop-shadow(0 0 8px rgba(246,144,255,.6)) drop-shadow(0 9px 8px rgba(15,5,30,.38)); }
.crystal-light { width: clamp(62px,8vmin,88px); height: auto; object-fit: contain; filter: drop-shadow(0 0 11px rgba(193,126,255,.68)) drop-shadow(0 10px 8px rgba(15,5,30,.36)); }
.blink-curtain { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; opacity: 0; pointer-events: none; color: #f9d779; font-size: 74px; background: radial-gradient(circle, rgba(74,48,112,.85), rgba(31,20,57,.96)); transition: opacity .24s ease; }
.blink-curtain.is-closed { opacity: 1; }

.answer-console { position: relative; z-index: 3; width: min(100%, 650px); height: 166px; display: grid; place-items: center; padding: 18px 28px 43px; border: 7px solid transparent; border-radius: 42px 42px 52px 52px; background: radial-gradient(ellipse at 50% -20%,rgba(126,77,112,.95),rgba(64,34,59,.98) 53%,rgba(43,23,43,.99) 100%) padding-box,linear-gradient(145deg,#fff2af 0%,#dca74f 13%,#8b5138 31%,#3f2435 50%,#a4683f 69%,#e4b75f 86%,#fff3b0 100%) border-box; box-shadow: 0 0 0 3px rgba(69,35,45,.9),inset 0 3px rgba(255,235,182,.17),inset 0 -13px rgba(25,12,30,.28),0 8px 0 #42253a,0 16px 25px rgba(15,7,26,.45),0 0 24px rgba(247,198,92,.18); }
.answer-console::before { content: ""; position: absolute; inset: 11px 15px 40px; border: 2px solid rgba(255,220,133,.34); border-radius: 29px; background: radial-gradient(ellipse at 50% 0,rgba(245,213,151,.14),transparent 58%),linear-gradient(180deg,rgba(39,21,53,.32),rgba(22,11,32,.18)); box-shadow: inset 0 0 20px rgba(211,163,229,.08); pointer-events: none; }
.answer-console::after { content: ""; position: absolute; z-index: 1; left: 50%; bottom: -43px; width: 116px; height: 84px; transform: translateX(-50%); border: 5px solid #5c3440; border-radius: 0 0 54px 54px; background: linear-gradient(180deg,#c38a44,#6f3f36 64%,#3d2435); box-shadow: inset 0 3px rgba(255,225,147,.45),0 7px 13px rgba(17,8,28,.42); }
.choice-rack { position: relative; z-index: 2; width: 100%; display: flex; justify-content: center; gap: clamp(12px, 2vw, 24px); }
.number-choice { position: relative; width: clamp(96px, 10vw, 126px); height: clamp(92px, 12vh, 116px); border: 5px solid transparent; border-radius: 34px 34px 27px 27px; background: radial-gradient(ellipse at 50% 6%,#fffef3 0 24%,#faedd1 58%,#e8c59c 100%) padding-box,linear-gradient(145deg,#fff5bd,#d79f4d 26%,#8a4f3d 48%,#5c3547 68%,#d99d4d 87%,#fff0a2) border-box; box-shadow: inset 0 5px rgba(255,255,255,.92),inset 0 -6px rgba(117,66,57,.16),0 7px 0 #5b3345,0 11px 17px rgba(15,7,27,.42),0 0 0 2px rgba(248,213,126,.22); display: grid; place-items: center; transition: transform .15s ease, filter .15s ease, box-shadow .15s ease; overflow: hidden; }
.number-choice::before { content: ""; position: absolute; inset: 7px; border: 2px solid rgba(188,127,68,.3); border-radius: 25px 25px 18px 18px; box-shadow: inset 0 2px rgba(255,255,255,.6); pointer-events: none; }
.number-choice::after { content: "✦"; position: absolute; right: 10px; top: 7px; color: rgba(203,145,54,.58); font-size: 16px; text-shadow: 0 0 8px #fff0a3; pointer-events: none; }
.number-choice:hover { filter: brightness(1.04); }
.number-choice.is-selected { transform: translateY(-6px); box-shadow: inset 0 4px #fff,0 8px 0 #8b5d38,0 0 0 7px rgba(255,218,104,.5),0 0 30px rgba(255,215,102,.46),0 15px 22px rgba(32,17,49,.34); filter: brightness(1.035); }
.number-choice.is-pressed { transform: translateY(2px) scale(.96); filter: brightness(1.08); }
.number-choice.is-hint { animation: hint-pulse .9s ease-in-out infinite; }
.pip-grid { width: 70%; height: 72%; position: relative; }
.choice-pip { position: absolute; width: clamp(17px, 2vw, 23px); aspect-ratio: 1; border: 1px solid rgba(255,226,166,.34); border-radius: 50% 0 50% 50%; transform: rotate(-45deg); background: radial-gradient(circle at 30% 25%,#d2a9e8 0 7%,#9466b2 23%,#654184 52%,#302044 84%); box-shadow: inset 3px 3px 4px rgba(255,255,255,.28),inset -2px -2px 3px rgba(25,11,42,.3),0 2px 5px rgba(20,9,34,.4); }
.check-button { position: absolute; z-index: 4; left: 50%; bottom: -55px; width: 86px; height: 86px; transform: translateX(-50%); filter: drop-shadow(0 7px 5px rgba(31,15,31,.45)); }
.check-button:active { transform: translateX(-50%) scale(.96) translateY(2px); }
.check-button.is-pressed { transform: translateX(-50%) translateY(3px) scale(.94); filter: brightness(1.08) drop-shadow(0 3px 2px rgba(31,15,31,.4)); }
.check-button:disabled { cursor: default; filter: grayscale(.25) opacity(.65); }
.demo-badge { position: absolute; z-index: 9; top: 12px; left: 50%; transform: translateX(-50%); min-width: 78px; height: 52px; display: flex; align-items: center; justify-content: center; gap: 7px; border-radius: 999px; background: #fff6d5; border: 4px solid #d7a44a; box-shadow: 0 5px 0 #8b542d; }
.demo-badge::before { content: ""; position: absolute; width: 16px; height: 16px; top: -12px; border-radius: 50%; background: #f7cd61; box-shadow: 0 0 13px #fff0a2; }
.demo-badge i { width: 22px; height: 28px; border: 3px solid #573563; border-radius: 50%; background: #fff; position: relative; }
.demo-badge i::after { content: ""; position: absolute; width: 8px; height: 12px; left: 7px; top: 8px; border-radius: 50%; background: #573563; }
.skip-demo { position: absolute; z-index: 11; top: 10px; right: 12px; width: 80px; height: 80px; min-width: 80px; min-height: 80px; border-radius: 50%; background: #f4dfbf; border: 4px solid #a66d42; box-shadow: 0 5px 0 #714328; }
.skip-demo i { position: absolute; width: 0; height: 0; top: 24px; border-top: 12px solid transparent; border-bottom: 12px solid transparent; border-left: 16px solid #56345e; }
.skip-demo i:first-child { left: 22px; }
.skip-demo i:last-child { left: 38px; }
.demo-pointer { position: fixed; z-index: 60; width: 62px; height: 62px; transform: translate(-50%,-50%); border: 7px solid #ffd96e; border-radius: 50%; box-shadow: 0 0 0 5px rgba(255,248,211,.92), 0 7px 14px rgba(50,30,25,.35); transition: left .55s ease, top .55s ease; pointer-events: none; animation: pointer-pulse .75s ease-in-out infinite; }
.demo-pointer i, .demo-pointer::before, .demo-pointer::after { content: ""; position: absolute; background: #fff5b8; transform: rotate(45deg); border-radius: 3px 60%; box-shadow: 0 0 9px #ffd35b; }
.demo-pointer i { width: 13px; height: 13px; right: -15px; top: -8px; }
.demo-pointer::before { width: 9px; height: 9px; left: -12px; bottom: 1px; }
.demo-pointer::after { width: 7px; height: 7px; right: -10px; bottom: -4px; }

.guide-zone { justify-content: flex-start; padding-top: 4vh; }
.guide-button { width: min(100%, 230px); height: min(32vh, 260px); min-height: 120px; z-index: 2; }
.guide-character { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 12px 14px rgba(47,28,62,.28)); }
.speech-bubble { position: relative; z-index: 3; width: min(100%, 250px); min-height: 102px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 16px 18px; text-align: center; font-size: clamp(18px, 2vw, 25px); font-weight: 900; line-height: 1.05; color: #422c44; border: 5px solid #c08a45; border-radius: 36px 36px 18px 36px; background: #fff8df; box-shadow: 0 8px 0 rgba(111,65,38,.42); }
.speech-bubble::after { content: ""; position: absolute; right: 25px; bottom: -22px; width: 34px; height: 34px; background: #fff8df; border-right: 5px solid #c08a45; border-bottom: 5px solid #c08a45; transform: rotate(35deg) skew(8deg); border-radius: 0 0 10px 0; }
.speech-bubble.is-speaking { animation: bubble-glow .8s ease-in-out infinite alternate; }
.task-icon { flex: 0 0 42px; width: 42px; height: 48px; display: grid; place-items: center; }
.task-icon img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(79,42,61,.22)); }
.task-icon-eye { grid-template-columns: 1fr 1fr; gap: 3px; height: 33px; }
.task-icon-eye i { width: 18px; height: 28px; border: 3px solid #6b3e78; border-radius: 50%; background: #fff; position: relative; }
.task-icon-eye i::after { content: ""; position: absolute; width: 7px; height: 12px; left: 5px; top: 7px; border-radius: 50%; background: #573563; }
.bodi-helper { position: absolute; width: 150px; right: -12px; bottom: 8px; filter: drop-shadow(0 8px 8px rgba(44,25,54,.25)); }

.overlay { position: absolute; z-index: 30; inset: 0; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: rgba(37,23,55,.52); backdrop-filter: blur(5px); }
.modal-panel { position: relative; width: min(760px, 92vw); max-height: 92vh; min-height: 390px; overflow: hidden; display: grid; place-items: center; gap: 12px; padding: 26px 34px; text-align: center; border: 9px solid #a06a3e; border-radius: 44px; background: linear-gradient(155deg,#fff9e9,#efd8f2); box-shadow: inset 0 6px #fff, 0 24px 50px rgba(32,18,47,.46); }
.modal-panel h1 { margin: 0; font-size: clamp(28px, 4vw, 48px); color: #643d75; }
.modal-panel p { margin: 4px 0; font-size: clamp(18px, 2.5vw, 28px); font-weight: 800; }
.modal-symbol { width: 120px; height: 120px; }
.modal-symbol img { width: 100%; }
.modal-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; }
.wood-action { width: 84px; height: 84px; filter: drop-shadow(0 6px 4px rgba(82,46,27,.25)); }
.coral-action { filter: sepia(.15) saturate(1.2) drop-shadow(0 6px 4px rgba(82,46,27,.25)); }
.menu-heading { display: flex; align-items: center; gap: 12px; font-size: clamp(25px, 4vw, 39px); color: #69447e; }
.menu-heading span { font-size: 50px; color: #c7802b; }
.level-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 16px; }
.level-button { width: 88px; height: 88px; border-radius: 50%; border: 5px solid #9d6941; background: #fff4d8; box-shadow: 0 7px 0 #754526; color: #5c3a63; font-size: 34px; font-weight: 900; }
.level-button:disabled { opacity: .45; cursor: default; }
.level-button.is-complete { background: #ffe08a; }
.reward-panel { grid-template-columns: 1fr 1.45fr; grid-template-areas: "star copy" "highfive highfive" "actions actions"; }
.reward-star-wrap { grid-area: star; position: relative; width: 150px; aspect-ratio: 1; }
.reward-count-pill,.final-count-pill { position: absolute; z-index: 5; min-width: 64px; padding: 7px 10px; border: 3px solid #9a603c; border-radius: 999px; background: linear-gradient(180deg,#fffbe9,#f4ddb8); color: #583753; box-shadow: inset 0 2px #fff,0 4px 0 rgba(97,55,43,.32),0 0 16px rgba(255,216,104,.42); font-size: 18px; line-height: 1; white-space: nowrap; }
.reward-count-pill { right: -13px; bottom: 3px; }
.reward-star, .reward-burst { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.reward-burst { transform: scale(1.35); animation: slow-spin 7s linear infinite; }
.reward-copy { grid-area: copy; }
.highfive { grid-area: highfive; width: min(400px, 76vw); height: 255px; }
.celebration-pair { position: relative; margin-inline: auto; filter: drop-shadow(0 12px 10px rgba(67,42,76,.22)); }
.celebration-pair::after { content: "✦"; position: absolute; z-index: 3; left: 50%; top: 10%; transform: translateX(-50%); color: #f2c141; font-size: 34px; text-shadow: 0 0 14px #fff4a7, 0 0 28px #f2c141; }
.highfive-art { width: 100%; height: 100%; object-fit: contain; display: block; }
.reward-panel .modal-actions, .final-panel .modal-actions { grid-area: actions; }
.final-panel { min-height: min(680px, 92vh); grid-template-columns: 1fr; grid-template-areas: "stars" "copy" "highfive" "actions"; }
.final-stars { grid-area: stars; position: relative; display: flex; justify-content: center; gap: 3px; padding-bottom: 32px; }
.final-stars img { width: clamp(48px, 7vw, 74px); }
.final-count-pill { left: 50%; bottom: 0; transform: translateX(-50%); }
.final-celebration { grid-area: highfive; position: relative; width: min(510px, 82vw); height: 280px; margin-inline: auto; }
.final-highfive { width: 100%; height: 100%; max-height: 280px; }
.magic-badge { position: absolute; z-index: 4; right: -18px; top: 10px; width: 104px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 36% 30%,#fff9bd 0 10%,#f9cf55 36%,#bd7628 68%,#75422c 100%); border: 7px solid #fff0a1; box-shadow: 0 0 0 5px #87523b,0 9px 16px rgba(44,25,60,.3),inset 0 5px rgba(255,255,255,.72); transform: rotate(7deg); }
.magic-badge::before { content: ""; position: absolute; inset: 13px; border: 3px dashed rgba(99,53,75,.58); border-radius: 50%; }
.magic-badge span { position: relative; width: 43px; height: 43px; border-radius: 50%; background: #f8df72; box-shadow: 0 0 16px rgba(255,246,183,.82); transform: rotate(-20deg); }
.magic-badge span::after { content: ""; position: absolute; width: 39px; height: 39px; left: 13px; top: -7px; border-radius: 50%; background: #61407d; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -30px; width: 12px; height: 20px; border-radius: 5px; animation: confetti-fall 3.2s linear infinite; }
.corner-rune { position: fixed; z-index: 100; left: max(10px, calc(env(safe-area-inset-left) + 10px)); bottom: max(8px, calc(env(safe-area-inset-bottom) + 8px)); width: clamp(58px, 7vw, 92px); height: auto; pointer-events: none; filter: drop-shadow(0 5px 5px rgba(45,25,28,.28)); }
#fx-layer { position: absolute; z-index: 25; inset: 0; pointer-events: none; overflow: hidden; }
.spark { position: absolute; width: 12px; height: 12px; background: #ffe585; transform: rotate(45deg); border-radius: 3px 50%; animation: spark-fly .85s ease-out forwards; }
.reward-flight { position: fixed !important; z-index: 4; margin: 0; object-fit: contain; pointer-events: none; animation: reward-flight 1.05s cubic-bezier(.18,.68,.2,1) forwards; filter: drop-shadow(0 0 10px rgba(255,222,120,.85)); }
.juice-butterfly { position: fixed; width: 18px; height: 13px; z-index: 5; animation: butterfly-loop 1.15s ease-out forwards; }
.juice-butterfly::before,.juice-butterfly::after { content: ""; position: absolute; top: 1px; width: 9px; height: 11px; border-radius: 70% 20% 70% 25%; background: radial-gradient(circle at 40% 35%,#fff0bb,#d595eb 44%,#80519f); box-shadow: 0 0 8px #ffe3a0; }
.juice-butterfly::before { left: 0; transform: rotate(-25deg); }
.juice-butterfly::after { right: 0; transform: scaleX(-1) rotate(-25deg); }
.ambient-mote { position: fixed; z-index: 0; width: 8px; height: 8px; border-radius: 50% 0 50% 50%; background: #ffe69a; opacity: .42; box-shadow: 0 0 12px #ffd46c; animation: ambient-drift 8s ease-in-out infinite alternate; }
.ambient-mote-1 { left: 8%; top: 28%; animation-delay: -2s; }
.ambient-mote-2 { right: 7%; top: 57%; animation-duration: 10s; animation-delay: -5s; }
.ambient-mote-3 { left: 50%; bottom: 5%; animation-duration: 12s; animation-delay: -7s; }
.rare-magic-swirl { position: fixed; right: 4%; top: 44%; width: 76px; height: 76px; border: 3px solid rgba(255,225,133,.7); border-left-color: transparent; border-radius: 50%; filter: drop-shadow(0 0 9px #d897ee); animation: rare-swirl 3.4s ease-in-out forwards; }
.choice-rack.is-idle { animation: rack-breathe 1s ease-in-out 2; }
.check-button.is-idle { animation: check-breathe .9s ease-in-out 2; }
.moon-cluster.gag-soft-bobble { animation: material-bobble .66s ease-in-out; }
.hero-character.mistake-ma-49 { animation: curious-lean .9s ease-in-out; }
.hero-character.mistake-ma-08 { animation: balloon-breath 1.05s ease-in-out; }
.hero-character.mistake-ma-11 { animation: zigzag-giggle .8s ease-in-out; }
.hero-character.mistake-ma-56 { animation: head-tilt .95s ease-in-out; }
.reward-panel.juice-celebrate::before,.final-panel.juice-finale::before { content: ""; position: absolute; z-index: -1; inset: -25%; background: conic-gradient(from 0deg,transparent 0 9%,rgba(255,223,115,.38) 10% 13%,transparent 14% 24%); animation: halo-turn 5s linear infinite; }
.final-panel.juice-finale { box-shadow: inset 0 6px #fff,0 24px 50px rgba(32,18,47,.46),0 0 45px rgba(255,218,102,.58); }

.moon-stage[data-material="moon"] .blink-curtain span { width: 88px; height: 88px; font-size: 0; background: url("assets/props/Prop-MagicRealm-Moon-Crescent.webp") center/contain no-repeat; filter: drop-shadow(0 0 14px rgba(255,190,241,.72)); }
.moon-stage[data-material="potion"] .blink-curtain span { border-radius: 0; background: url("assets/props/prop-magicrealm-potionvial-v2.webp") center/contain no-repeat; box-shadow: none; }
.moon-stage[data-material="potion"] .blink-curtain span::after { display: none; }
.moon-stage[data-material="crystal"] .blink-curtain span { border-radius: 0; background: url("assets/props/prop-magicrealm-gem-purple.webp") center/contain no-repeat; box-shadow: none; }
.moon-stage[data-material="crystal"] .blink-curtain span::after { display: none; }
.moon-stage[data-material="potion"] .blink-curtain span,.moon-stage[data-material="crystal"] .blink-curtain span { width: 82px; height: 82px; font-size: 0; filter: drop-shadow(0 0 14px rgba(255,216,123,.52)); }
.moon-stage[data-material="eye"] .blink-curtain span { font-size: 0; width: 76px; height: 42px; background: radial-gradient(ellipse at 25% 50%,#fff 0 17%,#d6b5e8 18% 27%,transparent 28%),radial-gradient(ellipse at 75% 50%,#fff 0 17%,#d6b5e8 18% 27%,transparent 28%); filter: drop-shadow(0 0 10px #c994e6); }

@keyframes hero-hop { 0%,100%{transform:translateY(0) rotate(0)} 35%{transform:translateY(-22px) rotate(-3deg)} 68%{transform:translateY(-5px) rotate(3deg)} }
@keyframes gentle-wobble { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-3deg)} 50%{transform:rotate(3deg)} 75%{transform:rotate(-1deg)} }
@keyframes board-success { 35%{transform:translateY(-4px) scale(1.008); filter:brightness(1.08) drop-shadow(0 0 16px rgba(255,218,108,.5))} }
@keyframes board-retry { 30%{transform:translateX(-5px); filter:sepia(.08) brightness(1.02)} 60%{transform:translateX(4px)} }
@keyframes hint-pulse { 50%{transform:translateY(-5px) scale(1.05); box-shadow:0 0 0 10px rgba(255,215,102,.42),0 8px 0 #744424} }
@keyframes pointer-pulse { 50%{transform:translate(-50%,-50%) scale(.88); filter:brightness(1.1)} }
@keyframes bubble-glow { to{filter:drop-shadow(0 0 12px #ffe6a0)} }
@keyframes slow-spin { to{transform:scale(1.35) rotate(360deg)} }
@keyframes confetti-fall { to{transform:translateY(110vh) rotate(420deg)} }
@keyframes spark-fly { to{transform:translate(var(--x),var(--y)) rotate(180deg) scale(.2); opacity:0} }
@keyframes progress-star-arrive { 0%{transform:scale(.55);filter:brightness(2)} 58%{transform:scale(1.38) rotate(10deg);filter:drop-shadow(0 0 10px #ffd75d)} 100%{transform:scale(1)} }
@keyframes count-kiss { 50%{transform:scale(1.14);background:#fff0ae;box-shadow:0 0 15px #ffd46c} }
@keyframes reward-flight { 0%{transform:translate(0,0) scale(1);opacity:1} 55%{transform:translate(var(--fly-mid-x),var(--fly-mid-y)) scale(.82);opacity:1} 100%{transform:translate(var(--fly-x),var(--fly-y)) scale(.2) rotate(18deg);opacity:0} }
@keyframes butterfly-loop { 0%{transform:translate(0,0) scale(.7);opacity:0} 20%{opacity:1} 55%{transform:translate(28px,-24px) rotate(18deg)} 100%{transform:translate(-6px,-58px) rotate(-18deg) scale(.7);opacity:0} }
@keyframes ambient-drift { to{transform:translate(17px,-25px) rotate(90deg);opacity:.72} }
@keyframes rare-swirl { 0%{transform:scale(.4) rotate(0);opacity:0} 25%{opacity:.8} 70%{transform:scale(1.15) rotate(420deg);opacity:.72} 100%{transform:scale(.5) rotate(680deg);opacity:0} }
@keyframes rack-breathe { 50%{transform:translateY(-4px);filter:drop-shadow(0 0 12px rgba(255,218,111,.6))} }
@keyframes check-breathe { 50%{transform:translateX(-50%) scale(1.08);filter:drop-shadow(0 0 14px rgba(128,238,90,.65))} }
@keyframes material-bobble { 30%{transform:translateY(3px) rotate(-1.5deg)} 60%{transform:translateY(-2px) rotate(1.5deg)} }
@keyframes curious-lean { 45%{transform:rotate(-5deg) translateY(2px)} }
@keyframes balloon-breath { 45%{transform:scale(1.055,.96) translateY(2px)} }
@keyframes zigzag-giggle { 25%{transform:translateX(-3px) rotate(-2deg)} 50%{transform:translateX(4px) rotate(2deg)} 75%{transform:translateX(-2px) rotate(-1deg)} }
@keyframes head-tilt { 45%{transform:rotate(6deg) translateY(2px)} }
@keyframes halo-turn { to{transform:rotate(360deg)} }

@media (orientation: portrait) and (min-width: 601px) {
  .game-layout { inset: 108px 12px 18px; grid-template-columns: 138px minmax(470px,1fr) 152px; gap: 10px; }
  .hero-character { width: 158px; }
  .guide-zone { padding-top: 2vh; }
  .guide-button { width: 150px; height: 190px; min-height: 120px; }
  .speech-bubble { width: 152px; min-height: 94px; padding: 12px 10px; font-size: 18px; }
  .game-board { min-height: 520px; padding-inline: 12px; }
  .number-choice { width: clamp(92px, 11vw, 112px); }
}

@media (orientation: portrait) and (max-width: 600px) {
  .play-screen { padding: 7px 8px; }
  .top-hud { display: block; height: 138px; }
  .round-stars { position: absolute; left: 3px; top: 86px; width: 154px; min-width: 154px; min-height: 43px; height: 43px; padding: 4px 6px; gap: 4px; }
  .round-token-track { gap: 1px; }
  .round-token-track img { width: 16px; height: 16px; }
  .round-count { min-width: 40px; padding: 5px 5px; border-width: 1px; font-size: 12px; }
  .level-path { position: absolute; top: 86px; right: 3px; min-height: 43px; height: 43px; padding: 4px 7px; gap: 5px; }
  .level-dot { width: 21px; height: 21px; border-width: 3px; }
  .hud-controls { position: absolute; top: 0; left: 50%; transform: translateX(-50%); min-height: 80px; padding: 2px; gap: 0; }
  .icon-button { width: 80px; height: 80px; min-width: 80px; min-height: 80px; }
  .game-layout { inset: 138px 8px 8px; display: grid; grid-template-columns: 1fr; grid-template-rows: 88px minmax(0,1fr); gap: 5px; }
  .guide-zone { grid-row: 1; padding: 0 0 0 77px; height: 88px; flex-direction: row; justify-content: flex-end; gap: 2px; }
  .guide-button { flex: 0 0 80px; width: 80px; height: 86px; min-width: 80px; min-height: 80px; }
  .speech-bubble { flex: 1 1 auto; width: auto; min-height: 68px; padding: 8px 9px; font-size: clamp(15px, 4.5vw, 20px); border-width: 4px; border-radius: 26px 26px 15px 26px; box-shadow: 0 5px 0 rgba(111,65,38,.42); }
  .task-icon { flex-basis: 34px; width: 34px; height: 40px; }
  .task-icon-eye i { width: 14px; height: 23px; border-width: 2px; }
  .task-icon-eye i::after { width: 5px; height: 9px; left: 4px; top: 6px; }
  .speech-bubble::after { right: -12px; left: auto; bottom: 13px; width: 24px; height: 24px; transform: rotate(38deg) skew(8deg); border-width: 4px; }
  .speech-bubble span:first-child { font-size: 25px; }
  .bodi-helper { width: 92px; right: 0; bottom: -18px; }
  .game-board { grid-row: 2; width: 100%; height: 100%; min-height: 0; grid-template-rows: minmax(115px,1fr) 134px; gap: 8px; padding: 0 3px 58px; border-radius: 30px; }
  .game-board::before { inset: -12px -8px 8px; }
  .game-board::after { left: 10%; right: 10%; bottom: 14px; height: 62px; }
  .moon-stage { min-height: 110px; height: 100%; border-radius: 34px 34px 28px 28px; border-width: 6px; box-shadow: 0 0 0 2px rgba(70,39,54,.92),0 0 0 4px rgba(235,186,92,.52),inset 0 0 0 2px rgba(255,244,192,.2),inset 0 0 0 6px rgba(42,23,66,.72),inset 0 -24px 45px rgba(10,5,29,.46),0 6px 0 #48263a,0 11px 18px rgba(17,8,31,.45); }
  .moon-stage::after { inset: 9px; border-radius: 24px 24px 19px 19px; }
  .stage-gem { top: 11px; width: 21px; height: 21px; border-width: 2px; }
  .stage-gem-left { left: 13px; } .stage-gem-right { right: 13px; }
  .moonlight { width: clamp(48px, 13vw, 69px); }
  .moon-light { width: clamp(58px,16vw,78px); }
  .potion-light { width: clamp(50px,13vw,62px); }
  .crystal-light { width: clamp(48px,12vw,60px); }
  .blink-curtain { font-size: 52px; }
  .answer-console { width: 100%; height: 134px; padding: 4px 5px 36px; border-width: 5px; border-radius: 30px 30px 38px 38px; }
  .answer-console::before { inset: 7px 9px 28px; border-radius: 21px; }
  .answer-console::after { bottom: -45px; width: 100px; height: 80px; border-width: 4px; }
  .choice-rack { gap: clamp(8px, 3vw, 15px); }
  .number-choice { width: clamp(82px, 25vw, 104px); height: clamp(80px, 13vh, 96px); border-radius: 22px; border-width: 4px; }
  .number-choice::before { inset: 5px; border-radius: 16px; }
  .choice-pip { width: clamp(14px, 4.3vw, 19px); }
  .check-button { bottom: -58px; width: 80px; height: 80px; min-width: 80px; min-height: 80px; }
  .hero-zone { position: absolute; z-index: 6; grid-row: 1; left: 0; top: 0; width: 82px; height: 88px; align-items: center; justify-content: flex-end; padding: 0; }
  .hero-character { width: 88px; height: 86px; object-fit: contain; }
  .hero-aura { width: 102px; }
  .demo-badge { top: 5px; height: 45px; min-width: 68px; }
  .demo-badge i { width: 18px; height: 23px; }
  .demo-badge i::after { width: 7px; height: 10px; left: 5px; top: 6px; }
  .skip-demo { top: 4px; right: 5px; width: 80px; height: 80px; min-width: 80px; min-height: 80px; font-size: 25px; border-width: 3px; }
  .modal-panel { width: min(94vw, 520px); max-height: 88vh; min-height: 0; gap: 7px; padding: 18px 15px; border-width: 6px; border-radius: 31px; }
  .reward-panel { grid-template-columns: 105px 1fr; grid-template-areas: "star copy" "highfive highfive" "actions actions"; }
  .reward-star-wrap { width: 96px; }
  .highfive { height: 195px; width: min(330px, 78vw); }
  .modal-actions { gap: 10px; }
  .wood-action { width: 80px; height: 80px; min-width: 80px; min-height: 80px; }
  .final-panel { min-height: 0; }
  .final-celebration { height: 205px; width: min(360px, 82vw); }
  .final-highfive { height: 205px; }
  .magic-badge { width: 78px; right: -7px; top: 2px; border-width: 5px; }
  .magic-badge span { width: 31px; height: 31px; }
  .magic-badge span::after { width: 28px; height: 28px; left: 9px; top: -5px; }
  .corner-rune { width: clamp(52px, 15vw, 68px); }
}

@media (orientation: portrait) and (max-width: 600px) and (max-height: 700px) {
  .game-layout { top: 132px; grid-template-rows: 80px minmax(0,1fr); }
  .guide-zone { height: 80px; padding-left: 76px; }
  .hero-zone { width: 78px; height: 80px; }
  .hero-character { width: 80px; height: 78px; }
  .guide-button { width: 80px; height: 80px; min-width: 80px; min-height: 80px; }
  .speech-bubble { min-height: 58px; font-size: 16px; }
  .task-icon { flex-basis: 31px; width: 31px; height: 36px; }
  .game-board { grid-template-rows: minmax(95px,1fr) 120px; gap: 7px; padding-top: 0; padding-bottom: 58px; }
  .answer-console { height: 120px; padding: 4px 4px 28px; }
  .answer-console::before { bottom: 23px; }
  .number-choice { height: 80px; min-height: 80px; }
  .check-button { bottom: -58px; width: 80px; height: 80px; min-width: 80px; min-height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
