:root {
  --space:  #070b1a;
  --panel:  #111833;
  --text:   #e9eefc;
  --dim:    #8f9bc2;
  --fuel:   #ff8a3d;
  --food:   #6fd38f;
  --dist:   #7fb2ff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--space);
  color: var(--text);
  font: 16px/1.5 system-ui, "Segoe UI", sans-serif;
}

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; display: grid; gap: 24px; }

/* top bar */
.top {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--panel);
  font-weight: 600;
}
.levels { display: flex; gap: 8px; }
.levels button {
  font: inherit; font-size: 14px;
  padding: 6px 12px;
  color: var(--text); background: transparent;
  border: 1px solid var(--dim); border-radius: 6px;
  cursor: pointer;
}
.levels button.on { background: var(--text); color: var(--space); }

/* the trip */
.trip {
  display: grid;
  grid-template-columns: 90px 1fr 140px;
  align-items: center;
  gap: 8px;
  min-height: 200px;
}
.body img, .rocket img { width: 100%; display: block; }
.body img { border-radius: 50%; }   /* round off the black corners of the NASA photos */
.path {
  position: relative;
  height: 80px;
  border-top: 2px dashed rgba(233, 238, 252, 0.25);
  margin-top: 40px;
}
.rocket {
  position: absolute;
  top: -1px;          /* centered on the dashed flight path */
  left: 0;
  width: 140px;
  transform: translate(-50%, -50%);
  z-index: 1;
}

/* placeholder shown until a drawing is added */
.placeholder {
  display: grid; place-items: center;
  aspect-ratio: 1;
  border: 2px dashed var(--dim);
  border-radius: 8px;
  color: var(--dim);
  font-size: 12px;
  text-align: center;
  padding: 4px;
}

/* gauges */
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.gauge { background: var(--panel); padding: 12px 14px; border-radius: 8px; }
.gauge-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; margin-bottom: 8px; }
.gauge-head span:last-child { font-variant-numeric: tabular-nums; }
.bar { height: 12px; background: rgba(255, 255, 255, 0.08); border-radius: 6px; overflow: hidden; }
.fill { height: 100%; width: 100%; }
.fill.fuel { background: var(--fuel); }
.fill.food { background: var(--food); }
.fill.dist { background: var(--dist); }

.status { margin: 0; min-height: 1.5em; color: var(--dim); }

.go {
  justify-self: start;
  font: 700 18px system-ui, sans-serif;
  padding: 12px 28px;
  color: var(--space); background: var(--fuel);
  border: 0; border-radius: 8px;
  cursor: pointer;
}
.go:disabled { opacity: 0.4; cursor: default; }

/* intro */
.intro { gap: 16px; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.intro-title { margin: 0; font-size: clamp(36px, 8vw, 64px); line-height: 1; text-wrap: balance; color: var(--fuel); }
.intro-story { font-size: 18px; max-width: 62ch; }
.how { margin: 0; padding-left: 1.4em; display: grid; gap: 8px; max-width: 70ch; }
.how li::marker { color: var(--fuel); font-weight: 700; }

/* mission clock */
.clock { font-family: Consolas, "Courier New", monospace; color: var(--food); font-variant-numeric: tabular-nums; }

/* phase panels */
.panel { display: grid; gap: 14px; background: var(--panel); padding: 20px; border-radius: 10px; }
.panel h2 { margin: 0; font-size: 26px; }
.panel p { margin: 0; }
.hint { color: var(--dim); font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.good { color: var(--food); }
.bad  { color: #ff6b7a; }

.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.facts div { background: rgba(255, 255, 255, 0.04); padding: 10px 12px; border-radius: 8px; }
.facts dt { color: var(--dim); font-size: 13px; }
.facts dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* loading fuel and food */
.load-row {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.load-row > div:first-child { min-width: 0; flex: 1 1 260px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button, .ghost {
  font: 600 14px system-ui, sans-serif;
  padding: 8px 12px;
  color: var(--text); background: transparent;
  border: 1px solid var(--dim); border-radius: 6px;
  cursor: pointer;
}
.stepper output { min-width: 3ch; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* on the surface */
.surface-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: baseline; justify-content: space-between; }
.timer { font: 700 32px Consolas, "Courier New", monospace; font-variant-numeric: tabular-nums; }
.timer.low { color: #ff6b7a; }
.quota { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quota-item {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
}
.quota-item.met { border-color: var(--food); color: var(--food); }
.spots { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.spot {
  position: relative;
  aspect-ratio: 1; max-width: 100%;
  display: grid; place-items: center;
  font: 600 15px system-ui, sans-serif;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 2px dashed var(--dim);
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
}
.spot img { width: 80%; height: 80%; object-fit: contain; }
.spot:hover { border-color: var(--text); }
.spot-rock    { border-color: #c9a27a; }
.spot-picture { border-color: var(--dist); }
.spot-ground  { border-color: #b58b5a; border-style: dotted; }
.spot-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: var(--food); }
.spot.working .spot-bar { animation: fill var(--seconds, 2s) linear forwards; }
@keyframes fill { to { width: 100%; } }
.spot.done { opacity: 0.35; cursor: default; border-style: solid; }
.spot.done .spot-bar { width: 100%; }

/* the boss */
.boss { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 20px; align-items: start; }
.boss-pic { display: grid; gap: 6px; justify-items: center; }
.boss-pic img, .boss-pic .placeholder { width: 100%; }
.boss-name { font-weight: 700; color: var(--dim); }
.bubble {
  position: relative;
  min-height: 4.5em;
  padding: 16px 18px;
  background: var(--text); color: var(--space);
  border-radius: 14px;
  font-size: 18px;
}
.bubble::before {
  content: ""; position: absolute; left: -12px; top: 24px;
  border: 8px solid transparent; border-right: 12px solid var(--text); border-left: 0;
}
.verdict {
  justify-self: start;
  margin: 0;
  padding: 4px 20px;
  font-size: clamp(40px, 9vw, 72px) !important;
  text-transform: uppercase;
  border: 5px double currentColor;
  transform: rotate(-4deg);
  animation: stamp 0.3s cubic-bezier(.2, 1.6, .4, 1) backwards;
}
@keyframes stamp { from { transform: rotate(-4deg) scale(1.8); opacity: 0; } }

/* educational captions behind the space scene */
.trip { position: relative; padding-bottom: 64px; }
.caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  margin: 0;
  min-height: 3em;
  text-align: center;
  font-style: italic;
  font-size: 15px;
  line-height: 1.5;
  color: var(--dim);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.caption.show { opacity: 1; }
.caption::before { content: "Did you know? "; font-style: normal; font-weight: 700; color: var(--dist); }
.caption:empty::before { content: none; }

/* flight day counter */
.fly-day { margin: 0; font: 700 22px Consolas, "Courier New", monospace; font-variant-numeric: tabular-nums; }

/* data sources */
.sources { font-size: 13px; color: var(--dim); border-top: 1px solid rgba(255, 255, 255, 0.08); padding-top: 12px; }
.sources a { color: var(--dist); }

/* mission log */
.log-box h3 { margin: 0 0 8px; font-size: 14px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.log .t { color: var(--dim); font-family: Consolas, "Courier New", monospace; margin-right: 6px; }

@media (max-width: 560px) {
  .trip { grid-template-columns: 60px 1fr 80px; }
  .rocket { width: 90px; }
  .boss { grid-template-columns: 1fr; }
  .boss-pic { max-width: 120px; }
  .bubble::before { display: none; }
}

/* what-if cards */
.wi-title { margin: 8px 0 0; font-size: 22px; }
.what-ifs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.what-ifs { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.what-if {
  display: grid; gap: 10px; align-content: start;
  padding: 14px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--dim);
}
.what-if.open { border-style: solid; border-color: var(--fuel); }
.wi-q { margin: 0; font-weight: 700; }
.wi-options { display: grid; gap: 6px; }
.wi-option {
  text-align: left; padding: 8px 10px; border-radius: 6px;
  font: 14px system-ui, sans-serif; color: var(--text);
  background: transparent; border: 1px solid var(--dim); cursor: pointer;
}
.wi-option:hover:not(:disabled) { border-color: var(--text); }
.wi-option:disabled { cursor: default; }
.wi-option.right { border-color: var(--food); background: rgba(111, 211, 143, 0.15); }
.wi-option.wrong { border-color: #ff6b7a; background: rgba(255, 107, 122, 0.15); }
.wi-why, .wi-real { margin: 0; font-size: 14px; }
.wi-why:empty, .wi-real:empty { display: none; }
.wi-real { color: var(--dim); }
.wi-real strong { color: var(--dist); }

/* popup */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(7, 11, 26, 0.8);
}
.modal-box {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px); overflow: auto;
  display: grid; gap: 12px;
  padding: 20px;
  background: var(--panel);
  border: 2px solid var(--dist);
  border-radius: 12px;
}
.modal-box h3 { margin: 0; font-size: 22px; }
.modal-box p { margin: 0; }
.disaster-box { border-color: #ff6b7a; }
.alarm { color: #ff6b7a; animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.disaster { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; align-items: center; }
.disaster img, .disaster .placeholder { width: 100%; }
.learn { font-size: 14px; color: var(--dim); }
.learn strong { color: var(--dist); }
.danger { border-color: #ff6b7a; color: #ff6b7a; }
.go:disabled { opacity: 0.4; cursor: not-allowed; }

/* mini games */
.mini-area { display: grid; gap: 12px; justify-items: start; }
.bar.big { height: 20px; width: 100%; }
.track { position: relative; width: 100%; height: 36px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.target { position: absolute; top: 0; bottom: 0; background: rgba(111, 211, 143, 0.35); border: 2px solid var(--food); }
.marker { position: absolute; top: 0; bottom: 0; width: 4px; margin-left: -2px; background: var(--text); }
.mini-msg { min-height: 1.4em; color: #ff6b7a; }
#mini-btn { touch-action: none; user-select: none; }

/* quiz */
.quiz-q { font-size: 20px; font-weight: 700; }
.quiz-count { margin: 0 0 4px; color: var(--space); opacity: 0.6; }
.options { display: grid; gap: 8px; }
.option {
  text-align: left; padding: 12px 14px; border-radius: 8px;
  font: 600 16px system-ui, sans-serif;
  color: var(--text); background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--dim); cursor: pointer;
}
.option:hover:not(:disabled) { border-color: var(--text); }
.option:disabled { cursor: default; }
.option.right { border-color: var(--food); background: rgba(111, 211, 143, 0.15); }
.option.wrong { border-color: #ff6b7a; background: rgba(255, 107, 122, 0.15); }
.quiz-why { margin: 0; min-height: 1.5em; color: var(--dim); }

@media (max-width: 560px) {
  .disaster { grid-template-columns: 1fr; }
  .disaster img, .disaster .placeholder { max-width: 100px; }
}

/* heater / cooler toggles */
.gear { display: grid; grid-template-columns: auto auto; gap: 6px 10px; align-items: center; }
.toggle {
  min-width: 130px; padding: 8px 12px; border-radius: 6px;
  font: 600 14px system-ui, sans-serif; color: var(--text);
  background: transparent; border: 1px solid var(--dim); cursor: pointer;
}
.toggle.on { background: var(--food); border-color: var(--food); color: var(--space); }
.hint.warn { color: var(--fuel); }
.decide { margin: 0; font-weight: 700; color: #ff6b7a; }

/* mission report card */
.report { display: grid; gap: 12px; padding: 18px 20px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--dim); }
.report h3 { margin: 0; font-size: 22px; }
.report h4 { margin: 8px 0 0; font-size: 16px; color: var(--dist); text-transform: uppercase; letter-spacing: 0.08em; }
.report p { margin: 0; }
.report ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--dim); }
.report ul strong { color: var(--text); }
.report-verdict.good { color: var(--food); }
.report-verdict.bad { color: #ff6b7a; }
.table-wrap { overflow-x: auto; }
.report-table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
.report-table th, .report-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.report-table th { color: var(--dim); font-weight: 600; }
.ok { color: var(--food); font-weight: 700; white-space: nowrap; }
.short { color: #ff6b7a; font-weight: 700; white-space: nowrap; }

/* boss on the intro */
.boss-intro { grid-template-columns: 180px minmax(0, 1fr); align-items: center; }
.intro-story { display: grid; gap: 8px; font-size: 18px; }
.intro-story p { margin: 0; }
.boss-pic img { background: rgba(255, 255, 255, 0.04); border-radius: 12px; }

/* rocket space meter */
.space-meter { display: grid; gap: 8px; padding: 16px 18px; border-radius: 12px; background: rgba(127, 178, 255, 0.10); border: 2px solid var(--dist); position: sticky; top: 8px; z-index: 5; }
.space-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 700; font-size: 18px; }
.space-head strong { font: 700 34px Consolas, "Courier New", monospace; font-variant-numeric: tabular-nums; color: var(--dist); }
.space-bar { height: 18px; border-radius: 9px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.space-fill { height: 100%; width: 0; background: var(--dist); transition: width 0.2s; }
.space-note { margin: 0; font-size: 15px; color: var(--dim); }
.space-meter.low { border-color: var(--fuel); background: rgba(255, 138, 61, 0.12); }
.space-meter.low .space-head strong, .space-meter.low .space-note { color: var(--fuel); }
.space-meter.low .space-fill { background: var(--fuel); }
.space-meter.full { border-color: #ff6b7a; }

/* Mission Control check */
.check { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.check li { padding: 10px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }
.check li.ok { border-left: 4px solid var(--food); }
.check li.short { border-left: 4px solid #ff6b7a; }
.check .math { display: block; margin-top: 4px; font: 14px Consolas, "Courier New", monospace; color: var(--dim); }

@media (max-width: 560px) {
  .boss-intro { grid-template-columns: 1fr; }
}

/* field notes in the briefing */
.notes { display: grid; gap: 8px; padding: 14px 16px; border-radius: 10px; background: rgba(111, 211, 143, 0.08); border: 1px dashed var(--food); }
.notes .eyebrow { color: var(--food); }
.notes ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }

/* music button */
.top-right { display: flex; align-items: center; gap: 14px; }
.music-btn {
  font: 600 14px system-ui, sans-serif; color: var(--text);
  background: transparent; border: 1px solid var(--dim); border-radius: 999px;
  padding: 4px 12px; cursor: pointer;
}
.music-btn[aria-pressed="false"] { color: var(--dim); }

/* intro: the team's drawing points up and to its left, so the boss stands on the right of his speech bubble */
.boss-intro { grid-template-columns: minmax(0, 1fr) 220px; }
.boss-intro .boss-pic { order: 2; }
.boss-intro .bubble { order: 1; }
.boss-intro .bubble::before { left: auto; right: -12px; border-right: 0; border-left: 12px solid var(--text); }
.boss-pic img { background: transparent; }
@media (max-width: 560px) {
  .boss-intro { grid-template-columns: 1fr; }
  .boss-intro .boss-pic { order: 0; }
}

/* repair tasks */
.repair-box { border-color: var(--fuel); }
.task { display: grid; justify-items: center; }
.wires { display: grid; grid-template-columns: 1fr 60px 1fr; gap: 10px; width: 100%; }
.wcol { display: grid; gap: 10px; }
.wire { padding: 10px; border-radius: 8px; border: 3px solid transparent; font: 700 15px system-ui, sans-serif; color: #14213d; cursor: pointer; text-transform: capitalize; }
.wire.picked { border-color: var(--text); transform: scale(1.05); }
.wire.joined { opacity: 0.45; cursor: default; }
.wire.joined::after { content: " ✓"; }
.panel-area { position: relative; width: 100%; height: 220px; border-radius: 10px; }
.panel-area.hull { background: #5b6478; }
.panel-area.dusty { background: #9aa0aa; }
.spot-fix { position: absolute; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transform: translate(-50%, -50%); }
.spot-fix.hole { background: #0b1022; border: 3px dashed #ff6b7a; }
.spot-fix.dust { background: #6b6253; border: 3px dashed #c9b48a; }
.spot-fix.fixed { background: var(--food); border: 3px solid var(--food); cursor: default; }
.door { display: grid; gap: 10px; justify-items: center; padding: 16px; border-radius: 12px; background: #2a3150; width: 100%; }
.door-code { margin: 0; font: 600 16px system-ui, sans-serif; color: var(--dim); }
.door-code strong { font: 700 28px Consolas, "Courier New", monospace; color: var(--fuel); letter-spacing: 0.15em; }
.door-entry { margin: 0; font: 700 32px Consolas, "Courier New", monospace; letter-spacing: 0.3em; }
.keypad { display: grid; grid-template-columns: repeat(3, 56px); gap: 8px; }
.key { height: 48px; border-radius: 8px; border: 1px solid var(--dim); background: var(--panel); color: var(--text); font: 700 20px system-ui, sans-serif; cursor: pointer; }
.thrust { display: flex; align-items: center; gap: 24px; }
.thrust-bar { position: relative; width: 48px; height: 200px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); overflow: hidden; border: 1px solid var(--dim); }
.thrust-zone { position: absolute; left: 0; right: 0; background: rgba(111, 211, 143, 0.4); border-top: 2px solid var(--food); border-bottom: 2px solid var(--food); }
.thrust-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--fuel); opacity: 0.85; }
#tbtn { touch-action: none; user-select: none; }

/* real NASA ground photo behind the sample spots */
.spots { padding: 14px; border-radius: 12px; background-color: #2a2f3f; background-size: cover; background-position: center; }
.spot { background: rgba(7, 11, 26, 0.6); backdrop-filter: blur(1px); }

/* photo icons on the sample spots */
.spot img { border-radius: 8px; }
