#mascot-game[data-episode] {
  --mit-figure: var(--mit-work-size, 139px);
}
#mascot-game[data-episode] .mit-actor {
  width: var(--mit-figure);
  height: var(--mit-figure);
}
#mascot-game[data-episode] :is(.mit-caption, .mit-ground) { display: none; }
#mascot-game[data-episode][data-work-side="left"] .mit-figure { scale: -1 1; }
#mascot-game[data-episode]:is([data-pose="carry-run"], [data-pose="frost-run"]) .mit-figure { scale: 1; }
#mascot-game[data-episode]:is([data-pose="carry-run"], [data-pose="frost-run"])[data-facing="left"] .mit-figure { scale: -1 1; }

#mascot-game:is([data-pose="carry-run"], [data-pose="carry-set"]) .mit-sprite {
  background: url("/assets/mitya-carry.webp") 0 0 / 200% 200% no-repeat;
}
#mascot-game[data-pose="carry-set"] .mit-sprite { background-position: 100% 100%; }
#mascot-game:is([data-pose="carry-fix"], [data-pose="carry-open"]) .mit-sprite {
  background: url("/assets/mitya-window.webp") 0 0 / 300% 200% no-repeat;
}
#mascot-game[data-pose="carry-open"] .mit-sprite { background-position: 0 100%; }

/* The approaching runner's eyes and boots meet their positions in the frost atlas. */
#mascot-game:is([data-pose="frost-notice"], [data-pose="frost-run"]) .mit-sprite {
  transform-origin: 50% 95%;
  transform: translateX(-22%) scale(.82);
}
#mascot-game[data-pose="frost-run"] .mit-sprite { background-position: 66.666667% 0; }

.mit-draft {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: var(--mit-work-size, 139px);
  height: var(--mit-work-size, 139px);
  pointer-events: none;
}
#mascot-game[data-episode="frost"] .mit-draft { display: block; }
.mit-draft-frame, .mit-squall {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#mascot-game[data-work-side="left"] :is(.mit-draft-frame, .mit-squall) { scale: -1 1; }
.mit-draft-frame { display: none; }
#mascot-game:is([data-pose="frost-notice"], [data-pose="frost-run"]) .mit-draft-frame {
  display: block;
  background: url("/assets/mitya-frost.webp") 0 0 / 300% 200% no-repeat;
  filter: drop-shadow(0 1px 1px #14233320);
}
#mascot-game:is([data-pose="frost-shiver"], [data-pose="frost-blue"], [data-pose="frost-snap"], [data-pose="frost-drill"], [data-pose="frost-done"]) .mit-sprite {
  position: relative;
  background: url("/assets/mitya-frost.webp") var(--mit-frost-cell) / 300% 200% no-repeat;
}
#mascot-game[data-pose="frost-shiver"] {
  --mit-frost-cell: 50% 0%;
  --mit-body-cut: polygon(0 0, 40% 0, 40% 27%, 41% 30%, 40% 34%, 43% 37%, 44% 42%, 42% 46%, 44% 49%, 45% 55%, 45% 62%, 41% 67%, 40% 75%, 44% 83%, 44% 100%, 0 100%);
}
#mascot-game[data-pose="frost-blue"] {
  --mit-frost-cell: 100% 0%;
  --mit-body-cut: polygon(0 0, 39% 0, 39% 27%, 40% 33%, 39% 36%, 42% 38%, 43.3% 41%, 42.6% 48%, 41.5% 64%, 39.4% 66%, 38% 57%, 37% 53%, 37% 69%, 39% 74%, 43% 83%, 43% 100%, 0 100%);
}
#mascot-game[data-pose="frost-snap"] { --mit-frost-cell: 0% 100%; }
#mascot-game[data-pose="frost-drill"] {
  --mit-frost-cell: 50% 100%;
  --mit-body-cut: polygon(0 0, 40% 0, 40% 22%, 43% 18%, 47% 16.5%, 51% 17.2%, 53% 19.5%, 52% 23%, 49% 26%, 46% 29%, 43% 31%, 44% 32%, 46% 35%, 46% 37%, 51% 36%, 57% 36.5%, 61% 38.5%, 68% 38%, 68.5% 40.5%, 62% 41.5%, 60% 44%, 55% 46%, 54% 53%, 57.5% 55%, 59% 58%, 59% 63.5%, 44% 65%, 41% 66%, 41% 75%, 48% 86%, 48% 100%, 0 100%);
}
#mascot-game[data-pose="frost-done"] { --mit-frost-cell: 100% 100%; }

/* Streaks emerge at the jamb and spread towards Mitya's cheek and scarf. */
.mit-squall { z-index: 1; }
.mit-squall i {
  --jet-y: 44%;
  --jet-rise: -.055;
  --jet-reach: -.46;
  --jet-length: 24%;
  --jet-angle: 5deg;
  --jet-time: .86s;
  --jet-delay: -.48s;
  position: absolute;
  right: 55%;
  top: var(--jet-y);
  width: var(--jet-length);
  height: 5%;
  border-top: 1.5px solid #e5fcff;
  border-radius: 85% 35% 0 0;
  transform: rotate(var(--jet-angle));
  transform-origin: 100% 0;
  filter: drop-shadow(0 1px 0 #649eb6) drop-shadow(0 0 1px #b8efff);
  opacity: .82;
}
.mit-squall i:nth-child(2) { --jet-y: 47%; --jet-reach: -.35; --jet-rise: .045; --jet-length: 16%; --jet-angle: -8deg; --jet-delay: -.06s; }
.mit-squall i:nth-child(3) { --jet-y: 51%; --jet-rise: .15; --jet-length: 20%; --jet-angle: -15deg; --jet-time: 1s; --jet-delay: -.32s; }
.mit-squall i:nth-child(4) { --jet-y: 41%; --jet-reach: -.39; --jet-rise: -.17; --jet-length: 14%; --jet-angle: 14deg; --jet-delay: -.67s; }
.mit-squall i:nth-child(5) { --jet-y: 45%; --jet-rise: -.11; --jet-length: 12%; --jet-angle: 10deg; --jet-time: .96s; --jet-delay: -.23s; }
.mit-squall i:nth-child(6) { --jet-y: 54%; --jet-reach: -.37; --jet-rise: .2; --jet-length: 13%; --jet-angle: -18deg; --jet-delay: -.52s; }
.mit-squall i:nth-child(7) { --jet-y: 49%; --jet-rise: .07; --jet-length: 19%; --jet-angle: -4deg; --jet-time: 1.04s; --jet-delay: -.87s; }
.mit-squall i:nth-child(3n+1)::before {
  content: "";
  position: absolute;
  left: -5%;
  top: -1px;
  width: 26%;
  height: 62%;
  border: 1px solid #d9f8ff;
  border-top-color: transparent;
  border-radius: 50%;
  transform: rotate(-16deg);
}
.mit-squall i:nth-child(odd)::after {
  content: "";
  position: absolute;
  left: -2px;
  top: -2px;
  width: clamp(2px, calc(var(--mit-work-size) * .033), 5px);
  aspect-ratio: 1;
  border-radius: 35%;
  background: #f1fdff;
  box-shadow: 4px 3px 0 -1px #bfefff;
  transform: rotate(40deg);
}
#mascot-game[data-pose="frost-done"] .mit-squall { visibility: hidden; }

@media (prefers-reduced-motion: no-preference) {
  #mascot-game[data-pose="carry-run"] .mit-sprite { animation: mit-carry-stride .32s steps(1, end) infinite; }
  #mascot-game[data-pose="carry-run"] .mit-figure { animation: mit-carry-bounce .32s ease-in-out infinite; }
  #mascot-game[data-pose="carry-set"] .mit-sprite { animation: mit-set-frame .68s steps(1, end) both; }
  #mascot-game[data-pose="carry-fix"] .mit-sprite { animation: mit-turn-screw .52s steps(1, end) infinite; }
  #mascot-game[data-pose="carry-open"] .mit-sprite { animation: mit-open-frame .55s steps(1, end) both; }
  #mascot-game[data-pose="frost-run"] .mit-sprite { animation: mit-stride .25s steps(1, end) infinite; }
  #mascot-game[data-pose="frost-run"] .mit-figure { animation: mit-carry-bounce .25s ease-in-out infinite; }

  /* An unbroken frame stays underneath a separate cutout of the moving body/tool. */
  #mascot-game:is([data-pose="frost-shiver"], [data-pose="frost-blue"], [data-pose="frost-drill"]) .mit-sprite {
    background-position: 0 0;
  }
  #mascot-game:is([data-pose="frost-shiver"], [data-pose="frost-blue"], [data-pose="frost-drill"]) .mit-sprite::after {
    content: "";
    position: absolute;
    inset: 0;
    background: inherit;
    background-position: var(--mit-frost-cell);
    clip-path: var(--mit-body-cut);
    transform-origin: 29% 91%;
    animation: mit-shudder .20s ease-in-out infinite alternate;
  }
  #mascot-game[data-pose="frost-blue"] .mit-sprite::after { animation-duration: .14s; }
  #mascot-game[data-pose="frost-drill"] .mit-sprite::after {
    transform-origin: 64% 39%;
    animation: mit-drill-vibration .18s ease-in-out infinite;
  }
  .mit-squall i { animation: mit-snow-jet var(--jet-time) linear var(--jet-delay) infinite; }
  #mascot-game[data-pose="frost-drill"] .mit-squall { animation: mit-stop-draft 1.35s ease-out both; }
}
@keyframes mit-carry-stride {
  0%, 100% { background-position: 0 0; }
  50% { background-position: 100% 0; }
}
@keyframes mit-carry-bounce {
  45% { transform: translateY(-2.4%) rotate(1deg); }
}
@keyframes mit-set-frame {
  0% { background-position: 0 100%; }
  69%, 100% { background-position: 100% 100%; }
}
@keyframes mit-open-frame {
  0% { background-position: 100% 0; }
  55%, 100% { background-position: 0 100%; }
}
@keyframes mit-shudder {
  0% { transform: translateX(-.45%) rotate(-.8deg); }
  60% { transform: translate(.45%, -.35%) rotate(.7deg); }
  100% { transform: translate(.15%, .2%) rotate(.1deg); }
}
@keyframes mit-drill-vibration {
  0%, 100% { transform: none; }
  40% { transform: rotate(-.65deg) translateX(.3%); }
  72% { transform: rotate(.35deg) translateX(-.2%); }
}
@keyframes mit-snow-jet {
  0% { opacity: 0; transform: rotate(var(--jet-angle)) scaleX(.18); }
  17% { opacity: .96; }
  66% { opacity: .84; }
  100% {
    opacity: 0;
    transform: translate(calc(var(--mit-work-size) * var(--jet-reach)), calc(var(--mit-work-size) * var(--jet-rise))) rotate(var(--jet-angle)) scaleX(1.18);
  }
}
@keyframes mit-stop-draft {
  0%, 18% { opacity: 1; }
  65% { opacity: .32; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mit-squall i:nth-child(n+4) { display: none; }
  #mascot-game[data-pose="frost-drill"] .mit-squall { opacity: .25; }
}
