:root {
  --bg: #101426;
  --bg-soft: #171b31;
  --panel: #f6f8ff;
  --panel-ink: #172039;
  --panel-muted: #5d6680;
  --line: rgba(255, 255, 255, 0.18);
  --text: #f7f9ff;
  --muted: #c7cee2;
  --teal: #80d8ca;
  --gold: #ffd36f;
  --coral: #ff8d7c;
  --mint: #a5ec9f;
  --violet: #b8a5ff;
  --focus: #ffffff;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.star-sky {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 8% 18%, rgba(255, 255, 255, 0.55) 0 1px, transparent 2px),
    radial-gradient(circle at 28% 32%, rgba(128, 216, 202, 0.55) 0 1px, transparent 2px),
    radial-gradient(circle at 55% 12%, rgba(255, 211, 111, 0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 76% 26%, rgba(255, 141, 124, 0.45) 0 1px, transparent 2px),
    radial-gradient(circle at 88% 72%, rgba(255, 255, 255, 0.52) 0 1px, transparent 2px),
    radial-gradient(circle at 42% 78%, rgba(165, 236, 159, 0.48) 0 1px, transparent 2px),
    linear-gradient(180deg, #111426 0%, #16152b 48%, #0e1824 100%);
}

.star-sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.3) 0 1px, transparent 1px),
    radial-gradient(circle, rgba(128, 216, 202, 0.22) 0 1px, transparent 1px);
  background-position:
    0 0,
    16px 22px;
  background-size:
    72px 72px,
    96px 96px;
  opacity: 0.5;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 36px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 10;
  border-radius: var(--radius);
  background: var(--gold);
  color: #17120b;
  padding: 10px 14px;
  font-weight: 800;
}

.skip-link:focus {
  top: 14px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 20, 38, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 320px;
}

.brand-block h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.05;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ship-mark,
.map-ship {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 34px;
  border-radius: 50% 50% 45% 45%;
  background:
    linear-gradient(90deg, transparent 0 10%, var(--coral) 10% 26%, transparent 26% 74%, var(--teal) 74% 90%, transparent 90%),
    linear-gradient(180deg, #fff7cf 0%, #ffd36f 55%, #f39b55 100%);
  box-shadow: 0 10px 22px rgba(255, 211, 111, 0.2);
}

.ship-mark::before,
.map-ship::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 13px;
  border-right: 14px solid #ff8d7c;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.ship-mark::after,
.map-ship::after {
  content: "";
  position: absolute;
  right: -11px;
  top: 13px;
  border-left: 15px solid #80d8ca;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.ship-window {
  position: absolute;
  left: 18px;
  top: 8px;
  width: 17px;
  height: 17px;
  border: 3px solid rgba(23, 32, 57, 0.72);
  border-radius: 50%;
  background: #b8eaff;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.tool-button,
.primary-button,
.secondary-button,
.planet-node,
.choice-button,
.icon-close {
  min-height: 46px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 800;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  background: rgba(246, 248, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.tool-button[aria-pressed="true"],
.station-button {
  background: rgba(128, 216, 202, 0.18);
  border-color: rgba(128, 216, 202, 0.58);
}

.schedule-wrap {
  margin: 16px 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 20, 38, 0.78);
  overflow-x: auto;
}

.schedule {
  display: grid;
  grid-template-columns: repeat(5, minmax(142px, 1fr));
  gap: 0;
  min-width: 710px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.schedule li {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 12px 14px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  font-weight: 800;
}

.schedule li:last-child {
  border-right: 0;
}

.schedule .step-dot {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.9rem;
}

.schedule li.done {
  color: #e8fff9;
}

.schedule li.done .step-dot {
  background: rgba(165, 236, 159, 0.22);
  color: var(--mint);
}

.schedule li.active {
  color: #191d2a;
  background: var(--gold);
}

.schedule li.active .step-dot {
  background: rgba(25, 29, 42, 0.14);
  color: #191d2a;
}

main {
  display: grid;
  gap: 22px;
  min-height: 640px;
}

.screen {
  display: none;
}

.screen.active {
  display: grid;
  gap: 18px;
  align-content: start;
}

.screen-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0 6px;
}

.screen-heading.compact {
  margin-top: 14px;
}

.screen-heading h2,
.modal h2,
.reward-stage h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.8vw, 2.6rem);
  line-height: 1.05;
}

.screen-heading p:not(.step-chip),
.modal p,
.reward-stage p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.challenge-meter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
}

.challenge-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(246, 248, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
  font-weight: 900;
}

.challenge-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
}

.challenge-chip.done {
  background: rgba(165, 236, 159, 0.18);
  border-color: rgba(165, 236, 159, 0.44);
}

.challenge-chip.done::before {
  background: var(--mint);
}

.challenge-chip.active {
  background: rgba(255, 211, 111, 0.2);
  border-color: rgba(255, 211, 111, 0.58);
  color: #fff9e7;
}

.challenge-chip.active::before {
  background: var(--gold);
}

.challenge-chip.pending {
  opacity: 0.7;
}

.quest-layout.stage-flash .quest-panel,
.quest-layout.stage-flash .choice-panel,
.quest-layout.stage-flash .flight-deck {
  animation: stageShift 520ms ease;
}

.step-chip,
.clue-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(128, 216, 202, 0.16);
  color: #dffff8;
  border: 1px solid rgba(128, 216, 202, 0.42);
  font-size: 0.86rem;
  font-weight: 900;
}

.space-map {
  position: relative;
  min-height: 740px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 18% 26%, rgba(128, 216, 202, 0.16), transparent 26%),
    radial-gradient(circle at 82% 18%, rgba(255, 211, 111, 0.12), transparent 25%),
    rgba(16, 20, 38, 0.75);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.orbit-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.orbit-lines path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.24);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 12 14;
}

.map-ship {
  position: absolute;
  left: 7%;
  bottom: 12%;
  transform: rotate(-16deg);
  animation: floatShip 5.5s ease-in-out infinite;
}

.planet-nodes {
  position: absolute;
  inset: 0;
}

.planet-node {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 160px;
  min-height: 164px;
  padding: 14px;
  color: var(--text);
  background: rgba(246, 248, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.25);
}

.planet-node.ready {
  background: rgba(128, 216, 202, 0.14);
  border-color: rgba(128, 216, 202, 0.58);
}

.planet-node.locked {
  color: var(--muted);
  cursor: default;
  opacity: 0.72;
}

.planet-node.completed {
  border-color: rgba(165, 236, 159, 0.78);
  box-shadow:
    0 0 0 4px rgba(165, 236, 159, 0.14),
    0 14px 34px rgba(0, 0, 0, 0.25);
}

.planet-node strong,
.planet-node span {
  display: block;
}

.planet-node small {
  color: inherit;
  font-weight: 700;
}

.completion-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(165, 236, 159, 0.94);
  color: #0e2d16;
  border: 2px solid rgba(12, 68, 31, 0.38);
  font-size: 1rem;
  font-weight: 1000;
}

.planet-node[data-position="orbit"] {
  left: 42%;
  top: 38%;
}

.planet-node[data-position="music"] {
  right: 4%;
  top: 8%;
}

.planet-node[data-position="maps"] {
  left: 4%;
  top: 9%;
}

.planet-node[data-position="symbols"] {
  right: 6%;
  bottom: 8%;
}

.planet-node[data-position="solar"] {
  left: 4%;
  bottom: 10%;
}

.planet-node[data-position="chemistry"] {
  left: 18%;
  top: 50%;
}

.planet-node[data-position="geometry"] {
  right: 18%;
  top: 35%;
}

.planet-node[data-position="algebra"] {
  left: 44%;
  bottom: 10%;
}

.planet-node[data-position="geography"] {
  right: 30%;
  bottom: 30%;
}

.planet-node[data-position="language"] {
  left: 52%;
  top: 8%;
}

.planet-visual {
  --planet-size: 72px;
  --planet-color: #73b9ff;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--planet-size);
  height: var(--planet-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.72), transparent 18%),
    radial-gradient(circle at 62% 68%, rgba(0, 0, 0, 0.18), transparent 28%),
    var(--planet-color);
  border: 3px solid rgba(255, 255, 255, 0.58);
  box-shadow:
    inset -10px -12px 16px rgba(0, 0, 0, 0.16),
    0 12px 24px rgba(0, 0, 0, 0.22);
}

.planet-visual.small {
  --planet-size: 54px;
}

.planet-visual.medium {
  --planet-size: 72px;
}

.planet-visual.large {
  --planet-size: 92px;
}

.planet-visual.blue {
  --planet-color: #69b8ff;
}

.planet-visual.red {
  --planet-color: #ff8d7c;
}

.planet-visual.yellow {
  --planet-color: #ffd36f;
}

.planet-visual.mint {
  --planet-color: #a5ec9f;
}

.planet-visual.violet {
  --planet-color: #b8a5ff;
}

.planet-visual.purple {
  --planet-color: #b8a5ff;
}

.planet-visual.gold {
  --planet-color: #ffd36f;
}

.planet-visual.coral {
  --planet-color: #ff8d7c;
}

.planet-visual.teal {
  --planet-color: #80d8ca;
}

.planet-visual.gray {
  --planet-color: #a7b0c9;
}

.planet-visual.orange {
  --planet-color: #ffab67;
}

.planet-visual.white {
  --planet-color: #f8fbff;
}

.planet-visual.ring::before {
  content: "";
  position: absolute;
  width: 145%;
  height: 36%;
  border: 6px solid rgba(255, 255, 255, 0.52);
  border-left-color: rgba(255, 255, 255, 0.18);
  border-right-color: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.planet-symbol {
  position: relative;
  z-index: 1;
  color: rgba(18, 25, 43, 0.78);
  font-size: 1.65rem;
  font-weight: 1000;
}

.quest-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.85fr);
  gap: 20px;
}

.quest-panel,
.choice-panel,
.reward-stage,
.modal {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(246, 248, 255, 0.96);
  color: var(--panel-ink);
  box-shadow: var(--shadow);
}

.quest-panel,
.choice-panel {
  padding: 18px;
}

.quest-clue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.quest-clue-row .clue-pill {
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  border-color: rgba(23, 32, 57, 0.14);
}

.attempt-note {
  color: var(--panel-muted);
  font-weight: 700;
}

.pattern-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(88px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 238px;
  padding: 18px;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(23, 32, 57, 0.06) 0 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 32, 57, 0.06) 0 1px, transparent 1px),
    #ffffff;
  background-size: 34px 34px;
  border: 2px solid rgba(23, 32, 57, 0.12);
}

.trivia-board {
  display: grid;
  gap: 14px;
  min-height: 238px;
  padding: 18px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at top right, rgba(128, 216, 202, 0.16), transparent 30%),
    radial-gradient(circle at bottom left, rgba(255, 211, 111, 0.14), transparent 30%),
    #ffffff;
  border: 2px solid rgba(23, 32, 57, 0.12);
}

.trivia-subject {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  font-size: 0.85rem;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: 0;
}

.trivia-prompt {
  color: var(--panel-ink);
  font-size: clamp(1.2rem, 2.5vw, 1.9rem);
  line-height: 1.15;
  font-weight: 1000;
}

.trivia-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fact-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(128, 216, 202, 0.14);
  color: var(--panel-ink);
  border: 1px solid rgba(31, 152, 134, 0.22);
  font-size: 0.84rem;
  font-weight: 900;
}

.pattern-slot {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 10px;
  min-height: 182px;
  padding: 14px 8px;
  border-radius: var(--radius);
}

.pattern-slot:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -17px;
  top: 50%;
  color: rgba(23, 32, 57, 0.46);
  font-size: 1.55rem;
  font-weight: 900;
}

.slot-label {
  color: var(--panel-muted);
  font-weight: 900;
}

.missing-slot {
  border: 3px dashed rgba(128, 216, 202, 0.92);
  background: rgba(128, 216, 202, 0.1);
}

.missing-slot.active-drop {
  border-color: #1f9886;
  background: rgba(128, 216, 202, 0.24);
}

.missing-mark {
  display: grid;
  place-items: center;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  font-size: 2.35rem;
  font-weight: 1000;
}

.hint-glow {
  animation: hintPulse 1.8s ease-in-out 2;
}

.drop-helper {
  min-height: 32px;
  margin: 12px 0;
  color: var(--panel-muted);
  font-weight: 800;
}

.flight-deck {
  margin: 10px 0 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(23, 32, 57, 0.05), rgba(23, 32, 57, 0.02));
  border: 2px solid rgba(23, 32, 57, 0.12);
}

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

.flight-status {
  margin: 0;
  color: var(--panel-ink);
  font-weight: 900;
}

.thrust-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-button {
  min-width: 132px;
}

.orbit-rail {
  position: relative;
  min-height: 228px;
  padding: 84px 10px 16px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 20% 24%, rgba(128, 216, 202, 0.12), transparent 28%),
    radial-gradient(circle at 76% 26%, rgba(255, 211, 111, 0.12), transparent 24%),
    #fefeff;
  border: 2px solid rgba(23, 32, 57, 0.1);
  overflow: hidden;
}

.orbit-rail::before {
  content: "";
  position: absolute;
  inset: 56px 16px 72px;
  border-top: 3px solid rgba(23, 32, 57, 0.16);
  border-bottom: 3px solid rgba(23, 32, 57, 0.16);
  border-radius: 999px;
}

.orbit-gates {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.orbit-gate {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 150px;
  padding: 14px 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--panel-ink);
  border: 2px solid rgba(23, 32, 57, 0.14);
  text-align: center;
}

.orbit-gate[aria-pressed="true"] {
  border-color: #1f9886;
  box-shadow: 0 0 0 5px rgba(128, 216, 202, 0.18);
}

.gate-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  font-weight: 1000;
}

.gate-planet .planet-visual {
  margin: 0 auto;
}

.gate-copy {
  display: grid;
  gap: 4px;
}

.gate-copy strong,
.gate-copy small {
  overflow-wrap: anywhere;
}

.gate-copy small {
  color: var(--panel-muted);
  font-weight: 800;
}

.ship-runway {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 30%;
  transform: translateX(-50%);
  transition: left 180ms ease;
  display: grid;
  justify-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 2;
}

.ship-marker {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(128, 216, 202, 0.16);
  color: var(--panel-ink);
  border: 2px solid rgba(31, 152, 134, 0.32);
  box-shadow: 0 8px 18px rgba(23, 32, 57, 0.12);
  font-size: 1.8rem;
  animation: shipPing 2.6s ease-in-out infinite;
}

.ship-marker-label {
  color: var(--panel-ink);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
}

.feedback-box {
  min-height: 72px;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  font-size: 1.08rem;
  font-weight: 800;
}

.feedback-box.success {
  background: rgba(165, 236, 159, 0.28);
}

.feedback-box.coach {
  background: rgba(255, 211, 111, 0.28);
}

.feedback-box.error-state {
  background: rgba(255, 43, 43, 0.16);
  color: #d81313;
  font-size: clamp(2.2rem, 6vw, 4rem);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.error-reset-copy {
  display: block;
  margin-top: 8px;
  color: #b60000;
  font-size: clamp(1rem, 2.6vw, 1.45rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.error-splash {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  color: #ff2b2b;
  text-shadow: 0 0 0 transparent;
  font-size: clamp(6rem, 20vw, 14rem);
  font-weight: 1000;
  letter-spacing: 0;
  background: rgba(8, 10, 18, 0.18);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.error-splash.show {
  opacity: 1;
  transform: scale(1);
}

.choice-panel h3 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.logic-hint {
  min-height: 48px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(23, 32, 57, 0.06);
  color: var(--panel-muted);
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.35;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.choice-button {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 116px;
  padding: 12px;
  background: #ffffff;
  color: var(--panel-ink);
  border: 2px solid rgba(23, 32, 57, 0.12);
  text-align: left;
}

.choice-button.trivia-choice {
  background:
    radial-gradient(circle at top right, rgba(128, 216, 202, 0.08), transparent 35%),
    #ffffff;
}

.choice-button:hover,
.choice-button:focus-visible {
  border-color: #1f9886;
}

.choice-button[aria-pressed="true"] {
  border-color: #1f9886;
  background: rgba(128, 216, 202, 0.14);
}

.choice-text {
  display: grid;
  gap: 4px;
}

.choice-text strong,
.choice-text small {
  overflow-wrap: anywhere;
}

.choice-text small {
  color: var(--panel-muted);
  font-weight: 800;
}

.choice-button.is-selected {
  border-color: #1f9886;
  background: rgba(128, 216, 202, 0.14);
}

.quest-actions,
.reward-actions,
.regulation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-button,
.secondary-button {
  min-width: 148px;
  padding: 12px 16px;
}

.primary-button {
  background: var(--panel-ink);
  color: #ffffff;
}

.secondary-button {
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  border: 2px solid rgba(23, 32, 57, 0.1);
}

.reward-stage {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(760px, 100%);
  margin: 38px auto 0;
  padding: clamp(26px, 5vw, 54px);
  text-align: center;
}

.completion-burst {
  position: relative;
  width: min(100%, 420px);
  height: 180px;
  margin-bottom: -18px;
  pointer-events: none;
}

.completion-burst span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--spark-color, var(--gold));
  opacity: 0;
  transform:
    translate(-50%, -50%)
    rotate(var(--spark-angle))
    translateY(0)
    scale(0.6);
}

.completion-burst.play span {
  animation: burstSpark 1.8s ease-out var(--spark-delay) both;
}

.completion-burst.play::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 86px;
  height: 86px;
  margin-left: -43px;
  margin-top: -43px;
  border-radius: 50%;
  border: 3px solid rgba(255, 211, 111, 0.3);
  animation: burstRing 1.8s ease-out both;
}

.completion-burst.play::after {
  content: "✦";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 88px;
  height: 88px;
  margin-left: -44px;
  margin-top: -44px;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 2.4rem;
  animation: burstCore 1.8s ease-out both;
}

.reward-star {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(255, 211, 111, 0.24);
  color: #d89300;
  font-size: 5.3rem;
  animation: gentleShine 2.4s ease-in-out infinite;
}

.badge-shelf {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 211, 111, 0.25);
  color: var(--panel-ink);
  border: 1px solid rgba(216, 147, 0, 0.28);
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5, 8, 16, 0.72);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  padding: 24px;
}

.icon-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 46px;
  background: rgba(23, 32, 57, 0.08);
  color: var(--panel-ink);
  font-size: 1.6rem;
  line-height: 1;
}

.regulation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.breathing-tool,
.quiet-field {
  min-height: 230px;
  border-radius: var(--radius);
  background: #ffffff;
  border: 2px solid rgba(23, 32, 57, 0.1);
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: var(--panel-ink);
}

.breathing-circle {
  display: grid;
  place-items: center;
  width: 138px;
  height: 138px;
  border-radius: 50%;
  background: rgba(128, 216, 202, 0.28);
  border: 4px solid rgba(31, 152, 134, 0.34);
  animation: breathe 6s ease-in-out infinite;
}

.breathing-circle span,
.quiet-field p {
  font-weight: 1000;
}

.quiet-field {
  position: relative;
  overflow: hidden;
  background: #14182b;
  color: #f7f9ff;
}

.quiet-field span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.quiet-field span:nth-child(1) {
  left: 20%;
  top: 24%;
}

.quiet-field span:nth-child(2) {
  left: 68%;
  top: 18%;
  background: var(--teal);
}

.quiet-field span:nth-child(3) {
  left: 44%;
  top: 54%;
  background: #ffffff;
}

.quiet-field span:nth-child(4) {
  left: 78%;
  top: 70%;
  background: var(--mint);
}

.quiet-field span:nth-child(5) {
  left: 25%;
  top: 76%;
  background: var(--coral);
}

.break-message {
  min-height: 32px;
  color: var(--panel-ink);
  font-weight: 900;
}

.settings-modal fieldset {
  margin: 18px 0;
  padding: 0;
  border: 0;
}

.settings-modal legend {
  margin-bottom: 10px;
  color: var(--panel-ink);
  font-weight: 1000;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.segmented-control button {
  min-height: 48px;
  border: 2px solid rgba(23, 32, 57, 0.12);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--panel-ink);
  font-weight: 900;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--panel-ink);
  color: #ffffff;
}

.settings-list {
  display: grid;
  gap: 10px;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--panel-ink);
  border: 2px solid rgba(23, 32, 57, 0.1);
}

.setting-row small {
  display: block;
  margin-top: 3px;
  color: var(--panel-muted);
  font-weight: 700;
}

.setting-row input {
  width: 28px;
  height: 28px;
  accent-color: #1f9886;
}

.caption-note {
  color: var(--panel-muted);
  font-weight: 800;
}

.quiet-mode .star-sky,
.quiet-mode .space-map {
  filter: saturate(0.74);
}

.quiet-mode .map-ship,
.quiet-mode .reward-star,
.quiet-mode .breathing-circle,
.quiet-mode .error-splash {
  animation: none;
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
}

@keyframes floatShip {
  0%,
  100% {
    transform: translateY(0) rotate(-16deg);
  }
  50% {
    transform: translateY(-12px) rotate(-12deg);
  }
}

@keyframes hintPulse {
  0%,
  100% {
    box-shadow: none;
  }
  50% {
    box-shadow: 0 0 0 8px rgba(255, 211, 111, 0.34);
  }
}

@keyframes gentleShine {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.88);
  }
  50% {
    transform: scale(1);
  }
}

@keyframes shipPing {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes stageShift {
  0% {
    transform: translateY(10px) scale(0.99);
    filter: saturate(0.88);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
}

@keyframes burstSpark {
  0% {
    opacity: 0;
    transform:
      translate(-50%, -50%)
      rotate(var(--spark-angle))
      translateY(0)
      scale(0.35);
  }
  40% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(-50%, -50%)
      rotate(var(--spark-angle))
      translateY(-130px)
      scale(1.2);
  }
}

@keyframes burstRing {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.65);
  }
}

@keyframes burstCore {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.5) rotate(20deg);
  }
}

@media (max-width: 880px) {
  .top-bar,
  .screen-heading,
  .quest-clue-row {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .tool-button {
    flex: 1 1 180px;
    justify-content: center;
  }

  .space-map {
    min-height: 980px;
  }

  .planet-node[data-position="orbit"] {
    left: calc(50% - 84px);
    top: 10%;
  }

  .planet-node[data-position="language"] {
    right: 5%;
    top: 24%;
    left: auto;
  }

  .planet-node[data-position="music"] {
    left: 5%;
    top: 23%;
    right: auto;
  }

  .planet-node[data-position="maps"] {
    left: 7%;
    top: 46%;
  }

  .planet-node[data-position="geometry"] {
    right: 7%;
    top: 45%;
  }

  .planet-node[data-position="solar"] {
    left: 7%;
    bottom: 12%;
  }

  .planet-node[data-position="chemistry"] {
    left: calc(50% - 84px);
    top: 47%;
  }

  .planet-node[data-position="algebra"] {
    left: calc(50% - 84px);
    bottom: 15%;
  }

  .planet-node[data-position="geography"] {
    right: 7%;
    bottom: 20%;
  }

  .planet-node[data-position="symbols"] {
    right: 7%;
    bottom: 4%;
  }

  .quest-layout,
  .regulation-grid {
    grid-template-columns: 1fr;
  }

  .flight-deck-head {
    flex-direction: column;
    align-items: stretch;
  }

  .orbit-rail {
    padding-top: 76px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 16px, 1180px);
    padding-top: 8px;
  }

  .brand-block {
    min-width: 0;
  }

  .brand-block h1 {
    font-size: 1.26rem;
  }

  .space-map {
    min-height: 1120px;
  }

  .planet-node {
    width: 144px;
    min-height: 154px;
  }

  .completion-badge {
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
  }

  .planet-node[data-position="orbit"] {
    left: calc(50% - 72px);
    top: 7%;
  }

  .planet-node[data-position="language"] {
    right: 4%;
    top: 20%;
    left: auto;
  }

  .planet-node[data-position="music"] {
    left: 4%;
    top: 20%;
    right: auto;
  }

  .planet-node[data-position="maps"] {
    left: 4%;
    top: 38%;
  }

  .planet-node[data-position="geometry"] {
    right: 4%;
    top: 38%;
  }

  .planet-node[data-position="solar"] {
    left: 4%;
    top: 56%;
    bottom: auto;
  }

  .planet-node[data-position="chemistry"] {
    left: calc(50% - 72px);
    top: 56%;
  }

  .planet-node[data-position="geography"] {
    right: 4%;
    top: 56%;
    bottom: auto;
  }

  .planet-node[data-position="algebra"] {
    left: calc(50% - 72px);
    top: 76%;
    bottom: auto;
  }

  .planet-node[data-position="symbols"] {
    left: 4%;
    top: 76%;
    right: auto;
    bottom: auto;
  }

  .map-ship {
    left: 9%;
    bottom: 12%;
  }

  .pattern-track {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .pattern-slot {
    min-height: 128px;
    align-content: center;
  }

  .pattern-slot:not(:last-child)::after {
    content: "↓";
    right: auto;
    top: auto;
    bottom: -22px;
  }

  .choice-button {
    grid-template-columns: 74px minmax(0, 1fr);
    min-height: 104px;
  }

  .orbit-gate {
    min-height: 112px;
    padding: 10px 8px;
  }

  .orbit-gates {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .ship-runway {
    width: 36%;
  }

  .planet-visual.large {
    --planet-size: 78px;
  }

  .planet-visual.medium {
    --planet-size: 64px;
  }

  .planet-visual.small {
    --planet-size: 50px;
  }

  .segmented-control {
    grid-template-columns: 1fr;
  }
}
