:root {
  color-scheme: light;
  --ink: #17343a;
  --muted: #5d7478;
  --teal: #087f82;
  --teal-dark: #056568;
  --teal-soft: #e5f6f3;
  --orange: #f2763d;
  --orange-dark: #c84d22;
  --gold: #ffc94d;
  --coral: #ec5e54;
  --line: #d9e9e4;
  --surface: rgba(255, 255, 255, .96);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next Rounded", "Nunito", system-ui, sans-serif;
}

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

.game { position: relative; display: grid; place-items: center; width: 100%; height: 100%; min-width: 0; min-height: 650px; overflow: hidden; isolation: isolate; }
.world-art { position: absolute; z-index: -4; inset: -22px; width: calc(100% + 44px); height: calc(100% + 44px); object-fit: cover; filter: blur(2.5px) saturate(.78); opacity: .42; transform: scale(1.02); }
.world-wash { position: absolute; z-index: -3; inset: 0; background: linear-gradient(115deg, rgba(238,248,244,.9), rgba(251,249,236,.72) 48%, rgba(231,247,242,.88)); }
.world-wash::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 52% 47%, rgba(255,255,255,.18), rgba(237,248,245,.58) 72%); }

.mission-hud { position: absolute; z-index: 10; top: 26px; left: 28px; right: 28px; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; }
.mission-chip { display: grid; gap: 3px; padding: 10px 15px; border-radius: 16px; background: rgba(255,255,255,.8); box-shadow: 0 8px 28px rgba(29,77,72,.08); backdrop-filter: blur(12px); }
.mission-chip span { color: var(--teal); font-size: 11px; font-weight: 900; letter-spacing: .085em; text-transform: uppercase; }
.mission-chip strong { font-size: 14px; }
.practice-stats { display: flex; align-items: stretch; gap: 8px; padding: 7px; border-radius: 18px; background: rgba(255,255,255,.84); box-shadow: 0 8px 28px rgba(29,77,72,.08); backdrop-filter: blur(12px); }
.practice-stats > div { min-width: 70px; padding: 6px 10px; text-align: center; }
.practice-stats span { display: block; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.practice-stats strong { display: block; margin-top: 2px; font-size: 21px; 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: 999px; background: #dcebe7; }
.charge-stat i b { display: block; height: 100%; width: 18%; border-radius: inherit; background: linear-gradient(90deg,var(--teal),#40c3ad); transition: width 220ms ease-out; }

.play-surface { position: relative; z-index: 2; width: min(820px, calc(100% - 280px)); min-width: 680px; min-height: 640px; padding: 36px 54px 30px; border: 1px solid rgba(213,231,225,.95); border-radius: 34px; background: var(--surface); box-shadow: 0 28px 80px rgba(31,76,68,.15), 0 3px 0 rgba(255,255,255,.75) inset; backdrop-filter: blur(18px); }
.mission-copy { max-width: 670px; margin: 0 auto 8px; text-align: center; }
.phase-label { display: inline-block; margin-bottom: 8px; color: var(--orange-dark); font-size: 11px; font-weight: 950; letter-spacing: .105em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 3vw, 43px); font-weight: 950; line-height: 1.04; letter-spacing: -.035em; text-wrap: balance; }
.mission-copy p { min-height: 24px; margin: 10px 0 0; color: var(--muted); font-size: 16px; font-weight: 650; line-height: 1.4; }

.circuit-zone { position: relative; height: 390px; max-width: 760px; margin: 0 auto; }
.circuit { display: block; width: 100%; height: 100%; overflow: visible; }
.wire, .wire-gap { fill: none; stroke: #344d52; stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; }
.wire-gap { opacity: 0; stroke: var(--teal); transition: opacity 180ms ease-out; }
.circuit.front-connected .bridge-front, .circuit.rear-connected .bridge-rear { opacity: 1; animation: cableSnap 340ms cubic-bezier(.2,.9,.3,1.25); }
.battery-shadow { fill: #164b52; opacity: .13; transform: translate(0,7px); }
.battery-body { fill: #ffc83e; stroke: #da8d19; stroke-width: 5; }
.battery-cap { fill: #bfcdd0; stroke: #71868a; stroke-width: 4; }
.battery-plus { fill: none; stroke: #754b0c; stroke-width: 7; stroke-linecap: round; }
.switch-base { fill: #dbe9e6; stroke: #9cb5b2; stroke-width: 5; }
.switch-arm { fill: none; stroke: var(--orange); stroke-width: 12; stroke-linecap: round; transform-origin: -23px 0; transition: transform 180ms ease-out; }
.switch-node.is-on .switch-arm { transform: rotate(28deg); }
.terminal { fill: #f7fbfa; stroke: #70898c; stroke-width: 5; }
.bulb { fill: #e6efed; stroke: #789092; stroke-width: 5; transition: fill 180ms ease-out, stroke 180ms ease-out; }
.filament { fill: none; stroke: #799092; stroke-width: 5; stroke-linecap: round; transition: stroke 180ms ease-out; }
.socket { fill: #789092; }
.socket-line { fill: none; stroke: #d5e2df; stroke-width: 4; stroke-linecap: round; }
.lamp-halo { fill: #ffe679; opacity: 0; filter: url(#softGlow); transition: opacity 220ms ease-out; }
.lamp.is-lit .lamp-halo { opacity: .7; }
.lamp.is-lit .bulb { fill: #fff1a0; stroke: #e6a927; }
.lamp.is-lit .filament { stroke: #f08d2c; filter: url(#smallGlow); }
.lamp.is-removed { opacity: .15; transform: translate(380px, 290px) rotate(-13deg) translateY(-28px); transform-origin: center; }
.lamp-two { opacity: 0; pointer-events: none; transition: opacity 180ms ease-out, transform 220ms ease-out; }
.circuit.two-lamps .lamp-two { opacity: 1; }
.gap { opacity: 0; pointer-events: none; transition: opacity 160ms ease-out; }
.gap.is-open { opacity: 1; }
.drop-ring { fill: rgba(8,127,130,.035); stroke: rgba(8,127,130,.36); stroke-width: 3; stroke-dasharray: 7 9; transform-origin: center; animation: ringBreathe 1.8s ease-in-out infinite; }
.gap.is-target .drop-ring { fill: rgba(255,201,77,.18); stroke: var(--orange); stroke-width: 5; }
.current-dots, .trace-pulse { opacity: 0; transition: opacity 160ms ease-out; }
.current-dots circle { fill: #45d6d0; filter: url(#smallGlow); }
.circuit.is-powered .current-dots { opacity: 1; }
.trace-pulse circle { fill: var(--orange); filter: url(#smallGlow); }
.trace-pulse.is-tracing { opacity: 1; }

.cable-bay { position: absolute; right: 6px; bottom: 8px; display: flex; gap: 10px; min-height: 54px; }
.spare-cable { position: relative; display: grid; place-items: center; width: 148px; height: 54px; padding: 0; border: 0; border-radius: 17px; background: #eef8f5; box-shadow: 0 5px 0 #c8dfd9, 0 12px 22px rgba(25,87,79,.1); cursor: grab; touch-action: none; transition: transform 140ms ease-out, box-shadow 140ms ease-out, opacity 140ms ease-out; }
.spare-cable::before { content: ""; width: 104px; height: 13px; border-radius: 99px; background: var(--teal); box-shadow: -11px 0 0 -2px #bccbcd, 11px 0 0 -2px #bccbcd; }
.spare-cable::after { content: attr(data-label); position: absolute; top: -22px; color: var(--teal-dark); font-size: 10px; font-weight: 900; letter-spacing: .07em; text-transform: uppercase; }
.spare-cable:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #c8dfd9, 0 14px 25px rgba(25,87,79,.12); }
.spare-cable:active, .spare-cable.is-dragging { cursor: grabbing; transform: scale(1.05) rotate(-2deg); box-shadow: 0 10px 25px rgba(25,87,79,.2); }
.spare-cable.is-dragging { position: fixed; z-index: 40; pointer-events: none; }
.snap-burst { position: absolute; z-index: 5; left: 50%; top: 45%; color: var(--gold); font-size: 70px; opacity: 0; pointer-events: none; text-shadow: 0 4px 24px rgba(244,151,40,.34); transform: translate(-50%,-50%) scale(.35); }
.snap-burst.is-showing { animation: snapBurst 430ms ease-out; }

.action-area { min-height: 65px; max-width: 610px; margin: -2px auto 0; }
.choice-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 11px; }
.choice-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.choice, .primary, .secondary { min-height: 58px; padding: 12px 17px; border-radius: 16px; font-weight: 900; cursor: pointer; transition: transform 130ms ease-out, box-shadow 130ms ease-out, background 130ms ease-out; }
.choice { color: var(--ink); border: 2px solid var(--line); background: #fff; box-shadow: 0 4px 0 #d9e7e3; }
.choice:hover { border-color: #78bdb4; background: var(--teal-soft); transform: translateY(-2px); box-shadow: 0 6px 0 #c7dfd9; }
.choice:active { transform: translateY(3px); box-shadow: 0 1px 0 #c7dfd9; }
.choice small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 650; }
.primary { display: flex; align-items: center; justify-content: center; width: min(360px,100%); margin: 0 auto; color: #fff; border: 1px solid #057174; background: linear-gradient(180deg,#19a3a2,var(--teal)); box-shadow: 0 6px 0 var(--teal-dark), 0 13px 26px rgba(8,127,130,.17); font-size: 17px; }
.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--teal-dark), 0 15px 28px rgba(8,127,130,.2); }
.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--teal-dark); }
.primary.is-orange { border-color: #bd421d; background: linear-gradient(180deg,#f88a4e,var(--orange)); box-shadow: 0 6px 0 var(--orange-dark), 0 13px 26px rgba(219,93,43,.18); }
.feedback { min-height: 22px; margin: 10px auto 0; color: var(--coral); font-size: 13px; font-weight: 850; text-align: center; }
.play-surface.is-miss { animation: gentleShake 320ms ease-out; }

.mascot { position: absolute; z-index: 4; left: max(24px, calc(50% - 650px)); bottom: 35px; width: 205px; pointer-events: none; transform-origin: 50% 100%; }
.sticker-art, .sticker-prop { overflow: hidden; padding: 7px; border: 1px solid rgba(29,74,68,.1); border-radius: 26px; background: #fffdf7; box-shadow: 0 11px 28px rgba(25,62,59,.16); }
.sticker-art img, .sticker-prop img { display: block; width: 100%; border-radius: 19px; }
.mascot p { position: absolute; top: 5px; left: 138px; width: 150px; margin: 0; padding: 11px 13px; border-radius: 15px 15px 15px 5px; background: rgba(255,255,255,.94); box-shadow: 0 10px 26px rgba(29,74,68,.12); color: var(--teal-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.6s ease-in-out infinite; }
.mascot.is-sad { animation: mascotNudge 360ms ease-out; }
.prop-art { position: absolute; z-index: 0; opacity: .72; pointer-events: none; }
.battery-art { right: max(12px, calc(50% - 690px)); bottom: 62px; width: 170px; transform: rotate(3deg); }
.kit-art { right: max(45px, calc(50% - 635px)); top: 90px; width: 130px; transform: rotate(-4deg); opacity: .45; }

.toast { position: absolute; z-index: 50; top: 25px; left: 50%; max-width: 420px; padding: 11px 18px; border-radius: 999px; background: #173f45; box-shadow: 0 14px 34px rgba(18,56,59,.2); color: #fff; font-size: 13px; font-weight: 850; opacity: 0; pointer-events: none; transform: translate(-50%,-12px) scale(.96); transition: opacity 180ms ease-out, transform 180ms ease-out; }
.toast.is-showing { opacity: 1; transform: translate(-50%,0) scale(1); }
.celebration { position: absolute; z-index: 45; inset: 0; overflow: hidden; pointer-events: none; }
.celebration i { position: absolute; top: 45%; left: 50%; color: var(--gold); font-style: normal; font-size: 25px; opacity: 0; }
.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:-240px;--y:-280px;color:var(--teal)}.celebration i:nth-child(3){--x:-165px;--y:-250px;color:var(--orange)}.celebration i:nth-child(4){--x:-85px;--y:-300px}.celebration i:nth-child(5){--x:25px;--y:-270px;color:var(--teal)}.celebration i:nth-child(6){--x:120px;--y:-310px;color:var(--orange)}.celebration i:nth-child(7){--x:190px;--y:-245px}.celebration i:nth-child(8){--x:270px;--y:-285px;color:var(--teal)}.celebration i:nth-child(9){--x:330px;--y:-210px;color:var(--orange)}.celebration i:nth-child(10){--x:70px;--y:-230px}

@keyframes ringBreathe { 50% { transform: scale(1.08); opacity: .75; } }
@keyframes cableSnap { from { stroke-dasharray: 15 18; stroke-width: 7; } to { stroke-dasharray: 200 0; stroke-width: 13; } }
@keyframes snapBurst { 0%{opacity:0;transform:translate(-50%,-50%) scale(.3) rotate(-15deg)} 45%{opacity:1;transform:translate(-50%,-50%) scale(1.1) rotate(8deg)} 100%{opacity:0;transform:translate(-50%,-50%) scale(1.5) rotate(15deg)} }
@keyframes gentleShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px) rotate(-.25deg)} 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: 1220px) {
  .play-surface { width: min(780px, calc(100% - 260px)); min-width: 680px; padding-inline: 42px; }
  .mascot { left: 16px; bottom: 24px; width: 128px; }
  .mascot p { top: -22px; left: 14px; width: 140px; border-radius: 15px 15px 5px 15px; }
  .battery-art { right: 8px; width: 135px; }
  .kit-art { display: none; }
}

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