:root {
  --space-black: #05070b;
  --cosmic-blue: #0d1b2a;
  --nebula-violet: #6a4c93;
  --stellar-white: #f8f9fa;
  --solar-gold: #ffd166;
  --accent-cyan: #4cc9f0;
  --panel-line: rgba(248, 249, 250, 0.14);
  --muted: rgba(248, 249, 250, 0.64);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  background: var(--space-black);
  color: var(--stellar-white);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input { font: inherit; }

#app {
  position: fixed;
  inset: 0;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 42%, rgba(76, 201, 240, 0.08), transparent 38%),
    linear-gradient(135deg, var(--space-black), #030409 64%, var(--cosmic-blue));
}

#cosmosCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.command-panel,
.perspective-panel {
  position: absolute;
  z-index: 5;
  border: 1px solid var(--panel-line);
  background: linear-gradient(135deg, rgba(5, 7, 11, 0.68), rgba(13, 27, 42, 0.42));
  backdrop-filter: blur(22px) saturate(145%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.panel-kicker,
label {
  display: block;
  color: var(--accent-cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
}

.command-panel {
  left: 18px;
  top: 18px;
  width: min(310px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  padding: 14px;
  border-radius: 24px;
  display: grid;
  gap: 12px;
}

.scale-slider-wrap {
  display: grid;
  gap: 5px;
}

.scale-range {
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.scale-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--solar-gold), var(--accent-cyan));
  box-shadow: 0 0 14px rgba(76, 201, 240, 0.36);
}

.scale-range::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--solar-gold), var(--accent-cyan));
  box-shadow: 0 0 14px rgba(76, 201, 240, 0.36);
}

.scale-range::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  border: 1px solid rgba(248, 249, 250, 0.85);
  background: var(--space-black);
  box-shadow: 0 0 0 4px rgba(76, 201, 240, 0.16), 0 0 18px rgba(255, 209, 102, 0.65);
}

.scale-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(248, 249, 250, 0.85);
  background: var(--space-black);
  box-shadow: 0 0 0 4px rgba(76, 201, 240, 0.16), 0 0 18px rgba(255, 209, 102, 0.65);
}

.scale-slider-labels {
  display: flex;
  justify-content: space-between;
  color: rgba(248, 249, 250, 0.42);
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scale-navigator {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  max-height: min(48vh, 560px);
  overflow: hidden;
}

.journey-rail {
  position: relative;
  width: 2px;
  margin: 8px auto;
  border-radius: 999px;
  background: rgba(248, 249, 250, 0.12);
}

.journey-rail span {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--journey-progress, 0%);
  border-radius: inherit;
  background: linear-gradient(180deg, var(--solar-gold), var(--accent-cyan));
  box-shadow: 0 0 16px rgba(76, 201, 240, 0.7);
  transition: height 300ms ease;
}

.journey-steps {
  display: grid;
  gap: 3px;
}

.journey-step {
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 19px;
  color: rgba(248, 249, 250, 0.46);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  transition: color 180ms ease, transform 180ms ease;
}

.journey-step::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid rgba(248, 249, 250, 0.24);
  background: rgba(5, 7, 11, 0.84);
  box-shadow: 0 0 0 0 rgba(76, 201, 240, 0);
}

.journey-step.passed { color: rgba(248, 249, 250, 0.64); }
.journey-step.passed::before { background: rgba(76, 201, 240, 0.5); border-color: rgba(76, 201, 240, 0.7); }
.journey-step:hover { color: rgba(248, 249, 250, 0.86); }
.journey-step.active { color: var(--stellar-white); transform: translateX(2px); }
.journey-step.active::before {
  background: var(--solar-gold);
  border-color: var(--solar-gold);
  box-shadow: 0 0 16px rgba(255, 209, 102, 0.8);
}

.readout-line {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: baseline;
  border-top: 1px solid rgba(248, 249, 250, 0.08);
  padding-top: 8px;
}

.readout-line span {
  color: var(--muted);
  font-size: 0.86rem;
}

.readout-line strong {
  color: var(--stellar-white);
  text-align: right;
  font-weight: 700;
}

.brief-text,
.perspective-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.perspective-panel {
  right: 18px;
  bottom: 18px;
  width: min(390px, calc(100vw - 36px));
  padding: 18px;
  border-radius: 24px;
  display: grid;
  gap: 14px;
  overflow: hidden;
}

.perspective-panel::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto;
  height: 90px;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.18), transparent 68%);
  pointer-events: none;
}

#perspectiveText {
  position: relative;
  color: rgba(248, 249, 250, 0.86);
  font-size: 1rem;
  animation: revealPerspective 480ms ease;
}

@keyframes revealPerspective {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 22px;
  background: radial-gradient(circle, rgba(13, 27, 42, 0.78), rgba(5, 7, 11, 0.96) 62%);
  transition: opacity 700ms ease, visibility 700ms ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-orbit {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 1px solid rgba(76, 201, 240, 0.25);
  border-top-color: var(--accent-cyan);
  border-right-color: var(--solar-gold);
  animation: spin 1.4s linear infinite;
  box-shadow: 0 0 40px rgba(76, 201, 240, 0.22);
}

.loading-screen p {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

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

@media (max-width: 760px) {
  .command-panel {
    width: min(285px, calc(100vw - 36px));
    max-height: 58vh;
    overflow: auto;
  }
  .scale-navigator { max-height: 36vh; }
  .perspective-panel {
    left: 18px;
    right: 18px;
    bottom: 18px;
    width: auto;
  }
}

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