:root {
  color-scheme: dark;
  --road-tilt: 0deg;
  --cart-lean: 0deg;
  --cart-cycle: 520ms;
  --cart-frame-x: 0%;
  --cart-frame-y: 0%;
  --beat-pulse: 0;
  --target-x: 50%;
  --target-y: 37%;
  --note-asset: url("./assets/note-paw-coin.png?v=1");
  --world-shift: 0px;
  --backdrop-shift: 0px;
  --backdrop-tilt: 0deg;
  --backdrop-image: url("./assets/background-track-01-loop.png");
  --pixel-shadow: 0 4px 0 #25170f, 0 8px 18px rgba(28, 18, 10, 0.45);
  font-family: "Trebuchet MS", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  background: #121016;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
  touch-action: manipulation;
  user-select: none;
}

button {
  font: inherit;
}

.game-shell {
  width: min(100vw, 480px);
  height: 100dvh;
  min-height: 620px;
  max-height: 940px;
  background: #20151c;
  overflow: hidden;
  position: relative;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: #48c2c6;
  cursor: pointer;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(11, 45, 55, 0.08), transparent 34%, rgba(12, 9, 20, 0.2) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 4px);
  pointer-events: none;
}

.backdrop {
  position: absolute;
  inset: -4% -8% auto;
  z-index: 0;
  width: auto;
  height: 78%;
  background-image: var(--backdrop-image);
  background-position: var(--backdrop-shift) top;
  background-repeat: repeat-x;
  background-size: auto 100%;
  image-rendering: pixelated;
  transform: rotate(var(--backdrop-tilt)) scale(1.07);
  transform-origin: center 78%;
  transition: background-image 220ms steps(2, end), transform 140ms linear;
}

.sky-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(63, 218, 214, 0.1) 0%, transparent 45%),
    radial-gradient(circle at 50% 40%, transparent 0 40%, rgba(26, 25, 34, 0.16) 88%);
  pointer-events: none;
}

.hud {
  position: fixed;
  z-index: 12;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: max(14px, calc((100vw - min(100vw, 480px)) / 2 + 14px));
  right: max(14px, calc((100vw - min(100vw, 480px)) / 2 + 14px));
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr;
  gap: 8px;
  pointer-events: none;
}

.hud div,
.meter,
.track-badge {
  border: 3px solid #2c1a17;
  background: rgba(255, 240, 199, 0.9);
  box-shadow: var(--pixel-shadow);
}

.hud div {
  min-width: 0;
  padding: 7px 8px 6px;
}

.hud span,
.meter-readout span,
.track-badge span {
  display: block;
  color: #6e3f2e;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.hud strong {
  display: block;
  margin-top: 4px;
  color: #201017;
  font-size: 18px;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  position: fixed;
  z-index: 12;
  top: calc(82px + env(safe-area-inset-top, 0px));
  right: max(14px, calc((100vw - min(100vw, 480px)) / 2 + 14px));
  width: 74px;
  padding: 8px;
  pointer-events: none;
}

.track-badge {
  position: fixed;
  z-index: 12;
  top: calc(82px + env(safe-area-inset-top, 0px));
  left: max(14px, calc((100vw - min(100vw, 480px)) / 2 + 14px));
  width: min(56vw, 210px);
  padding: 7px 9px 6px;
  pointer-events: none;
}

.track-badge strong {
  display: block;
  margin-top: 4px;
  color: #201017;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.speed-strip {
  position: relative;
  height: 112px;
  border: 2px solid #3a2319;
  background:
    linear-gradient(180deg, #e34f42 0 19%, #f1bb49 19% 36%, #7ec26d 36% 64%, #f1bb49 64% 81%, #6aa7d8 81% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0 2px, transparent 2px 7px);
}

.speed-strip i {
  position: absolute;
  left: -5px;
  right: -5px;
  top: 50%;
  height: 6px;
  border: 2px solid #2a1714;
  background: #fbf0ce;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transform: translateY(-50%);
}

.meter-readout {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  text-align: center;
}

.meter-readout b {
  color: #201017;
  font-size: 15px;
  line-height: 1;
}

.note-field {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.pixel-note {
  position: absolute;
  width: min(82vw, 340px);
  height: 74px;
  --note-gap: 142px;
  --orb-size: 50px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 0 rgba(33, 18, 15, 0.3));
}

.note-orb {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: var(--orb-size);
  height: var(--orb-size);
  background: var(--note-asset) center / contain no-repeat;
  image-rendering: pixelated;
  filter: saturate(var(--note-saturation, 1)) hue-rotate(var(--note-hue, 0deg));
  animation: note-flicker 420ms steps(2, end) infinite;
}

.note-orb.left {
  transform: translate(calc(-50% - var(--note-gap)), -50%);
}

.note-orb.right {
  transform: translate(calc(-50% + var(--note-gap)), -50%);
  animation-delay: -210ms;
}

.note-orb::before,
.note-orb::after {
  content: "";
  display: none;
  position: absolute;
  border-radius: 50%;
}

.note-orb::before {
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.76);
  box-shadow: inset 0 0 0 2px rgba(52, 32, 21, 0.28);
}

.note-orb::after {
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  background: #2c1a17;
  transform: translate(-50%, -50%);
}

.pixel-note.rescue {
  height: 82px;
  --orb-size: 56px;
  --note-hue: 328deg;
  --note-saturation: 1.25;
}

.pixel-note.hit {
  animation: pop-note 160ms steps(2, end) forwards;
}

@keyframes pop-note {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.16);
  }
}

@keyframes note-flicker {
  50% {
    filter: brightness(1.16);
    scale: 1.08;
  }
}

.target-ring {
  position: absolute;
  z-index: 11;
  left: var(--target-x);
  top: var(--target-y);
  width: 62px;
  height: 62px;
  transform: translate(-50%, -50%) scale(calc(1 + var(--beat-pulse) * 0.08));
  border: 0;
  background: var(--note-asset) center / contain no-repeat;
  filter:
    drop-shadow(0 0 0 rgba(44, 26, 23, 0.72))
    drop-shadow(0 0 18px rgba(255, 218, 83, 0.82));
  image-rendering: pixelated;
  opacity: 0.58;
  pointer-events: none;
}

.target-ring span {
  position: absolute;
  inset: -6px;
  border: 3px solid rgba(255, 244, 178, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 218, 83, 0.72);
}

.target-ring.pulse {
  animation: ring-pulse 170ms steps(2, end);
}

.impact-burst {
  position: absolute;
  z-index: 12;
  left: var(--burst-x);
  top: var(--burst-y);
  width: 0;
  height: 0;
  pointer-events: none;
}

.impact-burst i {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 2px solid #2c1a17;
  background: var(--burst-color, #ffe26e);
  box-shadow: 2px 2px 0 rgba(255, 240, 199, 0.38);
  transform: translate(-50%, -50%);
  animation: burst-pixel 360ms steps(4, end) forwards;
}

@keyframes burst-pixel {
  60% {
    opacity: 1;
  }

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

.stage.rescue-active .target-ring {
  filter:
    hue-rotate(328deg)
    saturate(1.25)
    drop-shadow(0 0 0 rgba(44, 26, 23, 0.7))
    drop-shadow(0 0 30px rgba(255, 108, 95, 0.92));
}

.tap-guide {
  position: absolute;
  z-index: 11;
  left: var(--target-x);
  top: calc(var(--target-y) + 36px);
  min-width: 116px;
  padding: 5px 7px;
  border: 3px solid #2c1a17;
  color: #201017;
  background: rgba(255, 240, 199, 0.94);
  box-shadow: 0 4px 0 rgba(44, 26, 23, 0.42);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

@keyframes ring-pulse {
  50% {
    transform: translate(-50%, -50%) scale(1.16);
  }
}

.cart {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: 25%;
  width: min(82vw, 340px);
  aspect-ratio: 568 / 314;
  transform:
    translateX(-50%)
    rotate(var(--cart-lean))
    scale(
      calc(1 + var(--beat-pulse) * 0.018),
      calc(1 - var(--beat-pulse) * 0.01)
    );
  transform-origin: 52% 78%;
  pointer-events: none;
  animation: cart-bob var(--cart-cycle) steps(2, end) infinite;
}

.cart-sprite {
  width: 100%;
  height: 100%;
  background: url("./assets/bicycle-band-ingame-sprite.png") var(--cart-frame-x) var(--cart-frame-y) / 700% 400% no-repeat;
  image-rendering: pixelated;
}

.cart .cart-sprite {
  position: absolute;
  inset: 0;
  z-index: 2;
  filter: drop-shadow(0 8px 0 rgba(34, 21, 12, 0.38));
}

.cart::before {
  content: "";
  position: absolute;
  left: -5%;
  top: 18%;
  width: 33%;
  height: 56%;
  z-index: 0;
  opacity: 0.62;
  background:
    radial-gradient(circle, rgba(255, 236, 150, 0.95) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(255, 112, 84, 0.85) 0 2px, transparent 3px),
    radial-gradient(circle, rgba(113, 214, 194, 0.82) 0 2px, transparent 3px);
  background-size: 30px 24px, 42px 31px, 54px 37px;
  background-position: 0 0, 14px 9px, 25px 18px;
  image-rendering: pixelated;
  animation: dust-stream 700ms steps(4, end) infinite;
}

.cart::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 11%;
  bottom: 8%;
  height: 10px;
  background: rgba(34, 22, 18, 0.3);
  filter: blur(2px);
  transform: skewX(-18deg);
}

.event-popup {
  position: absolute;
  z-index: 19;
  left: 50%;
  top: 38%;
  width: min(84%, 340px);
  min-height: 74px;
  display: grid;
  place-items: center;
  padding: 14px 18px;
  border: 4px solid #2c1a17;
  color: #201017;
  background: #fff06a;
  box-shadow: var(--pixel-shadow);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px), 0 8px, 8px 8px);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  opacity: 0;
  white-space: pre-line;
  transform: translate(-50%, -50%) scale(0.82);
  pointer-events: none;
}

.event-popup.visible {
  animation: event-popup 640ms steps(5, end) both;
}

.event-popup.countdown {
  top: 41%;
  width: 118px;
  min-height: 118px;
  border-radius: 50%;
  clip-path: none;
  color: #fff8dc;
  background: #c74236;
  font-size: 66px;
  text-shadow: 4px 4px 0 #2c1a17;
}

.event-popup.rescue {
  top: 41%;
  color: #fff8dc;
  background: #ff6c5f;
  text-shadow: 3px 3px 0 #2c1a17;
}

@keyframes event-popup {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -54%) scale(1.08);
  }

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

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

.cart.too-fast {
  animation: cart-bob 280ms steps(2, end) infinite, danger-shake 160ms steps(2, end) infinite;
}

.cart.too-slow {
  animation: cart-bob 920ms steps(2, end) infinite;
  filter: saturate(0.75);
}

@keyframes cart-bob {
  50% {
    translate: 0 -3px;
  }
}

@keyframes danger-shake {
  50% {
    margin-left: -5px;
  }
}

@keyframes dust-stream {
  to {
    background-position: -30px 0, -28px 9px, -29px 18px;
  }
}

@keyframes rescue-flash {
  50% {
    opacity: 0.46;
  }
}

.road-rig {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: -5%;
  width: 180%;
  height: 43%;
  transform: translateX(-50%) rotate(var(--road-tilt));
  transform-origin: center 17%;
  pointer-events: none;
  transition: transform 120ms linear;
}

.road {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-top: 6px solid rgba(62, 38, 25, 0.86);
  background-color: #8d603d;
  background-image:
    linear-gradient(180deg, rgba(255, 230, 168, 0.26) 0%, rgba(129, 80, 48, 0.1) 34%, rgba(44, 24, 20, 0.34) 100%),
    url("./assets/road-texture-tile.png");
  background-repeat: no-repeat, repeat;
  background-size: 100% 100%, 560px 280px;
  background-position:
    0 0,
    calc(var(--world-shift) * -1.25) calc(var(--world-shift) * -0.1);
  box-shadow: 0 -12px 0 rgba(56, 40, 30, 0.18);
}

.road::before {
  content: "";
  position: absolute;
  inset: -12px;
  background:
    linear-gradient(180deg, rgba(65, 37, 22, 0.32), transparent 18%, transparent 72%, rgba(28, 16, 15, 0.34)),
    radial-gradient(ellipse at 50% 0%, rgba(255, 237, 183, 0.24), transparent 46%);
  mix-blend-mode: multiply;
  opacity: 0.72;
  transform: translateX(calc(var(--world-shift) * -0.14));
}

.road::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 18px;
  background: linear-gradient(180deg, rgba(255, 231, 161, 0.32), rgba(70, 48, 38, 0));
  opacity: 0.7;
}

.lane {
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  display: none;
}

.lane-a {
  top: 42%;
}

.lane-b {
  top: 70%;
  opacity: 0.56;
}

.road-grain {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(32, 19, 17, 0.18) 0 1px, transparent 1px),
    radial-gradient(circle, rgba(255, 237, 175, 0.1) 0 1px, transparent 1px);
  background-size: 17px 17px, 29px 29px;
  background-position:
    calc(var(--world-shift) * -0.6) 0,
    calc(var(--world-shift) * -0.95) 9px;
  mix-blend-mode: multiply;
  opacity: 0.34;
}

.tap-status {
  position: fixed;
  z-index: 13;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  width: min(84%, 320px);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.judgement {
  min-height: 26px;
  color: #fff1bf;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.15;
  text-shadow: 3px 3px 0 #2b1716, 0 5px 0 rgba(0, 0, 0, 0.16);
}

.instruction {
  min-height: 15px;
  margin-top: 3px;
  color: #fff8dc;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  text-shadow: 2px 2px 0 #2b1716;
}

.judgement-popup {
  position: absolute;
  z-index: 18;
  left: 50%;
  top: 22%;
  width: min(58vw, 226px);
  height: auto;
  opacity: 0;
  image-rendering: pixelated;
  transform: translate(-50%, -50%) scale(0.72);
  pointer-events: none;
}

.judgement-popup.show {
  animation: judgement-pop 520ms steps(5, end) forwards;
}

@keyframes judgement-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -58%) scale(1.08);
  }

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

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

.judgement.perfect {
  color: #c74236;
}

.judgement.good {
  color: #1d7b67;
}

.judgement.miss {
  color: #5b4c6f;
}

.rescue-count {
  position: relative;
  width: min(100%, 260px);
  height: 22px;
  margin: 8px auto 0;
  border: 3px solid #2c1a17;
  background: rgba(255, 240, 199, 0.92);
  box-shadow: 0 4px 0 rgba(44, 26, 23, 0.42);
  opacity: 0;
  overflow: hidden;
}

.rescue-count.visible {
  opacity: 1;
}

.rescue-count b {
  position: relative;
  z-index: 1;
  display: block;
  color: #201017;
  font-size: 12px;
  font-weight: 900;
  line-height: 16px;
}

.rescue-count i {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--rescue-time, 100%);
  background: #ff6c5f;
}

.tap-button {
  position: fixed;
  z-index: 14;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 88px;
  height: 88px;
  border: 0;
  border-radius: 50%;
  color: transparent;
  background: url("./assets/button-tap-labeled.png?v=2") center / contain no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 8px 0 rgba(42, 23, 20, 0.42)) drop-shadow(0 14px 14px rgba(0, 0, 0, 0.25));
  image-rendering: pixelated;
  font-size: 0;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(255, 247, 198, 0.72);
  touch-action: manipulation;
  transform: translateX(-50%) scale(calc(1 + var(--beat-pulse) * 0.04));
}

.pause-button {
  position: fixed;
  z-index: 15;
  right: max(14px, calc((100vw - min(100vw, 480px)) / 2 + 14px));
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  width: 104px;
  height: 35px;
  padding: 0;
  border: 0;
  color: transparent;
  background: url("./assets/button-pause.png?v=2") center / contain no-repeat;
  filter: drop-shadow(0 5px 0 rgba(42, 23, 20, 0.42));
  image-rendering: pixelated;
  font-size: 0;
  touch-action: manipulation;
}

.pause-button.hidden {
  display: none;
}

.pause-button:active {
  transform: translateY(3px);
  filter: drop-shadow(0 2px 0 rgba(42, 23, 20, 0.48));
}

.tap-button:active,
.tap-button.pressed {
  transform: translate(-50%, 5px) scale(0.96);
  filter: drop-shadow(0 3px 0 rgba(42, 23, 20, 0.5)) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.22));
}

.stage.rescue-active .tap-button {
  filter: hue-rotate(322deg) saturate(1.25) brightness(1.06) drop-shadow(0 8px 0 rgba(42, 23, 20, 0.42));
  animation: rescue-button 180ms steps(2, end) infinite;
}

@keyframes rescue-button {
  50% {
    filter: brightness(1.18);
  }
}

.curtain {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 24px 14px 28px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(26, 19, 23, 0.1), rgba(26, 19, 23, 0.58)),
    rgba(18, 16, 22, 0.16);
  backdrop-filter: blur(1px);
}

.curtain.hidden {
  display: none;
}

.curtain h1,
.curtain h2 {
  margin: 0;
  color: #fff1bf;
  font-size: clamp(36px, 12vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
  text-shadow: 4px 4px 0 #2b1716, 0 8px 0 rgba(0, 0, 0, 0.16);
}

.curtain h2 {
  font-size: clamp(34px, 10vw, 50px);
}

.curtain p {
  margin: 0;
  max-width: 18em;
  color: #fff8dc;
  font-size: 17px;
  font-weight: 800;
  text-shadow: 2px 2px 0 #2b1716;
}

.primary-button {
  width: min(76vw, 292px);
  height: min(25vw, 96px);
  min-width: 0;
  min-height: 0;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: transparent;
  background: var(--button-image, url("./assets/button-primary.png?v=2")) center / contain no-repeat;
  box-shadow: none;
  filter: drop-shadow(0 8px 0 rgba(42, 23, 20, 0.42)) drop-shadow(0 14px 16px rgba(0, 0, 0, 0.24));
  image-rendering: pixelated;
  font-size: 0;
  font-weight: 900;
  line-height: 1;
  overflow: hidden;
}

.start-button {
  --button-image: url("./assets/button-start.png?v=2");
}

.restart-button {
  --button-image: url("./assets/button-restart.png?v=2");
}

.resume-button {
  --button-image: url("./assets/button-resume.png?v=2");
}

.title-button {
  --button-image: url("./assets/button-title.png?v=2");
}

.primary-button:active {
  transform: translateY(4px);
  filter: drop-shadow(0 3px 0 rgba(42, 23, 20, 0.48)) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.2));
}

.title-screen {
  display: block;
  padding: 0;
  overflow: hidden;
  background: #20bdd0 url("./assets/title-screen-bg.png") center / cover no-repeat;
  backdrop-filter: none;
}

.title-fireworks {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.title-spark {
  position: absolute;
  left: var(--fx-x);
  top: var(--fx-y);
  width: var(--fx-size);
  height: var(--fx-size);
  background: url("./assets/title-firework-particles.png?v=2") var(--fx-frame-x) var(--fx-frame-y) / 400% 300% no-repeat;
  image-rendering: pixelated;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.25) rotate(var(--fx-rot));
  animation: title-spark-pop var(--fx-life) steps(5, end) forwards;
  filter: drop-shadow(0 2px 0 rgba(42, 23, 20, 0.22));
}

@keyframes title-spark-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.25) rotate(var(--fx-rot));
  }

  16% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(var(--fx-rot));
  }

  72% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--fx-dx)), calc(-50% + var(--fx-dy))) scale(0.64) rotate(var(--fx-rot));
  }
}

.title-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 36%, rgba(38, 21, 14, 0.2) 100%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 5px);
  pointer-events: none;
}

.title-logo {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 7%;
  width: min(118vw, 500px);
  max-width: none;
  height: auto;
  image-rendering: pixelated;
  transform: translateX(-50%);
  filter: drop-shadow(0 9px 0 rgba(42, 23, 20, 0.38)) drop-shadow(0 16px 18px rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.title-cart {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(172px + env(safe-area-inset-bottom, 0px));
  width: min(88vw, 352px);
  height: auto;
  image-rendering: pixelated;
  transform: translateX(-50%);
  filter: drop-shadow(0 8px 0 rgba(42, 23, 20, 0.35)) drop-shadow(0 16px 18px rgba(0, 0, 0, 0.2));
  pointer-events: none;
}

.title-screen .primary-button {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: calc(44px + env(safe-area-inset-bottom, 0px));
  width: min(82vw, 318px);
  height: min(27vw, 104px);
  transform: translateX(-50%);
}

.title-screen .primary-button:active {
  transform: translate(-50%, 4px);
}

.title-links {
  position: absolute;
  z-index: 5;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.title-links a {
  display: block;
  max-width: 164px;
  padding: 5px 8px 4px;
  border: 2px solid rgba(42, 23, 20, 0.9);
  color: #fff8dc;
  background: rgba(28, 83, 93, 0.86);
  box-shadow: 0 3px 0 rgba(42, 23, 20, 0.35);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  text-shadow: 1px 1px 0 #2b1716;
}

.title-links a:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(42, 23, 20, 0.42);
}

.track-select {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 12, 16, 0.45);
}

.track-select.hidden {
  display: none;
}

.track-select-panel {
  width: min(86vw, 340px);
  padding: 14px;
  border: 4px solid #2c1a17;
  background: rgba(255, 240, 199, 0.96);
  box-shadow: var(--pixel-shadow);
  display: grid;
  gap: 10px;
}

.track-select-panel strong {
  color: #201017;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 2px 2px 0 rgba(255, 181, 70, 0.55);
}

.track-options {
  display: grid;
  gap: 8px;
}

.track-option,
.track-cancel {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 3px solid #2c1a17;
  color: #fff8dc;
  background: #c74236;
  box-shadow: 0 4px 0 rgba(42, 23, 20, 0.42);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 2px 2px 0 #2b1716;
}

.track-option:nth-child(2) {
  background: #167b75;
}

.track-option:nth-child(3) {
  background: #df9a26;
}

.track-cancel {
  min-height: 38px;
  color: #201017;
  background: #fff06a;
  font-size: 14px;
  text-shadow: none;
}

.track-option:active,
.track-cancel:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(42, 23, 20, 0.5);
}

.result-screen {
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(20, 15, 18, 0.24), rgba(20, 15, 18, 0.7)),
    rgba(16, 12, 16, 0.24);
}

.result-panel {
  width: min(90vw, 360px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 4px solid #2c1a17;
  background:
    linear-gradient(180deg, rgba(255, 248, 220, 0.98), rgba(255, 226, 147, 0.96)),
    #fff0c7;
  box-shadow: var(--pixel-shadow);
}

.result-panel h2 {
  color: #ffcf58;
  font-size: clamp(30px, 9vw, 42px);
  text-shadow: 3px 3px 0 #2b1716, 0 5px 0 rgba(0, 0, 0, 0.16);
}

.result-panel p {
  max-width: none;
  color: #5d3026;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
  text-shadow: none;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-stats div {
  min-width: 0;
  padding: 9px 8px 8px;
  border: 3px solid #2c1a17;
  background: rgba(255, 250, 229, 0.92);
  box-shadow: 0 4px 0 rgba(42, 23, 20, 0.26);
}

.result-stats div:first-child {
  grid-column: 1 / -1;
}

.result-stats span,
.rank-form label {
  display: block;
  color: #7c4933;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
}

.result-stats strong {
  display: block;
  margin-top: 5px;
  min-width: 0;
  color: #201017;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#resultTrack {
  font-size: 18px;
}

.rank-form {
  display: grid;
  gap: 7px;
  text-align: left;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.rank-row input,
.rank-submit {
  min-width: 0;
  height: 42px;
  border: 3px solid #2c1a17;
  box-shadow: 0 4px 0 rgba(42, 23, 20, 0.32);
  font-weight: 900;
}

.rank-row input {
  width: 100%;
  padding: 0 9px;
  color: #201017;
  background: #fff8dc;
  font-size: 16px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

.rank-submit {
  padding: 0 8px;
  color: #fff8dc;
  background: #167b75;
  font-size: 14px;
  line-height: 1;
  text-shadow: 2px 2px 0 #2b1716;
}

.rank-submit:disabled {
  filter: grayscale(0.45);
  opacity: 0.72;
}

.rank-status {
  min-height: 18px;
  color: #7c4933;
  font-size: 12px;
  line-height: 1.25;
}

.online-rank-panel {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  border: 3px solid #2c1a17;
  background: rgba(255, 250, 229, 0.86);
  box-shadow: 0 4px 0 rgba(42, 23, 20, 0.24);
}

.online-rank-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #201017;
  text-align: left;
}

.online-rank-head strong {
  min-width: 0;
  overflow: hidden;
  color: #201017;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-refresh {
  min-height: 30px;
  padding: 0 9px;
  border: 2px solid #2c1a17;
  color: #201017;
  background: #fff06a;
  box-shadow: 0 3px 0 rgba(42, 23, 20, 0.28);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.rank-refresh:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(42, 23, 20, 0.35);
}

.online-rank-list {
  display: grid;
  gap: 5px;
  max-height: min(28dvh, 210px);
  margin: 0;
  padding: 0 3px 0 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: #c74236 rgba(255, 255, 255, 0.56);
  scrollbar-width: thin;
}

.online-rank-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 5px 7px;
  border: 2px solid rgba(44, 26, 23, 0.24);
  color: #201017;
  background: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-align: left;
}

.online-rank-list li.is-current {
  border-color: #df9a26;
  background: #fff0a8;
}

.online-rank-list span {
  color: #c74236;
}

.online-rank-list b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-rank-list strong {
  color: #167b75;
  white-space: nowrap;
}

.online-rank-empty {
  grid-template-columns: 1fr !important;
  color: #7c4933;
  text-align: center !important;
}

.result-panel .restart-button {
  justify-self: center;
  width: min(72vw, 260px);
  height: min(23vw, 86px);
}

.pause-screen {
  z-index: 29;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(20, 15, 18, 0.28), rgba(20, 15, 18, 0.68)),
    rgba(16, 12, 16, 0.18);
}

.pause-screen .primary-button {
  width: min(76vw, 292px);
  height: min(25vw, 96px);
}

.stage.game-over .note-field,
.stage.game-over .target-ring,
.stage.game-over .cart,
.stage.game-over .road-rig {
  filter: grayscale(0.4) saturate(0.65);
}

@media (max-height: 700px) {
  .game-shell {
    min-height: 100dvh;
  }

  .title-logo {
    top: 4%;
    width: min(112vw, 430px);
  }

  .title-cart {
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
    width: min(82vw, 292px);
  }

  .title-screen .primary-button {
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    width: min(74vw, 266px);
    height: min(24vw, 88px);
  }

  .cart {
    width: min(78vw, 300px);
    bottom: 26%;
  }

  .pixel-note {
    height: 68px;
    --orb-size: 46px;
    --note-gap: 132px;
  }

  .pixel-note.rescue {
    height: 74px;
    --orb-size: 50px;
  }

  .target-ring {
    width: 56px;
    height: 56px;
  }

  .tap-guide {
    top: calc(var(--target-y) + 40px);
    font-size: 11px;
  }

  .tap-status {
    bottom: calc(98px + env(safe-area-inset-bottom, 0px));
  }

  .judgement {
    font-size: 18px;
  }

  .judgement-popup {
    top: 20%;
    width: min(54vw, 196px);
  }

  .tap-button {
    width: 72px;
    height: 72px;
  }

  .pause-button {
    width: 92px;
    height: 31px;
    bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  }

  .primary-button {
    width: min(72vw, 250px);
    height: min(23vw, 82px);
  }
}
