:root {
  color-scheme: dark;
  font-family: Georgia, "Times New Roman", serif;
  --ink: #f9efd2;
  --ink-dark: #2b2118;
  --focus: #fff0a4;
  --coo-left: 33%;
  --coo-bottom: 10%;
  --coo-scale: 0.86;
  --coo-facing: 1;
  --coo-duration: 1ms;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 20rem;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #142d37;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.interstitial-page {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #142d37;
}

.interstitial-page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0.22;
  background: repeating-linear-gradient(0deg, rgba(35, 24, 15, 0.08) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
}

.interstitial-plate,
.interstitial-plate img {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.interstitial-plate img {
  object-fit: cover;
  object-position: center;
}

.interstitial-copy {
  position: absolute;
  top: max(4.5%, env(safe-area-inset-top));
  left: clamp(1.25rem, 5vw, 5rem);
  z-index: 6;
  width: min(51vw, 48rem);
  color: var(--ink);
  pointer-events: none;
}

.interstitial-copy h1 {
  max-width: 18ch;
  margin: 0;
  color: #fff8e9;
  font-size: clamp(2.2rem, 5.5vw, 6.2rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.045em;
  text-wrap: balance;
  text-shadow:
    0 2px 0 rgba(22, 34, 31, 0.7),
    0 6px 20px rgba(7, 20, 23, 0.58);
}

.interstitial-hint {
  display: inline-block;
  max-width: 34rem;
  margin: 1rem 0 0;
  padding: 0.45rem 0.72rem;
  border: 1px solid rgba(255, 244, 215, 0.42);
  border-radius: 0.3rem;
  background: rgba(16, 42, 45, 0.74);
  box-shadow: 0 0.5rem 1.5rem rgba(10, 22, 22, 0.2);
  color: #fff8e9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.78rem, 1.35vw, 1.05rem);
  line-height: 1.35;
  letter-spacing: 0.015em;
}

.board-copy {
  position: absolute;
  top: 55.5%;
  left: 66%;
  z-index: 5;
  display: grid;
  width: 27.5%;
  height: 20.5%;
  padding: 0.8rem;
  place-items: center;
  color: var(--ink-dark);
  text-align: center;
  transform: rotate(0.3deg);
}

.board-copy[data-empty="true"] {
  pointer-events: none;
}

.board-copy > p:not(.visually-hidden) {
  margin: 0;
  white-space: pre-line;
  font-size: clamp(1.35rem, 3.2vw, 3.7rem);
  font-weight: 800;
  line-height: 0.93;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  text-shadow: 0 1px 0 rgba(255, 227, 159, 0.45);
}

.board-copy:has(.countdown:not([hidden])) > p:not(.visually-hidden) {
  align-self: end;
  font-size: clamp(0.9rem, 1.55vw, 1.7rem);
  line-height: 1.05;
}

.countdown {
  align-self: start;
  width: 100%;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.countdown span {
  font-size: clamp(1.1rem, 2.25vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.countdown i {
  padding: 0 0.04em;
  font-size: clamp(0.9rem, 1.7vw, 2rem);
  font-style: normal;
}

.countdown small {
  display: block;
  margin-top: 0.32rem;
  font-family: Arial, sans-serif;
  font-size: clamp(0.42rem, 0.7vw, 0.72rem);
  font-weight: 700;
  letter-spacing: 0.09em;
}

.ground-prop {
  position: absolute;
  z-index: 2;
  display: block;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1.25rem 0.9rem rgba(14, 25, 14, 0.34));
}

.ground-prop--mechanic {
  left: 18%;
  bottom: 1.5%;
  width: clamp(15rem, 31vw, 34rem);
}

.ground-prop--tools {
  left: 12%;
  bottom: 4%;
  width: clamp(7rem, 12vw, 13rem);
}

.ground-prop--calf {
  right: -1.8%;
  bottom: 35%;
  width: clamp(4rem, 8.5vw, 8.5rem);
  clip-path: inset(0 38% 0 0);
  opacity: 0.92;
  filter: drop-shadow(0 0.7rem 0.5rem rgba(14, 25, 14, 0.25));
}

.interstitial-coo {
  position: absolute;
  left: var(--coo-left);
  bottom: var(--coo-bottom);
  z-index: 4;
  width: clamp(15rem, 29vw, 33rem);
  aspect-ratio: 1 / 1;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 48%;
  outline: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  transform: translateX(-50%) scale(var(--coo-scale));
  transform-origin: center bottom;
  transition:
    left var(--coo-duration) ease-in-out,
    bottom var(--coo-duration) ease-in-out,
    transform var(--coo-duration) ease-in-out;
  filter: drop-shadow(0 1.5rem 1.05rem rgba(12, 28, 16, 0.35));
}

.interstitial-coo:focus-visible {
  outline: 0.28rem solid var(--focus);
  outline-offset: 0.28rem;
  box-shadow: 0 0 0 0.6rem rgba(25, 56, 54, 0.76);
}

.interstitial-coo[data-dragging="true"] {
  z-index: 7;
  cursor: grabbing;
  transition: none;
}

.interstitial-coo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  transform: scaleX(var(--coo-facing));
  transform-origin: center bottom;
}

.interstitial-page[data-phase="wandering"] .interstitial-coo img {
  animation: cooWalk 850ms ease-in-out infinite;
}

.interstitial-page[data-phase="parachuting"] .interstitial-coo {
  z-index: 7;
  transition: none;
}

.interstitial-page[data-phase="parachuting"] .interstitial-coo::before,
.interstitial-page[data-phase="parachuting"] .interstitial-coo::after {
  content: "";
  position: absolute;
  left: 50%;
  pointer-events: none;
}

.interstitial-page[data-phase="parachuting"] .interstitial-coo::before {
  top: -27%;
  z-index: 2;
  width: 68%;
  height: 32%;
  border: 0.24rem solid #2f2a24;
  border-bottom-width: 0.14rem;
  border-radius: 50% 50% 12% 12%;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.48), transparent 22%),
    repeating-linear-gradient(90deg, #b94742 0 18%, #fff2d8 18% 36%);
  box-shadow: 0 0.7rem 1rem rgba(26, 25, 16, 0.35);
  transform: translateX(-50%) rotate(-2deg);
  animation: parachuteBob 650ms ease-in-out infinite alternate;
}

.interstitial-page[data-phase="parachuting"] .interstitial-coo::after {
  top: 0;
  z-index: 0;
  width: 48%;
  height: 28%;
  transform: translateX(-50%);
  background:
    linear-gradient(63deg, transparent 48%, #2f2a24 49% 51%, transparent 52%),
    linear-gradient(-63deg, transparent 48%, #2f2a24 49% 51%, transparent 52%);
}

.recovery-link {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 7;
  min-height: 2.8rem;
  padding: 0.72rem 1rem;
  border: 0.12rem solid rgba(255, 239, 198, 0.74);
  border-radius: 0.25rem;
  background: rgba(21, 52, 49, 0.9);
  box-shadow: 0 0.6rem 1.2rem rgba(8, 20, 17, 0.35);
  color: #fff5d9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
}

.recovery-link:hover {
  background: rgba(45, 81, 61, 0.96);
}

.recovery-link:focus-visible {
  outline: 0.2rem solid var(--focus);
  outline-offset: 0.18rem;
}

@keyframes cooWalk {
  0%, 100% { transform: scaleX(var(--coo-facing)) translateY(0) rotate(0); }
  50% { transform: scaleX(var(--coo-facing)) translateY(0.34rem) rotate(-0.7deg); }
}

@keyframes parachuteBob {
  to { transform: translateX(-50%) translateY(0.3rem) rotate(2deg); }
}

@media (max-aspect-ratio: 4/5) {
  .interstitial-plate {
    background: linear-gradient(#142d37 0%, #1b3a41 34%, #615326 100%);
  }

  .interstitial-plate img {
    object-fit: cover;
    object-position: 56% center;
  }

  .interstitial-copy {
    top: max(2.5rem, env(safe-area-inset-top));
    left: 1rem;
    width: calc(100% - 2rem);
    text-align: center;
  }

  .interstitial-copy h1 {
    max-width: 11ch;
    margin-inline: auto;
    font-size: clamp(2.25rem, 12vw, 4rem);
    line-height: 0.98;
  }

  .interstitial-hint {
    max-width: 25rem;
    margin-top: 0.7rem;
    font-size: clamp(0.72rem, 3.3vw, 0.9rem);
  }

  .board-copy {
    top: 46.2%;
    left: 45%;
    width: 55%;
    height: 20.2%;
    padding: 0.35rem;
  }

  .board-copy > p:not(.visually-hidden) {
    font-size: clamp(1.1rem, 7vw, 2.15rem);
  }

  .board-copy:has(.countdown:not([hidden])) > p:not(.visually-hidden) {
    font-size: clamp(0.68rem, 3.6vw, 1rem);
  }

  .countdown span {
    font-size: clamp(0.82rem, 5vw, 1.35rem);
  }

  .countdown i {
    font-size: clamp(0.66rem, 3.8vw, 1rem);
  }

  .countdown small {
    margin-top: 0.15rem;
    font-size: clamp(0.5rem, 2.1vw, 0.62rem);
    letter-spacing: 0.02em;
  }

  .interstitial-coo {
    width: min(62vw, 19rem);
  }

  .ground-prop--mechanic {
    left: 2%;
    bottom: 1%;
    width: min(61vw, 18rem);
  }

  .ground-prop--tools {
    left: 2%;
    bottom: 3%;
    width: min(24vw, 8rem);
  }

  .ground-prop--calf {
    right: -8%;
    bottom: 40%;
    width: min(25vw, 8rem);
    clip-path: inset(0 46% 0 0);
  }

  .recovery-link {
    right: auto;
    left: max(0.8rem, env(safe-area-inset-left));
    bottom: max(0.8rem, env(safe-area-inset-bottom));
    min-height: 2.5rem;
    padding: 0.62rem 0.8rem;
    font-size: 0.88rem;
  }
}

@media (prefers-contrast: more) {
  .interstitial-copy h1,
  .interstitial-hint {
    text-shadow: 0 0 0.2rem #000, 0 0.2rem 0.6rem #000;
  }

  .interstitial-hint,
  .recovery-link {
    border-width: 0.18rem;
    background: #12332f;
  }
}

@media (prefers-reduced-motion: reduce) {
  .interstitial-coo,
  .interstitial-coo img,
  .interstitial-page[data-phase="parachuting"] .interstitial-coo::before {
    animation: none !important;
    transition: none !important;
  }
}
