:root {
  color-scheme: dark;
  --ink: #f7f4ed;
  --paper: rgba(247, 244, 237, 0.78);
  --muted: rgba(247, 244, 237, 0.48);
  --faint: rgba(247, 244, 237, 0.24);
  --line: rgba(247, 244, 237, 0.15);
  --line-bright: rgba(247, 244, 237, 0.33);
  --black: #020202;
  --glass: rgba(4, 5, 7, 0.5);
  --glass-strong: rgba(4, 5, 7, 0.74);
  --accent: #e8c66c;
  --blue: #95c9ff;
  --red: #df725b;
  --green: #8fe6c8;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

#space {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #000;
}

.scene-fade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.93) 18%, rgba(0, 0, 0, 0.2) 56%, rgba(0, 0, 0, 0.9) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.9), transparent 38%, rgba(0, 0, 0, 0.64));
  z-index: 1;
}

.site-header,
.chapter-nav,
.planet-rail,
.archive-layout,
.side-index,
.mission-strip,
.control-dock,
.label-layer {
  position: fixed;
  z-index: 4;
}

.site-header {
  top: 32px;
  left: 28px;
  right: 28px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.brand {
  display: grid;
  gap: 5px;
  min-width: 152px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
}

.brand span,
.chapter-button,
.card-head span,
.story-copy span,
.metric-list span,
.tag-row button,
.mission-card span,
.mission-card small,
.quiz-head span,
.compare-selects span {
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

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

.archive-tabs {
  display: flex;
  gap: 28px;
  pointer-events: auto;
}

.archive-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 8px;
}

.archive-tab.active {
  color: var(--ink);
}

.archive-tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 28px;
  height: 2px;
  transform: translateX(-50%);
  background: var(--ink);
}

.chapter-nav {
  top: 44%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 28px;
  pointer-events: auto;
}

.chapter-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 5px 0;
}

.chapter-button.active,
.chapter-button:hover {
  color: var(--ink);
}

.planet-rail {
  top: calc(44% + 34px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  max-width: min(760px, calc(100vw - 420px));
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

.planet-button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-width: 48px;
  padding: 7px 12px;
  font-size: 12px;
}

.planet-button.active {
  border-color: rgba(247, 244, 237, 0.28);
  background: rgba(247, 244, 237, 0.08);
  color: var(--ink);
}

.archive-layout {
  left: 28px;
  right: 28px;
  bottom: 122px;
  display: grid;
  grid-template-columns: minmax(280px, 460px) minmax(300px, 390px);
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  pointer-events: none;
}

.story-copy {
  padding-bottom: 112px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
}

.story-copy span {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 10px;
}

.story-copy h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 58px);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0;
}

.story-copy p {
  width: min(420px, 90vw);
  margin: 13px 0 0;
  color: var(--paper);
  font-size: 15px;
  line-height: 1.8;
}

.archive-card {
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(8, 9, 12, 0.58), rgba(6, 7, 10, 0.88));
  backdrop-filter: blur(20px) saturate(125%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  padding: 22px;
}

.card-head {
  display: grid;
  gap: 10px;
  margin-bottom: 15px;
}

.card-head span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.card-head strong {
  font-size: 25px;
  font-weight: 500;
}

.card-copy {
  margin: 0 0 16px;
  color: var(--paper);
  font-size: 13px;
  line-height: 1.75;
}

.metric-list {
  display: grid;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 32px;
  border-bottom: 1px solid rgba(247, 244, 237, 0.08);
}

.metric:last-child {
  border-bottom: 0;
}

.metric span {
  color: var(--muted);
  font-size: 10px;
}

.metric strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 15px 0;
}

.tag-row button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--paper);
  cursor: pointer;
  padding: 0 10px;
  font-size: 10px;
}

.tag-row button:hover,
.tag-row button.active {
  border-color: var(--line-bright);
  color: var(--accent);
}

.next-stop {
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  cursor: pointer;
  padding: 0 14px;
}

.next-stop span {
  color: var(--muted);
  text-align: left;
}

.next-stop strong {
  font-weight: 500;
}

.compare-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compare-selects label {
  display: grid;
  gap: 6px;
}

.compare-selects span {
  color: var(--muted);
  font-size: 10px;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.34);
  color: var(--ink);
  padding: 10px;
}

select option {
  background: #0b0c10;
  color: white;
}

.comparison {
  display: grid;
  gap: 13px;
  margin-top: 16px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-row header {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.bar {
  position: relative;
  height: 25px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.bar::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c), rgba(247, 244, 237, 0.25));
}

.bar strong {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding-left: 10px;
  font-size: 11px;
  font-weight: 600;
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.quiz-head strong {
  color: var(--accent);
}

.mode-pane h2 {
  margin: 12px 0 14px;
  font-size: 18px;
  line-height: 1.42;
  font-weight: 600;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 9px 11px;
  text-align: left;
}

.quiz-option:hover {
  border-color: var(--line-bright);
}

.quiz-option.correct {
  border-color: rgba(143, 230, 200, 0.75);
  background: rgba(143, 230, 200, 0.12);
}

.quiz-option.wrong {
  border-color: rgba(223, 114, 91, 0.75);
  background: rgba(223, 114, 91, 0.12);
}

#quiz-feedback {
  min-height: 22px;
  color: var(--paper);
  font-size: 12px;
  line-height: 1.6;
  margin: 12px 0 0;
}

.side-index {
  top: 50%;
  right: 28px;
  transform: translateY(-50%);
  display: grid;
  gap: 15px;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
  pointer-events: none;
}

.side-index strong {
  color: var(--ink);
  font-weight: 700;
}

.mission-strip {
  left: 28px;
  right: 28px;
  bottom: 25px;
  height: 54px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 160px minmax(210px, 1fr);
  gap: 0;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

.mission-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 8px 18px;
  text-align: left;
}

.mission-card + .mission-card {
  border-left: 1px solid var(--line);
}

.mission-card span {
  grid-row: 1 / 3;
  color: var(--blue);
  font-size: 17px;
  font-weight: 500;
}

.mission-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.mission-card small {
  color: var(--muted);
  font-size: 9px;
}

.progress-line {
  position: relative;
  align-self: center;
  height: 1px;
  background: var(--line);
}

.progress-line span {
  position: absolute;
  inset: -1px auto -1px 0;
  width: var(--progress, 38%);
  background: var(--ink);
}

.control-dock {
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  pointer-events: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--paper);
  cursor: pointer;
}

.icon-button:hover,
.icon-button.active {
  border-color: var(--line);
  color: var(--accent);
}

.icon-button i,
.speed-control i {
  font-size: 17px;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
}

.speed-control input {
  width: 96px;
  accent-color: var(--accent);
}

.speed-control span {
  min-width: 34px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.label-layer {
  inset: 0;
  pointer-events: none;
}

.planet-label {
  position: absolute;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.54);
  color: rgba(247, 244, 237, 0.78);
  font-size: 11px;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(12px);
}

.loading {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  background: #000;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

.loading span {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading strong {
  color: var(--paper);
  font-size: 13px;
  font-weight: 500;
}

.loading.done {
  opacity: 0;
  visibility: hidden;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 980px) {
  .scene-fade {
    background:
      linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.96) 24%, rgba(0, 0, 0, 0.2) 52%, rgba(0, 0, 0, 0.94) 100%),
      linear-gradient(90deg, rgba(0, 0, 0, 0.58), transparent);
  }

  .site-header {
    top: 18px;
    left: 16px;
    right: 16px;
  }

  .brand {
    min-width: 142px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(14px);
  }

  .archive-tabs {
    flex-direction: column;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(14px);
  }

  .archive-tab {
    font-size: 16px;
    padding: 0;
  }

  .archive-tab.active::after {
    display: none;
  }

  .chapter-nav,
  .side-index {
    display: none;
  }

  .planet-rail {
    top: 51vh;
    left: 16px;
    right: 16px;
    transform: none;
    max-width: none;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .planet-rail::-webkit-scrollbar {
    display: none;
  }

  .planet-button {
    min-width: max-content;
    padding-inline: 14px;
  }

  .archive-layout {
    top: calc(51vh + 54px);
    left: 12px;
    right: 12px;
    bottom: 118px;
    display: block;
    overflow: auto;
    padding-bottom: 12px;
    pointer-events: auto;
  }

  .story-copy {
    padding: 18px 18px 14px;
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: rgba(3, 4, 7, 0.7);
    backdrop-filter: blur(18px);
  }

  .story-copy h1 {
    font-size: 40px;
  }

  .story-copy p {
    width: auto;
    font-size: 14px;
  }

  .archive-card {
    border-top: 0;
    border-radius: 0 0 8px 8px;
    padding: 18px;
  }

  .mission-strip {
    display: none;
  }

  .control-dock {
    bottom: 16px;
    width: calc(100vw - 32px);
    border-radius: 8px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .speed-control {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 520px) {
  .site-header {
    align-items: start;
  }

  .brand strong {
    font-size: 14px;
  }

  .archive-tab {
    font-size: 15px;
  }

  .planet-rail {
    top: 50.5vh;
  }

  .archive-layout {
    top: calc(50.5vh + 54px);
  }

  .story-copy h1 {
    font-size: 36px;
  }

  .compare-selects {
    grid-template-columns: 1fr;
  }

  .metric {
    grid-template-columns: 76px 1fr;
  }
}
