:root {
  color-scheme: light;
  --ink: #173f3b;
  --muted: #617b72;
  --paper: #fffaf0;
  --white: #fff;
  --teal: #238d82;
  --teal-dark: #14655f;
  --mint: #a9ddc9;
  --coral: #ed745c;
  --coral-dark: #a84738;
  --gold: #f4be45;
  --gold-dark: #a86d17;
  --wood: #774b2e;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; min-width: 1000px; min-height: 650px; overflow: hidden; }
body { margin: 0; color: var(--ink); background: #cfe7df; }
button { color: inherit; font: inherit; cursor: pointer; }
:focus-visible { outline: 4px solid #0a6f8e; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.lesson { width: 100%; height: 100%; padding: 14px; }
.flip-lab { position: relative; width: min(1360px,100%); height: 100%; min-height: 620px; margin: auto; overflow: hidden; isolation: isolate; border: 1px solid rgba(26,72,59,.18); border-radius: 30px; background: #d9ebe3; box-shadow: 0 9px 0 rgba(53,99,81,.12), 0 28px 65px rgba(40,74,65,.2); }
.world-art { position: absolute; z-index: -5; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(.74) contrast(.84) brightness(1.05) blur(.7px); transform: scale(1.006); }
.world-wash { position: absolute; z-index: -4; inset: 0; background: linear-gradient(180deg,rgba(235,248,242,.58),rgba(244,248,240,.66) 48%,rgba(87,55,34,.12)); }
.world-wash::after { position: absolute; inset: 0; content: ""; background: radial-gradient(ellipse at 55% 52%,rgba(255,255,255,.23),rgba(255,255,255,.54) 55%,rgba(232,243,235,.7)); }

.lab-hud { position: absolute; z-index: 30; left: 22px; right: 22px; top: 18px; display: flex; justify-content: space-between; pointer-events: none; }
.campaign-progress,.practice-progress { min-height: 52px; display: flex; align-items: center; gap: 14px; padding: 9px 16px; border: 1px solid rgba(31,79,65,.14); border-radius: 999px; background: rgba(255,250,240,.9); box-shadow: 0 5px 18px rgba(36,72,59,.11); backdrop-filter: blur(12px); }
.campaign-progress > span,.campaign-progress > b,.practice-progress span { color: var(--muted); font-size: 10px; font-weight: 950; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.campaign-progress > b { color: var(--ink); }
.mission-dots { display: flex; gap: 7px; }
.mission-dots i { width: 11px; height: 11px; border: 2px solid #a9bdb3; border-radius: 50%; background: #eef3ec; transition: transform 150ms ease-out, background 150ms ease-out; }
.mission-dots i.done { border-color: var(--gold-dark); background: var(--gold); }
.mission-dots i.current { transform: scale(1.25); border-color: var(--teal-dark); background: var(--teal); box-shadow: 0 0 0 4px rgba(35,141,130,.13); }
.practice-progress { display: grid; grid-template-columns: auto 170px auto auto; border-radius: 18px; }
.practice-progress > div:not(.difficulty-track) { min-width: 45px; text-align: center; }
.practice-progress b { display: block; margin-top: 1px; font-size: 18px; line-height: 1; }
.difficulty-track { height: 8px; overflow: hidden; border-radius: 999px; background: #d8e4dd; }
.difficulty-track i { display: block; width: 18%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--gold),var(--coral)); transition: width 240ms ease-out; }

.mission-copy { position: absolute; z-index: 14; left: 50%; top: 19px; width: 520px; transform: translateX(-50%); text-align: center; }
.mission-copy span { color: var(--coral-dark); font-size: 10px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.mission-copy h1 { margin: 5px 0 0; font-size: 27px; line-height: 1.05; letter-spacing: -.035em; }
.mission-copy p { margin: 5px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; }

.sticker-art { overflow: hidden; border: 1px solid rgba(35,72,60,.12); border-radius: 24px; background: white; box-shadow: 0 8px 0 rgba(48,88,70,.1),0 15px 28px rgba(40,73,61,.14); }
.sticker-art img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mascot { position: absolute; z-index: 18; left: 25px; bottom: 32px; width: 188px; height: 230px; padding: 8px; transform-origin: 50% 100%; transition: transform 150ms ease-out; }
.mascot img { object-fit: cover; object-position: center; border-radius: 17px; }
.speech { position: absolute; z-index: 3; left: 116px; top: -39px; min-width: 144px; max-width: 185px; padding: 10px 13px; border: 1px solid rgba(36,75,62,.16); border-radius: 17px 17px 17px 4px; background: rgba(255,250,240,.98); box-shadow: 0 5px 16px rgba(42,77,64,.14); font-size: 11px; font-weight: 900; line-height: 1.25; }
.mascot.is-happy { animation: mascot-pop 520ms ease-out; }
.mascot.is-thinking { animation: mascot-wobble 350ms ease-out; }
.machine-art { position: absolute; z-index: 1; right: 28px; top: 90px; width: 170px; height: 150px; padding: 6px; opacity: .76; transform: rotate(2deg); }

.workbench { position: absolute; z-index: 12; left: 226px; right: 226px; top: 118px; bottom: 60px; display: grid; grid-template-columns: minmax(210px,.72fr) 84px minmax(410px,1.45fr); align-items: center; gap: 20px; padding: 32px 34px; border: 1px solid rgba(70,46,29,.18); border-radius: 28px; background: rgba(255,250,240,.9); box-shadow: 0 10px 0 rgba(93,60,36,.14),0 24px 46px rgba(56,48,36,.18); backdrop-filter: blur(15px); }
.source-zone,.dock-zone { min-width: 0; text-align: center; }
.zone-label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 10px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.source-card { position: relative; width: 100%; min-height: 285px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 20px 20px; border: 3px solid var(--teal-dark); border-radius: 25px; background: #fffdf8; box-shadow: 0 9px 0 #b8d4c8,0 17px 26px rgba(35,79,65,.15); transition: transform 150ms ease-out,box-shadow 150ms ease-out,border-color 150ms ease-out; touch-action: none; }
.source-card:hover,.source-card.is-armed { transform: translateY(-5px) rotate(-1deg); border-color: var(--coral); box-shadow: 0 14px 0 #f0c4b8,0 23px 30px rgba(35,79,65,.14); }
.source-card:active { transform: translateY(3px) scale(.985); box-shadow: 0 4px 0 #b8d4c8; }
.source-card.is-dragging { opacity: .7; transform: rotate(-4deg) scale(.98); }
.source-card strong { font-size: clamp(46px,5vw,72px); line-height: 1; letter-spacing: -.045em; }
.source-card small { margin-top: 13px; color: var(--muted); font-size: 10px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.card-pin { position: absolute; left: 50%; top: 13px; width: 14px; height: 14px; transform: translateX(-50%); border: 3px solid #b27619; border-radius: 50%; background: var(--gold); box-shadow: 0 2px 0 #8d5d17; }
.model { width: 86%; min-height: 45px; display: flex; flex-direction: column; justify-content: center; gap: 6px; margin-top: 21px; }
.fraction-bar { position: relative; width: 100%; height: 32px; overflow: hidden; border: 3px solid var(--ink); border-radius: 10px; background: #eef0e8; }
.fraction-bar .fill { position: absolute; inset: 0 auto 0 0; width: var(--fill); background: linear-gradient(90deg,#f4be45,#ed745c); transition: width 420ms ease-out; }
.fraction-bar .segments { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--parts),1fr); }
.fraction-bar .segments i { border-right: 2px solid rgba(23,63,59,.58); }
.fraction-bar .segments i:last-child { border-right: 0; }
.fraction-bar.is-extra { height: 22px; opacity: .86; }
.source-card.is-pointing .fraction-bar { animation: bar-pulse 500ms ease-out 3; }

.link-coil { display: flex; align-items: center; justify-content: center; color: var(--gold-dark); }
.link-coil i { width: 22px; height: 3px; border-radius: 3px; background: currentColor; }
.link-coil span { width: 42px; height: 42px; display: grid; place-items: center; border: 3px solid var(--gold-dark); border-radius: 50%; background: #ffe69c; font-size: 22px; box-shadow: 0 4px 0 #d4a33d; transition: transform 180ms ease-out,background 180ms ease-out; }
.flip-lab.is-locked .link-coil span { transform: scale(1.18) rotate(180deg); color: white; background: var(--teal); box-shadow: 0 0 0 10px rgba(35,141,130,.13); }
.docks { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.dock { position: relative; min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px 12px; border: 3px dashed #7d9a8e; border-radius: 23px; background: rgba(237,244,235,.78); box-shadow: inset 0 -5px 0 rgba(84,119,100,.09); transition: transform 150ms ease-out,border-color 150ms ease-out,background 150ms ease-out,box-shadow 150ms ease-out; }
.dock::before { position: absolute; left: 50%; top: 13px; width: 32px; height: 7px; content: ""; transform: translateX(-50%); border-radius: 6px; background: #b7c7bd; }
.dock:hover,.dock.is-over { transform: translateY(-5px); border-style: solid; border-color: var(--teal); background: #effaf4; box-shadow: 0 8px 0 #c5ddd1; }
.dock strong { font-size: clamp(28px,3vw,42px); line-height: 1; letter-spacing: -.035em; white-space: nowrap; }
.dock small { margin-top: 12px; color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.dock.is-selected { border-style: solid; }
.dock.is-correct { border-color: var(--teal-dark); color: var(--teal-dark); background: #def5e9; box-shadow: 0 8px 0 #9bcdb9,0 0 0 9px rgba(35,141,130,.1); animation: dock-lock 430ms ease-out; }
.dock.is-wrong { border-color: var(--coral-dark); background: #fff0eb; animation: gentle-shake 330ms ease-out; }

.comparison { position: absolute; z-index: 5; left: 50%; bottom: 20px; width: min(560px,70%); min-height: 94px; display: grid; grid-template-columns: 1fr 34px 1fr; align-items: center; gap: 13px; padding: 13px 17px; transform: translateX(-50%); border: 1px solid rgba(31,76,63,.14); border-radius: 18px; background: rgba(255,255,255,.98); box-shadow: 0 7px 22px rgba(37,74,60,.15); }
.comparison > div > span { display: block; margin-bottom: 5px; font-size: 11px; font-weight: 950; text-align: center; }
.comparison .fraction-bar { height: 24px; border-width: 2px; }
.comparison > b { font-size: 25px; text-align: center; }
.comparison.is-match > b { color: var(--teal-dark); }
.comparison.is-mismatch > b { color: var(--coral-dark); }

.result-card { position: absolute; z-index: 40; right: 35px; bottom: 32px; width: 275px; padding: 17px 18px; border: 1px solid rgba(35,76,62,.15); border-left: 6px solid var(--gold); border-radius: 10px 20px 20px 10px; background: rgba(255,250,240,.98); box-shadow: 0 10px 28px rgba(39,73,60,.18); }
.result-card > span { color: var(--coral-dark); font-size: 9px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.result-card > strong { display: block; margin-top: 4px; font-size: 21px; line-height: 1.1; }
.result-card p { margin: 6px 0 13px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.result-card button { width: 100%; min-height: 48px; border: 2px solid var(--teal-dark); border-radius: 13px; color: white; background: var(--teal); box-shadow: 0 5px 0 var(--teal-dark); font-size: 12px; font-weight: 950; transition: transform 140ms ease-out,box-shadow 140ms ease-out; }
.result-card button:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--teal-dark); }
.result-card button:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--teal-dark); }

.toast { position: absolute; z-index: 55; left: 50%; bottom: 25px; max-width: 520px; padding: 10px 17px; opacity: 0; transform: translate(-50%,12px); border-radius: 999px; color: white; background: var(--coral-dark); pointer-events: none; font-size: 12px; font-weight: 900; transition: opacity 150ms ease-out,transform 150ms ease-out; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.celebration { position: absolute; z-index: 50; left: 54%; top: 45%; pointer-events: none; }
.celebration .sticker-art { position: absolute; left: -65px; top: -65px; width: 130px; height: 130px; padding: 5px; opacity: 0; transform: scale(.4) rotate(-8deg); }
.flip-lab.is-celebrating .celebration .sticker-art { animation: sticker-pop 700ms ease-out both; }
.celebration > i { position: absolute; width: 14px; height: 14px; opacity: 0; border-radius: 4px; background: var(--gold); }
.flip-lab.is-celebrating .celebration > i { animation: sparkle 650ms ease-out both; }
.celebration > i:nth-of-type(1){--x:-180px;--y:-105px}.celebration > i:nth-of-type(2){--x:-90px;--y:-170px;animation-delay:35ms}.celebration > i:nth-of-type(3){--x:20px;--y:-185px;animation-delay:70ms}.celebration > i:nth-of-type(4){--x:150px;--y:-120px;animation-delay:105ms}.celebration > i:nth-of-type(5){--x:190px;--y:5px;animation-delay:140ms}.celebration > i:nth-of-type(6){--x:100px;--y:110px;animation-delay:175ms}.celebration > i:nth-of-type(7){--x:-110px;--y:115px;animation-delay:210ms}.celebration > i:nth-of-type(8){--x:-190px;--y:15px;animation-delay:245ms}

@keyframes mascot-pop { 0%,100%{transform:scale(1) rotate(0)}45%{transform:scale(1.07) rotate(-3deg)} }
@keyframes mascot-wobble { 0%,100%{transform:translateX(0) rotate(0)}30%{transform:translateX(-5px) rotate(-2deg)}70%{transform:translateX(5px) rotate(2deg)} }
@keyframes gentle-shake { 0%,100%{transform:translateX(0)}30%{transform:translateX(-6px)}70%{transform:translateX(6px)} }
@keyframes dock-lock { 0%{transform:scale(.88) rotate(2deg)}60%{transform:scale(1.05) rotate(-1deg)}100%{transform:none} }
@keyframes bar-pulse { 50%{transform:scaleY(1.16);box-shadow:0 0 0 7px rgba(244,190,69,.22)} }
@keyframes sticker-pop { 0%{opacity:0;transform:scale(.4) rotate(-8deg)}45%{opacity:1;transform:scale(1.05) rotate(4deg)}100%{opacity:0;transform:scale(.92) rotate(7deg)} }
@keyframes sparkle { 0%{opacity:0;transform:translate(0,0) rotate(0) scale(.2)}30%{opacity:1}100%{opacity:0;transform:translate(var(--x),var(--y)) rotate(190deg) scale(1.15)} }

@media (max-height: 760px) {
  .lesson { padding: 9px; }.flip-lab { border-radius: 24px; }.mission-copy { top: 15px; }.mission-copy h1 { font-size: 23px; }.workbench { top: 101px; bottom: 38px; padding-top: 20px; padding-bottom: 20px; }.source-card { min-height: 245px; }.dock { min-height: 195px; }.mascot { bottom: 22px; width: 165px; height: 202px; }.machine-art { width: 145px; height: 128px; }.result-card { bottom: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
