:root {
  color-scheme: light;
  --ink: #173b35;
  --muted: #60766f;
  --green: #168266;
  --green-dark: #0c604a;
  --mint: #e8f6ee;
  --line: #d6e7dd;
  --coral: #ee6c55;
  --gold: #f7bd3d;
  --blue: #42a3cf;
  --carbon: #53626a;
  --paper: rgba(255,255,252,.96);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next Rounded", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background: #eaf5ed; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 4px solid rgba(28,127,173,.28); outline-offset: 4px; }

.game { position: relative; width: 100%; height: 100%; min-width: 320px; min-height: 650px; display: grid; place-items: center; overflow: hidden; isolation: isolate; }
.world-art { position: absolute; z-index: -4; inset: -24px; width: calc(100% + 48px); height: calc(100% + 48px); object-fit: cover; opacity: .42; filter: blur(3px) saturate(.72); transform: scale(1.03); }
.world-wash { position: absolute; z-index: -3; inset: 0; background: linear-gradient(105deg,rgba(235,247,239,.92),rgba(255,253,238,.7) 52%,rgba(232,247,241,.91)); }
.world-wash::after { position: absolute; inset: 0; content: ""; background: radial-gradient(circle at 50% 45%,rgba(255,255,255,.18),rgba(235,247,240,.5) 75%); }

.mission-hud { position: absolute; z-index: 20; top: 24px; left: 28px; right: 28px; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; }
.mission-chip, .practice-stats { border: 1px solid rgba(23,59,53,.08); background: rgba(255,255,252,.84); box-shadow: 0 10px 30px rgba(34,83,67,.09); backdrop-filter: blur(14px); }
.mission-chip { display: grid; gap: 3px; padding: 10px 15px; border-radius: 16px; }
.mission-chip span, .practice-stats span { color: var(--green); font-size: 12px; font-weight: 950; letter-spacing: .09em; text-transform: uppercase; }
.mission-chip strong { font-size: 14px; }
.practice-stats { display: flex; gap: 4px; padding: 7px; border-radius: 18px; }
.practice-stats > div { min-width: 66px; padding: 5px 10px; text-align: center; }
.practice-stats strong { display: block; margin-top: 2px; font-size: 20px; line-height: 1; }
.practice-stats .charge-stat { width: 145px; text-align: left; }
.charge-stat span { display: flex; justify-content: space-between; }
.charge-stat i { display: block; height: 7px; margin-top: 8px; overflow: hidden; border-radius: 99px; background: #dbeae1; }
.charge-stat i b { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--green),#61c59d); transition: width 220ms ease-out; }

.play-surface { position: relative; z-index: 3; width: min(880px,calc(100% - 310px)); min-width: 690px; height: min(760px,calc(100% - 66px)); min-height: 620px; display: grid; grid-template-rows: auto minmax(0,1fr) auto auto; padding: 35px 54px 28px; overflow: hidden; border: 1px solid rgba(208,228,217,.98); border-radius: 34px; background: var(--paper); box-shadow: 0 28px 85px rgba(35,76,63,.16),0 3px 0 rgba(255,255,255,.8) inset; backdrop-filter: blur(18px); }
.mission-copy { max-width: 690px; margin: 0 auto 8px; text-align: center; }
.phase-label { display: inline-block; margin-bottom: 7px; color: #bf542e; font-size: 12px; font-weight: 950; letter-spacing: .11em; text-transform: uppercase; }
.mission-copy h1 { margin: 0; font-size: clamp(28px,3vw,41px); font-weight: 950; line-height: 1.04; letter-spacing: -.04em; text-wrap: balance; }
.mission-copy p { min-height: 22px; margin: 9px 0 0; color: var(--muted); font-size: 15px; font-weight: 650; line-height: 1.35; }

.scene { position: relative; min-height: 0; display: grid; place-items: center; }
.action-area { width: 100%; max-width: 650px; min-height: 64px; display: grid; align-items: center; margin: 5px auto 0; }
.feedback { min-height: 20px; margin: 8px 0 0; color: #b34a38; font-size: 12px; font-weight: 850; text-align: center; }
.play-surface.is-miss { animation: gentleShake 320ms ease-out; }

.choice-grid { width: 100%; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; }
.choice, .primary, .secondary, .factor-button { min-height: 60px; border-radius: 16px; font-weight: 900; transition: transform 140ms ease-out,box-shadow 140ms ease-out,border-color 140ms ease-out,background 140ms ease-out; }
.choice { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 10px; padding: 11px 13px; border: 2px solid var(--line); background: #fff; box-shadow: 0 4px 0 #dce8e1; text-align: left; }
.choice:hover, .factor-button:hover { transform: translateY(-2px); border-color: #75b4a0; background: #f0faf5; box-shadow: 0 6px 0 #cfe4d9; }
.choice:active, .factor-button:active { transform: translateY(3px); box-shadow: 0 1px 0 #cfe4d9; }
.choice .icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #fff; background: var(--green); font-size: 18px; font-weight: 950; }
.choice strong, .choice small { display: block; }
.choice strong { font-size: 13px; line-height: 1.15; }
.choice small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.2; }
.primary { min-width: 260px; min-height: 58px; justify-self: center; padding: 0 24px; border: 1px solid #075940; color: #fff; background: linear-gradient(#20a17d,var(--green)); box-shadow: 0 6px 0 var(--green-dark),0 13px 26px rgba(22,130,102,.17); font-size: 16px; }
.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--green-dark),0 16px 28px rgba(22,130,102,.2); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--green-dark); }
.factor-controls { display: grid; grid-template-columns: repeat(3,1fr); gap: 11px; }
.factor-button { border: 2px solid var(--line); background: #fff; box-shadow: 0 4px 0 #dce8e1; }

.intro-card, .finale { position: absolute; z-index: 40; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 44px; background: rgba(255,255,252,.97); text-align: center; backdrop-filter: blur(15px); }
.level-stamp { width: 62px; height: 62px; display: grid; place-items: center; margin-bottom: 15px; transform: rotate(-4deg); border: 3px solid var(--ink); border-radius: 18px; background: var(--gold); box-shadow: 5px 5px 0 var(--ink); font-size: 24px; font-weight: 950; }
.intro-kicker, .finale > span { margin: 0 0 7px; color: #bd542f; font-size: 12px; font-weight: 950; letter-spacing: .11em; text-transform: uppercase; }
.intro-card h2, .finale h2 { margin: 0 0 10px; font-size: 39px; line-height: 1.02; letter-spacing: -.045em; }
.intro-card > p:not(.intro-kicker), .finale > p { max-width: 430px; margin: 0 0 24px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.finale-art { width: 175px; margin-bottom: 17px; }

.sticker-art, .sticker-prop { overflow: hidden; padding: 7px; border: 1px solid rgba(29,74,68,.11); border-radius: 26px; background: #fffdf8; box-shadow: 0 12px 30px rgba(30,69,59,.16); }
.sticker-art img, .sticker-prop img { display: block; width: 100%; border-radius: 19px; }
.mascot { position: absolute; z-index: 5; left: max(20px,calc(50% - 650px)); bottom: 34px; width: 190px; pointer-events: none; transform-origin: 50% 100%; }
.mascot p { position: absolute; left: 136px; top: 5px; width: 145px; margin: 0; padding: 10px 12px; border-radius: 15px 15px 15px 5px; background: rgba(255,255,255,.95); box-shadow: 0 10px 25px rgba(29,74,68,.12); color: var(--green-dark); font-size: 12px; font-weight: 850; line-height: 1.3; }
.mascot.is-happy { animation: mascotPop 600ms cubic-bezier(.2,.85,.25,1.2); }
.mascot.is-thinking .sticker-art { animation: mascotThink 1.7s ease-in-out infinite; }
.mascot.is-sad { animation: mascotNudge 360ms ease-out; }
.harvest-prop { position: absolute; z-index: 1; right: max(18px,calc(50% - 665px)); bottom: 50px; width: 160px; opacity: .7; transform: rotate(3deg); }

/* Gather mission */
.plant-scene { position: relative; width: 100%; height: 100%; min-height: 360px; }
.plant-sticker { position: absolute; left: 50%; top: 50%; width: min(430px,68%); padding: 8px; transform: translate(-50%,-50%); }
.plant-sticker img { display: block; width: 100%; border-radius: 20px; }
.ingredient-token { position: absolute; z-index: 3; width: 92px; display: grid; gap: 3px; place-items: center; padding: 10px; border: 2px solid rgba(23,59,53,.12); border-radius: 18px; background: #fff; box-shadow: 0 7px 0 rgba(27,75,58,.1); font-size: 12px; font-weight: 900; }
.ingredient-token b { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--blue); font-size: 15px; }
.ingredient-token.co2 { right: 10%; top: 38%; }.ingredient-token.co2 b { background: var(--carbon); }
.ingredient-token.light { right: 15%; top: 7%; }.ingredient-token.light b { color: #725400; background: #ffd668; font-size: 23px; }
.ingredient-token.water { left: 10%; bottom: 8%; }
.ingredient-token.active { animation: tokenBob 900ms ease-in-out infinite alternate; border-color: var(--green); }
.ingredient-token.done::after { position: absolute; right: -5px; top: -7px; width: 26px; height: 26px; display: grid; place-items: center; content: "✓"; border-radius: 50%; color: #fff; background: var(--green); }
.route { position: absolute; z-index: 2; opacity: 0; pointer-events: none; border: 4px dashed currentColor; }
.route.show { opacity: .82; animation: routeIn 450ms ease-out; }
.route.water { left: 25%; bottom: 18%; width: 18%; height: 22%; color: var(--blue); border-left: 0; border-bottom: 0; border-radius: 0 60px 0 0; }
.route.co2 { right: 22%; top: 46%; width: 18%; height: 1px; color: var(--carbon); border-width: 4px 0 0; }
.route.light { right: 27%; top: 16%; width: 17%; height: 23%; color: #d59d12; border-left: 0; border-bottom: 0; border-radius: 60px 0 0; }

/* Atom mission */
.atom-lab { position: relative; width: 100%; display: grid; grid-template-columns: 1fr 1.18fr; gap: 16px; align-items: stretch; }
.lab-panel { min-width: 0; padding: 15px; border-radius: 21px; background: #f1f8f1; box-shadow: 0 0 0 1px #d4e5d8 inset; }
.lab-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: var(--green-dark); font-size: 12px; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; }
.lab-label b { padding: 4px 8px; border-radius: 99px; background: #fff; color: var(--muted); font-size: 12px; letter-spacing: 0; text-transform: none; }
.molecule-shelf { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.molecule { min-height: 82px; display: flex; align-items: center; justify-content: center; padding: 8px; border-radius: 16px; background: #fff; box-shadow: 0 4px 0 #dce8df; }
.molecule.is-empty { color: #94a69e; box-shadow: none; border: 2px dashed #d1e0d7; background: transparent; font-size: 12px; }
.molecule .atom + .atom { margin-left: -8px; }
.atom { width: 49px; height: 49px; flex: 0 0 49px; display: grid; place-items: center; padding: 0; border: 3px solid var(--ink); border-radius: 50%; color: #fff; background: var(--carbon); box-shadow: inset 6px 7px rgba(255,255,255,.18),0 4px 0 rgba(23,59,53,.18); font-size: 17px; font-weight: 950; transition: transform 140ms ease-out,filter 140ms ease-out; }
button.atom:hover { z-index: 4; transform: translateY(-4px) scale(1.04); }
.atom[data-kind="H"] { color: var(--ink); background: #fffdf4; }.atom[data-kind="O"] { background: var(--coral); }
.atom.selected { z-index: 5; transform: translateY(-5px) scale(1.08); filter: drop-shadow(0 0 7px var(--gold)); }
.atom.placed { width: 43px; height: 43px; flex-basis: 43px; font-size: 15px; }
.product-board { display: grid; gap: 9px; }
.product-zone { position: relative; min-height: 92px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; padding: 28px 10px 10px; border: 2px dashed #a8bdae; border-radius: 17px; background: rgba(255,255,255,.72); }
.product-zone::before { position: absolute; left: 11px; top: 8px; content: attr(data-label); color: var(--green-dark); font-size: 12px; font-weight: 950; letter-spacing: .04em; text-transform: uppercase; }
.socket { width: 43px; height: 43px; flex: 0 0 43px; display: grid; place-items: center; padding: 0; border: 2px dashed #8fa197; border-radius: 50%; color: #7d9187; background: #f7faf7; font-weight: 900; transition: transform 130ms ease-out,background 130ms ease-out; }
.socket:hover, .socket.hot { transform: scale(1.08); background: #fff5c7; border-color: var(--gold); }
.socket.filled { border: 0; background: transparent; }
.oxygen-pairs, .oxygen-pair { display: flex; }.oxygen-pairs { gap: 20px; }.oxygen-pair .socket + .socket { margin-left: -6px; }
.lab-flash { animation: labFlash 650ms ease-out; }

/* Reactor mission */
.factory { position: relative; width: 100%; height: 100%; min-height: 350px; display: grid; grid-template-columns: .9fr 1fr .8fr; align-items: center; gap: 16px; }
.feed-lights, .outputs { display: grid; gap: 11px; }
.feed, .output-box { min-height: 65px; display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; padding: 10px; border-radius: 15px; background: #fff; box-shadow: 0 4px 0 #dce8e1; }
.feed i { width: 36px; height: 36px; border: 7px solid #dcebe4; border-top-color: var(--green); border-radius: 50%; }
.feed.is-low { color: #a34536; background: #fff2ed; }.feed.is-low i { border-color: #f1c5ba; border-top-color: var(--coral); }
.feed b, .feed small, .output-box b, .output-box small { display: block; }.feed b, .output-box b { font-size: 12px; }.feed small, .output-box small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.reactor-sticker { width: 100%; }.reactor-sticker img { display: block; width: 100%; border-radius: 19px; }.factory[data-rate="slow"] .reactor-sticker { animation: reactorSputter 650ms ease-in-out infinite alternate; }
.output-box span { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 12px; color: #fff; background: #b97824; font-size: 12px; font-weight: 950; }.output-box.oxygen span { background: var(--coral); }.factory[data-rate="slow"] .output-box { opacity: .45; }
.slider-control { display: grid; grid-template-columns: 80px 1fr 46px; align-items: center; gap: 12px; padding: 12px 15px; border: 2px solid #a7cabb; border-radius: 17px; background: #f2faf5; box-shadow: 0 4px 0 #d4e8dc; }
.slider-control b { font-size: 13px; }.slider-control output { font-size: 13px; font-weight: 950; text-align: right; }.slider-control input { width: 100%; accent-color: var(--green); }

/* Night + practice */
.night-scene { position: relative; width: 100%; height: 100%; min-height: 350px; overflow: hidden; border-radius: 24px; background: linear-gradient(#23445b,#315f55); }
.night-scene::before { position: absolute; left: 45px; top: 34px; width: 68px; height: 68px; content: ""; border-radius: 50%; background: #fff2bb; box-shadow: 0 0 35px rgba(255,242,187,.4); }
.night-scene .plant-sticker { width: 350px; bottom: -90px; top: auto; transform: translateX(-50%); filter: brightness(.55) saturate(.8); }
.night-status { position: absolute; left: 28px; bottom: 25px; display: flex; gap: 8px; }
.night-status span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 99px; color: #fff; background: rgba(10,27,35,.45); font-size: 12px; font-weight: 900; }
.lamp-off { position: absolute; right: 55px; top: 58px; width: 120px; height: 120px; display: grid; place-items: center; border: 5px solid rgba(255,255,255,.25); border-radius: 50%; color: #fff; background: rgba(13,31,39,.45); font-size: 43px; }.lamp-off::after { position: absolute; width: 105px; height: 5px; content: ""; transform: rotate(-42deg); border-radius: 9px; background: var(--coral); }
.practice-scene { width: 100%; max-width: 660px; display: grid; grid-template-columns: 180px 1fr; align-items: center; gap: 25px; }
.practice-prop { width: 180px; }
.scenario-card { min-height: 170px; display: grid; align-content: center; gap: 14px; padding: 22px; border-radius: 23px; background: #eff8f1; box-shadow: 0 0 0 1px #d4e5d8 inset; }
.scenario-card > span { color: var(--green); font-size: 12px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }.scenario-card strong { font-size: 23px; line-height: 1.15; }.scenario-values { display: flex; gap: 8px; }.scenario-values b { padding: 7px 10px; border-radius: 99px; background: #fff; font-size: 12px; }.scenario-values b.low { color: #a64231; background: #ffe7df; }

.toast { position: absolute; z-index: 60; left: 50%; top: 25px; max-width: 470px; padding: 11px 18px; opacity: 0; transform: translate(-50%,-12px) scale(.96); border-radius: 99px; color: #fff; background: #173f38; box-shadow: 0 14px 34px rgba(18,56,47,.2); pointer-events: none; font-size: 12px; font-weight: 850; transition: opacity 170ms ease-out,transform 170ms ease-out; }.toast.is-showing { opacity: 1; transform: translate(-50%,0) scale(1); }
.celebration { position: absolute; z-index: 55; inset: 0; overflow: hidden; pointer-events: none; }.celebration i { position: absolute; left: 50%; top: 50%; opacity: 0; color: var(--gold); font-style: normal; font-size: 24px; }.celebration.is-showing i { animation: confetti 850ms cubic-bezier(.15,.72,.25,1) forwards; }
.celebration i:nth-child(1){--x:-310px;--y:-230px}.celebration i:nth-child(2){--x:-245px;--y:-285px;color:var(--green)}.celebration i:nth-child(3){--x:-175px;--y:-240px;color:var(--coral)}.celebration i:nth-child(4){--x:-80px;--y:-310px}.celebration i:nth-child(5){--x:25px;--y:-265px;color:var(--green)}.celebration i:nth-child(6){--x:125px;--y:-305px;color:var(--coral)}.celebration i:nth-child(7){--x:190px;--y:-245px}.celebration i:nth-child(8){--x:270px;--y:-285px;color:var(--green)}.celebration i:nth-child(9){--x:325px;--y:-205px;color:var(--coral)}.celebration i:nth-child(10){--x:75px;--y:-225px}
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes tokenBob { to { transform: translateY(-6px); } }
@keyframes routeIn { from { clip-path: inset(100% 0 0); } to { clip-path: inset(0); } }
@keyframes labFlash { 45% { filter: brightness(1.12) drop-shadow(0 0 14px var(--gold)); } }
@keyframes reactorSputter { to { transform: translateY(3px) rotate(.5deg); } }
@keyframes gentleShake { 0%,100%{transform:translateX(0)}25%{transform:translateX(-7px) rotate(-.2deg)}65%{transform:translateX(6px) rotate(.2deg)} }
@keyframes mascotPop { 0%,100%{transform:translateY(0) rotate(0)}35%{transform:translateY(-18px) rotate(-3deg)}62%{transform:translateY(0) rotate(2deg)} }
@keyframes mascotThink { 50%{transform:translateY(-5px) rotate(1deg)} }
@keyframes mascotNudge { 35%{transform:rotate(-4deg)}70%{transform:rotate(3deg)} }
@keyframes confetti { 0%{opacity:0;transform:translate(-50%,-50%) scale(.4)}12%{opacity:1}100%{opacity:0;transform:translate(calc(-50% + var(--x)),calc(-50% + var(--y))) rotate(480deg) scale(1.1)} }

@media (max-width: 1180px) {
  .play-surface { width: min(790px,calc(100% - 235px)); min-width: 680px; padding-inline: 38px; }
  .mascot { left: 12px; width: 125px; }.mascot p { left: 15px; top: -37px; width: 135px; border-radius: 15px 15px 5px 15px; }
  .harvest-prop { right: 10px; width: 120px; }
}
@media (max-height: 740px) {
  .play-surface { height: calc(100% - 34px); min-height: 610px; padding-top: 24px; padding-bottom: 18px; }
  .mission-hud { top: 12px; }.plant-scene,.night-scene,.factory { min-height: 325px; }.mascot { bottom: 18px; }
}
@media (max-width: 760px) {
  body { overflow: auto; }.game { min-height: 760px; padding: 80px 14px 160px; }
  .play-surface { width: 100%; min-width: 0; height: auto; min-height: 620px; padding: 28px 18px 22px; border-radius: 26px; }
  .mission-hud { left: 14px; right: 14px; }.practice-stats .charge-stat { display: none; }
  .choice-grid { grid-template-columns: 1fr; }.choice { min-height: 56px; }.atom-lab { grid-template-columns: 1fr; }.lab-panel { padding: 10px; }.molecule { min-height: 65px; }
  .factory { grid-template-columns: 1fr 135px 1fr; gap: 8px; }.practice-scene { grid-template-columns: 110px 1fr; gap: 12px; }.practice-prop { width: 110px; }
  .mascot { left: 18px; bottom: 16px; width: 120px; }.harvest-prop { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
