:root {
  color-scheme: dark;
  --ink: #eff8f6;
  --muted: #9fb5b8;
  --panel: #102b38;
  --panel-dark: #091e29;
  --line: rgba(211, 248, 238, .15);
  --lime: #b7f34a;
  --cyan: #55d8e8;
  --orange: #ff9f43;
  --red: #ff7b78;
  --ok: #8de29b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); line-height: 1.5; background: radial-gradient(circle at 75% 0, rgba(85,216,232,.11), transparent 36rem), #07131d; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 20; left: 1rem; top: -5rem; padding: .7rem 1rem; background: white; color: #07131d; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.topbar { height: 68px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(1rem,4vw,4rem); border-bottom: 1px solid var(--line); background: rgba(7,19,29,.88); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--ink); font-weight: 850; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; color: #07131d; background: var(--lime); border-radius: 5px; transform: rotate(9deg); }
.pilot-badge { color: var(--muted); border: 1px solid var(--line); padding: .34rem .7rem; border-radius: 99px; font-size: .83rem; }
.shell { width: min(1120px, calc(100% - 2rem)); margin: 0 auto; padding: 1.2rem 0 4rem; }
.mission-tabs { position: sticky; top: 78px; z-index: 8; display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; margin: 0 0 clamp(2rem,5vw,4rem); padding: .55rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(10,27,37,.92); backdrop-filter: blur(14px); }
.mission-tab { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 46px; color: #c5d6d7; border: 0; border-radius: 10px; background: transparent; font-weight: 800; }
.mission-tab span { color: var(--cyan); font-size: 1.2rem; }
.mission-tab[aria-current="true"] { color: #0a1c1b; background: var(--lime); }
.mission-tab[aria-current="true"] span { color: inherit; }
.mission-tab.completed::after { content: "✓"; color: var(--ok); }
.mission-tab[aria-current="true"].completed::after { color: inherit; }
.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2rem; margin-bottom: 2rem; }
.eyebrow, .kicker, .step-label { margin: 0 0 .5rem; color: var(--lime); font-size: .74rem; font-weight: 900; text-transform: uppercase; letter-spacing: .13em; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 850px; margin-bottom: 1rem; font-size: clamp(2.5rem,7vw,5.4rem); line-height: .94; letter-spacing: -.065em; }
h2 { margin-bottom: .8rem; font-size: clamp(1.3rem,2.5vw,2rem); line-height: 1.1; letter-spacing: -.035em; }
.lede { max-width: 760px; margin-bottom: 0; color: #c4d5d5; font-size: clamp(1rem,2vw,1.23rem); }
.progress-wrap { width: 165px; color: var(--muted); font-size: .8rem; }
.progress-track { height: 5px; margin-top: .5rem; overflow: hidden; border-radius: 10px; background: #223d49; }
.progress-track span { display: block; width: 25%; height: 100%; background: var(--lime); transition: width .35s; }
.world-card, .curriculum-card, .task-card, .hint-card, .action-card, .transfer-card, .success-card, .data-card { border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, rgba(18,48,61,.94), rgba(10,30,41,.97)); box-shadow: 0 25px 70px rgba(0,0,0,.16); }
.curriculum-card { margin-bottom: 1rem; padding: clamp(1.2rem,3vw,1.7rem); }
.curriculum-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.curriculum-heading h2 { margin-bottom: .65rem; }
.source-link { flex: 0 0 auto; color: var(--cyan); font-size: .84rem; font-weight: 800; text-underline-offset: 3px; }
.skill-list { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0 1rem; padding: 0; list-style: none; }
.skill-list li { padding: .4rem .65rem; color: #d8e9e7; border: 1px solid var(--line); border-radius: 99px; background: rgba(4,15,23,.42); font-size: .82rem; }
.exam-connection { padding: .75rem .9rem; border-left: 3px solid var(--lime); background: rgba(183,243,74,.06); }
.exam-connection strong { color: var(--lime); }
.exam-connection p { margin: .25rem 0 0; color: var(--muted); font-size: .88rem; }
.world-card { margin-bottom: 1rem; overflow: hidden; }
.world-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem .8rem; }
.world-head h2 { margin: 0; }
.resource-counter { text-align: right; }
.resource-counter small { display: block; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.resource-counter strong { color: var(--lime); }
.world { position: relative; height: clamp(270px,40vw,420px); overflow: hidden; background: #56bdc9; isolation: isolate; }
.world-caption { margin: 0; padding: .8rem 1.4rem 1rem; color: var(--muted); font-size: .88rem; }
.mission-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(260px,.75fr); gap: 1rem; }
.task-card, .hint-card, .action-card, .transfer-card, .success-card, .data-card { padding: clamp(1.2rem,3vw,2rem); }
.facts { display: grid; grid-template-columns: repeat(3,1fr); gap: .6rem; margin: 1.2rem 0; }
.fact { min-width: 0; padding: .85rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(4,15,23,.48); }
.fact span { display: block; color: var(--muted); font-size: .76rem; }
.fact strong { color: var(--cyan); font-size: 1.28rem; }
.fact em { margin-left: .25rem; color: #d5e3e2; font-style: normal; font-size: .85rem; }
fieldset { margin: 0 0 1.2rem; padding: 0; border: 0; }
legend, .input-label { display: block; margin-bottom: .55rem; font-weight: 850; }
.choice { display: block; margin-bottom: .35rem; padding: .55rem .7rem; border-radius: 9px; background: rgba(4,15,23,.33); }
.choice input { accent-color: var(--lime); }
.answer-row { display: grid; grid-template-columns: minmax(100px,1fr) auto auto; align-items: stretch; gap: .55rem; }
input, select { min-width: 0; color: var(--ink); border: 1px solid #45616d; border-radius: 10px; background: #071923; padding: .75rem .85rem; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); }
.unit { align-self: center; color: var(--muted); }
.microcopy { margin: .55rem 0 0; color: var(--muted); font-size: .82rem; }
.button { padding: .78rem 1rem; color: var(--ink); border: 0; border-radius: 10px; font-weight: 900; }
.button:disabled { cursor: not-allowed; opacity: .43; }
.button-primary { color: #0b221d; background: var(--lime); }
.button-secondary { width: 100%; border: 1px solid #486570; background: rgba(4,15,23,.48); }
.button-action { min-width: 190px; color: #251000; background: var(--orange); }
.hint-card > p:not(.step-label) { color: var(--muted); }
.hint-list { padding-left: 1.35rem; }
.hint-list li { margin: .7rem 0; }
.feedback { min-height: 1.5rem; margin-top: .8rem; font-weight: 750; }
.feedback.error { color: #ffaaa7; }
.feedback.success { color: var(--ok); }
.action-card, .transfer-card, .success-card, .data-card { display: flex; align-items: center; justify-content: space-between; gap: 2rem; margin-top: 1rem; }
.action-card.locked { opacity: .56; }
.transfer-card > div:first-child { max-width: 50%; }
.transfer-form { flex: 1; max-width: 500px; }
.success-card { border-color: rgba(183,243,74,.35); background: linear-gradient(140deg, rgba(43,78,49,.8), rgba(13,40,42,.96)); }
.success-icon { flex: 0 0 auto; display: grid; place-items: center; width: 58px; height: 58px; color: #0a251b; border-radius: 50%; background: var(--lime); font-size: 1.8rem; font-weight: 900; }
.data-card { color: var(--muted); background: rgba(9,25,35,.68); }
.data-card h2 { color: var(--ink); }
.data-card p { max-width: 650px; margin-bottom: 0; }
.data-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.text-button { padding: .4rem; color: var(--cyan); border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.text-button.danger { color: var(--red); }
.robot-program { display: grid; gap: .55rem; }
.program-row { display: grid; grid-template-columns: 2rem minmax(0,1fr); align-items: center; gap: .6rem; }
.program-row code { color: var(--lime); font-weight: 900; }
.program-fixed { padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 10px; background: #071923; }
.step-input { width: 4.5rem; margin: 0 .3rem; }
.full-button { width: 100%; margin-top: 1rem; }
footer { padding: 2rem 1rem 3rem; color: #718b91; text-align: center; font-size: .8rem; }
[hidden] { display: none !important; }

/* Bridge */
.bridge-world { background: linear-gradient(#5cc5ce 0 45%, #a8dbcc 45% 47%, #294855 47%); }
.cliff { position: absolute; bottom: 0; z-index: 1; width: 40%; height: 50%; border-top: 16px solid #8fb451; background: repeating-linear-gradient(135deg,#5e7e55 0 24px,#50744f 24px 48px); }
.cliff.left { left: 0; } .cliff.right { right: 0; }
.chasm { position: absolute; top: 47%; bottom: 0; left: 40%; right: 40%; display: grid; place-items: center; color: #c2d9d8; background: linear-gradient(#294855,#081b27); font-weight: 800; writing-mode: vertical-rl; }
.bridge-deck { position: absolute; z-index: 3; top: 57%; left: 36%; right: 36%; height: 16%; display: grid; grid-template-columns: repeat(12,1fr); gap: 2px; opacity: 0; transform: translateY(-25px); transition: .5s; }
.bridge-deck.active { opacity: 1; transform: none; }
.bridge-deck span { border: 2px solid rgba(70,36,12,.3); background: linear-gradient(135deg,#e8ad4d,#bd7430); }
.traveler, .target-star { position: absolute; z-index: 4; top: 43%; font-size: 2rem; }
.traveler { left: 25%; color: #ffec70; transition: left 1.1s; } .world.done .traveler { left: 72%; }
.target-star { right: 22%; color: #fff4a7; }

/* Delivery */
.delivery-world { background: linear-gradient(#80ced6 0 52%,#7fb358 52%); }
.road { position: absolute; left: 4%; right: 4%; bottom: 16%; height: 28%; border: 8px solid #e0d091; border-radius: 48% 15% 35% 18% / 50%; background: #46525a; transform: rotate(-3deg); }
.road::after { content: ""; position: absolute; left: 5%; right: 5%; top: 50%; border-top: 4px dashed #e8e7c7; }
.courier, .station { position: absolute; z-index: 2; bottom: 28%; font-size: 2.4rem; filter: drop-shadow(0 6px 4px rgba(0,0,0,.3)); }
.courier { left: 8%; transition: left 1.6s ease-in-out; } .world.done .courier { left: 77%; }
.station { right: 8%; }
.battery { position: absolute; top: 18%; left: 8%; width: 150px; height: 20px; border: 3px solid #12333a; border-radius: 5px; }
.battery::before { content:""; display:block; width:100%; height:100%; background:var(--lime); transition:width 1.6s; }
.world.done .battery::before { width: 9%; }

/* Ricochet */
.ricochet-world { background: #0a2431; }
.coordinate-svg { width: 100%; height: 100%; }
.trajectory { fill: none; stroke: var(--orange); stroke-width: 4; stroke-dasharray: 700; stroke-dashoffset: 700; transition: stroke-dashoffset 1.3s; }
.world.done .trajectory { stroke-dashoffset: 0; }

/* Robot */
.robot-world { display: grid; place-items: center; background: linear-gradient(135deg,#173946,#0a2431); }
.robot-grid { display: grid; grid-template-columns: repeat(5,1fr); width: min(86%,390px); aspect-ratio: 1; border: 3px solid #557782; background: #0a1b24; }
.cell { position: relative; display: grid; place-items: center; border: 1px solid rgba(132,183,187,.25); }
.cell.obstacle { background: repeating-linear-gradient(45deg,#794a39 0 9px,#965b3e 9px 18px); }
.cell.goal::after { content:"✦"; color:#fff08a; font-size:2rem; }
.robot-token { position: absolute; z-index: 3; display: grid; place-items: center; width: 62%; height: 62%; color:#0b2425; border-radius: 10px; background:var(--lime); font-size:1.4rem; font-weight:900; transition: left .2s, top .2s; }

@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior:auto !important; animation-duration:.01ms !important; transition-duration:.01ms !important; } }
@media (max-width: 900px) {
  .shell { width: min(100% - 1rem,760px); }
  .mission-tabs { top: 72px; grid-template-columns: repeat(4,minmax(0,1fr)); }
  .mission-tab { flex-direction: column; gap: 0; font-size: .72rem; }
  .hero { grid-template-columns: 1fr; gap: 1rem; }
  .progress-wrap { width: 100%; }
  .mission-grid { grid-template-columns: 1fr; }
  .action-card,.transfer-card,.success-card,.data-card { flex-direction: column; align-items: stretch; gap: 1rem; }
  .action-card .button,.success-card .button { width: 100%; }
  .transfer-card > div:first-child,.transfer-form { width: 100%; max-width: none; }
  .data-actions { justify-content: flex-start; }
}
@media (max-width: 520px) {
  .pilot-badge { display:none; }
  .brand { font-size:.88rem; }
  .facts { grid-template-columns:1fr; }
  .answer-row { grid-template-columns:1fr auto; }
  .answer-row .button { grid-column:1/-1; }
  .world { height:270px; }
  .world-head { align-items:flex-start; }
  .curriculum-heading { flex-direction: column; gap: .25rem; }
}
