:root {
  color-scheme: dark;
  --night: #0e2a35;
  --panel: #173e4c;
  --panel-deep: #0e2d38;
  --cream: #fff7dc;
  --muted: #bed8d5;
  --yellow: #ffc84a;
  --yellow-dark: #a96513;
  --coral: #ff735f;
  --coral-dark: #a83a31;
  --teal: #31c6ae;
  --teal-dark: #137765;
  --blue: #54a9e8;
  --blue-dark: #24699a;
  --purple: #a782df;
  font-family: "Avenir Next Rounded", "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(--cream); background: var(--night); }
button { min-height: 46px; color: inherit; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 4px solid #fff1a5; 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 { height: 100%; padding: 12px; }
.build-yard {
  position: relative;
  height: 100%; min-height: 626px; overflow: hidden; isolation: isolate;
  border: 2px solid #376f77; border-radius: 28px;
  background: #1e5967 url("art/wall-yard-01.webp") center / cover no-repeat;
  box-shadow: inset 0 0 85px rgba(5,24,30,.48), 0 10px 0 #071d25, 0 28px 70px rgba(4,18,23,.5);
}
.world-shade { position: absolute; z-index: -1; inset: 0; background: linear-gradient(180deg,rgba(7,33,41,.68) 0 15%,rgba(11,40,46,.06) 45%,rgba(5,29,36,.62)); }

.lesson-hud { position: absolute; z-index: 20; left: 22px; right: 22px; top: 18px; height: 68px; display: grid; grid-template-columns: 210px 1fr auto auto; align-items: center; gap: 14px; }
.mission-card,.blueprint-track,.difficulty-card,.scoreboard { border: 1px solid rgba(255,240,184,.34); background: rgba(12,45,55,.92); box-shadow: inset 0 1px rgba(255,255,255,.1),0 5px 0 rgba(4,25,31,.7); backdrop-filter: blur(12px); }
.mission-card { height: 68px; display: grid; align-content: center; padding: 9px 16px; border-radius: 18px; }
.mission-card span,.difficulty-card span,.scoreboard span { color: #a9cfca; font-size: 10px; font-weight: 1000; letter-spacing: .1em; text-transform: uppercase; }
.mission-card strong { margin-top: 3px; font-size: 17px; }
.blueprint-track { justify-self: center; height: 58px; display: flex; align-items: center; padding: 8px 12px; border-radius: 18px; }
.blueprint-track i { width: 24px; height: 30px; display: grid; place-items: center; border: 2px solid #55818a; border-radius: 7px; color: #a4c2c4; background: #173945; font-size: 10px; font-style: normal; font-weight: 1000; transform: rotate(2deg); transition: transform 170ms ease-out,background 170ms ease-out; }
.blueprint-track b { width: 11px; height: 3px; background: #4d7178; }
.blueprint-track i.is-current { transform: rotate(-3deg) scale(1.16); border-color: var(--yellow); color: #263223; background: var(--yellow); box-shadow: 0 0 0 5px rgba(255,200,74,.14); }
.blueprint-track i.is-complete { border-color: var(--teal); color: #072e2a; background: var(--teal); }
.blueprint-track i.is-complete::before { content: "✓"; }.blueprint-track i.is-complete { font-size: 0; }.blueprint-track i.is-complete::before { font-size: 16px; }
.difficulty-card { width: 220px; display: grid; grid-template-columns: 1fr auto; gap: 5px 10px; padding: 9px 14px; border-radius: 17px; }
.difficulty-card span b { color: var(--yellow); font-size: 14px; }.difficulty-card strong { font-size: 11px; }
.difficulty-card > i { grid-column: 1 / -1; height: 7px; overflow: hidden; border-radius: 99px; background: #315963; }
.difficulty-card > i b { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--teal),var(--yellow),var(--coral)); transition: width 220ms ease-out; }
.scoreboard { height: 68px; display: flex; align-items: stretch; padding: 7px; border-radius: 18px; }
.scoreboard > div { min-width: 67px; display: grid; place-content: center; padding: 0 9px; text-align: center; }
.scoreboard > div + div { border-left: 1px solid rgba(206,235,229,.18); }
.scoreboard strong { display: block; margin-top: 2px; font-size: 21px; line-height: 1; }.scoreboard strong:first-letter { color: var(--yellow); }

.game-layout { position: absolute; z-index: 4; left: 22px; right: 22px; top: 104px; bottom: 20px; display: grid; grid-template-columns: 250px minmax(650px,1fr); gap: 18px; }
.mascot-zone { position: relative; min-width: 0; display: flex; align-items: end; justify-content: center; }
.mascot { position: relative; z-index: 3; width: min(272px,112%); height: auto; max-height: 76%; object-fit: contain; object-position: bottom; transform-origin: 50% 92%; filter: drop-shadow(0 15px 14px rgba(8,25,29,.42)); }
.speech { position: absolute; z-index: 7; left: 0; right: 0; top: 2%; min-height: 74px; display: grid; place-items: center; padding: 13px 15px; border: 3px solid var(--yellow-dark); border-radius: 21px 21px 21px 7px; color: #263223; background: #fff8dc; box-shadow: 0 6px 0 rgba(91,53,14,.54); font-size: 15px; font-weight: 1000; line-height: 1.24; text-align: center; }
.speech::after { position: absolute; left: 35px; bottom: -13px; width: 20px; height: 20px; content: ""; transform: rotate(45deg); border-right: 3px solid var(--yellow-dark); border-bottom: 3px solid var(--yellow-dark); background: #fff8dc; }
.toolbox { position: absolute; z-index: 5; right: -24px; bottom: -29px; width: 125px; height: 125px; object-fit: contain; filter: drop-shadow(0 10px 8px rgba(5,20,24,.42)); }
.mascot-zone.is-cheering .mascot { animation: mascot-cheer 650ms ease-out; filter: drop-shadow(0 0 24px rgba(255,215,73,.72)) drop-shadow(0 15px 14px rgba(8,25,29,.42)); }
.mascot-zone.is-oops .mascot { animation: mascot-oops 430ms ease-out; }
.mascot-zone.is-thinking .mascot { animation: mascot-think 2.4s ease-in-out infinite; }

.play-panel { min-width: 0; display: grid; grid-template-rows: auto minmax(330px,1fr) 38px auto; gap: 8px; padding: 18px 21px 17px; border: 2px solid rgba(255,237,177,.48); border-radius: 28px; background: linear-gradient(180deg,rgba(22,61,72,.94),rgba(10,41,50,.97)); box-shadow: inset 0 1px rgba(255,255,255,.12),0 9px 0 rgba(4,24,30,.72),0 24px 48px rgba(4,21,26,.36); backdrop-filter: blur(10px); }
.challenge-copy { min-height: 78px; padding: 0 4px; }
.challenge-copy > span { color: var(--yellow); font-size: 10px; font-weight: 1000; letter-spacing: .11em; text-transform: uppercase; }
.challenge-copy h1 { margin: 4px 0 3px; font-size: clamp(28px,2.8vw,41px); line-height: 1; letter-spacing: -.035em; text-shadow: 0 3px 0 rgba(5,25,30,.55); }
.challenge-copy p { max-width: 700px; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.wall-stage { position: relative; min-height: 330px; overflow: hidden; display: grid; align-content: center; gap: 14px; padding: 22px 28px; border: 2px solid #668f91; border-radius: 24px; background: linear-gradient(180deg,rgba(238,224,188,.96),rgba(206,183,141,.97)); box-shadow: inset 0 0 34px rgba(75,51,23,.22),0 5px 0 #113844; color: #15313a; }
.wall-stage::before { position: absolute; inset: 0; content: ""; opacity: .18; background: repeating-linear-gradient(0deg,transparent 0 53px,#70482c 54px 57px),repeating-linear-gradient(90deg,#70482c 0 3px,transparent 3px 112px); pointer-events: none; }
.blueprint-label { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; color: #3a5050; font-size: 11px; font-weight: 1000; letter-spacing: .08em; text-transform: uppercase; }
.equivalence-stack,.compare-stack { position: relative; z-index: 2; display: grid; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 78px minmax(390px,680px) 76px; align-items: center; gap: 12px; }
.bar-row > strong { font-size: 21px; text-align: right; }.bar-row > em { color: #405456; font-size: 12px; font-style: normal; font-weight: 900; }
.fraction-bar { position: relative; height: 62px; display: flex; overflow: hidden; border: 4px solid #143e47; border-radius: 12px; background: #f7efd9; box-shadow: 0 5px 0 rgba(32,61,60,.35); }
.fraction-bar .piece { position: relative; flex: 1 1 0; border-right: 3px solid #17434c; background: rgba(255,255,255,.52); }
.fraction-bar .piece:last-child { border-right: 0; }.fraction-bar .piece.is-filled { background: var(--bar-color,var(--coral)); }
.fraction-bar .piece.is-filled::after { position: absolute; inset: 6px; content: ""; border-radius: 5px; background: linear-gradient(145deg,rgba(255,255,255,.25),transparent 46%); }
.bar-row.is-snapped { animation: snap-in 430ms cubic-bezier(.2,1.5,.35,1); }.bar-row.is-snapped .fraction-bar { box-shadow: 0 0 0 5px rgba(49,198,174,.3),0 5px 0 rgba(32,61,60,.35); }
.end-line { position: absolute; z-index: 4; top: 34px; bottom: 28px; width: 4px; border-radius: 4px; background: var(--yellow); box-shadow: 0 0 0 3px rgba(255,255,255,.6),0 0 20px rgba(255,189,43,.7); }
.end-line::before { position: absolute; top: -23px; left: 50%; content: "MATCH"; transform: translateX(-50%); padding: 3px 7px; border-radius: 6px; color: #38331e; background: var(--yellow); font-size: 9px; font-weight: 1000; letter-spacing: .08em; }
.compare-symbol { position: absolute; z-index: 5; right: 22px; top: 50%; transform: translateY(-50%); width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; color: #17343b; background: var(--yellow); box-shadow: 0 5px 0 var(--yellow-dark); font-size: 34px; font-weight: 1000; }
.evidence-card { position: relative; z-index: 2; display: flex; align-items: center; gap: 13px; padding: 11px 14px; border: 2px solid #4f7775; border-radius: 14px; color: #17333a; background: rgba(255,249,226,.88); font-size: 14px; font-weight: 900; }
.evidence-card b { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #09352d; background: var(--teal); }
.feedback { min-height: 38px; display: grid; place-items: center; color: #bfeadd; font-size: 14px; font-weight: 900; text-align: center; }
.feedback.is-error { color: #ffd0c8; }
.action-area { min-height: 62px; display: flex; align-items: center; justify-content: center; }
.choice-grid { width: 100%; display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.choice,.primary { position: relative; border: 2px solid #6d9696; border-radius: 15px; color: var(--cream); background: #285866; box-shadow: 0 5px 0 #0a303b; font-weight: 1000; transition: transform 140ms ease-out,background 140ms ease-out,box-shadow 140ms ease-out; }
.choice { min-height: 66px; display: grid; place-content: center; padding: 8px 12px; font-size: 23px; text-align: center; }
.choice small { display: block; margin-top: 3px; color: #b9d9d4; font-size: 10px; font-weight: 800; }
.primary { min-width: 260px; padding: 13px 22px; border-color: #ffd36c; color: #253325; background: var(--yellow); box-shadow: 0 5px 0 var(--yellow-dark); font-size: 16px; }
.choice:hover,.primary:hover { transform: translateY(-2px); filter: brightness(1.08); }.choice:active,.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #0a303b; }
.choice.is-coral { border-color: #ff9d8d; background: #b64d42; }.choice.is-teal { border-color: #83e3d3; background: #167c70; }.choice.is-blue { border-color: #9bd3fa; background: #2e729f; }
.wall-stage.is-miss { animation: stage-shake 340ms ease-out; }
.toast { position: absolute; z-index: 30; left: 50%; bottom: 28px; max-width: 560px; padding: 11px 18px; transform: translate(-50%,30px); border: 1px solid #ffb0a4; border-radius: 999px; opacity: 0; color: #fff5df; background: #873b35; box-shadow: 0 8px 20px rgba(18,31,32,.35); font-size: 13px; font-weight: 900; pointer-events: none; transition: opacity 160ms ease-out,transform 160ms ease-out; }
.toast.is-showing { transform: translate(-50%,0); opacity: 1; }
.brick-prop { position: absolute; z-index: 2; width: 142px; height: 142px; object-fit: contain; filter: drop-shadow(0 12px 10px rgba(5,24,29,.42)); pointer-events: none; }.brick-prop-left { left: -34px; bottom: -34px; }.brick-prop-right { right: -39px; bottom: -36px; transform: scaleX(-1); }
.brick-burst { position: absolute; z-index: 25; left: 66%; top: 43%; width: 10px; height: 10px; pointer-events: none; }
.brick-burst i { position: absolute; width: 18px; height: 11px; border-radius: 3px; opacity: 0; background: var(--coral); }.brick-burst i:nth-child(2n) { background: var(--yellow); }.brick-burst i:nth-child(3n) { background: var(--teal); }.brick-burst.is-active i { animation: brick-pop 720ms ease-out forwards; }.brick-burst i:nth-child(2) { --x: 110px;--y:-95px;transform:rotate(22deg) }.brick-burst i:nth-child(3) { --x:-94px;--y:-78px;transform:rotate(-35deg) }.brick-burst i:nth-child(4) { --x:142px;--y:18px;transform:rotate(65deg) }.brick-burst i:nth-child(5) { --x:-142px;--y:10px;transform:rotate(-55deg) }.brick-burst i:nth-child(6) { --x:72px;--y:92px;transform:rotate(48deg) }.brick-burst i:nth-child(7) { --x:-77px;--y:89px;transform:rotate(-25deg) }.brick-burst i:nth-child(8) { --x:8px;--y:-127px;transform:rotate(90deg) }

@keyframes snap-in { 0% { transform: translateX(70px) rotate(1deg); opacity: .35; } 72% { transform: translateX(-5px) rotate(-.5deg); } 100% { transform: none; opacity: 1; } }
@keyframes stage-shake { 20% { transform: translateX(-8px); } 42% { transform: translateX(7px); } 65% { transform: translateX(-4px); } 100% { transform: none; } }
@keyframes mascot-cheer { 0%,100% { transform: none; } 35% { transform: translateY(-18px) rotate(-4deg) scale(1.04); } 64% { transform: translateY(2px) rotate(3deg); } }
@keyframes mascot-oops { 25% { transform: rotate(-5deg); } 55% { transform: rotate(5deg); } 100% { transform: none; } }
@keyframes mascot-think { 0%,100% { transform: rotate(-1deg); } 50% { transform: translateY(-5px) rotate(1deg); } }
@keyframes brick-pop { 0% { opacity: 1; transform: translate(0,0) scale(.5); } 70% { opacity: 1; transform: translate(var(--x,0),var(--y,-110px)) scale(1) rotate(180deg); } 100% { opacity: 0; transform: translate(var(--x,0),calc(var(--y,-110px) + 45px)) scale(.7) rotate(260deg); } }

@media (max-width: 1120px) { .game-layout { grid-template-columns: 210px minmax(620px,1fr); }.scoreboard > div { min-width: 60px; }.blueprint-track { display: none; }.lesson-hud { grid-template-columns: 200px 1fr auto; }.mascot { width: 235px; }.bar-row { grid-template-columns: 66px minmax(360px,1fr) 60px; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } }
