:root {
  --ink: #f4f6ff;
  --muted: #aeb8df;
  --night: #090e2b;
  --night-2: #131a46;
  --panel: #182052;
  --panel-dark: #0e153d;
  --aqua: #52f1df;
  --aqua-dark: #078f91;
  --gold: #ffd35b;
  --gold-dark: #b96920;
  --pink: #ff6fad;
  --violet: #a48bff;
  --danger: #ff806f;
  --good: #80ff9b;
  --metal: #6675a8;
  --line: rgba(148, 173, 255, .28);
  --shadow: 0 18px 45px rgba(0, 0, 25, .38);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  min-width: 320px;
  background: var(--night);
  color-scheme: dark;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 75% 12%, rgba(112, 88, 236, .32), transparent 33rem),
    radial-gradient(circle at 10% 72%, rgba(13, 176, 186, .18), transparent 30rem),
    linear-gradient(160deg, #070b22 0%, #10163e 58%, #090d27 100%);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.sky-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  background-image:
    linear-gradient(rgba(121, 147, 236, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(121, 147, 236, .08) 1px, transparent 1px),
    radial-gradient(circle, rgba(255, 255, 255, .9) 0 1px, transparent 1.5px);
  background-size: 42px 42px, 42px 42px, 113px 91px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.topbar {
  position: relative;
  z-index: 10;
  width: min(1180px, calc(100% - 30px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd4ff;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .16em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #09172f;
  background: var(--aqua);
  border: 2px solid #d9fffa;
  clip-path: polygon(18% 0, 82% 0, 100% 20%, 100% 80%, 82% 100%, 18% 100%, 0 80%, 0 20%);
  box-shadow: 0 0 20px rgba(82, 241, 223, .5);
  letter-spacing: 0;
}

.icon-button {
  min-width: 72px;
  min-height: 42px;
  padding: 8px 12px;
  color: var(--ink);
  background: #151d4c;
  border: 1px solid #5b6ba5;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px rgba(9, 14, 43, .55);
}

#app {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 30px));
  margin: 0 auto;
}

.screen { min-height: calc(100svh - 64px); }

.start-screen {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(360px, 1.08fr);
  grid-template-rows: 1fr auto;
  gap: 18px 50px;
  align-items: center;
  padding: 48px 0 28px;
}

.hero-copy { position: relative; z-index: 2; }

.eyebrow {
  margin: 0 0 12px;
  color: var(--aqua);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .18em;
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 7vw, 6.2rem);
  line-height: .94;
  letter-spacing: -.055em;
  text-shadow: 0 8px 34px rgba(0, 0, 0, .36);
}

h1 span {
  display: block;
  width: max-content;
  margin: 0 0 10px 4px;
  padding: 7px 16px 6px;
  color: #111736;
  background: var(--gold);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  font-size: .31em;
  letter-spacing: .02em;
  text-shadow: none;
}

.hero-lead {
  margin: 28px 0 24px;
  color: #d7ddf7;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 700;
  line-height: 1.8;
}

.start-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 15px; }
.start-actions p { max-width: 230px; margin: 0; color: var(--muted); font-size: .78rem; line-height: 1.6; }

.primary-button,
.run-button {
  min-height: 58px;
  padding: 0;
  display: inline-flex;
  align-items: stretch;
  color: #0b1632;
  background: var(--gold);
  border: 0;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 13px, 100% 100%, 13px 100%, 0 calc(100% - 13px));
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(255, 211, 91, .18);
  font-weight: 950;
}

.primary-button span,
.run-button span { padding: 17px 22px; }
.primary-button b,
.run-button b {
  min-width: 56px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #cf7223;
  border-left: 2px solid rgba(77, 37, 6, .24);
}

.primary-button:hover,
.run-button:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.primary-button:active,
.run-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button.compact { min-height: 50px; }
.primary-button.compact span { padding: 13px 20px; }
.primary-button.compact b { min-width: 48px; }

.record-tape {
  width: max-content;
  max-width: 100%;
  margin-top: 30px;
  padding: 12px 18px;
  display: grid;
  grid-template-columns: auto auto auto auto auto;
  align-items: baseline;
  gap: 7px 12px;
  color: #cad2f3;
  background: #0a1030;
  border: 1px solid #4d5c91;
  border-left: 5px solid var(--pink);
  font-family: Consolas, monospace;
}

.record-tape span { font-size: .67rem; letter-spacing: .1em; }
.record-tape strong { color: #fff; font-size: 1.08rem; }
.record-tape small { color: var(--muted); }

.hero-station {
  position: relative;
  min-height: min(580px, 63vw);
  isolation: isolate;
}

.orbit {
  position: absolute;
  border: 1px solid rgba(135, 153, 231, .2);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.orbit::before,
.orbit::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 14px #fff;
}

.orbit-one { inset: 7% 4% 8% 2%; }
.orbit-one::before { left: 12%; top: 17%; }
.orbit-one::after { right: 8%; bottom: 29%; }
.orbit-two { inset: 19% 14% 18% 12%; transform: rotate(24deg); }
.orbit-two::before { left: 31%; bottom: -4px; }
.orbit-two::after { right: 24%; top: -4px; }

.hero-gate {
  position: absolute;
  z-index: 4;
  left: 38%;
  top: 32%;
  width: 130px;
  height: 170px;
  display: grid;
  place-items: center;
  color: var(--aqua);
  background:
    linear-gradient(#1c285f, #10163b) padding-box,
    linear-gradient(145deg, var(--aqua), #8295ff, var(--pink)) border-box;
  border: 8px solid transparent;
  border-radius: 55px 55px 12px 12px;
  box-shadow: 0 0 0 7px #0b1133, 0 0 44px rgba(82, 241, 223, .38), inset 0 0 30px rgba(82, 241, 223, .13);
  font: 950 2.1rem/1 Consolas, monospace;
}

.hero-gate::before {
  content: "";
  position: absolute;
  inset: 18px 20px 14px;
  border: 2px dashed rgba(190, 255, 246, .4);
  border-radius: 38px 38px 5px 5px;
}

.hero-source {
  position: absolute;
  z-index: 2;
  left: 3%;
  top: calc(45% - 22px);
  width: 34%;
  height: 50px;
  background: linear-gradient(#40528f 0 15%, #121b4a 15% 85%, #40528f 85%);
  clip-path: polygon(0 18%, 93% 18%, 100% 50%, 93% 82%, 0 82%);
}

.hero-source i {
  position: absolute;
  width: 9px;
  height: 9px;
  top: 20px;
  border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 12px var(--aqua);
}
.hero-source i:nth-child(1) { left: 20%; }
.hero-source i:nth-child(2) { left: 48%; }
.hero-source i:nth-child(3) { left: 76%; }

.hero-rail {
  position: absolute;
  z-index: 1;
  left: 55%;
  width: 32%;
  height: 10px;
  background: linear-gradient(90deg, #445998, #93a7ff);
  box-shadow: 0 0 15px rgba(137, 163, 255, .38);
  transform-origin: left center;
}
.rail-a { top: 46%; transform: rotate(-24deg); }
.rail-b { top: 49%; transform: rotate(25deg); }

.hero-dock {
  position: absolute;
  right: 0;
  width: 120px;
  height: 100px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #26326b, #10163a);
  border: 4px solid #7084c9;
  clip-path: polygon(12% 0, 100% 0, 100% 82%, 87% 100%, 0 100%, 0 18%);
  font: 800 .72rem/1 Consolas, monospace;
  letter-spacing: .1em;
}
.dock-a { top: 14%; color: var(--aqua); border-color: var(--aqua-dark); }
.dock-b { bottom: 14%; color: var(--gold); border-color: var(--gold-dark); }

.hero-capsule,
.flying-capsule {
  width: 56px;
  height: 31px;
  border: 4px solid #d9fffa;
  border-radius: 19px 9px 9px 19px;
  background: var(--aqua);
  box-shadow: 0 0 18px rgba(82, 241, 223, .8);
}

.hero-capsule::after,
.flying-capsule::after {
  content: "";
  position: absolute;
  left: -9px;
  top: 7px;
  width: 11px;
  height: 11px;
  background: var(--pink);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
}

.hero-capsule em,
.flying-capsule i {
  position: absolute;
  inset: 6px 12px;
  display: block;
  background: #0b1c43;
  clip-path: polygon(50% 0, 62% 36%, 100% 38%, 69% 60%, 80% 100%, 50% 74%, 20% 100%, 31% 60%, 0 38%, 38% 36%);
}

.capsule-a { position: absolute; z-index: 6; left: 17%; top: 42%; animation: heroFlight 3.2s ease-in-out infinite; }
.capsule-b { position: absolute; z-index: 5; left: 64%; top: 63%; background: var(--gold); border-color: #fff6c7; transform: scale(.76) rotate(24deg); box-shadow: 0 0 18px rgba(255, 211, 91, .8); }

.tower-light {
  position: absolute;
  left: calc(38% + 56px);
  top: 21%;
  width: 20px;
  height: 20px;
  background: var(--pink);
  border: 4px solid #ffd0e5;
  border-radius: 50%;
  box-shadow: 0 0 30px var(--pink);
  animation: beacon 1.4s ease-in-out infinite;
}

.quick-guide {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.quick-guide div {
  position: relative;
  min-height: 92px;
  padding: 17px 18px 15px 70px;
  border-right: 1px solid var(--line);
}
.quick-guide div:last-child { border-right: 0; }
.quick-guide span {
  position: absolute;
  left: 19px;
  top: 18px;
  color: transparent;
  -webkit-text-stroke: 1px #7182bf;
  font: 900 2.4rem/1 Consolas, monospace;
}
.quick-guide b { display: block; color: #fff; font-size: .92rem; }
.quick-guide small { display: block; margin-top: 5px; color: var(--muted); line-height: 1.45; }

/* Play screen */
.play-screen { padding: 18px 0 45px; }

.hud {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: stretch;
}

.stage-meter,
.hud-readout {
  min-height: 62px;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(27, 37, 91, .94), rgba(12, 18, 55, .94));
  border: 1px solid #48598f;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

.stage-meter > span,
.hud-readout small { color: var(--aqua); font: 800 .67rem/1.2 Consolas, monospace; letter-spacing: .11em; }
.hud-readout { min-width: 116px; display: grid; place-content: center; text-align: right; }
.hud-readout strong { margin-top: 3px; font: 900 1.4rem/1 Consolas, monospace; }

.stage-dots { display: flex; gap: 6px; margin-top: 9px; }
.stage-dots i {
  width: clamp(16px, 3.3vw, 38px);
  height: 7px;
  background: #2a356e;
  transform: skewX(-22deg);
}
.stage-dots i.done { background: var(--aqua); box-shadow: 0 0 9px rgba(82, 241, 223, .5); }
.stage-dots i.current { background: var(--gold); box-shadow: 0 0 9px rgba(255, 211, 91, .5); }

.mission-banner {
  margin: 16px 0;
  display: flex;
  min-height: 78px;
  align-items: stretch;
  background: linear-gradient(90deg, rgba(23, 32, 80, .95), rgba(14, 20, 57, .75));
  border-left: 4px solid var(--pink);
  border-bottom: 1px solid #3e4d83;
}

.mission-number {
  min-width: 82px;
  display: grid;
  place-items: center;
  color: #10163c;
  background: var(--pink);
  font: 950 2.2rem/1 Consolas, monospace;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
}
.mission-banner > div:last-child { padding: 10px 20px 11px; }
.mission-banner p { margin: 0; color: var(--muted); font: 800 .65rem/1.2 Consolas, monospace; letter-spacing: .13em; }
.mission-banner h2 { display: inline; margin: 0 12px 0 0; font-size: 1.45rem; }
.mission-banner span { color: #c8d0ee; font-size: .9rem; }

.route-console {
  overflow: hidden;
  background: rgba(7, 12, 38, .88);
  border: 2px solid #46588e;
  border-top-color: #7d8ec6;
  box-shadow: var(--shadow), inset 0 0 50px rgba(69, 91, 179, .09);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
}

.console-topline {
  height: 34px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #afbbec;
  background: linear-gradient(90deg, #202c69, #111945);
  border-bottom: 1px solid #4e6097;
  font: 800 .67rem/1 Consolas, monospace;
  letter-spacing: .12em;
}
.console-topline b { color: var(--gold); }

.route-map {
  position: relative;
  min-height: 410px;
  background:
    radial-gradient(circle at 50% 50%, rgba(61, 84, 172, .18), transparent 45%),
    linear-gradient(rgba(79, 98, 174, .07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 98, 174, .07) 1px, transparent 1px);
  background-size: auto, 26px 26px, 26px 26px;
}

.rails { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rails path {
  fill: none;
  stroke: #3f4f8a;
  stroke-width: 13;
  stroke-linecap: square;
  filter: drop-shadow(0 0 5px rgba(94, 118, 211, .45));
}
.rails path::after { stroke: #fff; }
.layout-one .two-rails, .layout-one .three-rails,
.layout-two .one-rails, .layout-two .three-rails,
.layout-three .one-rails, .layout-three .two-rails { display: none; }

.launch-port {
  position: absolute;
  left: 3.8%;
  top: calc(50% - 31px);
  width: 68px;
  height: 62px;
  display: grid;
  place-items: center;
  color: var(--aqua);
  background: #111942;
  border: 4px solid #4f619f;
  clip-path: polygon(0 12px, 12px 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  font: 900 .72rem/1 Consolas, monospace;
}
.launch-port i { position: absolute; right: -11px; width: 14px; height: 24px; background: var(--aqua); box-shadow: 0 0 13px var(--aqua); }

.gate-slot {
  position: absolute;
  width: 124px;
  min-height: 88px;
  padding: 9px 8px 7px;
  color: var(--ink);
  background: linear-gradient(160deg, #263572, #131a48);
  border: 4px solid #7186cc;
  border-radius: 30px 30px 7px 7px;
  box-shadow: 0 0 0 4px #090f31, inset 0 0 22px rgba(132, 152, 230, .13);
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 3;
}
.gate-slot::before {
  content: "IF";
  position: absolute;
  top: -17px;
  left: calc(50% - 21px);
  width: 42px;
  height: 24px;
  display: grid;
  place-items: center;
  color: #09172f;
  background: var(--aqua);
  border: 2px solid #d8fffb;
  clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 7px 100%, 0 50%);
  font: 950 .71rem/1 Consolas, monospace;
}
.gate-slot small { display: block; color: #8998cf; font: 700 .56rem/1 Consolas, monospace; letter-spacing: .08em; }
.gate-slot b { display: grid; min-height: 40px; place-items: center; margin: 2px 0; font-size: .76rem; line-height: 1.25; }
.gate-slot > span { display: flex; justify-content: space-between; color: #c6cfef; font: 700 .52rem/1 Consolas, monospace; }
.gate-slot > span i { font-style: normal; }
.gate-slot.is-filled { border-color: var(--gold); box-shadow: 0 0 0 4px #090f31, 0 0 20px rgba(255, 211, 91, .33); }
.gate-slot.is-targeted { border-color: #fff; transform: translate(-50%, -50%) scale(1.04); }
.gate-slot.is-active { animation: gateFlash .32s ease-out; }
.gate-slot.is-wrong { border-color: var(--danger); }

.layout-one .gate-root { left: 38%; top: 50%; }
.layout-two .gate-root { left: 27%; top: 50%; }
.layout-two .gate-lower { left: 53%; top: 68.75%; }
.layout-three .gate-root { left: 24%; top: 50%; }
.layout-three .gate-upper { left: 50.5%; top: 28.1%; }
.layout-three .gate-lower { left: 50.5%; top: 71.9%; }
.layout-one .gate-upper, .layout-one .gate-lower,
.layout-two .gate-upper { display: none; }

.docks { position: absolute; inset: 0; }
.dock-node {
  position: absolute;
  right: 3%;
  width: 155px;
  min-height: 58px;
  padding: 8px 10px 8px 17px;
  display: flex;
  align-items: center;
  color: #f4f6ff;
  background: linear-gradient(100deg, #202b68, #10163c);
  border: 2px solid #6475b0;
  clip-path: polygon(11px 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%, 0 11px);
  transform: translateY(-50%);
  font-size: .7rem;
  font-weight: 850;
  line-height: 1.25;
  z-index: 2;
}
.dock-node::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  background: var(--violet);
  box-shadow: 0 0 9px var(--violet);
}
.dock-node.is-arrival { animation: dockFlash .4s ease-out; }
.dock-node.is-correct { border-color: var(--good); }
.dock-node.is-wrong { border-color: var(--danger); }
.layout-one .dock-node:nth-child(1) { top: 25%; }
.layout-one .dock-node:nth-child(2) { top: 75%; }
.layout-two .dock-node:nth-child(1) { top: 18.75%; }
.layout-two .dock-node:nth-child(2) { top: 56.25%; }
.layout-two .dock-node:nth-child(3) { top: 87.5%; }
.layout-three .dock-node:nth-child(1) { top: 11.5%; }
.layout-three .dock-node:nth-child(2) { top: 37.5%; }
.layout-three .dock-node:nth-child(3) { top: 62.5%; }
.layout-three .dock-node:nth-child(4) { top: 88.5%; }

.flying-capsule {
  --capsule-color: var(--aqua);
  position: absolute;
  z-index: 8;
  left: 7%;
  top: 50%;
  display: none;
  background: var(--capsule-color);
  border-color: #fff;
  transform: translate(-50%, -50%) scale(.72);
  transition: left .2s ease-in-out, top .2s ease-in-out, transform .2s ease-in-out;
}
.flying-capsule.is-moving { display: block; }
.flying-capsule.power-dim { box-shadow: 0 0 0 transparent; opacity: .88; }
.flying-capsule.shape-hex i { clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }

.route-pulse {
  position: absolute;
  left: 50%;
  bottom: 7px;
  z-index: 9;
  min-height: 28px;
  padding: 5px 14px;
  color: #08132e;
  background: var(--aqua);
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
  transform: translateX(-50%);
  opacity: 0;
  font-size: .73rem;
  font-weight: 900;
  pointer-events: none;
}
.route-pulse.show { opacity: 1; }

.manifest {
  min-height: 58px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  overflow-x: auto;
  background: #0d143a;
  border-top: 1px solid #344477;
  scrollbar-width: thin;
}
.manifest::before { content: "QUEUE"; flex: 0 0 auto; color: #8190c5; font: 800 .62rem/1 Consolas, monospace; letter-spacing: .1em; }
.capsule-chip {
  --capsule-color: var(--aqua);
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #09122d;
  background: var(--capsule-color);
  border: 3px solid rgba(255,255,255,.8);
  border-radius: 16px 7px 7px 16px;
  font: 950 .64rem/1 Consolas, monospace;
  transition: opacity .2s, transform .2s;
}
.capsule-chip::before { content: ""; width: 12px; height: 12px; background: #10183f; clip-path: polygon(50% 0, 61% 34%, 98% 37%, 69% 58%, 79% 96%, 50% 73%, 21% 96%, 31% 58%, 2% 37%, 39% 34%); }
.capsule-chip.shape-hex::before { clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); }
.capsule-chip.power-glow { box-shadow: 0 0 12px var(--capsule-color); }
.capsule-chip.power-dim { opacity: .68; }
.capsule-chip.is-dispatched { opacity: .22; transform: scale(.84); }

.rule-bay {
  margin-top: 15px;
  padding: 17px 18px 18px;
  background: linear-gradient(145deg, rgba(28, 38, 91, .96), rgba(11, 17, 51, .96));
  border: 1px solid #4b5c91;
  border-left: 5px solid var(--aqua);
  box-shadow: var(--shadow);
}
.rule-heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; }
.rule-heading p { margin: 0 0 2px; color: var(--aqua); font: 800 .62rem/1.2 Consolas, monospace; letter-spacing: .11em; }
.rule-heading h3 { margin: 0; font-size: 1.02rem; }
.rule-heading > span { color: var(--muted); font-size: .76rem; }

.rule-tray { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.rule-card {
  position: relative;
  min-height: 58px;
  padding: 8px 30px 8px 46px;
  color: #f7f9ff;
  background: linear-gradient(110deg, #263877, #182253);
  border: 2px solid #6d81c0;
  clip-path: polygon(9px 0, calc(100% - 9px) 0, 100% 9px, 100% calc(100% - 9px), calc(100% - 9px) 100%, 9px 100%, 0 calc(100% - 9px), 0 9px);
  text-align: left;
  cursor: grab;
  font-size: .84rem;
  font-weight: 850;
}
.rule-card::before { content: "IF"; position: absolute; left: 9px; top: 14px; width: 28px; height: 28px; display: grid; place-items: center; color: #0d1735; background: var(--gold); font: 950 .62rem/1 Consolas, monospace; }
.rule-card::after { content: "⋮⋮"; position: absolute; right: 10px; top: 18px; color: #8998cf; letter-spacing: -3px; }
.rule-card:hover { border-color: #fff; }
.rule-card.is-selected { border-color: var(--gold); background: linear-gradient(110deg, #4a3c67, #22295b); box-shadow: 0 0 18px rgba(255, 211, 91, .22); }
.rule-card.is-used { opacity: .32; }

.control-row { display: flex; justify-content: flex-end; gap: 10px; }
.secondary-button {
  min-height: 52px;
  padding: 0 18px;
  color: #d8def7;
  background: #111943;
  border: 1px solid #6374ae;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  cursor: pointer;
  font-weight: 800;
}
.run-button { min-width: 210px; }
.run-button:disabled { filter: saturate(.15); opacity: .5; cursor: not-allowed; }

.stage-feedback {
  margin-top: 12px;
  min-height: 48px;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #c9d2ef;
  background: rgba(8, 14, 43, .86);
  border: 1px solid #3e4d7d;
}
.stage-feedback p { margin: 0; font-size: .85rem; line-height: 1.5; }
.feedback-icon { flex: 0 0 auto; width: 27px; height: 27px; display: grid; place-items: center; color: #0a1730; background: var(--aqua); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); font: 900 .77rem/1 serif; }
.stage-feedback.is-error { border-color: var(--danger); }
.stage-feedback.is-error .feedback-icon { background: var(--danger); }
.stage-feedback.is-good { border-color: var(--good); }
.stage-feedback.is-good .feedback-icon { background: var(--good); }

/* Quiz */
.quiz-screen {
  max-width: 820px;
  margin: 0 auto;
  padding: 52px 0 45px;
  text-align: center;
}
.quiz-beacon { position: relative; width: 126px; height: 126px; margin: 0 auto 28px; display: grid; place-items: center; border: 5px solid var(--aqua); border-radius: 50%; box-shadow: 0 0 40px rgba(82, 241, 223, .3), inset 0 0 30px rgba(82, 241, 223, .14); }
.quiz-beacon span { color: var(--gold); font: 950 4rem/1 Consolas, monospace; }
.quiz-beacon i { position: absolute; left: 50%; top: 50%; width: 172px; height: 1px; background: linear-gradient(90deg, transparent, #596ca9, transparent); transform-origin: center; }
.quiz-beacon i:nth-child(2) { transform: translate(-50%, -50%) rotate(0deg); }
.quiz-beacon i:nth-child(3) { transform: translate(-50%, -50%) rotate(60deg); }
.quiz-beacon i:nth-child(4) { transform: translate(-50%, -50%) rotate(120deg); }
.quiz-screen h2 { margin: 0; font-size: clamp(2rem, 5vw, 3.6rem); }
.quiz-question { max-width: 680px; min-height: 64px; margin: 22px auto; color: #f5f7ff; font-size: clamp(1.05rem, 2.3vw, 1.35rem); font-weight: 800; line-height: 1.7; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.quiz-choice { min-height: 64px; padding: 12px 15px; color: #eef1ff; background: #182253; border: 2px solid #6476b2; clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px); cursor: pointer; font-weight: 800; }
.quiz-choice:hover:not(:disabled) { border-color: var(--aqua); }
.quiz-choice.is-correct { color: #07192c; background: var(--good); border-color: #e0ffe6; }
.quiz-choice.is-wrong { background: #5e2944; border-color: var(--danger); }
.quiz-explanation { margin: 17px 0; padding: 14px 18px; color: #dce2f8; background: #0b1237; border-left: 5px solid var(--aqua); line-height: 1.7; text-align: left; }
.quiz-screen .primary-button { margin-top: 8px; }

/* Results */
.result-screen { max-width: 900px; margin: 0 auto; padding: 38px 0 60px; text-align: center; }
.result-sky { position: relative; width: 220px; height: 150px; margin: 0 auto 8px; }
.result-sky i { position: absolute; width: 10px; height: 10px; background: var(--gold); clip-path: polygon(50% 0, 63% 36%, 100% 50%, 63% 64%, 50% 100%, 37% 64%, 0 50%, 37% 36%); animation: beacon 1.5s infinite; }
.result-sky i:nth-child(1) { left: 7%; top: 24%; }
.result-sky i:nth-child(2) { right: 9%; top: 15%; animation-delay: -.4s; }
.result-sky i:nth-child(3) { left: 21%; bottom: 8%; animation-delay: -.8s; }
.result-sky i:nth-child(4) { right: 16%; bottom: 17%; animation-delay: -1.1s; }
.result-gate { position: absolute; left: 65px; top: 8px; width: 92px; height: 130px; display: grid; place-items: center; color: var(--aqua); background: #131c4d; border: 7px solid var(--aqua); border-radius: 42px 42px 8px 8px; box-shadow: 0 0 35px rgba(82, 241, 223, .4), inset 0 0 24px rgba(82, 241, 223, .16); font: 950 1.7rem/1 Consolas, monospace; }
.result-screen h2 { margin: 0; font-size: clamp(2.6rem, 7vw, 5rem); line-height: 1; }
.result-message { max-width: 650px; margin: 18px auto; color: #cbd3ef; line-height: 1.8; }
.final-score { position: relative; width: min(480px, 100%); margin: 22px auto; padding: 17px 25px; background: #0a1031; border: 2px solid #6478bb; border-left: 8px solid var(--gold); border-right: 8px solid var(--aqua); }
.final-score small { display: block; color: var(--muted); font: 800 .7rem/1 Consolas, monospace; letter-spacing: .13em; }
.final-score strong { color: var(--gold); font: 950 clamp(3rem, 10vw, 5.4rem)/1 Consolas, monospace; text-shadow: 0 0 22px rgba(255, 211, 91, .28); }
.final-score span { margin-left: 5px; color: #d9def4; font-weight: 850; }
.final-score b { position: absolute; right: -14px; top: -13px; padding: 6px 10px; color: #101736; background: var(--pink); transform: rotate(3deg); font: 950 .74rem/1 Consolas, monospace; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.result-stats div { padding: 13px 8px; background: linear-gradient(#1a2459, #10163e); border: 1px solid #4c5d97; }
.result-stats span { display: block; color: var(--muted); font-size: .72rem; }
.result-stats strong { display: block; margin-top: 5px; color: #fff; font: 900 1.25rem/1 Consolas, monospace; }
.badge-rail { display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin: 18px 0 24px; }
.badge { width: 48px; height: 48px; display: grid; place-items: center; color: #151b42; background: var(--gold); border: 3px solid #fff3b1; clip-path: polygon(50% 0, 63% 16%, 84% 16%, 84% 37%, 100% 50%, 84% 63%, 84% 84%, 63% 84%, 50% 100%, 37% 84%, 16% 84%, 16% 63%, 0 50%, 16% 37%, 16% 16%, 37% 16%); font: 950 .88rem/1 Consolas, monospace; box-shadow: 0 0 17px rgba(255, 211, 91, .35); }
.ranking-shell { margin-top: 34px; padding: 20px; color: #111936; background: #f1f3ff; clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px); text-align: left; }
.ranking-shell h3 { margin: 0 0 10px; color: #151d4b; }
.itc-ranking { color: #111936; }
.itc-ranking button { min-height: 42px; color: #111936; background: #fff; border: 1px solid #606c9d; }
.itc-ranking button[aria-pressed="true"] { color: #07172b; background: #63e8d9; }
.itc-ranking table { width: 100%; border-collapse: collapse; }
.itc-ranking th, .itc-ranking td { padding: 7px; border-bottom: 1px solid #ccd1e8; }

/* Modal */
.modal-backdrop { position: fixed; z-index: 50; inset: 0; padding: 20px; display: grid; place-items: center; background: rgba(4, 7, 25, .82); backdrop-filter: blur(8px); }
.clear-panel { width: min(520px, 100%); padding: 28px 30px 31px; color: #eff2ff; background: linear-gradient(155deg, #202d6b, #0d143d); border: 3px solid var(--aqua); clip-path: polygon(18px 0, calc(100% - 18px) 0, 100% 18px, 100% calc(100% - 18px), calc(100% - 18px) 100%, 18px 100%, 0 calc(100% - 18px), 0 18px); box-shadow: 0 0 60px rgba(82, 241, 223, .27); text-align: center; }
.clear-burst { position: relative; width: 90px; height: 90px; margin: 0 auto 8px; display: grid; place-items: center; }
.clear-burst span { position: relative; z-index: 2; width: 58px; height: 58px; display: grid; place-items: center; color: #07172b; background: var(--good); border-radius: 50%; font-size: 2rem; font-weight: 950; box-shadow: 0 0 27px rgba(128, 255, 155, .5); }
.clear-burst i { position: absolute; width: 88px; height: 4px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.clear-burst i:nth-child(1) { transform: rotate(0); }
.clear-burst i:nth-child(2) { transform: rotate(45deg); }
.clear-burst i:nth-child(3) { transform: rotate(90deg); }
.clear-burst i:nth-child(4) { transform: rotate(135deg); }
.clear-panel > p:first-of-type { margin: 0; color: var(--aqua); font: 900 .7rem/1 Consolas, monospace; letter-spacing: .13em; }
.clear-panel h2 { margin: 6px 0; font-size: 2rem; }
.clear-stars { min-height: 37px; color: var(--gold); font-size: 2rem; letter-spacing: 7px; }
.clear-panel > strong { display: block; color: var(--gold); font: 950 2.5rem/1.2 Consolas, monospace; }
.clear-panel > p:last-of-type { margin: 10px 0 20px; color: #cad2ef; line-height: 1.65; }

@keyframes heroFlight {
  0%, 8% { transform: translate(0, 0) rotate(0); }
  44% { transform: translate(180%, 0) rotate(0); }
  75%, 100% { transform: translate(480%, -260%) rotate(-23deg); }
}
@keyframes beacon { 50% { opacity: .42; transform: scale(.78); } }
@keyframes gateFlash { 0% { filter: brightness(2); } 100% { filter: brightness(1); } }
@keyframes dockFlash { 0% { filter: brightness(2.2); transform: translateY(-50%) scale(1.08); } 100% { filter: brightness(1); transform: translateY(-50%) scale(1); } }

@media (max-width: 860px) {
  .start-screen { grid-template-columns: 1fr; padding-top: 32px; }
  .hero-copy { text-align: center; }
  h1 span, .record-tape { margin-left: auto; margin-right: auto; }
  .start-actions { justify-content: center; }
  .start-actions p { text-align: left; }
  .hero-station { width: min(620px, 100%); min-height: 440px; margin: -20px auto -20px; }
  .rule-tray { grid-template-columns: 1fr 1fr; }
  .dock-node { width: 130px; font-size: .64rem; }
  .gate-slot { width: 112px; }
}

@media (max-width: 600px) {
  .topbar, #app { width: min(100% - 20px, 1180px); }
  .topbar { min-height: 56px; }
  .brand { font-size: .66rem; }
  .brand-mark { width: 30px; height: 30px; }
  .icon-button { min-height: 40px; min-width: 66px; font-size: .72rem; }
  .screen { min-height: calc(100svh - 56px); }
  .start-screen { padding-top: 25px; }
  h1 { font-size: clamp(2.65rem, 15vw, 4.6rem); }
  .hero-lead { margin: 20px 0; font-size: .96rem; }
  .start-actions { display: block; }
  .start-actions .primary-button { width: min(310px, 100%); justify-content: space-between; }
  .start-actions p { margin: 10px auto 0; text-align: center; }
  .record-tape { grid-template-columns: auto auto auto; gap: 6px 10px; font-size: .75rem; }
  .record-tape span:nth-of-type(2) { grid-column: 1; }
  .hero-station { min-height: 330px; margin-top: -12px; }
  .hero-gate { width: 84px; height: 120px; left: 38%; top: 31%; border-width: 5px; box-shadow: 0 0 0 4px #0b1133, 0 0 30px rgba(82,241,223,.35); font-size: 1.35rem; }
  .hero-gate::before { inset: 13px; }
  .hero-source { top: 43%; }
  .hero-dock { width: 82px; height: 72px; font-size: .54rem; }
  .hero-capsule { transform: scale(.7); }
  .capsule-a { animation-name: none; left: 18%; top: 41%; }
  .capsule-b { transform: scale(.6) rotate(24deg); }
  .tower-light { left: calc(38% + 33px); top: 20%; width: 16px; height: 16px; }
  .quick-guide { grid-template-columns: 1fr; }
  .quick-guide div { min-height: 70px; padding-top: 12px; padding-bottom: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .quick-guide div:last-child { border-bottom: 0; }

  .play-screen { padding-top: 10px; }
  .hud { grid-template-columns: 1fr auto auto; gap: 5px; }
  .stage-meter, .hud-readout { min-height: 55px; padding: 8px; }
  .stage-meter > span, .hud-readout small { font-size: .53rem; }
  .hud-readout { min-width: 66px; }
  .hud-readout strong { font-size: .98rem; }
  .stage-dots { gap: 3px; }
  .stage-dots i { width: clamp(10px, 3vw, 18px); height: 6px; }
  .mission-banner { min-height: 70px; }
  .mission-number { min-width: 62px; font-size: 1.6rem; }
  .mission-banner > div:last-child { padding: 8px 10px; }
  .mission-banner h2 { display: block; font-size: 1.08rem; }
  .mission-banner span { display: block; margin-top: 2px; font-size: .73rem; line-height: 1.35; }
  .route-map { min-height: 350px; }
  .launch-port { left: 2.5%; width: 45px; height: 52px; font-size: .58rem; }
  .gate-slot { width: 82px; min-height: 73px; padding: 8px 5px 5px; border-width: 3px; box-shadow: 0 0 0 3px #090f31; }
  .gate-slot::before { top: -14px; width: 35px; height: 20px; left: calc(50% - 17px); }
  .gate-slot small { font-size: .45rem; }
  .gate-slot b { min-height: 35px; font-size: .61rem; }
  .gate-slot > span { font-size: .42rem; }
  .layout-one .gate-root { left: 36%; }
  .layout-two .gate-root { left: 26%; }
  .layout-two .gate-lower { left: 52%; }
  .layout-three .gate-root { left: 23%; }
  .layout-three .gate-upper, .layout-three .gate-lower { left: 49.5%; }
  .dock-node { right: 1.5%; width: 88px; min-height: 48px; padding: 6px 5px 6px 12px; font-size: .55rem; }
  .rails path { stroke-width: 10; }
  .flying-capsule { transform: translate(-50%, -50%) scale(.52); }
  .manifest { min-height: 54px; padding: 9px; gap: 6px; }
  .capsule-chip { width: 40px; height: 26px; }
  .rule-bay { padding: 14px 12px; }
  .rule-heading { display: block; }
  .rule-heading > span { display: block; margin-top: 5px; }
  .rule-tray { grid-template-columns: 1fr; gap: 7px; }
  .rule-card { min-height: 50px; }
  .control-row { display: grid; grid-template-columns: .8fr 1.2fr; }
  .secondary-button, .run-button { min-width: 0; min-height: 52px; padding: 0 10px; font-size: .82rem; }
  .run-button span { padding: 14px 9px; }
  .run-button b { min-width: 48px; font-size: .72rem; }
  .stage-feedback p { font-size: .75rem; }

  .quiz-screen { padding-top: 34px; }
  .quiz-beacon { width: 96px; height: 96px; }
  .quiz-beacon i { width: 130px; }
  .quiz-beacon span { font-size: 3rem; }
  .quiz-choices { grid-template-columns: 1fr; }
  .quiz-choice { min-height: 54px; }
  .result-screen { padding-top: 25px; }
  .result-stats { gap: 4px; }
  .result-stats div { padding: 10px 4px; }
  .result-stats span { font-size: .63rem; }
  .result-stats strong { font-size: 1rem; }
  .ranking-shell { padding: 15px 10px; }
  .clear-panel { padding: 22px 17px 24px; }
}

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