@import url("https://fonts.googleapis.com/css2?family=Bungee&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #050915;
  --bg-soft: #0b1430;
  --ink: #f5f7ff;
  --muted: rgba(245, 247, 255, 0.72);
  --card: rgba(10, 18, 42, 0.78);
  --card-border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(2, 6, 18, 0.55);
  --accent: #ffb347;
  --accent-strong: #ff7a59;
  --accent-cool: #5be4ff;
  --accent-fuel: #8bff9b;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 179, 71, 0.16), transparent 45%),
    radial-gradient(circle at 85% 12%, rgba(91, 228, 255, 0.18), transparent 42%),
    radial-gradient(circle at 60% 85%, rgba(139, 255, 155, 0.18), transparent 40%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(1px 1px at 12px 24px, rgba(255, 255, 255, 0.8), transparent 65%),
    radial-gradient(1px 1px at 44px 88px, rgba(255, 255, 255, 0.55), transparent 65%),
    radial-gradient(1.5px 1.5px at 76px 44px, rgba(255, 255, 255, 0.7), transparent 65%),
    radial-gradient(1px 1px at 104px 12px, rgba(255, 255, 255, 0.6), transparent 65%),
    radial-gradient(1.5px 1.5px at 140px 100px, rgba(255, 255, 255, 0.65), transparent 65%);
  background-size: 160px 160px;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.4rem 6vw 3rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.22rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--ink);
}

.hero {
  display: grid;
  gap: 0.8rem;
  margin-bottom: 2rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.32rem;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  font-family: "Bungee", "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 3vw + 1rem, 3.2rem);
  letter-spacing: 0.08rem;
}

.subtitle {
  color: var(--muted);
  max-width: 40ch;
  line-height: 1.5;
}

.mission-stats {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12rem;
  color: var(--muted);
}

.stat .value {
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 1.6rem;
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.6rem;
  border: 1px solid var(--card-border);
  box-shadow: 0 20px 40px var(--shadow);
  backdrop-filter: blur(14px);
}

.quiz {
  display: grid;
  gap: 1.4rem;
  position: relative;
  overflow: hidden;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.progress-label {
  font-weight: 600;
}

.progress-track {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-cool));
  transition: width 0.4s ease;
}

.difficulty {
  display: grid;
  gap: 0.6rem;
}

.difficulty-label {
  font-weight: 600;
}

.difficulty-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.difficulty-button {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease;
}

.difficulty-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.45);
}

.difficulty-button.is-active {
  background: linear-gradient(120deg, rgba(91, 228, 255, 0.3), rgba(255, 179, 71, 0.25));
  border-color: rgba(91, 228, 255, 0.6);
}

.question-block {
  display: grid;
  gap: 0.4rem;
}

.question {
  font-size: clamp(2.2rem, 2vw + 1.4rem, 3.2rem);
  font-weight: 700;
}

.hint {
  color: var(--muted);
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.8rem;
}

.choice {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.2s ease, border 0.2s ease, background 0.2s ease;
}

.choice:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
}

.choice:disabled {
  cursor: default;
  opacity: 0.85;
}

.choice.correct {
  border-color: var(--accent-fuel);
  background: rgba(139, 255, 155, 0.18);
  box-shadow: 0 0 0 2px rgba(139, 255, 155, 0.2);
}

.choice.wrong {
  border-color: var(--danger);
  background: rgba(255, 107, 107, 0.18);
}

.feedback {
  min-height: 2.2rem;
  font-weight: 600;
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.controls .is-hidden {
  display: none;
}

.results-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.6rem;
  background: rgba(5, 9, 21, 0.92);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.results-panel.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.results-card {
  background: rgba(10, 18, 42, 0.9);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1.8rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  display: grid;
  gap: 1.2rem;
}

.results-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.results-title {
  font-size: 1.8rem;
}

.start-text {
  color: var(--muted);
  line-height: 1.5;
}

.results-grid {
  display: grid;
  gap: 0.8rem;
}

.results-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
}

.results-item span {
  color: var(--muted);
  font-size: 0.85rem;
}

.results-item strong {
  font-size: 1.05rem;
}

.record-entry {
  display: none;
  gap: 0.8rem;
}

.record-entry.is-visible {
  display: grid;
}

.record-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.record-form {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.record-form input {
  flex: 1 1 160px;
  padding: 0.6rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

.record-form input::placeholder {
  color: rgba(245, 247, 255, 0.6);
}

button {
  border: none;
  cursor: pointer;
}

button.primary,
button.ghost {
  padding: 0.8rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.04rem;
}

button.primary {
  background: linear-gradient(120deg, var(--accent-strong), var(--accent));
  color: #1b0d06;
}

button.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.rocket-panel {
  display: grid;
  gap: 1.2rem;
}

.panel-header h2 {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}

.panel-header p {
  color: var(--muted);
  line-height: 1.4;
}

.launchpad {
  position: relative;
  height: 320px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(12, 18, 40, 0.9), rgba(5, 9, 21, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.launchpad.launch-ready {
  box-shadow: 0 0 30px rgba(91, 228, 255, 0.25);
}

.launchpad.launching::after {
  opacity: 0.4;
  animation: streaks 1.2s linear infinite;
}

.launchpad::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(91, 228, 255, 0.18), transparent 40%),
    radial-gradient(circle at 70% 70%, rgba(255, 179, 71, 0.16), transparent 45%);
}

.launchpad::after {
  content: "";
  position: absolute;
  inset: -80px -60px;
  background-image:
    linear-gradient(transparent 0%, rgba(255, 255, 255, 0.2) 40%, transparent 70%),
    linear-gradient(transparent 0%, rgba(91, 228, 255, 0.3) 50%, transparent 80%);
  background-size: 140px 220px;
  opacity: 0;
  transform: translateY(60px);
}

.orbit {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  top: 40px;
  right: -40px;
}

.launchpad.launching .orbit {
  animation: orbit-spin 2s linear infinite;
  opacity: 0.8;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Bungee", "Space Grotesk", sans-serif;
  font-size: 3.4rem;
  letter-spacing: 0.2rem;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(255, 179, 71, 0.8), 0 0 30px rgba(91, 228, 255, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 3;
}

.launchpad.is-countdown .countdown {
  opacity: 1;
  animation: countdown-pulse 0.8s ease-in-out infinite;
}

.rocket {
  position: absolute;
  left: 50%;
  bottom: 24px;
  width: 90px;
  height: 180px;
  transform: translate(-50%, 0);
  transition: transform 0.6s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.rocket-piece {
  position: absolute;
  opacity: 0;
  --x: 0px;
  --y: 6px;
  transform: translate(var(--x), var(--y));
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.rocket-piece.is-visible {
  opacity: 1;
  --y: 0px;
}

.rocket::after {
  content: "";
  position: absolute;
  bottom: -130px;
  left: 50%;
  width: 16px;
  height: 130px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255, 242, 176, 0.9), rgba(255, 122, 89, 0.2), transparent);
  opacity: 0;
  filter: blur(1px);
}

.rocket.launched {
  animation: liftoff 2.4s ease-in forwards;
  filter: drop-shadow(0 0 18px rgba(255, 179, 71, 0.6));
}

.rocket.launched::after {
  opacity: 1;
  animation: trail 1.6s ease-out forwards;
}

.rocket-nose {
  top: 0;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 26px solid transparent;
  border-right: 26px solid transparent;
  border-bottom: 40px solid #f5f7ff;
  --x: -50%;
}

.rocket-body-segment {
  left: 50%;
  width: 62px;
  height: 24px;
  background: linear-gradient(180deg, #f5f7ff, #ccd2f5);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.08);
  --x: -50%;
}

.rocket-body-segment.segment-1 {
  top: 40px;
  border-radius: 20px 20px 6px 6px;
}

.rocket-body-segment.segment-2 {
  top: 64px;
}

.rocket-body-segment.segment-3 {
  top: 88px;
}

.rocket-body-segment.segment-4 {
  top: 112px;
  border-radius: 6px 6px 16px 16px;
}

.rocket-window {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cool);
  border: 3px solid rgba(255, 255, 255, 0.6);
  position: absolute;
  top: 70px;
  left: 50%;
  --x: -50%;
  box-shadow: 0 0 12px rgba(91, 228, 255, 0.6);
  z-index: 2;
}

.rocket-stripe {
  position: absolute;
  top: 126px;
  left: 50%;
  width: 36px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  --x: -50%;
  z-index: 2;
}

.rocket-fin {
  position: absolute;
  bottom: 30px;
  width: 26px;
  height: 30px;
  background: var(--accent-strong);
}

.rocket-fin-left {
  left: 6px;
  border-radius: 0 0 0 14px;
  transform: skewX(-12deg);
}

.rocket-fin-right {
  right: 6px;
  border-radius: 0 0 14px 0;
  transform: skewX(12deg);
}

.rocket-flame {
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 22px;
  height: 36px;
  background: radial-gradient(circle at 50% 18%, #fff2b0, var(--accent-strong));
  border-radius: 0 0 14px 14px;
  --x: calc(-50% - 2px);
  filter: drop-shadow(0 0 12px rgba(255, 122, 89, 0.6));
  animation: flame 0.6s ease-in-out infinite alternate;
}

.rocket-flame::after {
  content: "";
  position: absolute;
  inset: -10px -8px auto;
  height: 40px;
  background: radial-gradient(circle at 50% 30%, rgba(230, 235, 255, 0.6), transparent 70%);
  opacity: 0.5;
  filter: blur(6px);
}

.rocket-flame::before {
  content: "";
  position: absolute;
  bottom: 18px;
  left: 50%;
  width: 32px;
  height: 52px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 50%, rgba(200, 210, 230, 0.35), transparent 70%);
  filter: blur(8px);
  opacity: 0.4;
}

.rocket.launched .rocket-flame {
  animation: flame-boost 0.35s ease-in-out infinite alternate;
  height: 48px;
  width: 28px;
}

.waypoints {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: grid;
  gap: 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.rocket-status {
  display: grid;
  gap: 0.5rem;
}

.fuel-meter {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.fuel-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-fuel), var(--accent-cool));
  transition: width 0.4s ease;
}

.footer {
  margin-top: 2.4rem;
  text-align: center;
  color: var(--muted);
}

[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  animation: reveal 0.8s ease forwards;
  animation-delay: calc(var(--delay) * 0.12s);
}

[data-reveal="1"] {
  --delay: 1;
}

[data-reveal="2"] {
  --delay: 2;
}

[data-reveal="3"] {
  --delay: 3;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flame {
  from {
    transform: scaleY(0.8);
  }
  to {
    transform: scaleY(1.1);
  }
}

@keyframes countdown-pulse {
  from {
    transform: scale(0.95);
  }
  to {
    transform: scale(1.08);
  }
}

@keyframes liftoff {
  0% {
    transform: translate(-50%, 0);
    opacity: 1;
  }
  18% {
    transform: translate(-50%, -20px) scale(1.02);
  }
  40% {
    transform: translate(-50%, -280px) scale(1) rotate(-2deg);
  }
  65% {
    transform: translate(-50%, -420px) scale(0.92) rotate(3deg);
  }
  85% {
    transform: translate(-50%, -560px) scale(0.82) rotate(-4deg);
  }
  100% {
    transform: translate(-50%, -740px) scale(0.7) rotate(-6deg);
    opacity: 0;
  }
}

@keyframes trail {
  0% {
    opacity: 0;
    transform: translateX(-50%) scaleY(0.2);
  }
  40% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scaleY(1.2);
  }
}

@keyframes flame-boost {
  from {
    transform: scaleY(0.9);
  }
  to {
    transform: scaleY(1.3);
  }
}

@keyframes streaks {
  from {
    transform: translateY(60px);
  }
  to {
    transform: translateY(-120px);
  }
}

@keyframes orbit-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .rocket-panel {
    order: -1;
  }
}

@media (max-width: 600px) {
  .quiz {
    min-height: 75vh;
  }

  .results-panel {
    align-items: flex-start;
    overflow-y: auto;
  }

  .results-card {
    max-width: 100%;
    max-height: 100%;
    padding: 1.4rem;
  }

  .difficulty-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .difficulty-button,
  .results-card button.primary {
    width: 100%;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .rocket,
  .rocket-flame,
  .rocket::after,
  .progress-fill,
  .fuel-fill {
    transition: none;
    animation: none;
  }

  .launchpad::after {
    animation: none;
  }

  .launchpad.launching .orbit {
    animation: none;
  }

  .launchpad.is-countdown .countdown {
    animation: none;
  }
}
