:root {
  --bg: #02060c;
  --bg-deep: #010308;
  --ink: #eaf7ff;
  --ink-soft: #c3dce8;
  --muted: #7f9cad;
  --faint: #526c7c;
  --cyan: #5ff3ff;
  --teal: #38d8c2;
  --amber: #ffb45c;
  --red: #ff6b6b;
  --green: #63f5a6;
  --blue: #6f9dff;
  --violet: #b58cff;
  --line: rgba(118, 214, 244, 0.14);
  --line-strong: rgba(118, 214, 244, 0.28);
  --panel: rgba(7, 18, 29, 0.76);
  --panel-solid: rgba(6, 16, 26, 0.94);
  --font: "Segoe UI", "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  --radius: 18px;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.055);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(95, 243, 255, 0.85);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(95, 243, 255, 0.25);
  color: #fff;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 0;
  cursor: grab;
  touch-action: none;
}

#scene:active {
  cursor: grabbing;
}

.ambient-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 44%, transparent 22%, rgba(1, 3, 8, 0.22) 60%, rgba(1, 3, 8, 0.78) 100%),
    linear-gradient(180deg, rgba(1, 3, 8, 0.6) 0%, transparent 17%, transparent 72%, rgba(1, 3, 8, 0.68) 100%);
}

.ambient-grid {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(95, 243, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 243, 255, 0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at center, transparent 35%, #000 100%);
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 35%, #000 100%);
}

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 22px 34px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}

body.is-playing .topbar {
  opacity: 1;
  transform: none;
}

.topbar > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  justify-self: start;
  user-select: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: linear-gradient(145deg, #8efaff 0%, #32c4dc 45%, #11617a 100%);
  clip-path: polygon(50% 0%, 96% 24%, 96% 76%, 50% 100%, 4% 76%, 4% 24%);
  filter: drop-shadow(0 0 18px rgba(95, 243, 255, 0.35));
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 2px;
  background: #04111b;
  clip-path: inherit;
}

.brand-mark i {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1px solid var(--cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 12px rgba(95, 243, 255, 0.7);
}

.brand-mark b {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px #fff;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-kicker {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.2em;
}

.brand-copy strong {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.09em;
}

.progress {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 7px 12px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(4, 13, 22, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.step {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 8px;
  color: var(--faint);
  transition: color 0.3s ease;
}

.step:not(:last-child)::after {
  content: "";
  width: 15px;
  height: 1px;
  margin-left: 8px;
  background: rgba(118, 214, 244, 0.14);
}

.step-dot {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid rgba(118, 214, 244, 0.22);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 8px;
  transition: all 0.3s ease;
}

.step-label {
  font-size: 10px;
  letter-spacing: 0.1em;
}

.step.is-active {
  color: var(--ink);
}

.step.is-active .step-dot {
  border-color: var(--cyan);
  color: #041018;
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(95, 243, 255, 0.5);
}

.step.is-done {
  color: var(--ink-soft);
}

.step.is-done .step-dot {
  border-color: rgba(99, 245, 166, 0.55);
  color: var(--green);
  background: rgba(99, 245, 166, 0.12);
  font-size: 0;
}

.step.is-done .step-dot::after {
  content: "✓";
  font-size: 10px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 8px;
  justify-self: end;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(4, 13, 22, 0.5);
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color 0.25s ease, background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.icon-btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(10, 25, 39, 0.72);
  transform: translateY(-1px);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn .sound-off {
  display: none;
}

.icon-btn.is-muted .sound-on {
  display: none;
}

.icon-btn.is-muted .sound-off {
  display: block;
}

/* ---------- HUD layout ---------- */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s var(--ease);
}

body.is-playing .hud {
  opacity: 1;
  visibility: visible;
}

.hud > * {
  pointer-events: auto;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(150deg, rgba(11, 27, 42, 0.82) 0%, rgba(5, 13, 22, 0.8) 58%, rgba(4, 11, 19, 0.84) 100%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(1.1);
}

.panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 18px;
  right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(95, 243, 255, 0.45), transparent);
  opacity: 0.65;
  pointer-events: none;
}

.mission {
  position: absolute;
  top: 104px;
  left: 32px;
  width: 356px;
  padding: 21px 22px 19px;
  animation: panelIn 0.55s var(--ease) both;
}

.mission.is-switching {
  animation: panelSwap 0.42s var(--ease) both;
}

.mission-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow b {
  color: var(--cyan);
  font-weight: 600;
}

.eyebrow i {
  color: var(--faint);
  font-style: normal;
}

.target-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 155px;
  padding: 4px 8px;
  border: 1px solid rgba(95, 243, 255, 0.18);
  border-radius: 999px;
  color: #b8eff8;
  background: rgba(95, 243, 255, 0.06);
  font-size: 9px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-badge i {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.mission h1 {
  margin: 0 0 9px;
  font-size: 31px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.035em;
}

.mission-objective {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.65;
}

.hint-box {
  display: flex;
  gap: 9px;
  margin: 15px 0 17px;
  padding: 10px 11px;
  border-left: 1px solid rgba(255, 180, 92, 0.55);
  background: linear-gradient(90deg, rgba(255, 180, 92, 0.07), transparent);
}

.hint-icon {
  display: grid;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  place-items: center;
  margin-top: 1px;
  border: 1px solid rgba(255, 180, 92, 0.5);
  border-radius: 50%;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 9px;
}

.hint-box p {
  margin: 0;
  color: #b7cad4;
  font-size: 11px;
  line-height: 1.6;
}

.meter-block {
  padding-top: 13px;
  border-top: 1px solid rgba(118, 214, 244, 0.1);
}

.meter-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.meter-label span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.meter-label strong {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.meter {
  position: relative;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.075);
}

.meter > span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2d93a8, var(--cyan) 60%, #d8ffff);
  box-shadow: 0 0 14px rgba(95, 243, 255, 0.55);
  transition: width 0.22s var(--ease), background 0.3s ease;
}

.meter.is-complete > span {
  background: linear-gradient(90deg, #2f9f75, var(--green) 60%, #d9ffe9);
  box-shadow: 0 0 18px rgba(99, 245, 166, 0.55);
}

.meter.is-complete + .meter-foot .live-dot {
  color: var(--green);
}

.meter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.live-dot i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  animation: blink 1.8s ease-in-out infinite;
}

/* ---------- Console ---------- */

.console {
  position: absolute;
  top: 104px;
  right: 32px;
  width: 348px;
  max-height: calc(100dvh - 146px);
  padding: 20px 20px 16px;
  overflow-y: auto;
  overflow-x: hidden;
  animation: panelIn 0.55s 0.06s var(--ease) both;
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 243, 255, 0.24) transparent;
}

.console::-webkit-scrollbar {
  width: 4px;
}

.console::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(95, 243, 255, 0.24);
}

.console-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 19px;
}

.console-head h2 {
  margin: 5px 0 0;
  font-size: 19px;
  font-weight: 550;
  letter-spacing: 0.08em;
}

.console-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid rgba(99, 245, 166, 0.15);
  border-radius: 999px;
  color: rgba(99, 245, 166, 0.7);
  background: rgba(99, 245, 166, 0.045);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.console-status i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}

.sliders {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.slider-group {
  --c: var(--cyan);
  --pct: 50%;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.axis-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.axis-label i {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 8px var(--c);
}

.slider-value {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.slider-value b {
  color: var(--c);
  font-weight: 500;
}

.slider-value em {
  color: var(--faint);
  font-size: 8px;
  font-style: normal;
}

.slider-control {
  display: grid;
  grid-template-columns: 22px 1fr 22px;
  align-items: center;
  gap: 8px;
}

.nudge {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(118, 214, 244, 0.13);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.018);
  font-size: 13px;
  line-height: 1;
  transition: all 0.2s ease;
}

.nudge:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: rgba(95, 243, 255, 0.07);
}

.nudge:active {
  transform: scale(0.92);
}

input[type="range"] {
  --c: var(--cyan);
  --pct: 50%;
  width: 100%;
  height: 20px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--c) 0%,
    var(--c) var(--pct),
    rgba(255, 255, 255, 0.12) var(--pct),
    rgba(255, 255, 255, 0.12) 100%
  );
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--c) 0%,
    var(--c) var(--pct),
    rgba(255, 255, 255, 0.12) var(--pct),
    rgba(255, 255, 255, 0.12) 100%
  );
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #07131e;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--c), 0 0 12px color-mix(in srgb, var(--c) 55%, transparent);
  transition: transform 0.15s ease;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 2px solid #07131e;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 1px var(--c), 0 0 12px color-mix(in srgb, var(--c) 55%, transparent);
}

input[type="range"]:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

.level-extra {
  margin-top: 18px;
}

.extra-box {
  padding: 12px 13px;
  border: 1px solid rgba(118, 214, 244, 0.1);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.022);
}

.extra-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.extra-title b {
  color: var(--ink-soft);
  font-weight: 500;
}

.axis-mini {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
}

.axis-mini span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.axis-mini i {
  width: 13px;
  height: 1px;
  background: var(--c);
}

.axis-mini em {
  color: var(--faint);
  font-style: normal;
}

.dim-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.dim-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 9.5px;
}

.dim-row b {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.color-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.swatch {
  height: 42px;
  border-radius: 8px;
  background: #222;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16), inset 0 10px 24px rgba(255, 255, 255, 0.12);
  transition: background 0.3s ease;
}

.swatch-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
}

.swatch-label b {
  color: var(--ink-soft);
  font-weight: 500;
}

.swatch-hex {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.orbit-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.orbit-cell {
  padding: 8px 9px;
  border: 1px solid rgba(118, 214, 244, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}

.orbit-cell span {
  display: block;
  margin-bottom: 3px;
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.orbit-cell b {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.orbit-cell b em {
  margin-left: 2px;
  color: var(--faint);
  font-size: 7px;
  font-style: normal;
}

.console-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 19px;
  padding-top: 13px;
  border-top: 1px solid rgba(118, 214, 244, 0.09);
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.text-btn:hover {
  color: var(--ink);
}

.text-btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.camera-note {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.04em;
}

/* ---------- Code dock ---------- */

.code-dock {
  position: absolute;
  left: 32px;
  bottom: 26px;
  width: 574px;
  max-height: 204px;
  overflow: hidden;
  border: 1px solid rgba(118, 214, 244, 0.14);
  border-radius: 13px;
  background: rgba(2, 9, 15, 0.88);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: panelIn 0.55s 0.12s var(--ease) both;
}

.code-dock header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 34px;
  padding: 0 11px 0 13px;
  border-bottom: 1px solid rgba(118, 214, 244, 0.09);
  background: rgba(255, 255, 255, 0.015);
}

.code-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.13em;
  color: var(--faint);
}

.code-title em {
  padding-left: 7px;
  border-left: 1px solid rgba(118, 214, 244, 0.15);
  color: var(--muted);
  font-style: normal;
  letter-spacing: 0.04em;
}

.code-led {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  border-radius: 5px;
  color: var(--faint);
  font-size: 8.5px;
  transition: color 0.2s ease, background 0.2s ease;
}

.copy-btn:hover {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.045);
}

.copy-btn svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.code-close {
  display: none;
}

.code-dock pre {
  max-height: 168px;
  margin: 0;
  padding: 11px 14px 13px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 243, 255, 0.18) transparent;
}

.code-dock code {
  display: block;
  color: #b9d3de;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  white-space: pre;
  tab-size: 2;
}

.tok-com {
  color: #4b6a7b;
}

.tok-str {
  color: #a7e2a0;
}

.tok-key {
  color: #ff9c6b;
}

.tok-num {
  color: #ffd37c;
}

.tok-fn {
  color: #75d8ff;
}

.tok-prop {
  color: #c7b3ff;
}

.code-dock code .tok-com,
.lesson-code code .tok-com {
  color: #4b6a7b;
}

.code-dock code .tok-str,
.lesson-code code .tok-str {
  color: #a7e2a0;
}

.code-dock code .tok-key,
.lesson-code code .tok-key {
  color: #ff9c6b;
}

.code-dock code .tok-num,
.lesson-code code .tok-num {
  color: #ffd37c;
}

.code-dock code .tok-fn,
.lesson-code code .tok-fn {
  color: #75d8ff;
}

.code-dock code .tok-prop,
.lesson-code code .tok-prop {
  color: #c7b3ff;
}

.code-toggle {
  display: none;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 58;
  max-width: min(420px, 88vw);
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(4, 14, 23, 0.92);
  color: var(--ink-soft);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.25s ease, transform 0.25s var(--ease);
  backdrop-filter: blur(16px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-elevated {
  z-index: 70;
}

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow-y: auto;
  animation: overlayIn 0.45s var(--ease) both;
}

.overlay.is-leaving {
  animation: overlayOut 0.34s ease both;
}

.intro-overlay {
  background:
    radial-gradient(ellipse at 74% 42%, rgba(23, 110, 128, 0.13), transparent 34%),
    radial-gradient(ellipse at 12% 90%, rgba(91, 46, 103, 0.1), transparent 38%),
    linear-gradient(90deg, rgba(2, 6, 12, 0.96) 0%, rgba(2, 7, 13, 0.88) 37%, rgba(2, 7, 13, 0.34) 66%, rgba(2, 6, 12, 0.52) 100%);
}

.intro-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  align-items: center;
  width: min(1280px, 92vw);
  min-height: calc(100dvh - 96px);
  margin: 0 auto;
  padding: 38px 0 20px;
}

.intro-copy {
  max-width: 620px;
  padding-left: 2vw;
}

.intro-kicker {
  margin-bottom: 26px;
  color: #8fb3c2;
}

.intro-kicker i {
  width: 24px;
  height: 1px;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.intro-copy h1 {
  margin: 0 0 24px;
  font-size: clamp(62px, 8.2vw, 118px);
  font-weight: 600;
  line-height: 0.93;
  letter-spacing: -0.055em;
  text-shadow: 0 20px 80px rgba(0, 0, 0, 0.4);
}

.intro-copy h1 span {
  color: var(--cyan);
  text-shadow: 0 0 50px rgba(95, 243, 255, 0.28);
}

.intro-lede {
  max-width: 520px;
  margin: 0 0 26px;
  color: #a8c0cc;
  font-size: 14px;
  line-height: 1.9;
  letter-spacing: 0.02em;
}

.curriculum {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 30px;
}

.curriculum span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid rgba(118, 214, 244, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.022);
  color: #a9c3cf;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.curriculum i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 7px var(--c);
}

.intro-actions,
.finale-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.primary-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 47px;
  padding: 0 22px;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(120deg, #8ffcff 0%, #4de7e4 46%, #2dc7c6 100%);
  color: #031016;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  box-shadow: 0 0 0 1px rgba(95, 243, 255, 0.4), 0 14px 38px rgba(45, 199, 198, 0.2);
  transition: transform 0.25s var(--ease), box-shadow 0.25s ease, filter 0.25s ease;
}

.primary-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.42) 47%, transparent 72%);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 0 0 1px rgba(95, 243, 255, 0.55), 0 18px 44px rgba(45, 199, 198, 0.3);
}

.primary-btn:hover::before {
  transform: translateX(120%);
}

.primary-btn:active {
  transform: translateY(0) scale(0.985);
}

.primary-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ghost-btn {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid rgba(118, 214, 244, 0.2);
  border-radius: 10px;
  color: #b6ced9;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  transition: all 0.25s ease;
}

.ghost-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: rgba(95, 243, 255, 0.055);
}

.intro-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 26px;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
}

.intro-meta span:not(:last-child)::after {
  content: "·";
  margin: 0 10px;
  color: rgba(118, 214, 244, 0.3);
}

.intro-visual {
  position: relative;
  height: min(66vh, 620px);
  pointer-events: none;
}

.scan-ring {
  position: absolute;
  top: 50%;
  left: 54%;
  width: min(38vw, 480px);
  height: min(38vw, 480px);
  border: 1px solid rgba(95, 243, 255, 0.09);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 80px rgba(95, 243, 255, 0.025), inset 0 0 80px rgba(95, 243, 255, 0.018);
}

.scan-ring::before,
.scan-ring::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.scan-ring::before {
  inset: 9%;
  border: 1px dashed rgba(95, 243, 255, 0.16);
  animation: spin 44s linear infinite;
}

.scan-ring::after {
  inset: 24%;
  border: 1px solid rgba(255, 180, 92, 0.09);
}

.visual-tag {
  position: absolute;
  right: 5%;
  bottom: 7%;
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(127, 156, 173, 0.6);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.visual-tag i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 7px var(--amber);
}

.intro-footer {
  position: absolute;
  right: 4vw;
  bottom: 22px;
  left: 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(82, 108, 124, 0.7);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
}

/* ---------- Complete overlay ---------- */

.complete-overlay {
  display: grid;
  place-items: center;
  padding: 28px;
  background: radial-gradient(ellipse at 50% 45%, rgba(3, 13, 21, 0.7), rgba(1, 4, 8, 0.9));
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.complete-card {
  width: min(580px, 94vw);
  max-height: 90dvh;
  padding: 25px 30px 28px;
  overflow-y: auto;
  border-color: rgba(99, 245, 166, 0.18);
  animation: cardIn 0.5s var(--ease) both;
  scrollbar-width: thin;
}

.complete-card::before {
  background: linear-gradient(90deg, transparent, rgba(99, 245, 166, 0.55), transparent);
}

.complete-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stamp {
  padding: 4px 8px;
  border: 1px solid rgba(99, 245, 166, 0.3);
  border-radius: 3px;
  color: rgba(99, 245, 166, 0.75);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.18em;
  transform: rotate(-2deg);
}

.complete-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  margin: 20px 0 16px;
  border: 1px solid rgba(99, 245, 166, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 245, 166, 0.14), transparent 67%);
  box-shadow: 0 0 36px rgba(99, 245, 166, 0.09);
}

.complete-icon svg {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: var(--green);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.complete-card h2 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.complete-summary {
  margin: 0 0 20px;
  color: #a9c1cc;
  font-size: 12.5px;
  line-height: 1.7;
}

.lesson {
  padding: 16px 17px;
  border: 1px solid rgba(118, 214, 244, 0.11);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.lesson h3 {
  margin: 7px 0 5px;
  font-size: 15px;
  font-weight: 550;
  letter-spacing: 0.035em;
}

.lesson > p {
  margin: 0 0 12px;
  color: #94adb9;
  font-size: 11px;
  line-height: 1.65;
}

.lesson-code {
  margin: 0;
  padding: 11px 12px;
  overflow-x: auto;
  border: 1px solid rgba(118, 214, 244, 0.09);
  border-radius: 8px;
  background: rgba(1, 6, 11, 0.55);
  scrollbar-width: thin;
}

.lesson-code code {
  color: #b9d3de;
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.6;
  white-space: pre;
}

.lesson-points {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.lesson-points li {
  position: relative;
  padding-left: 13px;
  color: #8da6b2;
  font-size: 10.5px;
  line-height: 1.5;
}

.lesson-points li::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--cyan);
}

.complete-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 21px;
}

.complete-actions .primary-btn {
  min-height: 43px;
  padding: 0 18px;
  font-size: 11px;
}

.complete-actions > span {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.04em;
}

/* ---------- Finale ---------- */

.finale-overlay {
  background:
    radial-gradient(ellipse at 70% 48%, rgba(25, 118, 128, 0.13), transparent 32%),
    radial-gradient(ellipse at 20% 75%, rgba(133, 66, 35, 0.1), transparent 34%),
    linear-gradient(90deg, rgba(2, 6, 12, 0.97) 0%, rgba(2, 7, 13, 0.9) 40%, rgba(2, 7, 13, 0.3) 72%, rgba(2, 6, 12, 0.42) 100%);
}

.finale-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: min(1280px, 92vw);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 32px 0;
}

.finale-copy {
  max-width: 620px;
  padding-left: 2vw;
}

.finale-copy > .eyebrow {
  margin-bottom: 24px;
}

.finale-copy > .eyebrow i {
  width: 24px;
  height: 1px;
  background: var(--green);
  box-shadow: 0 0 9px var(--green);
}

.finale-copy h2 {
  margin: 0 0 22px;
  font-size: clamp(48px, 5.7vw, 82px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.04em;
}

.finale-copy h2 em {
  color: var(--green);
  font-style: normal;
  text-shadow: 0 0 50px rgba(99, 245, 166, 0.2);
}

.finale-copy > p {
  max-width: 520px;
  margin: 0 0 22px;
  color: #a4bdc9;
  font-size: 12.5px;
  line-height: 1.85;
}

.finale-stats {
  display: flex;
  gap: 0;
  margin-bottom: 22px;
}

.finale-stats > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 22px;
  border-left: 1px solid rgba(118, 214, 244, 0.13);
}

.finale-stats > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.finale-stats b {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.finale-stats span {
  color: var(--faint);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.finale-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
}

.finale-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #94adb9;
  font-size: 9px;
}

.finale-list i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 6px var(--c);
}

.finale-list span {
  width: 38px;
  letter-spacing: 0.06em;
}

.finale-list code {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
}

.finale-actions {
  max-width: 520px;
}

.finale-actions .text-btn {
  color: var(--faint);
  font-size: 9px;
}

.finale-visual {
  position: relative;
  height: min(68vh, 680px);
  pointer-events: none;
}

.finale-ring {
  position: absolute;
  top: 50%;
  left: 54%;
  width: min(40vw, 540px);
  height: min(40vw, 540px);
  border: 1px dashed rgba(99, 245, 166, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: spin 70s linear infinite;
}

.finale-ring::before {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(95, 243, 255, 0.08);
  border-radius: 50%;
}

.finale-bar {
  position: fixed;
  right: 24px;
  bottom: 20px;
  left: 24px;
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(4, 13, 22, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: panelIn 0.5s var(--ease) both;
}

.finale-bar > span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
}

.finale-bar > span i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
  animation: blink 2s ease-in-out infinite;
}

.finale-bar > div {
  display: flex;
  gap: 7px;
}

/* ---------- Notebook ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  padding: 24px;
  place-items: center;
  background: rgba(1, 4, 9, 0.74);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: overlayIn 0.25s ease both;
}

.notebook {
  display: flex;
  width: min(900px, 96vw);
  max-height: 88dvh;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(155deg, rgba(10, 25, 39, 0.97), rgba(4, 11, 19, 0.98) 62%);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: cardIn 0.35s var(--ease) both;
}

.notebook-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 27px 19px;
  border-bottom: 1px solid rgba(118, 214, 244, 0.1);
}

.notebook-head h2 {
  margin: 7px 0 6px;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.notebook-head p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
}

.close-btn {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.close-btn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: rgba(95, 243, 255, 0.06);
}

.close-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.notebook-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 19px 27px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 243, 255, 0.2) transparent;
}

.note-card {
  display: flex;
  gap: 13px;
  padding: 15px 16px;
  border: 1px solid rgba(118, 214, 244, 0.1);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}

.note-card.note-wide {
  grid-column: 1 / -1;
}

.note-num {
  flex: 0 0 auto;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
}

.note-card h3 {
  margin: 0 0 6px;
  font-size: 13.5px;
  font-weight: 550;
  letter-spacing: 0.03em;
}

.note-card p {
  margin: 0 0 10px;
  color: #8fa8b4;
  font-size: 10px;
  line-height: 1.65;
}

.note-card p b {
  color: #c3dae4;
  font-weight: 550;
}

.note-card pre {
  margin: 0;
  padding: 9px 10px;
  overflow-x: auto;
  border: 1px solid rgba(118, 214, 244, 0.08);
  border-radius: 7px;
  background: rgba(1, 6, 11, 0.5);
  scrollbar-width: thin;
}

.note-card code {
  color: #b4cfda;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.55;
  white-space: pre;
}

.note-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.note-tags span {
  padding: 4px 8px;
  border: 1px solid rgba(118, 214, 244, 0.12);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.08em;
}

.notebook-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 27px;
  border-top: 1px solid rgba(118, 214, 244, 0.08);
  color: var(--faint);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

/* ---------- Boot / fallback ---------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg-deep);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.boot.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.boot-ring {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(95, 243, 255, 0.14);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
  box-shadow: 0 0 30px rgba(95, 243, 255, 0.08);
}

.no-js,
.webgl-error {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  padding: 32px;
  place-items: center;
  background: #02060c;
  color: var(--ink-soft);
  font-size: 14px;
  text-align: center;
}

/* ---------- Animations ---------- */

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes panelSwap {
  0% { opacity: 1; transform: none; }
  35% { opacity: 0; transform: translateY(5px); }
  100% { opacity: 1; transform: none; }
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes overlayOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1240px) {
  .topbar {
    padding: 19px 24px;
  }

  .mission {
    top: 94px;
    left: 24px;
    width: 326px;
  }

  .console {
    top: 94px;
    right: 24px;
    width: 322px;
    max-height: calc(100dvh - 132px);
  }

  .code-dock {
    left: 24px;
    bottom: 22px;
    width: 500px;
  }

  .code-dock code {
    font-size: 10.5px;
  }

  .intro-copy,
  .finale-copy {
    padding-left: 0;
  }
}

@media (max-width: 1080px) {
  .progress .step-label {
    display: none;
  }

  .step {
    padding: 2px 6px;
  }

  .step:not(:last-child)::after {
    width: 10px;
    margin-left: 5px;
  }

  .mission {
    width: 302px;
    padding: 19px 19px 17px;
  }

  .console {
    width: 296px;
    padding: 18px 17px 15px;
  }

  .mission h1 {
    font-size: 27px;
  }

  .code-dock {
    width: 430px;
  }

  .intro-copy h1 {
    font-size: clamp(58px, 8vw, 90px);
  }
}

@media (max-width: 920px) {
  .code-dock {
    display: none;
  }

  .code-toggle {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 4px 7px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: rgba(95, 243, 255, 0.06);
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 8px;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .code-toggle span {
    color: var(--cyan);
  }

  body.is-playing .code-toggle {
    display: inline-flex;
  }

  body.code-open .code-dock {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    z-index: 46;
    display: block;
    width: auto;
    max-height: 46dvh;
    transform: none;
    animation: cardIn 0.3s var(--ease) both;
  }

  body.code-open .code-dock pre {
    max-height: calc(46dvh - 34px);
  }

  body.code-open .code-toggle {
    opacity: 0;
    pointer-events: none;
  }

  .code-close {
    display: inline-flex;
  }

  .intro-grid,
  .finale-grid {
    grid-template-columns: 1fr;
    width: min(640px, 90vw);
    min-height: auto;
    padding-top: 80px;
    padding-bottom: 80px;
  }

  .intro-visual,
  .finale-visual {
    display: none;
  }

  .intro-overlay,
  .finale-overlay {
    background:
      radial-gradient(ellipse at 50% 18%, rgba(23, 110, 128, 0.13), transparent 38%),
      linear-gradient(180deg, rgba(2, 6, 12, 0.91), rgba(2, 7, 13, 0.97));
  }

  .intro-footer {
    display: none;
  }

  .finale-grid {
    padding-top: 60px;
  }

  .finale-copy {
    max-width: 600px;
  }

  .finale-stats {
    flex-wrap: wrap;
  }
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 12px 14px;
    gap: 10px;
  }

  .brand-mark {
    width: 31px;
    height: 31px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-kicker {
    font-size: 7px;
  }

  .progress {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
  }

  .icon-btn span {
    display: none;
  }

  .mission {
    top: 62px;
    right: 12px;
    left: 12px;
    width: auto;
    padding: 12px 14px 11px;
    border-radius: 14px;
  }

  .mission-top {
    margin-bottom: 7px;
  }

  .mission h1 {
    margin-bottom: 4px;
    font-size: 22px;
  }

  .mission-objective {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .hint-box {
    display: flex;
    margin: 8px 0 9px;
    padding: 5px 7px;
  }

  .hint-icon {
    width: 14px;
    height: 14px;
    font-size: 8px;
  }

  .hint-box p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .meter-block {
    padding-top: 8px;
  }

  .meter-label {
    margin-bottom: 5px;
  }

  .meter-label strong {
    font-size: 14px;
  }

  .meter-foot {
    margin-top: 6px;
    font-size: 8px;
  }

  .console {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 36dvh;
    padding: 11px 14px 10px;
    border-radius: 15px;
  }

  .console-head {
    display: none;
  }

  .console-status {
    display: none;
  }

  .sliders {
    gap: 8px;
  }

  .slider-head {
    margin-bottom: 3px;
  }

  .slider-group {
    min-height: 38px;
  }

  input[type="range"] {
    height: 16px;
  }

  .level-extra {
    display: none;
    margin-top: 9px;
  }

  body[data-level="light"] .level-extra {
    display: block;
  }

  .extra-title {
    display: none;
  }

  .swatch-label {
    margin-bottom: 4px;
    font-size: 8.5px;
  }

  .swatch {
    height: 30px;
  }

  .swatch-hex {
    display: none;
  }

  .console-foot {
    margin-top: 9px;
    padding-top: 8px;
  }

  .camera-note {
    display: none;
  }

  .code-toggle {
    font-size: 8.5px;
  }

  body.code-open .code-dock {
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-height: 50dvh;
  }

  body.code-open .code-dock pre {
    max-height: calc(50dvh - 34px);
  }

  .toast {
    bottom: calc(36dvh + 16px);
    font-size: 9.5px;
  }

  .intro-grid {
    width: 88vw;
    min-height: 100dvh;
    align-content: center;
    padding-top: 62px;
    padding-bottom: 42px;
  }

  .intro-kicker {
    margin-bottom: 20px;
    font-size: 7.5px;
  }

  .intro-copy h1 {
    margin-bottom: 19px;
    font-size: clamp(54px, 15vw, 76px);
  }

  .intro-lede {
    margin-bottom: 20px;
    font-size: 12px;
    line-height: 1.75;
  }

  .curriculum {
    margin-bottom: 24px;
    gap: 5px;
  }

  .curriculum span {
    padding: 6px 9px;
    font-size: 9px;
  }

  .intro-actions,
  .finale-actions {
    gap: 9px;
  }

  .primary-btn {
    min-height: 44px;
    padding: 0 18px;
    font-size: 11px;
  }

  .ghost-btn {
    min-height: 42px;
    padding: 0 13px;
    font-size: 9.5px;
  }

  .intro-meta {
    margin-top: 19px;
    font-size: 7.5px;
  }

  .complete-overlay {
    padding: 12px;
  }

  .complete-card {
    width: 100%;
    max-height: 92dvh;
    padding: 20px 19px 22px;
  }

  .complete-card h2 {
    font-size: 26px;
  }

  .complete-icon {
    width: 54px;
    height: 54px;
    margin: 16px 0 13px;
  }

  .complete-actions {
    flex-wrap: wrap;
    gap: 9px;
  }

  .complete-actions > span {
    width: 100%;
  }

  .finale-grid {
    width: 88vw;
    min-height: 100dvh;
    align-content: center;
    padding-top: 58px;
    padding-bottom: 36px;
  }

  .finale-copy h2 {
    font-size: clamp(45px, 13vw, 62px);
  }

  .finale-copy > p {
    font-size: 11.5px;
  }

  .finale-stats > div {
    padding: 0 14px;
  }

  .finale-stats b {
    font-size: 16px;
  }

  .finale-list {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .finale-bar {
    right: 8px;
    bottom: 8px;
    left: 8px;
    padding: 8px 9px 8px 12px;
  }

  .finale-bar .icon-btn {
    width: auto;
    padding: 0 9px;
  }

  .finale-bar .icon-btn span {
    display: inline;
    font-size: 9px;
  }

  .notebook-head {
    padding: 19px 18px 15px;
  }

  .notebook-head h2 {
    font-size: 22px;
  }

  .notebook-head p {
    display: none;
  }

  .notebook-body {
    grid-template-columns: 1fr;
    padding: 14px 16px 18px;
  }

  .note-columns {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .notebook-foot {
    padding: 9px 17px;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .notebook {
    max-height: 92dvh;
  }
}

@media (min-width: 821px) and (max-width: 920px) {
  .mission,
  .console {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
  }
}

@media (max-width: 920px) and (max-height: 700px) {
  .hint-box {
    display: none;
  }

  .mission-objective {
    max-height: 3.1em;
    overflow: hidden;
  }

  .intro-copy h1 {
    font-size: 50px;
  }

  .intro-meta {
    display: none;
  }
}

/* ---------- iOS launch choice ---------- */

.ios-choice {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  place-items: center;
  background: rgba(1, 4, 9, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.ios-choice[hidden] {
  display: none !important;
}

.ios-choice-card {
  position: relative;
  width: min(600px, 94vw);
  max-height: 92dvh;
  padding: 24px 26px 22px;
  overflow-y: auto;
  border-radius: 18px;
  scrollbar-width: thin;
}

.ios-choice-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
}

.ios-choice-card h2 {
  margin: 8px 0 7px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.ios-choice-card.is-steps .ios-choice-lede {
  display: none;
}

.ios-choice-lede {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
}

.ios-choice-options {
  display: grid;
  gap: 10px;
}

.ios-choice-option {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 76px;
  padding: 12px 14px;
  border: 1px solid rgba(118, 214, 244, 0.14);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink-soft);
  text-align: left;
  touch-action: manipulation;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.ios-choice-option:hover,
.ios-choice-option:focus-visible {
  border-color: var(--line-strong);
  background: rgba(95, 243, 255, 0.055);
}

.ios-choice-option:active {
  transform: scale(0.99);
}

.ios-choice-option.primary {
  border-color: rgba(95, 243, 255, 0.34);
  background: linear-gradient(120deg, rgba(95, 243, 255, 0.1), rgba(95, 243, 255, 0.035));
}

.choice-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(95, 243, 255, 0.2);
  border-radius: 11px;
  color: var(--cyan);
  background: rgba(95, 243, 255, 0.06);
}

.choice-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.choice-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}

.choice-copy b {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.choice-copy em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  line-height: 1.4;
}

.choice-arrow {
  color: var(--faint);
  font-size: 16px;
}

.ios-choice-steps h3 {
  margin: 4px 0 12px;
  font-size: 17px;
  font-weight: 550;
}

.ios-choice-steps ol {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ios-choice-steps li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.ios-choice-steps li > span {
  display: grid;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(95, 243, 255, 0.28);
  border-radius: 50%;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 10px;
}

.ios-choice-steps li p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.55;
}

.ios-choice-note {
  margin: 13px 0 0;
  padding: 9px 10px;
  border-left: 1px solid rgba(255, 180, 92, 0.45);
  background: rgba(255, 180, 92, 0.05);
  color: #b7cad4;
  font-size: 10px;
  line-height: 1.55;
}

.ios-choice-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 16px;
}

.ios-choice-actions .primary-btn {
  min-height: 44px;
  padding: 0 16px;
  font-size: 10.5px;
}

.ios-choice-actions .ghost-btn {
  min-height: 42px;
  font-size: 10px;
}

@media (max-width: 920px) {
  .ios-choice-card {
    padding: 20px 20px 18px;
  }

  .ios-choice-card h2 {
    font-size: 23px;
  }

  .ios-choice-option {
    min-height: 72px;
    padding: 11px 12px;
  }
}

@media (max-height: 500px) {
  .ios-choice-card {
    max-height: 94dvh;
    padding: 16px 18px 15px;
  }

  .ios-choice-card h2 {
    margin-top: 5px;
    font-size: 21px;
  }

  .ios-choice-lede {
    margin-bottom: 11px;
    font-size: 10.5px;
  }

  .ios-choice-option {
    min-height: 62px;
    padding: 8px 11px;
  }

  .choice-icon {
    width: 38px;
    height: 38px;
  }

  .choice-icon svg {
    width: 19px;
    height: 19px;
  }

  .choice-copy b {
    font-size: 12.5px;
  }

  .choice-copy em {
    font-size: 9px;
  }

  .ios-choice-steps h3 {
    margin: 2px 0 8px;
    font-size: 15px;
  }

  .ios-choice-steps ol {
    gap: 6px;
  }

  .ios-choice-steps li p {
    font-size: 10.5px;
  }

  .ios-choice-note {
    margin-top: 9px;
    padding: 7px 8px;
    font-size: 9px;
  }

  .ios-choice-actions {
    margin-top: 10px;
  }
}

/* ---------- Touch / PWA layer ---------- */

.install-btn,
.install-intro {
  display: none;
}

body.can-install .install-btn {
  display: inline-flex;
}

body.can-install .install-intro {
  display: inline-flex;
}

body.is-standalone .install-btn,
body.is-standalone .install-intro {
  display: none !important;
}

body.is-standalone .fullscreen-btn {
  display: none !important;
}

.fullscreen-btn.is-active {
  border-color: rgba(95, 243, 255, 0.38);
  color: var(--cyan);
  background: rgba(95, 243, 255, 0.07);
}

.code-backdrop {
  display: none;
}

.mission-extra {
  display: none;
}

.orientation-lock {
  display: none;
}

@media (any-pointer: coarse) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  button,
  input[type="range"] {
    touch-action: manipulation;
  }

  body {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

@media (any-pointer: coarse) and (orientation: portrait) {
  .orientation-lock {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 7px;
    padding:
      max(28px, env(safe-area-inset-top))
      max(28px, env(safe-area-inset-right))
      max(28px, env(safe-area-inset-bottom))
      max(28px, env(safe-area-inset-left));
    background:
      radial-gradient(ellipse at 50% 38%, rgba(27, 122, 144, 0.17), transparent 42%),
      #02060c;
    text-align: center;
  }

  .orientation-device {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: 12px;
  }

  .orientation-phone {
    position: absolute;
    top: 29px;
    left: 48px;
    width: 54px;
    height: 92px;
    border: 2px solid var(--cyan);
    border-radius: 10px;
    box-shadow: 0 0 38px rgba(95, 243, 255, 0.28), inset 0 0 24px rgba(95, 243, 255, 0.08);
    transform: rotate(90deg);
    animation: rotatePrompt 2.6s var(--ease) infinite;
  }

  .orientation-phone::after {
    content: "";
    position: absolute;
    bottom: 6px;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--cyan);
    transform: translateX(-50%);
  }

  .orientation-orbit {
    position: absolute;
    inset: 19px;
    border: 1px dashed rgba(95, 243, 255, 0.22);
    border-radius: 50%;
    animation: spin 20s linear infinite;
  }

  .orientation-lock > .eyebrow {
    margin-top: 8px;
  }

  .orientation-lock h2 {
    margin: 8px 0 6px;
    font-size: clamp(28px, 8vw, 42px);
    font-weight: 600;
    letter-spacing: 0.06em;
  }

  .orientation-lock p {
    margin: 0;
    color: #9cb6c3;
    font-size: 12px;
    line-height: 1.75;
  }

  .orientation-hint {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 17px;
    padding: 8px 13px;
    border: 1px solid rgba(95, 243, 255, 0.2);
    border-radius: 999px;
    color: var(--cyan);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: 0.12em;
  }

  .orientation-hint b {
    font-size: 16px;
    font-weight: 400;
  }

  @keyframes rotatePrompt {
    0%, 18% { transform: rotate(90deg); }
    50%, 72% { transform: rotate(0deg); }
    100% { transform: rotate(90deg); }
  }
}

@media (any-pointer: coarse) and (orientation: landscape) {
  .topbar {
    padding:
      max(8px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      8px
      max(14px, env(safe-area-inset-left));
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-copy strong {
    font-size: 17px;
  }

  .icon-btn {
    min-width: 44px;
    height: 44px;
    padding: 0 11px;
    justify-content: center;
    touch-action: manipulation;
  }

  .icon-btn span {
    display: none;
  }

  .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  .progress {
    padding: 6px 10px;
  }

  .mission {
    top: calc(env(safe-area-inset-top) + 64px);
    right: auto;
    bottom: auto;
    left: calc(env(safe-area-inset-left) + 14px);
    width: clamp(190px, 23vw, 300px);
    max-width: none;
    max-height: calc(100dvh - 82px);
    margin: 0;
    padding: 15px 15px 13px;
    overflow-y: auto;
    border-radius: 16px;
    scrollbar-width: none;
  }

  .mission::-webkit-scrollbar {
    display: none;
  }

  .mission-top {
    gap: 6px;
    margin-bottom: 9px;
  }

  .mission .eyebrow {
    font-size: 8.5px;
  }

  .target-badge {
    max-width: 100%;
    padding: 3px 7px;
    font-size: 8px;
  }

  .mission h1 {
    margin-bottom: 6px;
    font-size: clamp(20px, 2.3vw, 28px);
    line-height: 1.12;
  }

  .mission-objective {
    display: -webkit-box;
    overflow: hidden;
    font-size: 12px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 5;
  }

  .hint-box {
    display: flex;
    margin: 9px 0 10px;
    padding: 7px 8px;
  }

  .hint-icon {
    width: 16px;
    height: 16px;
    font-size: 8px;
  }

  .hint-box p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
  }

  .meter-block {
    padding-top: 9px;
  }

  .meter-label span {
    font-size: 9px;
  }

  .meter-label strong {
    font-size: 18px;
  }

  .meter {
    height: 6px;
  }

  .meter-foot {
    margin-top: 7px;
    font-size: 8px;
  }

  .console {
    top: auto;
    right: calc(env(safe-area-inset-right) + 14px);
    bottom: calc(env(safe-area-inset-bottom) + 12px);
    left: auto;
    width: clamp(240px, 26vw, 330px);
    max-width: none;
    max-height: calc(100dvh - 82px);
    margin: 0;
    padding: 13px 13px 11px;
    border-radius: 16px;
    scrollbar-width: thin;
  }

  .console-head {
    display: flex;
    margin-bottom: 9px;
  }

  .console-head .eyebrow {
    display: inline-flex;
    font-size: 8px;
  }

  .console-head h2 {
    margin-top: 3px;
    font-size: 16px;
  }

  .console-status {
    display: none;
  }

  .sliders {
    gap: 7px;
  }

  .slider-head {
    margin-bottom: 2px;
  }

  .axis-label {
    font-size: 12px;
  }

  .slider-value {
    font-size: 15px;
  }

  .slider-value b {
    font-size: 16px;
  }

  .slider-value em {
    font-size: 8px;
  }

  .slider-control {
    grid-template-columns: 44px 1fr 44px;
    gap: 7px;
  }

  .nudge {
    width: 44px;
    height: 44px;
    border-radius: 9px;
    font-size: 18px;
  }

  input[type="range"] {
    height: 36px;
  }

  input[type="range"]::-webkit-slider-runnable-track {
    height: 5px;
  }

  input[type="range"]::-moz-range-track {
    height: 5px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
    margin-top: -12px;
    border-width: 3px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-width: 3px;
  }

  .level-extra {
    display: none;
    margin-top: 12px;
  }

  body[data-level="light"] .level-extra {
    display: block;
  }

  .level-extra:empty {
    display: none !important;
  }

  body[data-level="light"] .mission-extra {
    display: block;
    margin-top: 9px;
  }

  body[data-level="light"] .hint-box {
    display: none;
  }

  .mission-extra .extra-box {
    padding: 8px;
  }

  .mission-extra .extra-title {
    display: none;
  }

  .mission-extra .swatch {
    height: 32px;
  }

  .mission-extra .swatch-label {
    margin-bottom: 4px;
    font-size: 8px;
  }

  .mission-extra .swatch-hex {
    display: none;
  }

  .extra-title {
    font-size: 8px;
  }

  .swatch {
    height: 38px;
  }

  .console-foot {
    position: sticky;
    bottom: -11px;
    z-index: 2;
    margin-top: 8px;
    padding-top: 8px;
    padding-bottom: 1px;
    gap: 7px;
    background: linear-gradient(180deg, rgba(6, 16, 26, 0), rgba(6, 16, 26, 0.97) 34%);
  }

  .console-foot .text-btn {
    min-height: 40px;
    font-size: 10.5px;
  }

  .console-foot .text-btn svg {
    width: 15px;
    height: 15px;
  }

  .camera-note {
    display: none;
  }

  .code-toggle {
    display: inline-flex;
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 10px;
  }

  .code-dock {
    display: none;
  }

  body.code-open .hud {
    z-index: 50;
  }

  body.code-open .code-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    background: rgba(1, 4, 9, 0.76);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
  }

  body.code-open .code-dock {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 5dvh);
    right: max(5vw, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 5dvh);
    left: max(5vw, env(safe-area-inset-left));
    z-index: 46;
    display: flex;
    width: auto;
    max-height: none;
    flex-direction: column;
    border-radius: 16px;
    transform: none;
    animation: cardIn 0.25s var(--ease) both;
  }

  body.code-open .code-dock header {
    height: 42px;
    flex: 0 0 auto;
    padding: 0 14px;
  }

  body.code-open .code-dock .code-title {
    font-size: 9px;
  }

  body.code-open .code-dock pre {
    max-height: none;
    flex: 1;
    padding: 14px 18px;
  }

  body.code-open .code-dock code {
    font-size: 13px;
    line-height: 1.75;
  }

  body.code-open .code-toggle {
    opacity: 0;
    pointer-events: none;
  }

  .code-close {
    display: inline-flex;
    min-height: 32px;
    padding: 4px 9px;
    font-size: 10px;
  }

  .copy-btn {
    min-height: 32px;
    font-size: 10px;
  }

  .toast {
    bottom: calc(env(safe-area-inset-bottom) + 14px);
    max-width: min(520px, 70vw);
    padding: 10px 16px;
    font-size: 11px;
  }

  .complete-card {
    width: min(720px, 90vw);
    max-height: 89dvh;
    padding: 18px 22px 0;
    border-radius: 16px;
  }

  .complete-icon {
    width: 46px;
    height: 46px;
    margin: 11px 0 9px;
  }

  .complete-icon svg {
    width: 28px;
    height: 28px;
  }

  .complete-card h2 {
    font-size: 25px;
  }

  .complete-summary {
    margin-bottom: 12px;
    font-size: 11.5px;
    line-height: 1.6;
  }

  .lesson {
    padding: 12px 13px;
  }

  .lesson h3 {
    font-size: 14px;
  }

  .lesson > p {
    font-size: 10.5px;
  }

  .lesson-code code {
    font-size: 10px;
  }

  .lesson-points li {
    font-size: 10px;
  }

  .complete-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 12px;
    padding: 11px 0 13px;
    background: linear-gradient(180deg, transparent, rgba(6, 16, 26, 0.98) 28%);
  }

  .complete-actions .primary-btn {
    min-height: 46px;
    font-size: 11px;
  }

  .notebook {
    width: min(900px, 92vw);
    max-height: 90dvh;
  }

  .notebook-head {
    padding: 17px 22px 13px;
  }

  .notebook-head h2 {
    font-size: 23px;
  }

  .notebook-head p {
    display: none;
  }

  .notebook-body {
    grid-template-columns: 1fr 1fr;
    padding: 14px 22px 18px;
  }

  .notebook-foot {
    padding: 8px 22px;
  }

  .intro-overlay,
  .finale-overlay {
    overflow-y: auto;
  }

  .intro-overlay {
    background:
      radial-gradient(ellipse at 74% 42%, rgba(23, 110, 128, 0.13), transparent 34%),
      radial-gradient(ellipse at 12% 90%, rgba(91, 46, 103, 0.1), transparent 38%),
      linear-gradient(90deg, rgba(2, 6, 12, 0.96) 0%, rgba(2, 7, 13, 0.88) 37%, rgba(2, 7, 13, 0.28) 68%, rgba(2, 6, 12, 0.46) 100%);
  }

  .finale-overlay {
    background:
      radial-gradient(ellipse at 70% 48%, rgba(25, 118, 128, 0.13), transparent 32%),
      radial-gradient(ellipse at 20% 75%, rgba(133, 66, 35, 0.1), transparent 34%),
      linear-gradient(90deg, rgba(2, 6, 12, 0.97) 0%, rgba(2, 7, 13, 0.9) 40%, rgba(2, 7, 13, 0.26) 74%, rgba(2, 6, 12, 0.4) 100%);
  }

  .intro-grid,
  .finale-grid {
    grid-template-columns: 1.06fr 0.94fr;
    width: 94vw;
    min-height: 100dvh;
    align-content: center;
    gap: 22px;
    padding:
      max(22px, env(safe-area-inset-top))
      max(0px, env(safe-area-inset-right))
      max(22px, env(safe-area-inset-bottom))
      max(0px, env(safe-area-inset-left));
  }

  .intro-copy,
  .finale-copy {
    max-width: 620px;
    padding-left: 0;
  }

  .intro-kicker {
    margin-bottom: 13px;
    font-size: 8px;
  }

  .intro-copy h1 {
    margin-bottom: 15px;
    font-size: clamp(48px, 7.2vw, 92px);
  }

  .intro-lede {
    margin-bottom: 15px;
    font-size: 12px;
    line-height: 1.65;
  }

  .curriculum {
    margin-bottom: 17px;
  }

  .curriculum span {
    padding: 6px 9px;
    font-size: 9px;
  }

  .intro-actions,
  .finale-actions {
    gap: 9px;
  }

  .primary-btn {
    min-height: 46px;
    padding: 0 19px;
    font-size: 11px;
  }

  .ghost-btn {
    min-height: 44px;
    padding: 0 14px;
    font-size: 10px;
  }

  .intro-meta {
    margin-top: 14px;
    font-size: 8px;
  }

  .intro-visual,
  .finale-visual {
    display: block;
    height: auto;
    min-height: 260px;
  }

  .scan-ring,
  .finale-ring {
    width: min(33vw, 400px);
    height: min(33vw, 400px);
  }

  .intro-footer {
    display: none;
  }

  .finale-copy h2 {
    margin-bottom: 12px;
    font-size: clamp(36px, 5vw, 64px);
  }

  .finale-copy > p {
    margin-bottom: 12px;
    font-size: 11px;
    line-height: 1.6;
  }

  .finale-stats {
    margin-bottom: 11px;
  }

  .finale-stats b {
    font-size: 17px;
  }

  .finale-stats span {
    font-size: 7.5px;
  }

  .finale-list {
    grid-template-columns: 1fr 1fr;
    gap: 4px 14px;
    margin-bottom: 13px;
  }

  .finale-list li {
    font-size: 8.5px;
  }

  .finale-actions .primary-btn {
    min-height: 46px;
  }

  .finale-bar {
    right: calc(env(safe-area-inset-right) + 12px);
    bottom: calc(env(safe-area-inset-bottom) + 10px);
    left: calc(env(safe-area-inset-left) + 12px);
  }

  body.code-open .toast {
    z-index: 55;
  }
}

@media (any-pointer: coarse) and (orientation: landscape) and (max-width: 760px) {
  .mission {
    padding: 12px;
  }

  .mission h1 {
    font-size: 19px;
  }

  .mission-objective {
    -webkit-line-clamp: 3;
    font-size: 11px;
  }

  .hint-box {
    display: none;
  }

  .meter-block {
    padding-top: 7px;
  }

  .meter-foot {
    display: none;
  }

  .console {
    width: 238px;
    padding: 11px 11px 9px;
  }

  .console-head {
    display: none;
  }

  .console-foot .text-btn {
    font-size: 9.5px;
  }

  .code-toggle {
    font-size: 9px;
    padding: 7px 8px;
  }

  .notebook-body {
    grid-template-columns: 1fr;
  }
}

@media (any-pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .console-head {
    display: none;
  }

  .complete-icon {
    display: none;
  }

  .complete-card {
    padding-top: 14px;
  }

  .complete-card h2 {
    font-size: 22px;
  }

  .intro-grid,
  .finale-grid {
    gap: 12px;
  }

  .intro-copy h1 {
    font-size: clamp(42px, 6.3vw, 70px);
  }

  .intro-lede {
    font-size: 11px;
  }

  .intro-visual,
  .finale-visual {
    min-height: 220px;
  }
}

@media (any-pointer: coarse) and (orientation: landscape) and (max-height: 380px) {
  .topbar {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: 6px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-kicker {
    font-size: 6.5px;
  }

  .top-actions {
    gap: 5px;
  }

  .icon-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
  }

  .icon-btn svg {
    width: 17px;
    height: 17px;
  }

  .mission {
    top: calc(env(safe-area-inset-top) + 54px);
    max-height: calc(100dvh - 62px);
    padding: 10px 11px 9px;
  }

  .mission-top {
    gap: 4px;
    margin-bottom: 5px;
  }

  .mission .eyebrow {
    font-size: 7.5px;
  }

  .target-badge {
    padding: 2px 6px;
    font-size: 7.5px;
  }

  .mission h1 {
    margin-bottom: 3px;
    font-size: 18px;
  }

  .mission-objective {
    font-size: 10.5px;
    line-height: 1.4;
    -webkit-line-clamp: 2;
  }

  .hint-box {
    display: none;
  }

  .meter-block {
    padding-top: 6px;
  }

  .meter-label {
    margin-bottom: 4px;
  }

  .meter-label span {
    font-size: 8px;
  }

  .meter-label strong {
    font-size: 15px;
  }

  .meter {
    height: 5px;
  }

  .meter-foot {
    display: none;
  }

  .console {
    bottom: calc(env(safe-area-inset-bottom) + 8px);
    max-height: calc(100dvh - 62px);
    padding: 8px 9px 7px;
  }

  .console-head {
    display: none;
  }

  .sliders {
    gap: 3px;
  }

  .slider-head {
    margin-bottom: 0;
  }

  .axis-label {
    font-size: 10.5px;
  }

  .slider-value {
    font-size: 13px;
  }

  .slider-value b {
    font-size: 14px;
  }

  .slider-control {
    grid-template-columns: 40px 1fr 40px;
    gap: 5px;
  }

  .nudge {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 16px;
  }

  input[type="range"] {
    height: 30px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -10px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }

  .console-foot {
    margin-top: 4px;
    padding-top: 5px;
    padding-bottom: 0;
  }

  .console-foot .text-btn {
    min-height: 36px;
    font-size: 9.5px;
  }

  .console-foot .text-btn svg {
    width: 13px;
    height: 13px;
  }

  .code-toggle {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 9px;
  }

  .toast {
    bottom: calc(env(safe-area-inset-bottom) + 10px);
  }

  .mission-extra .extra-box {
    padding: 6px;
  }

  .mission-extra .swatch {
    height: 26px;
  }

  .mission-extra .swatch-label {
    margin-bottom: 2px;
    font-size: 7.5px;
  }
}

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