:root {
  color-scheme: dark;
  --ink: #f5f8ff;
  --muted: #aebbd0;
  --night: #06101d;
  --night-2: #0a1c31;
  --panel: #0d223b;
  --line: rgba(178, 211, 240, .17);
  --cyan: #5de5f8;
  --cyan-dark: #13758a;
  --yellow: #ffdc62;
  --yellow-dark: #b98613;
  --coral: #ff796e;
  --green: #78dfa4;
  --green-dark: #28734a;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next Rounded", "Avenir Next", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; min-width: 900px; min-height: 660px; overflow: hidden; }
body { margin: 0; color: var(--ink); background: var(--night); }
button, input { color: inherit; font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.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%;
  display: grid;
  grid-template-rows: minmax(430px, 1fr) 190px;
  gap: 12px;
  padding: 12px 16px 16px;
  background: #071321;
}
.lesson.is-complete { grid-template-rows: minmax(0, 1fr); }

.space-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(123, 178, 219, .25);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 58%, rgba(35, 116, 179, .25), transparent 27%),
    radial-gradient(circle at 72% 28%, rgba(69, 101, 151, .19), transparent 28%),
    #06101d;
  box-shadow: 0 8px 0 #040b13, 0 22px 48px rgba(0, 0, 0, .24);
  isolation: isolate;
}
.space-stage::before,
.space-stage::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(237, 249, 255, .9) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(120, 205, 255, .7) 0 1px, transparent 1.5px);
  background-position: 17px 11px, 39px 33px;
  background-size: 67px 67px, 103px 103px;
  opacity: .42;
}
.space-stage::after { transform: scale(1.2) rotate(8deg); opacity: .2; }
#orbitCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.stage-meta {
  position: absolute;
  z-index: 12;
  inset: 18px 18px auto;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 18px;
  pointer-events: none;
}
.level-marker span { display: block; margin-bottom: 3px; color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.level-marker strong { font-size: 18px; letter-spacing: -.02em; }
.level-pips { display: flex; gap: 7px; }
.level-pips i { width: 36px; height: 7px; border-radius: 999px; background: rgba(255, 255, 255, .15); box-shadow: inset 0 1px 1px rgba(0, 0, 0, .2); }
.level-pips i.is-current, .level-pips i.is-complete { background: var(--cyan); }
.level-pips i.is-current { box-shadow: 0 0 0 3px rgba(93, 229, 248, .14), 0 0 16px rgba(93, 229, 248, .28); }
.mute-button { pointer-events: auto; justify-self: end; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: rgba(5, 15, 28, .72); box-shadow: 0 4px 0 rgba(0, 0, 0, .35); transition: transform 150ms ease-out, border-color 150ms ease-out; }
.mute-button:hover { transform: translateY(-2px); border-color: rgba(93, 229, 248, .65); }
.mute-button:active { transform: translateY(2px); }
.mute-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sound-off { display: none; }
.mute-button[aria-pressed="true"] .sound-on { display: none; }
.mute-button[aria-pressed="true"] .sound-off { display: block; }

.science-label {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(5, 15, 28, .8);
  box-shadow: 0 5px 18px rgba(0, 0, 0, .18);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out, border-color 160ms ease-out;
}
.science-label b { display: block; color: var(--ink); font-size: 12px; }
.science-label i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; }
.gravity-label { left: 18px; top: 86px; }
.gravity-label i { background: var(--coral); box-shadow: 0 0 10px rgba(255, 121, 110, .75); }
.speed-label { right: 18px; top: 86px; text-align: right; }
.speed-label i { order: 2; background: var(--yellow); box-shadow: 0 0 10px rgba(255, 220, 98, .65); }
.science-label.is-focus { transform: translateY(-3px) scale(1.03); border-color: currentColor; }
.gravity-label.is-focus { color: var(--coral); }
.speed-label.is-focus { color: var(--yellow); }
.science-label.is-focus i { animation: label-pulse 520ms ease-out 3; }

.planet-name { position: absolute; z-index: 9; left: 50%; bottom: 21px; display: grid; place-items: center; transform: translateX(-50%); pointer-events: none; text-align: center; }
.planet-name span { color: white; font-size: 11px; font-weight: 950; letter-spacing: .16em; }
.planet-name small { margin-top: 3px; color: #9bcdf4; font-size: 10px; font-weight: 750; }

.flight-status {
  position: absolute;
  z-index: 14;
  left: 50%;
  top: 92px;
  width: min(430px, 48%);
  padding: 12px 17px;
  transform: translateX(-50%);
  border: 1px solid rgba(93, 229, 248, .3);
  border-radius: 12px;
  background: rgba(6, 19, 34, .88);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
  text-align: center;
}
.flight-status span { display: block; color: var(--cyan); font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.flight-status strong { display: block; margin-top: 3px; font-size: 15px; }
.flight-status p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

.level-intro, .finale {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 48px));
  min-height: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 34px 50px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(142, 201, 238, .32);
  border-radius: 22px;
  background: rgba(9, 29, 50, .97);
  box-shadow: 0 14px 0 rgba(0, 0, 0, .28), 0 30px 70px rgba(0, 0, 0, .45);
  text-align: center;
}
.level-intro::before, .finale::before { position: absolute; inset: 9px; content: ""; border: 1px dashed rgba(137, 203, 238, .25); border-radius: 15px; pointer-events: none; }
.intro-number { z-index: 1; width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 12px; transform: rotate(-5deg); border: 2px solid #fff; border-radius: 15px; color: #10243b; background: var(--yellow); box-shadow: 5px 5px 0 var(--yellow-dark); font-size: 23px; font-weight: 950; }
.level-intro > p:first-of-type, .finale > span { z-index: 1; margin: 0; color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.level-intro h1, .finale h1 { z-index: 1; margin: 7px 0 8px; font-size: 40px; line-height: 1; letter-spacing: -.045em; }
.level-intro > p:last-of-type, .finale p { z-index: 1; max-width: 400px; margin: 0 0 22px; color: #c5d1df; font-size: 15px; line-height: 1.45; }
.intro-rule { z-index: 1; width: 155px; display: flex; align-items: center; margin: 4px 0 14px; }
.intro-rule i { height: 1px; flex: 1; background: rgba(255, 255, 255, .2); }
.intro-rule b { width: 8px; height: 8px; margin: 0 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.level-intro button, .finale button { z-index: 1; min-width: 220px; min-height: 52px; padding: 0 22px; border: 2px solid #fff3b8; border-radius: 12px; color: #15253b; background: var(--yellow); box-shadow: 0 6px 0 var(--yellow-dark); font-size: 15px; font-weight: 950; transition: transform 150ms ease-out, box-shadow 150ms ease-out; }
.level-intro button:hover, .finale button:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--yellow-dark); }
.level-intro button:active, .finale button:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--yellow-dark); }

.finale { min-height: 390px; border-color: rgba(255, 220, 98, .55); background: rgba(11, 33, 55, .98); }
.finale h1 { max-width: 440px; font-size: 38px; }
.orbit-badge { position: relative; z-index: 1; width: 92px; height: 92px; margin-bottom: 14px; border: 3px solid var(--cyan); border-radius: 50%; transform: rotate(-16deg); box-shadow: 0 0 0 8px rgba(93, 229, 248, .08), 0 0 30px rgba(93, 229, 248, .25); }
.orbit-badge i { position: absolute; inset: 20px; border-radius: 50%; background: #247bc9; box-shadow: inset -9px -8px rgba(5, 38, 86, .35); }
.orbit-badge b { position: absolute; right: 1px; top: 7px; width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: #2c2e2e; background: var(--yellow); font-size: 14px; }

.decision-card {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(245px, .72fr) minmax(0, 1.8fr);
  align-items: center;
  gap: 28px;
  padding: 18px 20px 18px 25px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #0b1d32;
  box-shadow: 0 6px 0 #040b13;
}
.decision-copy span { display: block; margin-bottom: 5px; color: var(--cyan); font-size: 10px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.decision-copy h2 { max-width: 345px; margin: 0; font-size: 24px; line-height: 1.12; letter-spacing: -.03em; }
.decision-copy p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.decision-content { min-width: 0; display: flex; align-items: center; justify-content: center; }

.choice-grid { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice-button {
  min-height: 104px;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  border: 2px solid rgba(178, 211, 240, .2);
  border-radius: 13px;
  background: #0e2743;
  text-align: left;
  transition: transform 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out, box-shadow 150ms ease-out;
}
.choice-button:hover { transform: translateY(-3px); border-color: var(--cyan); background: #11304f; box-shadow: 0 5px 0 #061321; }
.choice-button .choice-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; color: #16253a; background: var(--cyan); font-size: 20px; font-weight: 950; }
.choice-button[data-choice="crash"] .choice-icon { background: var(--coral); }
.choice-button[data-choice="orbit"] .choice-icon { background: var(--green); }
.choice-button[data-choice="escape"] .choice-icon { background: var(--yellow); }
.choice-button strong { display: block; font-size: 16px; }
.choice-button small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1.25; }

.speed-grid { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.speed-choice { min-height: 104px; padding: 12px; border: 2px solid rgba(178, 211, 240, .2); border-radius: 13px; background: #0e2743; text-align: center; transition: transform 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out; }
.speed-choice:hover { transform: translateY(-3px); border-color: var(--yellow); background: #142d48; }
.speed-choice span { display: block; color: var(--yellow); font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.speed-choice strong { display: block; margin-top: 4px; font-size: 24px; letter-spacing: -.03em; }
.speed-choice small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

.slider-wrap { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 22px; padding: 8px 5px 8px 2px; }
.slider-block { min-width: 0; }
.slider-value { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.slider-value span { color: var(--muted); font-size: 11px; font-weight: 750; }
.slider-value strong { color: var(--yellow); font-size: 25px; letter-spacing: -.03em; }
.speed-slider { width: 100%; height: 8px; appearance: none; border-radius: 8px; background: linear-gradient(90deg, #ff796e, #ffdc62 52%, #78dfa4); cursor: pointer; }
.speed-slider::-webkit-slider-thumb { width: 26px; height: 26px; appearance: none; border: 4px solid white; border-radius: 50%; background: #152c47; box-shadow: 0 0 0 5px rgba(255, 220, 98, .2); }
.speed-slider::-moz-range-thumb { width: 18px; height: 18px; border: 4px solid white; border-radius: 50%; background: #152c47; box-shadow: 0 0 0 5px rgba(255, 220, 98, .2); }
.slider-ends { display: flex; justify-content: space-between; margin-top: 9px; color: #8394aa; font-size: 9px; font-weight: 750; }

.primary-button, .fire-button { min-width: 190px; min-height: 62px; padding: 0 24px; border: 2px solid #fff3b8; border-radius: 12px; color: #15253b; background: var(--yellow); box-shadow: 0 6px 0 var(--yellow-dark); font-size: 15px; font-weight: 950; transition: transform 150ms ease-out, box-shadow 150ms ease-out, filter 150ms ease-out; }
.primary-button:hover, .fire-button:hover { transform: translateY(-2px); box-shadow: 0 8px 0 var(--yellow-dark); filter: brightness(1.04); }
.primary-button:active, .fire-button:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--yellow-dark); }
.fire-button { width: min(480px, 100%); min-height: 100px; display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 27px; }
.fire-button span { width: 56px; height: 56px; display: grid; place-items: center; border: 3px solid #263a4b; border-radius: 50%; font-size: 26px; }

.watching { display: flex; align-items: center; gap: 14px; color: #dce8f5; font-size: 18px; font-weight: 900; }
.watching i { width: 16px; height: 16px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); animation: watch-beat 650ms ease-in-out infinite alternate; }

.result-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.result-proof { min-width: 0; display: flex; align-items: center; gap: 13px; }
.result-badge { width: 58px; height: 58px; flex: 0 0 58px; display: grid; place-items: center; border: 3px solid white; border-radius: 50%; color: #17263a; background: var(--green); font-size: 27px; font-weight: 950; }
.result-badge.is-retry { background: var(--coral); }
.result-proof strong { display: block; font-size: 19px; line-height: 1.15; }
.result-proof p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.3; }
.primary-button.is-coral { border-color: #ffb2ac; background: var(--coral); box-shadow: 0 6px 0 #a53f3a; }

.explain-grid { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.explain-button { min-height: 83px; padding: 11px 15px; border: 2px solid rgba(178, 211, 240, .2); border-radius: 12px; background: #0e2743; font-size: 13px; font-weight: 850; line-height: 1.3; transition: transform 150ms ease-out, border-color 150ms ease-out, background 150ms ease-out; }
.explain-button:hover { transform: translateY(-2px); border-color: var(--cyan); background: #12304f; }

@keyframes watch-beat { from { transform: scale(.7); opacity: .55; } to { transform: scale(1.18); opacity: 1; } }
@keyframes label-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.65); } }

.space-stage.is-demoing .gravity-label,
.space-stage.is-demoing .speed-label { border-color: currentColor; animation: demo-nudge 600ms ease-out 3; }
@keyframes demo-nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

@media (max-height: 760px) {
  .lesson { grid-template-rows: minmax(400px, 1fr) 176px; gap: 10px; padding-top: 10px; }
  .level-intro { min-height: 310px; }
  .choice-button, .speed-choice { min-height: 94px; }
  .decision-card { padding-top: 14px; padding-bottom: 14px; }
}

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