:root {
  color-scheme: only light;
  --paper: #efe3c4;
  --ink: #2f2738;
  --ink-soft: #5b5066;
  --line: #3a3140;
  --pearx: #5c8c37;
  --healthyr: #d64a6e;
  --humana: #cf4b4f;
  --yale: #284880;
  --equine: #9a6b3f;
  --gold: #d8a93b;
  --stage-w: 920px;
  --font-pixel: "Press Start 2P", ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
  --font-hand: "Caveat", "Comic Sans MS", "Bradley Hand", ui-rounded, cursive;
  --font-round: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

html {
  background: var(--paper);
}

body {
  min-height: 100vh;
  background-color: var(--paper);
  background-image: radial-gradient(circle at center, rgb(58 49 64 / 10%) 1.4px, transparent 1.5px);
  background-position: 0 0;
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--font-round);
  letter-spacing: 0;
  -webkit-text-size-adjust: 100%;
}

body::before {
  position: fixed;
  z-index: 60;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, transparent 55%, rgb(74 58 40 / 16%) 100%),
    radial-gradient(130% 120% at 50% 100%, transparent 60%, rgb(74 58 40 / 18%) 100%);
  content: "";
  mix-blend-mode: multiply;
  pointer-events: none;
}

body::after {
  position: fixed;
  z-index: 61;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  content: "";
  opacity: 0.05;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: only light;
  }

  html {
    background: var(--paper) !important;
  }

  body {
    background-color: var(--paper) !important;
    color: var(--ink) !important;
  }
}

canvas,
.sprite {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.sprite {
  pointer-events: none;
  user-select: none;
}

#wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
}

#stage {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--stage-w);
  transform: translateX(-50%);
  transform-origin: top center;
}

#banner {
  position: absolute;
  z-index: 5;
  top: 6px;
  left: 50%;
  width: 560px;
  text-align: center;
  transform: translateX(-50%);
  opacity: 0;
  animation: fadeDown 0.9s ease 0.2s forwards;
}

#banner .kicker {
  color: #b54b3a;
  font-family: var(--font-pixel);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 1.5px 1.5px 0 rgb(0 0 0 / 12%);
}

#banner h1 {
  margin: 14px 0 0;
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 30px;
  font-weight: 900;
  line-height: 1.4;
  text-shadow: 3px 3px 0 #d8c79b, 5px 5px 0 rgb(0 0 0 / 12%);
}

#scrollHint {
  position: absolute;
  z-index: 5;
  top: 150px;
  left: 528px;
  color: var(--ink-soft);
  font-family: var(--font-hand);
  font-size: 26px;
  font-weight: 700;
  transform: rotate(-4deg) translateY(-14px);
  opacity: 0;
  transition: opacity 0.4s ease;
  animation: fadeHint 0.9s ease 1.1s forwards;
}

#scrollHint .arrow {
  display: inline-block;
  animation: bob 1.4s ease-in-out infinite;
}

#trainer {
  position: absolute;
  z-index: 6;
  top: 172px;
  left: 66px;
  width: 128px;
  height: 160px;
  transform-origin: 60% 90%;
  opacity: 0;
  animation: popUp 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) 0.55s forwards;
}

#trainer.bob {
  animation:
    popUp 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) 0.55s forwards,
    sway 3.4s ease-in-out 1.4s infinite;
}

#trainer.windup {
  animation: windup 0.42s ease-in-out forwards;
}

#trainer.throwidle {
  animation: sway 3.6s ease-in-out infinite;
}

#trainer .shadow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 96px;
  height: 18px;
  border-radius: 50%;
  background: rgb(58 42 30 / 22%);
  filter: blur(1px);
  transform: translateX(-50%);
}

#trainer .tag {
  position: absolute;
  bottom: -30px;
  left: 50%;
  color: #7a6a52;
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 800;
  white-space: nowrap;
  transform: translateX(-50%);
}

#bubble {
  position: absolute;
  z-index: 7;
  top: 104px;
  left: 146px;
  padding: 13px 16px;
  border: 4px solid var(--ink);
  border-radius: 4px;
  background: #fffdf6;
  box-shadow: 5px 6px 0 rgb(0 0 0 / 16%);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 11px;
  font-weight: 800;
  transform: scale(0.4);
  transform-origin: 0% 120%;
  opacity: 0;
}

#bubble.show {
  animation:
    popBubble 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) forwards,
    floaty 3s ease-in-out 1s infinite;
}

#bubble::after {
  position: absolute;
  bottom: -16px;
  left: 22px;
  width: 0;
  height: 0;
  border: 9px solid transparent;
  border-top-color: var(--ink);
  content: "";
}

#bubble::before {
  position: absolute;
  z-index: 1;
  bottom: -9px;
  left: 24px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: #fffdf6;
  content: "";
}

#bubble .cursor {
  color: #b54b3a;
}

#routeSvg {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 0;
  overflow: visible;
}

#route,
#routeShadow {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: url("#rough");
}

#route {
  stroke: var(--line);
  stroke-width: 6;
}

#routeShadow {
  stroke: rgb(58 42 30 / 18%);
  stroke-width: 9;
}

.node {
  position: absolute;
  z-index: 4;
}

.platform {
  position: absolute;
  top: 0;
  left: 50%;
  width: 78px;
  height: 22px;
  border-radius: 50%;
  background: rgb(58 42 30 / 16%);
  filter: blur(0.5px);
  transform: translate(-50%, -50%);
}

.ball {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  will-change: transform, left, top;
}

.ball.idle {
  animation: ballIdle 2.8s ease-in-out infinite;
}

.ball.wobble {
  animation: ballWobble 0.55s ease-in-out;
}

.ball.gone {
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  transition: all 0.25s ease;
}

#flyball {
  position: absolute;
  z-index: 9;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  will-change: left, top;
}

#flyball.wobble {
  animation: ballWobble 0.55s ease-in-out;
}

#flyball.gone {
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  transition: all 0.25s ease;
}

.flash {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 50%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffe9a8 35%, rgb(255 233 168 / 0%) 70%);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}

.flash.go {
  animation: flash 0.5s ease-out forwards;
}

.spark {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: var(--gold);
  transform: translate(-50%, -50%);
  opacity: 0;
}

.spark.go {
  animation: spark 0.6s ease-out forwards;
}

.itemSprite {
  position: absolute;
  z-index: 5;
  bottom: 50%;
  left: 50%;
  transform: translate(-50%, 18px) scale(0.2);
  transform-origin: 50% 100%;
  opacity: 0;
}

.itemSprite.show {
  animation:
    itemPop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) forwards,
    itemFloat 3.2s ease-in-out 0.6s infinite;
}

.card {
  position: absolute;
  z-index: 4;
  width: 300px;
  padding: 16px 18px 17px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fbf4df;
  box-shadow: 6px 8px 0 rgb(48 39 56 / 18%);
  opacity: 0;
}

.card.left {
  transform: translateX(40px) rotate(1.4deg);
}

.card.right {
  transform: translateX(-40px) rotate(-1.4deg);
}

.card.show {
  animation: cardIn 0.55s cubic-bezier(0.2, 1, 0.4, 1) forwards;
}

.card .tape,
.mcard .tape {
  position: absolute;
  top: -13px;
  width: 74px;
  height: 26px;
  border: 1px solid rgb(120 90 30 / 25%);
  background: rgb(216 169 59 / 42%);
}

.card.left .tape {
  right: 24px;
  transform: rotate(6deg);
}

.card.right .tape {
  left: 24px;
  transform: rotate(-6deg);
}

.card .no,
.mcard .no {
  color: #9a8a6c;
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
}

.card h2,
.mcard h2 {
  margin: 8px 0 3px;
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.5;
}

.card .role,
.mcard .role {
  margin: 2px 0 9px;
  font-family: var(--font-hand);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.card p,
.mcard p {
  margin: 0 0 12px;
  color: #473d4f;
  font-family: var(--font-round);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.5;
}

.badge {
  display: inline-block;
  padding: 5px 8px;
  border: 2px solid rgb(0 0 0 / 18%);
  border-radius: 3px;
  box-shadow: 2px 2px 0 rgb(0 0 0 / 14%);
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.statline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}

.statline .lab {
  width: 34px;
  color: #8a7b62;
  font-family: var(--font-pixel);
  font-size: 7px;
  font-weight: 800;
}

.bar {
  flex: 1;
  height: 11px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 2px;
  background: #e3d6b3;
}

.bar i {
  display: block;
  width: 0;
  height: 100%;
  border-right: 2px solid rgb(0 0 0 / 15%);
}

.card.show .bar i,
.mcard.show .bar i {
  transition: width 1s ease 0.35s;
}

.leader {
  position: absolute;
  z-index: 2;
  border-top: 3px dashed rgb(58 49 64 / 45%);
  opacity: 0;
  transition: opacity 0.4s ease 0.3s;
}

.node.open .leader {
  opacity: 1;
}

#endmark {
  position: absolute;
  z-index: 5;
  left: 50%;
  width: 420px;
  text-align: center;
  transform: translateX(-50%);
}

#endmark .star,
#mfoot .star {
  color: var(--gold);
  font-family: var(--font-pixel);
  font-size: 22px;
  font-weight: 900;
  text-shadow: 2px 2px 0 rgb(0 0 0 / 15%);
  animation: bob 2.2s ease-in-out infinite;
}

#endmark .tbc,
#mfoot .tbc {
  margin-top: 6px;
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 30px;
  font-weight: 700;
  transform: rotate(-2deg);
}

#endmark .sub,
#mfoot .sub {
  margin-top: 10px;
  color: #9a8a6c;
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: 800;
  line-height: 1.6;
}

#mroot {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px 70px;
}

#mbanner {
  padding: 22px 0 2px;
  text-align: center;
  opacity: 0;
  animation: fadeUp 0.7s ease 0.1s forwards;
}

#mbanner .kicker {
  color: #b54b3a;
  font-family: var(--font-pixel);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 1px;
  text-shadow: 1.5px 1.5px 0 rgb(0 0 0 / 12%);
}

#mbanner h1 {
  margin: 13px 0 0;
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 27px;
  font-weight: 900;
  text-shadow: 3px 3px 0 #d8c79b, 5px 5px 0 rgb(0 0 0 / 12%);
}

#mintro {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 150px;
  margin: 14px 0 2px;
}

#mtrainer {
  position: relative;
  flex: 0 0 auto;
  width: 96px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#mtrainer.in {
  opacity: 1;
  animation: sway 3.6s ease-in-out 1s infinite;
}

#mtrainer.windup {
  opacity: 1;
  animation: windup 0.42s ease-in-out forwards;
}

#mtrainer .shadow {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 72px;
  height: 14px;
  border-radius: 50%;
  background: rgb(58 42 30 / 22%);
  filter: blur(1px);
  transform: translateX(-50%);
}

#mtrainer .tag {
  position: absolute;
  bottom: -22px;
  left: 50%;
  color: #7a6a52;
  font-family: var(--font-pixel);
  font-size: 6px;
  font-weight: 800;
  white-space: nowrap;
  transform: translateX(-50%);
}

#mbubble {
  position: relative;
  margin-top: 26px;
  padding: 10px 13px;
  border: 3px solid var(--ink);
  border-radius: 4px;
  background: #fffdf6;
  box-shadow: 4px 5px 0 rgb(0 0 0 / 16%);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  transform: scale(0.4);
  transform-origin: 0 60%;
  opacity: 0;
}

#mbubble.show {
  animation:
    popBubble 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) forwards,
    floaty 3s ease-in-out 1s infinite;
}

#mbubble::after {
  position: absolute;
  top: 16px;
  left: -15px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-right-color: var(--ink);
  content: "";
}

#mbubble::before {
  position: absolute;
  z-index: 1;
  top: 18px;
  left: -9px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-right-color: #fffdf6;
  content: "";
}

#mtrail {
  position: relative;
  margin-top: 4px;
  padding-left: 74px;
}

svg.mroute {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

.mchap {
  position: relative;
  z-index: 1;
  min-height: 96px;
  margin: 0 0 30px;
}

.mlead {
  position: absolute;
  top: 50px;
  left: -14px;
  width: 16px;
  border-top: 3px dashed rgb(58 49 64 / 42%);
  opacity: 0;
}

.mchap.open .mlead {
  opacity: 1;
  transition: opacity 0.4s ease 0.3s;
}

.mbadge {
  position: absolute;
  z-index: 3;
  top: 34px;
  left: -68px;
  width: 62px;
  height: 62px;
}

.mbadge .mplat {
  position: absolute;
  bottom: 1px;
  left: 50%;
  width: 48px;
  height: 13px;
  border-radius: 50%;
  background: rgb(58 42 30 / 18%);
  filter: blur(0.5px);
  transform: translateX(-50%);
}

.mbadge .mball,
.mbadge .mitem {
  position: absolute;
  top: 46%;
  left: 50%;
}

.mbadge .mball {
  transform: translate(-50%, -50%);
  will-change: transform;
}

.mbadge .mball.idle {
  animation: ballIdle 2.8s ease-in-out infinite;
}

.mbadge .mball.wob {
  animation: ballWobble 0.52s ease-in-out;
}

.mbadge .mball.gone {
  transform: translate(-50%, -50%) scale(0.3);
  opacity: 0;
  transition: all 0.25s ease;
}

.mbadge .mitem {
  transform: translate(-50%, -50%) scale(0.2);
  transform-origin: 50% 50%;
  opacity: 0;
}

.mbadge .mitem.show {
  animation:
    mItemPop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) forwards,
    mItemFloat 3.2s ease-in-out 0.6s infinite;
}

.mbadge .mflash {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffe9a8 35%, rgb(255 233 168 / 0%) 70%);
  transform: translate(-50%, -50%) scale(0);
  pointer-events: none;
}

.mbadge .mflash.go {
  animation: flash 0.5s ease-out forwards;
}

.mbadge .mspark {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: var(--gold);
  transform: translate(-50%, -50%);
  opacity: 0;
}

.mbadge .mspark.go {
  animation: spark 0.6s ease-out forwards;
}

.mcard {
  position: relative;
  padding: 14px 16px 15px;
  border: 3px solid var(--ink);
  border-radius: 7px;
  background: #fbf4df;
  box-shadow: 5px 7px 0 rgb(48 39 56 / 18%);
  transform: translateY(16px);
  opacity: 0;
}

.mcard.show {
  animation: mCardIn 0.5s cubic-bezier(0.2, 1, 0.4, 1) forwards;
}

.mcard .tape {
  top: -12px;
  left: 22px;
  width: 70px;
  height: 24px;
  transform: rotate(-5deg);
}

.mcard .role {
  font-size: 23px;
}

.mcard p {
  font-size: 15px;
  line-height: 1.55;
}

#mflyball {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#mflyball.land {
  animation: ballWobble 0.5s ease-in-out;
}

#mfoot {
  margin-top: 14px;
  text-align: center;
}

#mfoot .star {
  display: inline-block;
  font-size: 18px;
}

#mfoot .tbc {
  font-size: 27px;
}

#mfoot .sub {
  margin-top: 8px;
  font-size: 7px;
}

@keyframes fadeDown {
  from {
    transform: translateX(-50%) translateY(-14px);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

@keyframes fadeHint {
  from {
    transform: rotate(-4deg) translateY(-14px);
    opacity: 0;
  }

  to {
    transform: rotate(-4deg) translateY(0);
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    transform: translateY(12px);
    opacity: 0;
  }

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

@keyframes popUp {
  from {
    transform: translateY(26px) scale(0.7);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes sway {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }

  50% {
    transform: translateY(-5px) rotate(1.5deg);
  }
}

@keyframes windup {
  0% {
    transform: rotate(0) translateX(0);
    opacity: 1;
  }

  45% {
    transform: rotate(-9deg) translateX(-8px) scale(1.03);
    opacity: 1;
  }

  100% {
    transform: rotate(3deg) translateX(2px);
    opacity: 1;
  }
}

@keyframes popBubble {
  from {
    transform: scale(0.4);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes floaty {
  0%,
  100% {
    margin-top: 0;
  }

  50% {
    margin-top: -5px;
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(5px);
  }
}

@keyframes ballIdle {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(-3deg);
  }

  50% {
    transform: translate(-50%, -54%) rotate(3deg);
  }
}

@keyframes ballWobble {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0);
  }

  20% {
    transform: translate(-56%, -50%) rotate(-16deg);
  }

  50% {
    transform: translate(-44%, -50%) rotate(16deg);
  }

  80% {
    transform: translate(-53%, -50%) rotate(-8deg);
  }
}

@keyframes flash {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }

  70% {
    opacity: 0.9;
  }

  100% {
    transform: translate(-50%, -50%) scale(2.6);
    opacity: 0;
  }
}

@keyframes spark {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(0.4);
    opacity: 0;
  }
}

@keyframes itemPop {
  0% {
    transform: translate(-50%, 18px) scale(0.2);
    opacity: 0;
  }

  60% {
    transform: translate(-50%, -14px) scale(1.18);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -6px) scale(1);
    opacity: 1;
  }
}

@keyframes itemFloat {
  0%,
  100% {
    margin-bottom: 0;
  }

  50% {
    margin-bottom: 9px;
  }
}

@keyframes mItemPop {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }

  60% {
    transform: translate(-50%, -62%) scale(1.16);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes mItemFloat {
  0%,
  100% {
    margin-top: 0;
  }

  50% {
    margin-top: -6px;
  }
}

@keyframes cardIn {
  to {
    transform: translateX(0) rotate(var(--rot));
    opacity: 1;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}
