@import url("https://fonts.googleapis.com/css2?family=Anton+SC&family=Bungee+Hairline&family=Patrick+Hand&family=Playwrite+GB+S:ital,wght@0,100..400;1,100..400&display=swap");
:root {
  --accent: #ff5a2c; /* Mars orange-red */
  --accent-glow: rgba(255, 90, 44, 0.5);
}

body {
  background-image: url("/images/starsBG.jpg"); /* optional: your star background */
  background-size: cover;
}
.app {
  background-color: #000;
  background-image: url("/images/starsBG.jpg"); /* optional: your star background */
  background-size: cover;
  background-position: center;
  max-width: 430px; /* don't rely on the Tailwind class */
  width: 100%;
}

/* a chapter's continue button shows only after its voiceover ends */
.story-btn.ready,
.chapter-btn.ready,
.c3-btn.ready,
.c4-btn.ready {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.6s ease;
}

/* ---------- Mars wrapper: animated with transform ---------- */
.mars-wrap {
  transition: transform 0.8s ease;
}
.explore .mars-wrap {
  transform: translateY(-40px) scale(0.6);
}

/* ---------- title overlay ---------- */
.hero-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
  pointer-events: none;
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}
.hero-text h1 {
  margin: 0;
  font-size: clamp(40px, 12vw, 56px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);

  font-family: "Anton SC", sans-serif;
  font-weight: 400;
  font-style: normal;
}
.hero-text p {
  margin: 4px 0 0;
  opacity: 0.85;

  font-family: "Bungee Hairline", sans-serif;
  font-weight: 700;
  font-style: normal;
}

/* ---------- buttons ---------- */
.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 999px;
  background: #ff37006c;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.1s,
    filter 0.2s,
    opacity 0.4s;
}

/* ---------- stage switching ---------- */
.menu {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}
.explore .hero-text,
.explore .intro-ui {
  opacity: 0;
  pointer-events: none;
}
.explore .hero-text {
  transform: translateY(-10px);
}
.explore .menu {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition:
    opacity 0.6s ease 0.6s,
    transform 0.6s ease 0.6s; /* appears after Mars settles */
}
.rover.active {
  outline: 2px solid var(--accent);
}

/* ---------- marker labels ---------- */
#mars.no-labels + #labels {
  display: none;
}
#labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mars-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  color: white;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

/* ---------- rover carousel ---------- */

.track {
  display: flex;
  width: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.track::-webkit-scrollbar {
  display: none;
}

.slide {
  flex: 0 0 100%;
  width: 100%;
  min-width: 0; /* stops content from widening the slide */
  scroll-snap-align: center;
  text-align: center;
  color: white;
}

.slide-model {
  position: relative;
  width: 100%;
  height: 250px;
  overflow: hidden;
}
/* the canvas fills the box and can't affect the layout */
.slide-model canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.slide-title {
  margin: -8px 0 0;
  font-size: 20px;
  font-weight: 600;
}
.slide-title {
  margin: -8px 0 0;
  font-size: 20px;
  font-weight: 600;
}
/* clickable */
.slide.clickable {
  cursor: pointer;
  transition: transform 0.15s;
}
.slide.clickable:hover .slide-title,
.slide.clickable:focus-visible .slide-title {
  color: var(--accent);
}
.slide.clickable:active {
  transform: scale(0.98);
}
.slide.clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

/* disabled */
.slide.disabled {
  cursor: not-allowed;
}
.slide.disabled .slide-model {
  filter: grayscale(1) brightness(0.6);
  opacity: 0.5;
}
.slide.disabled .slide-title {
  opacity: 0.5;
}

.slide-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.6);
}

.arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 30px;
  cursor: pointer;
  transition:
    color 0.2s,
    opacity 0.2s;
}
.arrow:hover {
  color: white;
}
.arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ---------- story scene 1 ---------- */
.story-scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 1. Mars flies up and disappears */
.explore.story .mars-wrap {
  transform: translateY(-120%) scale(0.6);
  opacity: 0;
  transition:
    transform 0.9s ease,
    opacity 0.9s ease;
}

/* 2. carousel slides down and disappears */
.explore.story .menu {
  opacity: 0;
  transform: translateY(120px);
  pointer-events: none;
  transition:
    opacity 0.7s ease,
    transform 0.7s ease;
}

/* 3. text fades in, centered */
.story-text {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: white;
  font-family: "Patrick Hand", cursive;
  font-weight: 400;
  font-style: normal;
  font-size: clamp(28px, 9vw, 42px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
}
.story .story-text {
  opacity: 1;
  transition: opacity 0.8s ease 1s;
}

/* 4. rover flies across the top, left to right */
.flyer {
  position: absolute;
  top: 12%;
  left: 0;
  width: 160px;
  height: 120px;
  transform: translateX(-200px);
  opacity: 0;
}
.flyer-model {
  position: relative;
  width: 100%;
  height: 100%;
}
.flyer-model canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}
.story .flyer {
  opacity: 1;
  animation: fly 6s linear 1.8s forwards;
}
.story .flyer-model {
  animation: bob 1.4s ease-in-out infinite;
}
@keyframes fly {
  from {
    transform: translateX(-200px);
  }
  to {
    transform: translateX(480px);
  } /* a bit past the 430px column */
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-12px) rotate(3deg);
  }
}
/* second flyer: bottom-right to top-left */
.flyer-rtl {
  top: auto;
  left: auto;
  right: 0;
  bottom: 12%;
  transform: translate(200px, 0);
}
.story .flyer-rtl {
  animation: fly-diagonal 6s linear 3s forwards; /* starts after flyer 1 is underway */
}
@keyframes fly-diagonal {
  from {
    transform: translate(200px, 0);
  }
  to {
    transform: translate(-640px, -70vh);
  } /* past the left edge and up to the top */
}
/* 5. continue button appears */
.story-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
}

/* ---------- chapter 2: blue theme ---------- */

/* old story content leaves */
.story.chapter2 .story-text,
.story.chapter2 .flyer {
  opacity: 0;
  animation: none;
  transition: opacity 0.4s ease;
}
.story.chapter2 .story-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* blue gradient opens from the center to the left and right */
.blue-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    to right,
    #00000000 0%,
    #1127558a 30%,
    #1127558a 70%,
    #00000000 100%
  );
  clip-path: inset(0 50% 0 50%); /* zero width at the center */
  transition: clip-path 1.2s ease 0.4s;
  pointer-events: none;
}
.chapter2 .blue-bg {
  clip-path: inset(0 0 0 0); /* full width */
}

/* keep the content above the backdrop */
.story-scene,
.chapter {
  z-index: 1;
}

/* chapter content */
.chapter {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 0 24px;
  text-align: center;
  color: white;
  pointer-events: none;
}
.chapter-map {
  width: 100%;
  max-width: 360px;
  opacity: 0;
}
.chapter-text {
  margin: 0;
  font-family: "Patrick Hand", cursive;
  font-weight: 400;
  font-style: normal;
  font-size: clamp(24px, 7.5vw, 34px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
}
.chapter-btn {
  opacity: 0;
  background: rgba(
    255,
    255,
    255,
    0.2
  ); /* the red button doesn't fit the blue theme */
}

/* timing: blue spreads first, then map, text, button */
.chapter2 .chapter-map {
  opacity: 1;
  transition: opacity 0.8s ease 1.6s;
}
.chapter2 .chapter-text {
  opacity: 1;
  transition: opacity 0.8s ease 2.2s;
}

/* ---------- chapter 3 ---------- */

/* chapter 2 content leaves (the extra class beats the earlier timing rules) */
.chapter2.chapter3 .chapter-map,
.chapter2.chapter3 .chapter-text,
.chapter2.chapter3 .chapter-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.chapter3-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* two models side by side in the top half */
.duo {
  position: absolute;
  top: 6%;
  left: 0;
  right: 0;
  height: 38%;
  display: flex;
  gap: 8px;
  padding: 0 12px;
  opacity: 0;
}
.duo-model {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.duo-model canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.c3-text {
  position: absolute;
  top: 52%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: white;
  font-family: "Patrick Hand", cursive;
  font-weight: 400;
  font-style: normal;
  font-size: clamp(22px, 6.5vw, 30px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
}

.c3-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
}

/* timing: old content fades (0.4s), then models, text, button */
.chapter3 .duo {
  opacity: 1;
  transition: opacity 0.8s ease 0.8s;
}
.chapter3 .c3-text {
  opacity: 1;
  transition: opacity 0.8s ease 1.6s;
}

/* blue backdrop leaves when chapter 3 starts */
.chapter2.chapter3 .blue-bg {
  opacity: 0;
  transition: opacity 0.6s ease;
}

/* ---------- chapter 4 ---------- */

/* chapter 3 content leaves */
.chapter3.chapter4 .duo,
.chapter3.chapter4 .c3-text,
.chapter3.chapter4 .c3-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.chapter4-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.c4-rover {
  position: absolute;
  top: 6%;
  left: 10%;
  right: 10%;
  height: 38%;
  opacity: 0;
}
.c4-rover canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.c4-text {
  position: absolute;
  top: 52%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: white;
  font-family: "Patrick Hand", cursive;
  font-weight: 400;
  font-style: normal;
  font-size: clamp(22px, 6.5vw, 30px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
}

.c4-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
}

/* timing: old content fades (0.4s), then rover, text, button */
.chapter4 .c4-rover {
  opacity: 1;
  transition: opacity 0.8s ease 0.8s;
}
.chapter4 .c4-text {
  opacity: 1;
  transition: opacity 0.8s ease 1.6s;
}

/* ---------- chapter 5 ---------- */

/* chapter 4 content leaves */
.chapter4.chapter5 .c4-rover,
.chapter4.chapter5 .c4-text,
.chapter4.chapter5 .c4-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* blueprint background (the grid is a fallback if the image is missing) */
.blueprint-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  background-color: #0a2a5e;
  background-image:
    url("/images/blueprint.jpg"),
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size:
    cover,
    28px 28px,
    28px 28px;
  background-position: center;
}
.chapter5 .blueprint-bg {
  opacity: 1;
  transition: opacity 1s ease 0.4s;
}

.chapter5-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.c5-stage {
  position: absolute;
  top: 4%;
  left: 0;
  right: 0;
  height: 62%;
  opacity: 0;
  pointer-events: none;
  touch-action: none;
}

.c5-text {
  position: absolute;
  bottom: 130px;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: white;
  font-family: "Anton SC", sans-serif;
  font-size: clamp(20px, 6vw, 28px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
}

.c5-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
}

/* timing: old content fades, blueprint fades in, then rocket and text */
.chapter5 .c5-stage {
  opacity: 1;
  pointer-events: auto; /* so the payload can be dragged */
  transition: opacity 0.8s ease 1.2s;
}
.chapter5 .c5-text {
  opacity: 1;
  transition: opacity 0.8s ease 1.8s;
}

/* after the payload is placed */
.rocket-done .c5-stage {
  pointer-events: none;
}
.rocket-done .c5-btn {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.6s ease 0.3s;
}

/* text swap after the part lands */
.c5-text {
  transition: opacity 0.3s ease;
}
.c5-text.swapping {
  opacity: 0 !important;
}

/* ---------- chapter 6 ---------- */

/* pure CSS launch scene: a daytime Earth sky, no clouds */
.launch-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    #14498f 0%,
    #2f6cb0 30%,
    #6ea3d4 52%,
    #b3d2e8 62%,
    #d8e8f2 66%,
    transparent 66.5%
  );
}

/* the almost-flat brown ground (the rocket stands where it meets the horizon) */
.launch-bg::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  background: linear-gradient(to bottom, #9a6a3f 0%, #7d5230 22%, #63401f 100%);
  /* horizon line with a few centimeters of bump - almost flat */
  clip-path: polygon(
    0% 1.6%,
    14% 0.7%,
    30% 1.4%,
    48% 0.3%,
    62% 1.1%,
    80% 0.4%,
    100% 1.2%,
    100% 100%,
    0% 100%
  );
}

/* a thin haze band where the ground meets the sky */
.launch-bg::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 32.5%;
  height: 4%;
  background: linear-gradient(to bottom, transparent, rgba(216, 232, 242, 0.5));
}

/* the gray launch pad, centered where the rocket stands */
.launch-stage {
  position: absolute;
  left: 50%;
  bottom: 34.6%; /* its top surface meets the rocket's base, its bottom sits on the horizon */
  width: 30%;
  height: 6%;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, #8d9199 0%, #7c8089 55%, #6d7179 100%);
  border-radius: 3px;
}
/* the darker front face, a little of depth */
.launch-stage::before {
  content: "";
  position: absolute;
  left: -1.5%;
  right: -1.5%;
  top: 100%;
  height: 38%;
  background: #52565e;
  border-radius: 0 0 3px 3px;
}
/* the soft shadow on the ground */
.launch-stage::after {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -9%;
  height: 46%;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0.4) 0%,
    transparent 70%
  );
}

/* blueprint fades out, then the launch photo fades in */
.chapter6 .blueprint-bg {
  opacity: 0;
  transition: opacity 1s ease;
}
.chapter6 .launch-bg {
  opacity: 1;
  transition: opacity 1s ease 0.8s;
}

/* screen shake while the rocket launches */
.launching .c5-stage,
.launching .launch-bg {
  animation: rumble 0.09s linear infinite;
}
@keyframes rumble {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-2px, 1px);
  }
  50% {
    transform: translate(2px, -1px);
  }
  75% {
    transform: translate(-1px, -2px);
  }
  100% {
    transform: translate(0, 0);
  }
}

/* the button hides while the rocket is flying, then comes back */
.launching .c5-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* button hidden until the voiceover ends */
.btn.wait-voice {
  opacity: 0;
  pointer-events: none;
}

/* "Tap to begin" hint, only shown if the browser blocks autoplay */
.tap-hint {
  position: absolute;
  bottom: 72px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  color: white;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.tap-hint.show {
  opacity: 1;
  animation: hint-pulse 1.6s ease-in-out infinite;
}
@keyframes hint-pulse {
  50% {
    opacity: 0.4;
  }
}

/* text + instruction stacked above the continue button */
.c5-caption {
  position: absolute;
  bottom: 130px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.c5-hint {
  margin: 0;
  padding: 6px 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font-size: 14px;
  letter-spacing: 1px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.c5-hint.show {
  opacity: 1;
}

/* ---------- chapter 6 ---------- */

/* chapter 5 text and button leave (the stage with the rocket stays) */
.chapter5.chapter6 .c5-caption,
.chapter5.chapter6 .c5-text,
.chapter5.chapter6 .c5-hint {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.chapter5.chapter6 .c5-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.chapter6-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* the story text sits on the brown ground, under the launch pad
   (white on brown reads better than white on the blue sky) */
.c6-text {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  bottom: 6%;
  text-align: center;
  color: white;
  font-family: "Anton SC", sans-serif;
  font-size: clamp(20px, 6vw, 28px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.c6-text.show {
  opacity: 1;
}

/* launch and continue sit in the same spot; only one is shown at a time */
.c6-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  pointer-events: none;
}
.c6-btn.ready {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.6s ease;
}

/* ---------- chapter 7 ---------- */

/* chapter 6 content leaves */
.chapter6.chapter7 .c5-stage,
.chapter6.chapter7 .launch-bg {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.chapter6.chapter7 .chapter6-scene {
  opacity: 0;
  visibility: hidden; /* also blocks the hidden buttons from being clicked */
  transition:
    opacity 0.5s ease,
    visibility 0s 0.5s;
}

.chapter7-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* every scene fades in and out by itself */
.c7-scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.8s ease,
    visibility 0s 0.8s;
}
#chapter7[data-scene="1"] .s1,
#chapter7[data-scene="2"] .s2,
#chapter7[data-scene="3"] .s3 {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.8s ease;
}

/* canvases fill their boxes */
.s1-mars canvas,
.s1-capsule canvas,
.s2-capsule canvas,
.s3-airbag canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ----- scene 1: flying to a small Mars ----- */
.s1-focus {
  position: absolute;
  left: 50%;
  top: 40%;
  width: 0;
  height: 0;
}
.s1-mars {
  position: absolute;
  left: -75px;
  top: -75px;
  width: 150px; /* Mars size */
  height: 150px;
}
.s1-capsule {
  position: absolute;
  left: -130px;
  top: -130px;
  width: 260px; /* starting size, close to the viewer */
  height: 260px;
  opacity: 0;
  transform: translate(170px, 260px) scale(1);
}
.go1 .s1-capsule {
  animation: s1-fly var(--s1-flight, 10000ms) cubic-bezier(0.25, 0.6, 0.35, 1)
    forwards;
}
/* starts large at the side, shrinks as it gets farther, disappears into Mars */
@keyframes s1-fly {
  0% {
    transform: translate(170px, 260px) scale(1);
    opacity: 1;
  }
  92% {
    transform: translate(8px, 6px) scale(0.09);
    opacity: 1;
  }
  100% {
    transform: translate(0, 0) scale(0.07);
    opacity: 0;
  }
}

/* ----- red atmosphere (scene 2 and 3) ----- */
.mars-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    #2a0d08 0%,
    #7a2410 35%,
    #c2501f 70%,
    #e8894a 100%
  );
}
.sky-on .mars-sky {
  opacity: 1;
  transition: opacity 1.2s ease;
}

/* wind streaks move from the bottom right to the top left (JS creates them) */
.wind {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.wind span {
  position: absolute;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    rgba(255, 235, 210, 0.9),
    rgba(255, 235, 210, 0)
  );
  transform: rotate(45deg);
  opacity: 0;
  animation: wind-blow linear infinite;
}
@keyframes wind-blow {
  0% {
    transform: rotate(45deg) translateX(0);
    opacity: 0;
  }
  15% {
    opacity: var(--o);
  }
  85% {
    opacity: var(--o);
  }
  100% {
    transform: rotate(45deg) translateX(-900px);
    opacity: 0;
  }
}

/* ----- scene 2: the capsule falls, swaying left and right ----- */
.s2-capsule {
  position: absolute;
  left: 50%;
  top: 28%;
  width: 230px;
  height: 230px;
  margin-left: -115px;
  filter: drop-shadow(0 0 24px rgba(255, 150, 60, 0.75)); /* heat glow */
}
.go2 .s2-capsule {
  animation: sway 3.4s ease-in-out infinite;
}
@keyframes sway {
  0%,
  100% {
    transform: translateX(-30px) rotate(-14deg);
  }
  50% {
    transform: translateX(30px) rotate(14deg);
  }
}

/* ----- scene 3: land + bouncing airbag ----- */
.s3-land {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 33%;
  transform: translateY(105%);
  transition: transform 1s ease;
  background:
    radial-gradient(
      circle at 15% 40%,
      rgba(0, 0, 0, 0.25) 0 6px,
      transparent 7px
    ),
    radial-gradient(
      circle at 62% 55%,
      rgba(0, 0, 0, 0.2) 0 9px,
      transparent 10px
    ),
    radial-gradient(
      circle at 85% 35%,
      rgba(255, 255, 255, 0.08) 0 5px,
      transparent 6px
    ),
    linear-gradient(to bottom, #a8481f 0%, #6b2a12 60%, #3d170a 100%);
  clip-path: polygon(
    0 14%,
    12% 6%,
    28% 12%,
    45% 3%,
    63% 10%,
    80% 5%,
    100% 12%,
    100% 100%,
    0 100%
  );
}
.go3 .s3-land {
  transform: none;
}

.s3-airbag {
  position: absolute;
  left: 50%;
  bottom: calc(30% - 24px); /* tweak so the airbag rests on the land */
  width: 190px;
  height: 190px;
  margin-left: -95px;
  transform: translate(-70px, -100vh);
}
.go3 .s3-airbag {
  animation: airbag-bounce var(--bounce-time, 3600ms) linear
    var(--bounce-delay, 1200ms) both;
}
/* falls, then bounces 3 times, each lower than the last, then rests */
@keyframes airbag-bounce {
  0% {
    transform: translate(-70px, -100vh) rotate(0deg);
    animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  }
  28% {
    transform: translate(-30px, 0) rotate(120deg);
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  42% {
    transform: translate(0, -200px) rotate(250deg);
    animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  }
  56% {
    transform: translate(25px, 0) rotate(360deg);
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  66% {
    transform: translate(40px, -80px) rotate(430deg);
    animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  }
  76% {
    transform: translate(50px, 0) rotate(490deg);
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  83% {
    transform: translate(54px, -26px) rotate(520deg);
    animation-timing-function: cubic-bezier(0.55, 0.085, 0.68, 0.53);
  }
  90% {
    transform: translate(58px, 0) rotate(540deg);
    animation-timing-function: ease-out;
  }
  100% {
    transform: translate(60px, 0) rotate(550deg);
  }
}

/* ----- sentence + button ----- */
.c7-text {
  position: absolute;
  bottom: 130px;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  color: white;
  font-family: "Anton SC", sans-serif;
  font-size: clamp(20px, 6vw, 28px);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.5s ease;
}
.c7-text.show {
  opacity: 1;
}
.c7-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  pointer-events: none;
}
.c7-btn.ready {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.6s ease;
}

/* ---------- chapter 8 ---------- */

/* chapter 7 content leaves; the sky and the land stay */
.chapter7.chapter8 .c7-text,
.chapter7.chapter8 .c7-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.chapter8 .s3-airbag {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.chapter8 .wind {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.chapter8-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* ----- the rover (JS moves it) ----- */
.rover8 {
  position: absolute;
  left: 0;
  bottom: 33%; /* the top line of the land */
  width: 170px;
  height: 130px;
  opacity: 0;
  will-change: transform;
  filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.35));
}
.chapter8 .rover8 {
  opacity: 1;
}
.rover-flip,
.rover-model {
  position: absolute;
  inset: 0;
}
.rover-model canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}
/* small bumps while driving */
.rover8.driving .rover-model {
  animation: rover-bob 0.35s ease-in-out infinite;
}
@keyframes rover-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-2px) rotate(-0.8deg);
  }
}

/* ----- sentence + guide message (top of the page) ----- */
.c8-caption {
  position: absolute;
  top: 9%;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  pointer-events: none;
}
.c8-text {
  margin: 0;
  text-align: center;
  color: white;
  font-family: "Anton SC", sans-serif;
  font-size: clamp(18px, 5.2vw, 24px);
  line-height: 1.35;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.c8-text.show {
  opacity: 1;
}
.c8-hint {
  margin: 0;
  padding: 6px 16px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: white;
  font-size: 14px;
  letter-spacing: 1px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.c8-hint.show {
  opacity: 1;
}

/* ----- arrows ----- */
.c8-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 64px;
  display: flex;
  justify-content: center;
  gap: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.c8-controls.show {
  opacity: 1;
}
.c8-arrow {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  pointer-events: none;
  touch-action: none; /* holding a button must not scroll the page */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.1s,
    opacity 0.2s,
    background 0.2s;
}
.c8-controls.show .c8-arrow {
  pointer-events: auto;
}
.c8-arrow:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.35);
}
.c8-arrow.blocked {
  /* the left wall */
  opacity: 0.3;
  cursor: not-allowed;
}

/* ----- continue ----- */
.c8-btn {
  position: absolute;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.2);
  opacity: 0;
  pointer-events: none;
}
.c8-btn.ready {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.6s ease;
}

/* ---------- chapter 9 ---------- */

/* chapter 8 content leaves, the old land slides away */
.chapter8.chapter9 .s3-land {
  transform: translateY(105%);
}
.chapter8.chapter9 #c8Text {
  opacity: 0;
}
.chapter8.chapter9 #continue8 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* the new land: another shape (it sits under the rover) */
.land9 {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 36%; /* the rover's bottom is set to the same 36% in JS */
  z-index: 0;
  pointer-events: none;
  transform: translateY(105%);
  transition: transform 1s ease 0.3s;
  background:
    radial-gradient(
      ellipse 22px 12px at 18% 32%,
      rgba(0, 0, 0, 0.35) 0 60%,
      transparent 62%
    ),
    radial-gradient(
      ellipse 34px 16px at 52% 52%,
      rgba(0, 0, 0, 0.3) 0 60%,
      transparent 62%
    ),
    radial-gradient(
      ellipse 18px 9px at 82% 38%,
      rgba(255, 255, 255, 0.1) 0 60%,
      transparent 62%
    ),
    radial-gradient(
      ellipse 50px 20px at 36% 70%,
      rgba(0, 0, 0, 0.25) 0 60%,
      transparent 62%
    ),
    linear-gradient(to bottom, #8f4425 0%, #5a2410 55%, #2b0f07 100%);
  clip-path: polygon(
    0 6%,
    14% 2%,
    28% 10%,
    42% 18%,
    56% 12%,
    70% 4%,
    84% 12%,
    100% 6%,
    100% 100%,
    0 100%
  );
}
.chapter9 .land9 {
  transform: none;
}

/* the broken rover */
.rover8.broken {
  transform-origin: 50% 100%; /* it tilts around its wheels */
  transition: opacity 0.8s ease;
}
.rover8.broken .rover-flip {
  transition: transform 0.25s ease; /* a short turn-around when it changes direction */
}
.rover8.broken.driving .rover-model {
  animation: rover-shake 0.14s linear infinite;
}
@keyframes rover-shake {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(-2px, 1px) rotate(-2deg);
  }
  50% {
    transform: translate(2px, -2px) rotate(1.5deg);
  }
  75% {
    transform: translate(-1px, -1px) rotate(-1deg);
  }
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
}

/* ---------- chapter 10 ---------- */

/* chapter 9 content leaves, the old land slides away */
.chapter9.chapter10 #c9Text {
  opacity: 0;
}
.chapter9.chapter10 #continue9 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter9.chapter10 .land9 {
  transform: translateY(105%);
}

/* the storm: a dusty sky that fades in over the red one */
.storm {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
  background: linear-gradient(
    to bottom,
    #4a2a14 0%,
    #8a5a2e 40%,
    #c28a4c 75%,
    #d9a566 100%
  );
}
.chapter10 .storm {
  opacity: 1;
}
/* a weak sun behind the dust */
.storm::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 72% 18%,
    rgba(255, 226, 170, 0.55) 0,
    rgba(255, 200, 120, 0.25) 60px,
    transparent 170px
  );
  animation: sun-dim 5s ease-in-out infinite;
}
@keyframes sun-dim {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}
/* gusts that darken the whole sky for a moment */
.storm::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(60, 30, 10, 0.5);
  opacity: 0;
  animation: gust 6s ease-in-out infinite;
}
@keyframes gust {
  0% {
    opacity: 0.05;
  }
  30% {
    opacity: 0.35;
  }
  55% {
    opacity: 0.1;
  }
  80% {
    opacity: 0.4;
  }
  100% {
    opacity: 0.05;
  }
}

/* the dust pieces (JS creates them): they fly from the right to the left */
.dust-streak,
.dust-cloud {
  position: absolute;
  pointer-events: none;
  animation: dust-blow linear infinite;
}
.dust-streak {
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    rgba(246, 208, 150, var(--o)),
    rgba(246, 208, 150, 0)
  );
}
.dust-cloud {
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(222, 170, 104, var(--o)) 0%,
    rgba(222, 170, 104, 0) 70%
  );
}
@keyframes dust-blow {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(calc(var(--travel) * -1 - 100%), var(--dy), 0);
  }
}

/* dust in front of the rover */
.dust-front {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.chapter10 .dust-front {
  opacity: 1;
}

/* the dusty ground (the rover's bottom is set to the same 32% in JS) */
.land10 {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 32%;
  z-index: 0;
  pointer-events: none;
  transform: translateY(105%);
  transition: transform 1s ease 0.3s;
}
.land10::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(220, 170, 110, 0.35), transparent 60%),
    linear-gradient(to bottom, #8d5a35 0%, #5a361d 55%, #2a170c 100%);
  clip-path: polygon(
    0 7%,
    16% 4%,
    34% 8%,
    52% 3%,
    70% 7%,
    86% 4%,
    100% 6%,
    100% 100%,
    0 100%
  );
}
.chapter10 .land10 {
  transform: none;
}

/* the rover is dark and weak when its energy is low */
.rover8 .rover-model {
  transition: filter 0.4s ease;
}
.rover8.drained .rover-model {
  filter: brightness(0.65) saturate(0.8);
}

/* ---------- chapter 11 ---------- */

/* chapter 9 content leaves, the old land slides away */
.chapter9.chapter11 #c9Text {
  opacity: 0;
}
.chapter9.chapter11 #continue9 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter9.chapter11 .land9 {
  transform: translateY(105%);
}

/* chapter 10 content leaves, the storm clears */
.chapter10.chapter11 #c10Text {
  opacity: 0;
}
.chapter10.chapter11 #continue10 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter10.chapter11 .land10 {
  transform: translateY(105%);
}
.chapter10.chapter11 .storm,
.chapter10.chapter11 .dust-front {
  opacity: 0;
  transition: opacity 1s ease;
}

/* the red background becomes slightly different: a warmer, dustier sky fades in over the old one */
.mars-sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    #3a1208 0%,
    #8c2e12 35%,
    #d0602a 70%,
    #f0a060 100%
  );
  opacity: 0;
  transition: opacity 1.5s ease;
}
.chapter11 .mars-sky::after {
  opacity: 1;
}

/* the new land: its surface is the ::before, the rocks (JS) sit on top of it so they can poke above the edge */
.land11 {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%; /* the rover's bottom is set to the same 34% in JS */
  z-index: 0;
  pointer-events: none;
  transform: translateY(105%);
  transition: transform 1s ease 0.3s;
}
.land11::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #a8552b 0%, #7a3418 55%, #3a160a 100%);
  clip-path: polygon(
    0 8%,
    18% 5%,
    36% 9%,
    54% 4%,
    72% 8%,
    88% 5%,
    100% 7%,
    100% 100%,
    0 100%
  );
}
.chapter11 .land11 {
  transform: none;
}

/* the brown rocks (clay and minerals) */
.rock11 {
  position: absolute;
  box-shadow:
    0 3px 4px rgba(0, 0, 0, 0.5),
    inset 2px 2px 3px rgba(255, 255, 255, 0.25),
    inset -2px -3px 4px rgba(0, 0, 0, 0.35);
}

/* the rover fades in on this land */
.chapter11 .rover8 {
  transition: opacity 0.8s ease;
}

/* the rover hops while celebrating */
.rover8.celebrate .rover-model {
  animation: rover-hop 0.55s ease-in-out infinite;
}
@keyframes rover-hop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-18px);
  }
}

/* ---------- chapter 12 ---------- */

/* chapter 11 content leaves, the old land slides away with its rocks */
.chapter11.chapter12 #c11Text {
  opacity: 0;
}
.chapter11.chapter12 #c11Hint,
.chapter11.chapter12 #c11Controls {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter11.chapter12 #continue11 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter11.chapter12 .confetti span {
  display: none;
}
.chapter11.chapter12 .land11 {
  transform: translateY(105%);
}

/* the new land: another shape (it sits under the rover) */
.land12 {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%; /* the rover's bottom is set to the same 30% in JS */
  z-index: 0;
  pointer-events: none;
  transform: translateY(105%);
  transition: transform 1s ease 0.3s;
}
.land12::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #9c4d28 0%, #642c14 55%, #2f1308 100%);
  clip-path: polygon(
    0 9%,
    15% 4%,
    33% 10%,
    50% 5%,
    68% 11%,
    85% 6%,
    100% 10%,
    100% 100%,
    0 100%
  );
}
.chapter12 .land12 {
  transform: none;
}

/* the speech bubble above the rover (JS moves it) */
.c12-bubble {
  position: absolute;
  left: 0;
  top: 0;
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 15px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.c12-bubble.show {
  opacity: 1;
}
.c12-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: inherit;
  border-right: 1px solid rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.6);
  transform: rotate(45deg);
}

/* the rover fades in on this land */
.chapter12 .rover8 {
  transition: opacity 0.8s ease;
}

/* a memory glitch: the rover freezes and flickers for a moment */
.rover8.glitch .rover-model {
  animation: rover-glitch 0.12s linear infinite;
  opacity: 0.6;
}
@keyframes rover-glitch {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-1px, 1px);
  }
  50% {
    transform: translate(2px, -1px);
  }
  75% {
    transform: translate(-1px, 0);
  }
}

/* confetti (JS creates the pieces) */
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3;
}
.confetti span {
  position: absolute;
  top: -24px;
  border-radius: 2px;
  animation: confetti-fall linear both;
}
@keyframes confetti-fall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(var(--dx), var(--fall), 0) rotate(var(--rot));
  }
}

/* ---------- chapter 13 ---------- */

/* chapter 12 content leaves, the old land slides away */
.chapter12.chapter13 #c12Text {
  opacity: 0;
}
.chapter12.chapter13 #c12Hint,
.chapter12.chapter13 #c12Controls {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter12.chapter13 #continue12 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter12.chapter13 .c12-bubble {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.chapter12.chapter13 .land12 {
  transform: translateY(105%);
}

/* the dense storm: a much darker sky, no visible sun (fades in over the warm one) */
.storm13 {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
  background: linear-gradient(
    to bottom,
    #1a0e06 0%,
    #3c2210 40%,
    #6b4520 75%,
    #8a6236 100%
  );
}
.chapter13 .storm13 {
  opacity: 1;
}
/* only a faint glow where the sun was, almost eaten by the dust */
.storm13::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 72% 18%,
    rgba(255, 220, 160, 0.3) 0,
    rgba(255, 200, 120, 0.12) 60px,
    transparent 160px
  );
}
/* the dust eats the whole sky in faster, heavier gusts than chapter 10 */
.storm13::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(35, 18, 8, 0.55);
  opacity: 0;
  animation: gust13 4s ease-in-out infinite;
}
@keyframes gust13 {
  0% {
    opacity: 0.15;
  }
  25% {
    opacity: 0.7;
  }
  50% {
    opacity: 0.25;
  }
  75% {
    opacity: 0.75;
  }
  100% {
    opacity: 0.15;
  }
}
/* a slow haze layer that adds density over the whole sky */
.storm13 .haze13 {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 200%;
  background: repeating-linear-gradient(
    100deg,
    rgba(70, 40, 18, 0.4) 0px,
    rgba(70, 40, 18, 0.4) 60px,
    rgba(90, 55, 25, 0.35) 130px,
    rgba(50, 28, 12, 0.4) 220px
  );
  animation: haze-drift 26s linear infinite;
}
@keyframes haze-drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(-50%, 0, 0);
  }
}

/* darker and more opaque dust than chapter 10's (same keyframes) */
.storm13 .dust-cloud,
.dust-front13 .dust-cloud {
  background: radial-gradient(
    ellipse at center,
    rgba(150, 105, 60, var(--o)) 0%,
    rgba(150, 105, 60, 0) 70%
  );
}
.storm13 .dust-streak,
.dust-front13 .dust-streak {
  background: linear-gradient(
    90deg,
    rgba(180, 140, 95, var(--o)),
    rgba(180, 140, 95, 0)
  );
}

/* dust in front of the rover */
.dust-front13 {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.chapter13 .dust-front13 {
  opacity: 1;
}

/* the dusty ground (the rover's bottom is set to the same 30% in JS) */
.land13 {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  z-index: 0;
  pointer-events: none;
  transform: translateY(105%);
  transition: transform 1s ease 0.3s;
}
.land13::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(180, 140, 95, 0.3), transparent 60%),
    linear-gradient(to bottom, #6e4525 0%, #432715 55%, #1c0f07 100%);
  clip-path: polygon(
    0 8%,
    14% 5%,
    32% 9%,
    50% 4%,
    66% 10%,
    82% 5%,
    100% 8%,
    100% 100%,
    0 100%
  );
}
.chapter13 .land13 {
  transform: none;
}

/* the rover fades in on this land */
.chapter13 .rover8 {
  transition: opacity 0.8s ease;
}

/* ---------- chapter 14 ---------- */

/* chapter 13 content leaves; the dense storm sky (and its glow) stays */
.chapter13.chapter14 #c13Text {
  opacity: 0;
}
.chapter13.chapter14 #c13Hint,
.chapter13.chapter14 #c13Controls {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter13.chapter14 #continue13 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.chapter13.chapter14 .land13 {
  transform: translateY(105%);
}
/* the storm effect stops, the dense atmosphere remains:
   the gusts and the haze drift are frozen (JS clears the dust pieces) */
.chapter14 .storm13::before {
  animation: none;
  opacity: 0.3;
}
.chapter14 .storm13 .haze13 {
  animation: none;
}
.chapter14 .storm13 .dust-cloud,
.chapter14 .storm13 .dust-streak,
.chapter14 .dust-front13 .dust-cloud,
.chapter14 .dust-front13 .dust-streak {
  animation-play-state: paused;
}
/* the storm sky now covers everything as a plain dark-dusty backdrop */
.chapter14 .storm13 {
  background: linear-gradient(
    to bottom,
    #241408 0%,
    #4a2d15 45%,
    #7a5429 75%,
    #a98150 100%
  );
}

/* the ground (the rover's bottom is set to the same 30% in JS) */
.land14 {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  z-index: 0;
  pointer-events: none;
  transform: translateY(105%);
  transition: transform 1s ease 0.3s;
}
.land14::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(180, 140, 95, 0.25), transparent 60%),
    linear-gradient(to bottom, #b08453 0%, #8f6239 55%, #5c3a1e 100%);
  clip-path: polygon(
    0 10%,
    16% 6%,
    34% 11%,
    52% 5%,
    70% 10%,
    86% 7%,
    100% 10%,
    100% 100%,
    0 100%
  );
}
.chapter14 .land14 {
  transform: none;
}

/* the dead rover: dark, grey, no life in it (JS adds .dead) */
.rover8.dead {
  filter: grayscale(0.85) brightness(0.55)
    drop-shadow(0 8px 6px rgba(0, 0, 0, 0.4));
}
.rover8.dead .rover-model {
  animation: none !important;
}
/* a short twitch when an arrow is pressed (JS toggles it for a moment) */
.rover8.twitch .rover-model {
  animation: rover-twitch 0.25s linear;
}
@keyframes rover-twitch {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  40% {
    transform: translate(2px, 1px) rotate(1deg);
  }
  70% {
    transform: translate(-1px, 0) rotate(-0.5deg);
  }
}

/* the "no signal" chip above the dead rover */
.c14-chip {
  position: absolute;
  left: 0;
  top: 0;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  letter-spacing: 1px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.c14-chip.show {
  opacity: 1;
}

/* ---------- chapter 15 ---------- */

/* chapter 14 leaves: the land slides away and the sky fades out,
   so the star background (.app) shows through again */
.chapter14.chapter15 #c14Text,
.chapter14.chapter15 #c14Chip {
  opacity: 0;
  transition: opacity 0.6s ease;
}
.chapter14.chapter15 .land14 {
  transform: translateY(105%);
}
.chapter15 .storm13 {
  opacity: 0;
  transition: opacity 1.6s ease;
}
/* the red Mars atmosphere (on since chapter 7) fades out too,
   and its wind streaks stop drifting */
.chapter15 .mars-sky {
  opacity: 0 !important;
  transition: opacity 1.6s ease;
}
.chapter15 .mars-sky .wind span {
  animation-play-state: paused;
}

/* the rover: a slow re-centering move, then it floats gently over the stars */
.chapter15 .rover8 {
  transition:
    opacity 0.8s ease,
    bottom 3s ease,
    transform 3s ease;
}
.rover8.drifting .rover-model {
  animation: rover-drift 4s ease-in-out infinite;
}
@keyframes rover-drift {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* ---------- chapter 16 ---------- */

/* chapter 15 content leaves */
.chapter15.chapter16 #c15Text {
  opacity: 0;
}
.chapter15.chapter16 #continue15 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#chapter16 {
  font-family: "Patrick Hand" !important;
}
/* the rover moves to the top of the page and scales down a bit,
   as if it is moving up into the sky (it keeps spinning: the 3D model) */
.chapter16 .rover8 {
  transition:
    opacity 0.8s ease,
    bottom 3s ease,
    transform 3s ease;
}

/* the title under the rover */
.c16-title {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  width: 90%;
  padding: 0 8% 16px;
  text-align: center;
  font-family: "Anton SC", sans-serif;
  font-size: 30px;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}
.c16-title.show {
  opacity: 1;
}

/* the achievements grid: 2 columns (JS fades the cards in one by one) */
.c16-grid {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 90%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}
.c16-card {
  padding: 12px 8px;
  border: 1px solid rgba(244, 217, 184, 0.35);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  color: #ffffff;
  font-family: "Patrick Hand", cursive;
  font-size: 15px;
  text-align: center;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
}
.c16-card.show {
  opacity: 1;
  transform: none;
}

/* ---------- chapter 17 ---------- */

/* chapter 16 content leaves: the title, the four cards and the button */
.chapter16.chapter17 #c16Title {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.chapter16.chapter17 .c16-card {
  opacity: 0;
  transform: none;
  transition: opacity 0.5s ease;
}
.chapter16.chapter17 #continue16 {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

/* the rover moves back to the middle of the page, full size again
   (the 3D model keeps spinning) */
.chapter17 .rover8 {
  transition:
    opacity 0.8s ease,
    bottom 3s ease,
    transform 3s ease;
}

/* "The End" at the top of the page */
.c17-end {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  font-family: "Anton SC", sans-serif;
  font-size: 44px;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}
.c17-end.show {
  opacity: 1;
}

/* the home button sits under the rover, not at the bottom edge */
.c8-btn#home17 {
  bottom: auto;
  top: 60%;
}
