body.fox-level #level .scene {
  background: #9097ed;
  overflow: hidden;
}

body.fox-level #level .header::before {
  content: '';
  position: absolute;
  inset: 18% 27% 0 32%;
  background:
    url("assets/fox-header-cloud.png") 54% 58% / auto 87% no-repeat,
    linear-gradient(165deg, #8e98ec 4%, #c4abed 52%, #ffd3b6 100%);
  mask-image: linear-gradient(to right, transparent, #000 16%, #000 85%, transparent);
  pointer-events: none;
}

body.fox-level #level .header h1 {
  display: grid;
  place-items: center;
  background: none;
  color: #78260c;
  -webkit-text-stroke: 4px #fff7e7;
  paint-order: stroke fill;
  filter: none;
  font-size: clamp(14px, 3vw, 34px);
}

body.fox-level #level .practice {
  background: #fff1df url("assets/fox-practice-garden.png") center / 100% 100% no-repeat;
}

/* Give the finale the same scene height as the spelling rounds on desktop. */
body.fox-level #level.game.fox-wedding-stage:has(#reading:not([hidden])) {
  --practice-height: 270px;
}

@media (max-width: 600px), (pointer: coarse) {
  body.fox-level #level.game.fox-wedding-stage:has(#reading:not([hidden])) {
    --practice-height: 230px;
  }
}

@media (max-width: 600px), (pointer: coarse) {
  body.fox-level #level .header h1 { -webkit-text-stroke-width: 2px; }
}

#foxWorld {
  position: absolute;
  inset: 0 auto auto 0;
  background: center / 100% 100% no-repeat;
  pointer-events: none;
}

#foxBalloon {
  position: absolute;
  width: auto;
  max-width: none;
  transform: translate(-51%, -97.4%);
  transform-origin: 51% 97.4%;
  animation: fox-balloon-sway 3.8s ease-in-out infinite alternate;
}

#foxBalloon.landed {
  animation: none;
  /* The flat edge of the grounded sprite sits at 1467 of 1536 pixels. */
  transform: translate(-51%, -95.5%);
}

#foxBalloon.wedding {
  transform: translate(-50%, -98.9%);
  transform-origin: 50% 98.9%;
}

#foxWeddingCloud {
  position: absolute;
  transform: translate(-50%, -33%);
}

@media (prefers-reduced-motion: reduce) {
  #foxBalloon.wedding { animation: none; }
}

#foxLandingShadow {
  position: absolute;
  aspect-ratio: 10 / 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse, #3037119c 20%, transparent 73%);
}

@keyframes fox-balloon-sway {
  from { rotate: -2deg; }
  to { rotate: 2deg; }
}

.fox-upright {
  position: absolute;
  aspect-ratio: 1;
  transform: translate(-50%, calc(var(--fox-foot, -98%) + var(--fox-gait-lift, 0px)));
  background: url("assets/fox-upright-run.png") 0 center / 300% 100% no-repeat;
  filter: drop-shadow(0 2px 1px #382a1755);
}

.fox-upright[data-pose="stride"] {
  --fox-foot: -93%;
  background-position-x: 50%;
}

.fox-upright[data-pose="reverse"] {
  --fox-foot: -92%;
  background-position-x: 100%;
}

.fox-upright[data-pose="pass"] {
  --fox-foot: -96%;
  background: url("assets/fox-upright-passing.png") center / contain no-repeat;
}

#foxWalker.inside { filter: brightness(.72) saturate(.83); }

#foxDoorForeground {
  position: absolute;
  inset: 0;
  background: url("assets/fox-castle-garden.png") center / 100% 100% no-repeat;
  clip-path: polygon(75.4% 14%, 90.7% 14%, 90.7% 59%, 86.5% 59%,
    86.4% 33%, 84.8% 27%, 82.6% 24%, 80.9% 27%, 80.7% 59%, 75.4% 59%);
}

#foxCourtyard {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #3d2948;
  animation: fox-courtyard-appear .65s ease-out;
}

#foxCourtyardArt {
  position: relative;
  aspect-ratio: 3 / 1;
}

#foxCourtyardArt > img:first-child {
  display: block;
  width: 100%;
}

#foxCourtyardRunner {
  width: 15.8%;
}

@keyframes fox-courtyard-appear {
  from { opacity: 0; }
}
