:root {
  color-scheme: dark;
  --cream: #fffbed;
  --ink: #123738;
  --mint: #62e6bd;
  --gold: #ffdb6e;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; overflow: hidden; background: #0b3132; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; touch-action: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button, a { font: inherit; }

.game-shell { position: relative; isolation: isolate; width: min(100vw, 540px); height: 100dvh; min-height: 600px; margin: auto; overflow: hidden; background: #1f7772; box-shadow: 0 0 70px #061a19; }
.scene-art { position: absolute; inset: 0; z-index: -3; background: url("../../assets/game-art/bubble-bloom-meadow.png") center/cover no-repeat; transition: filter .7s, transform .7s; }
.scene-wash { position: absolute; inset: 0; z-index: -2; pointer-events: none; transition: background .7s; }
.game-shell[data-scene="sunrise"] .scene-art { filter: saturate(1.04) brightness(1.02); }
.game-shell[data-scene="clover"] .scene-art { filter: hue-rotate(18deg) saturate(1.15); transform: scale(1.03); }
.game-shell[data-scene="peach"] .scene-art { filter: hue-rotate(315deg) saturate(1.08) brightness(1.05); }
.game-shell[data-scene="lavender"] .scene-art { filter: hue-rotate(55deg) saturate(1.12) brightness(.9); transform: scale(1.04); }
.game-shell[data-scene="dusk"] .scene-art { filter: hue-rotate(75deg) saturate(1.1) brightness(.57); }
.game-shell[data-scene="moon"] .scene-art { filter: hue-rotate(105deg) saturate(1.05) brightness(.42); transform: scale(1.035); }
.game-shell[data-scene="amber"] .scene-art { filter: sepia(.38) saturate(1.28) brightness(.78); }
.game-shell[data-scene="starlight"] .scene-art { filter: hue-rotate(120deg) saturate(1.35) brightness(.34); transform: scale(1.05); }
.game-shell[data-scene="sunrise"] .scene-wash { background: linear-gradient(rgba(7,75,78,.08), rgba(32,88,56,.08)); }
.game-shell[data-scene="clover"] .scene-wash { background: linear-gradient(rgba(0,120,110,.1), rgba(32,116,72,.16)); }
.game-shell[data-scene="peach"] .scene-wash { background: linear-gradient(rgba(255,141,161,.12), rgba(107,70,73,.08)); }
.game-shell[data-scene="lavender"] .scene-wash { background: linear-gradient(rgba(87,61,148,.18), rgba(42,77,80,.2)); }
.game-shell[data-scene="dusk"] .scene-wash { background: linear-gradient(rgba(35,26,77,.3), rgba(5,55,52,.3)); }
.game-shell[data-scene="moon"] .scene-wash { background: radial-gradient(circle at 72% 15%, rgba(203,236,255,.24), transparent 22%), linear-gradient(rgba(20,42,102,.35), rgba(4,34,50,.45)); }
.game-shell[data-scene="amber"] .scene-wash { background: linear-gradient(rgba(189,72,23,.18), rgba(70,34,12,.3)); }
.game-shell[data-scene="starlight"] .scene-wash { background: radial-gradient(circle at 30% 18%, rgba(158,126,255,.25), transparent 28%), linear-gradient(rgba(12,16,70,.45), rgba(12,8,38,.6)); }

.screen { position: absolute; inset: 0; display: none; opacity: 0; }
.screen.active { display: flex; animation: screenIn .36s ease both; }
@keyframes screenIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

.round-button { display: grid; place-items: center; width: 43px; height: 43px; padding: 0; border: 1px solid rgba(255,255,255,.38); border-radius: 50%; color: #fff; text-decoration: none; background: rgba(11,62,59,.58); box-shadow: inset 0 1px rgba(255,255,255,.18), 0 5px 15px rgba(4,32,27,.22); backdrop-filter: blur(7px); cursor: pointer; }
.round-button:active { transform: translateY(2px); }

.menu-screen { flex-direction: column; padding: max(18px, env(safe-area-inset-top)) 21px max(18px, env(safe-area-inset-bottom)); }
.menu-top { display: flex; justify-content: space-between; }
.title-area { text-align: center; margin-top: clamp(24px, 6vh, 58px); text-shadow: 0 3px 18px rgba(0,50,45,.32); }
.eyebrow { margin: 0 0 8px; color: #fff2a5; font-size: 9px; font-weight: 900; letter-spacing: .25em; }
.title-area h1 { margin: 0; color: #fffdf1; font-family: Georgia, serif; font-size: clamp(43px, 12vw, 66px); font-weight: 500; line-height: .88; letter-spacing: -.055em; }
.title-area h1 span { color: #ffdc72; font-style: italic; }
.tagline { margin: 10px 0 0; color: rgba(255,255,240,.84); font-size: 12px; }
.puff-trio { position: relative; width: 178px; height: 103px; margin: 11px auto 0; }
.puff { position: absolute; display: block; width: 72px; height: 72px; border-radius: 48% 52% 49% 51%; color: #ff7066; background: radial-gradient(circle at 34% 24%, #fff9 0 5%, currentColor 42%, color-mix(in srgb, currentColor 70%, #253e4c) 100%); box-shadow: 0 11px 16px rgba(14,46,37,.27), inset -8px -10px 13px rgba(21,45,42,.15); animation: menuBob 2.8s ease-in-out infinite; }
.puff::before, .puff::after { content: ""; position: absolute; z-index: -1; width: 20px; height: 22px; top: -6px; border-radius: 70% 30%; background: currentColor; transform: rotate(-25deg); }
.puff::after { right: 0; transform: rotate(25deg) scaleX(-1); }
.puff b { position: absolute; width: 10px; height: 13px; left: 21px; top: 27px; border-radius: 50%; background: #173e48; box-shadow: inset 3px 2px #fff; animation: blink 4s infinite; }
.puff b + b { left: 42px; animation-delay: .12s; }
.puff em { position: absolute; left: 31px; top: 46px; width: 12px; height: 7px; border-radius: 2px 2px 9px 9px; background: #734047; }
.puff-coral { left: 4px; top: 20px; transform: rotate(-8deg); }
.puff-mint { left: 54px; z-index: 2; color: #62dca9; animation-delay: -.8s; }
.puff-violet { right: 3px; top: 20px; color: #9c78e8; transform: rotate(8deg); animation-delay: -1.6s; }
@keyframes menuBob { 50% { translate: 0 -7px; } }
@keyframes blink { 0%, 44%, 49%, 100% { transform: scaleY(1); } 46%, 47% { transform: scaleY(.08); } }

.chapter-card { width: 100%; margin-top: auto; padding: 15px; border: 1px solid rgba(255,255,255,.3); border-radius: 23px; background: linear-gradient(150deg, rgba(252,255,233,.94), rgba(221,247,210,.91)); color: var(--ink); box-shadow: 0 17px 40px rgba(6,50,40,.25), inset 0 1px #fff; backdrop-filter: blur(9px); }
.card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.card-heading span { font-size: 9px; font-weight: 900; letter-spacing: .21em; }
.card-heading small { color: #568078; font-size: 9px; }
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.level-button { position: relative; aspect-ratio: 1; padding: 0; border: 1px solid rgba(28,88,75,.18); border-radius: 16px; color: #174a46; background: linear-gradient(145deg, #fffef0, #c9ecba); box-shadow: inset 0 1px #fff, 0 5px 0 #5b9b6c, 0 8px 12px rgba(31,87,67,.16); cursor: pointer; }
.level-button strong { display: block; font-family: Georgia, serif; font-size: 23px; }
.level-button small { display: block; margin-top: 1px; font-size: 7px; font-weight: 800; text-transform: uppercase; }
.level-button.locked { color: #7c9084; background: linear-gradient(145deg, #e9ebdf, #bccbb7); box-shadow: inset 0 1px #fff, 0 4px 0 #738a78; cursor: not-allowed; filter: saturate(.3); }
.level-button.locked::after { content: "•"; position: absolute; right: 8px; top: 5px; }
.level-button.completed::before { content: "✓"; position: absolute; right: 6px; top: 3px; color: #fff; width: 16px; height: 16px; border-radius: 50%; background: #36a775; font-size: 10px; line-height: 16px; }
.level-button:active:not(.locked) { translate: 0 3px; box-shadow: inset 0 1px #fff, 0 2px 0 #5b9b6c; }
.menu-tip { margin: 14px 3px 0; color: #52756d; font-size: 9px; line-height: 1.45; }

.play-screen { flex-direction: column; padding: max(12px, env(safe-area-inset-top)) 14px max(10px, env(safe-area-inset-bottom)); }
.game-header { display: grid; grid-template-columns: 43px 1fr 43px; align-items: center; gap: 8px; }
.scene-title { text-align: center; text-shadow: 0 2px 10px rgba(0,35,32,.55); }
.scene-title small, .hud small, .next-label small, .result-stats small { display: block; color: #fff0a8; font-size: 8px; font-weight: 900; letter-spacing: .2em; }
.scene-title strong { display: block; margin-top: 1px; color: #fff; font-family: Georgia, serif; font-size: 18px; font-weight: 500; }
.hud { display: grid; grid-template-columns: 1fr 1.4fr 1fr; align-items: center; margin-top: 8px; padding: 7px 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 14px; background: rgba(8,54,52,.5); box-shadow: inset 0 1px rgba(255,255,255,.12); backdrop-filter: blur(7px); }
.hud > div:last-child { text-align: right; }
.hud strong { color: #fff; font-family: Georgia, serif; font-size: 18px; font-variant-numeric: tabular-nums; }
.miss-meter { text-align: center; }
.miss-meter span { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.miss-meter i { width: 8px; height: 8px; border: 1px solid #ffe58c; border-radius: 50%; background: #ffce58; box-shadow: 0 0 7px rgba(255,214,91,.65); }
.miss-meter i.used { background: rgba(255,255,255,.16); box-shadow: none; }

.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 390px; margin: 7px 0 5px; overflow: hidden; border: 1px solid rgba(255,255,255,.24); border-radius: 24px; background: linear-gradient(rgba(5,59,62,.3), rgba(13,83,57,.11)); box-shadow: inset 0 0 35px rgba(5,39,36,.18), 0 12px 28px rgba(5,42,35,.16); backdrop-filter: blur(1.5px); }
#gameCanvas { display: block; width: 100%; height: 100%; touch-action: none; }
.toast { position: absolute; z-index: 5; left: 50%; top: 44%; transform: translate(-50%, 8px) scale(.94); padding: 8px 14px; border-radius: 99px; color: #143e3a; background: rgba(255,252,220,.94); box-shadow: 0 7px 20px rgba(9,57,47,.24); font-size: 10px; font-weight: 900; opacity: 0; transition: .22s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.game-footer { display: grid; grid-template-columns: 70px 1fr 82px; align-items: center; gap: 8px; min-height: 50px; padding: 5px 8px; border: 1px solid rgba(255,255,255,.24); border-radius: 16px; color: #efffe8; background: rgba(9,60,49,.58); backdrop-filter: blur(8px); }
.next-label { display: flex; align-items: center; gap: 7px; }
.next-label small { color: rgba(255,255,255,.7); }
.next-label i { display: block; width: 30px; height: 30px; border: 2px solid #fff8; border-radius: 50%; background: var(--next-color, #ff6e68); box-shadow: inset 5px 5px 8px #fff5, 0 4px 8px rgba(0,0,0,.18); }
.game-footer p { margin: 0; text-align: center; font-size: 8px; line-height: 1.45; letter-spacing: .05em; }
.game-footer p strong { color: #ffe58c; }
.swap-button { min-height: 38px; border: 1px solid #fff3a4; border-radius: 12px; color: #154b42; background: linear-gradient(#fff5a8, #d9c956); box-shadow: inset 0 1px #fff, 0 4px 0 #718b3c; font-size: 9px; font-weight: 900; cursor: pointer; }
.swap-button span { font-size: 15px; }
.swap-button:disabled { opacity: .45; filter: grayscale(1); }

.result-screen, .fail-screen { flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; background: linear-gradient(rgba(6,66,57,.2), rgba(5,46,43,.52)); backdrop-filter: blur(4px); }
.result-screen h2, .fail-screen h2 { margin: 0; color: #fffef0; font-family: Georgia, serif; font-size: clamp(43px, 12vw, 63px); font-weight: 500; text-shadow: 0 4px 20px rgba(0,40,36,.34); }
.result-sun { position: absolute; width: 260px; height: 260px; top: 24%; border-radius: 50%; background: radial-gradient(circle, rgba(255,238,133,.42), transparent 65%); animation: resultGlow 2s ease-in-out infinite; }
@keyframes resultGlow { 50% { transform: scale(1.12); opacity: .75; } }
.result-puff { position: relative; z-index: 1; width: 112px; height: 112px; margin: 26px 0; border-radius: 50%; background: radial-gradient(circle at 34% 25%, #fff 0 4%, #76ebbe 40%, #2ca384 100%); box-shadow: 0 16px 28px rgba(4,64,53,.28), inset -12px -13px 18px rgba(4,75,64,.17); animation: resultBounce 1.8s ease-in-out infinite; }
.result-puff i { position: absolute; left: 31px; top: 38px; width: 15px; height: 20px; border-radius: 50%; background: #164b54; box-shadow: inset 4px 3px #fff; }
.result-puff i + i { left: 66px; }
.result-puff b { position: absolute; left: 42px; top: 70px; width: 29px; height: 18px; border-radius: 4px 4px 20px 20px; background: #b55466; }
@keyframes resultBounce { 50% { transform: translateY(-10px) rotate(4deg); } }
.result-stats { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 310px); margin-bottom: 27px; }
.result-stats > div + div { border-left: 1px solid rgba(255,255,255,.3); }
.result-stats strong { display: block; margin-top: 5px; color: #fff; font-family: Georgia, serif; font-size: 28px; }
.continue-button { position: relative; z-index: 1; width: min(100%, 310px); min-height: 55px; border: 1px solid #fff4ae; border-radius: 16px; color: #17463f; background: linear-gradient(135deg, #fff3a0, #e2c34d); box-shadow: inset 0 1px #fff, 0 6px 0 #6a8b42, 0 13px 24px rgba(4,47,39,.24); font-size: 11px; font-weight: 900; letter-spacing: .1em; cursor: pointer; }
.continue-button span { float: right; font-size: 24px; line-height: 12px; }
.text-button { position: relative; z-index: 1; margin-top: 16px; padding: 3px; border: 0; color: #fff; background: none; font-size: 10px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.text-button + .text-button { margin-top: 8px; }
.fail-screen p:not(.eyebrow) { max-width: 300px; color: #eaffea; font-size: 12px; line-height: 1.55; }
.sleepy-puff { display: grid; place-items: center; width: 118px; height: 118px; margin: 25px; border-radius: 50%; color: #4b4374; background: radial-gradient(circle at 35% 25%, #fff 0 4%, #b49bf2 45%, #6f5eb3); box-shadow: inset -13px -15px 20px rgba(45,35,92,.18), 0 16px 28px rgba(5,43,38,.24); font-size: 30px; font-weight: 900; }

@media (min-width: 541px) { body { background: radial-gradient(circle, #26726d, #071f20 65%); } .game-shell { border-inline: 1px solid rgba(255,255,255,.16); } }
@media (max-height: 690px) { .title-area { margin-top: 8px; } .puff-trio { transform: scale(.76); height: 70px; margin-top: 0; } .chapter-card { padding: 10px 13px; } .level-grid { gap: 6px; } .menu-tip { margin-top: 9px; } .canvas-wrap { min-height: 335px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
