:root {
  color-scheme: dark;
  --bg: #03040a;
  --panel: rgba(8, 12, 24, 0.82);
  --panel-solid: #0b1020;
  --text: #eef4ff;
  --muted: #8c9ab7;
  --line: rgba(172, 193, 255, 0.18);
  --laser: #66f3ff;
  --accent: #ffd166;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: radial-gradient(circle at 20% 10%, #172348 0, transparent 34rem), var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 100vh;
  height: auto;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: max(100vh, 1180px);
  overflow: hidden;
}

#spaceCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.topbar {
  position: absolute;
  top: clamp(10px, 2vw, 18px);
  left: clamp(14px, 3vw, 32px);
  right: clamp(14px, 3vw, 32px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--laser);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 20ch;
  font-size: clamp(1.45rem, 2.25vw, 2.75rem);
  line-height: 1;
}

h2 {
  font-size: 1.55rem;
}

.readout,
.legend,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.readout {
  border-radius: 8px;
  padding: 12px 14px;
  text-align: right;
  min-width: 150px;
}

.readout span {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.readout small {
  color: var(--muted);
}

.legend {
  position: absolute;
  left: clamp(14px, 3vw, 32px);
  bottom: clamp(14px, 3vw, 28px);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: inline-block;
}

.sun-dot {
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

.laser-dot {
  background: var(--laser);
  box-shadow: 0 0 14px var(--laser);
}

.planet-dot {
  background: #d8e4ff;
}

.panel {
  position: relative;
  z-index: 2;
  align-self: start;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: -20px 0 70px rgba(0, 0, 0, 0.28);
}

.panel-head p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.9rem;
}

.planet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: rgba(102, 243, 255, 0.7);
  outline: none;
}

button.active,
.planet-grid button[aria-pressed="true"] {
  background: rgba(102, 243, 255, 0.16);
  border-color: rgba(102, 243, 255, 0.82);
}

.primary {
  background: linear-gradient(135deg, #6befff, #668cff);
  border: 0;
  color: #02040c;
  font-weight: 800;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.slider-label,
.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.slider-label strong,
.timeline-head span {
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--laser);
}

.scale-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.stats {
  display: grid;
  gap: 6px;
  margin: 0;
}

.stats div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5ch;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
  min-width: 7.5ch;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.timeline {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.timeline h3 {
  font-size: 1rem;
}

.timeline ol {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 5px;
}

.timeline li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.timeline li strong {
  min-width: 5.8ch;
  text-align: right;
  white-space: nowrap;
}

.timeline li.reached {
  color: var(--text);
}

.note {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .app {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .stage {
    height: 100vh;
    min-height: 700px;
  }

  .panel {
    position: relative;
    max-height: none;
    min-height: 42vh;
    box-shadow: 0 -20px 70px rgba(0, 0, 0, 0.28);
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    max-width: 16ch;
    font-size: 1.45rem;
  }

  .readout {
    align-self: flex-start;
    text-align: left;
  }

  .legend {
    max-width: calc(100% - 28px);
  }

  .panel {
    padding: 18px;
  }
}
