.game-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #1bacd0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  color: #fff;
}
#runner {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.game-hud {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  right: max(24px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 25px;
  pointer-events: none;
}
.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 15px;
}
.hud-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #fff;
  background: linear-gradient(#1aa7ff, #046fe0 55%, #004eb8);
  border: 2px solid #72edff;
  border-radius: 15px;
  box-shadow:
    0 4px 0 #004296,
    inset 0 2px 1px #fff7,
    0 4px 14px #003f7044;
  padding: 0;
  pointer-events: auto;
  transition:
    filter 0.14s ease,
    transform 0.14s ease;
}
.hud-button svg {
  width: 24px;
  height: 24px;
}
.hud-button:hover {
  filter: brightness(1.12);
}
.hud-button:active {
  transform: translateY(2px);
}
.hud-button:focus-visible {
  outline-color: #fff;
}
.stage-label {
  display: grid;
  gap: 3px;
  text-shadow: 0 2px 4px #004c7f;
  padding-top: 2px;
}
.stage-label span {
  color: #ffed92;
  font-size: 14px;
  letter-spacing: 2px;
  font-weight: 900;
}
.stage-label strong {
  font-size: 24px;
  line-height: 1.2;
}
.run-progress {
  width: min(35vw, 400px);
  border-radius: 16px;
  padding: 11px 18px 14px;
  background: #003f78bd;
  box-shadow:
    inset 0 1px 0 #ffffff40,
    0 5px 20px #00425b22;
  backdrop-filter: blur(8px);
}
.run-progress > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 9px;
  gap: 10px;
}
#distance-live {
  font-size: 22px;
  font-weight: 900;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#distance-live small {
  font-size: 14px;
  color: #d3f5ff;
}
.finish-label {
  font-size: 12px;
  font-weight: 800;
  color: #a8e7ef;
  letter-spacing: 1px;
}
#distance-progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 9px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #002e5c;
}
#distance-progress::-webkit-progress-bar {
  background: #002e5c;
  border-radius: 8px;
}
#distance-progress::-webkit-progress-value {
  background: linear-gradient(90deg, #ffbc00, #fff15e);
  border-radius: 8px;
}
#distance-progress::-moz-progress-bar {
  background: #ffd52c;
  border-radius: 8px;
}
.coin-counter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 15px 4px 6px;
  border: 1px solid #fff8;
  border-radius: 30px;
  background: #004882aa;
  backdrop-filter: blur(6px);
}
.coin-counter > img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(1px 2px 1px #78460088);
}
.coin-counter strong {
  font-size: 25px;
  min-width: 24px;
  font-variant-numeric: tabular-nums;
}
.coin-counter.pop {
  animation: coin-pop 0.22s ease-out;
}
.best-score {
  position: absolute;
  top: 100px;
  right: 89px;
  padding: 7px 11px;
  border-radius: 10px;
  color: #fff7c4;
  font-size: 14px;
  font-weight: 800;
  background: #00517aa1;
  letter-spacing: 0.5px;
  display: flex;
  gap: 18px;
}
.best-score strong {
  margin-left: 5px;
  color: #fff;
}
.game-callout {
  position: absolute;
  top: 23%;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 28px);
  border: 1px solid #ffecaa;
  border-radius: 18px;
  padding: 11px 24px;
  color: #fff;
  background: #00477bdb;
  backdrop-filter: blur(6px);
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: 0 5px 16px #00517d22;
  pointer-events: none;
}
.game-callout:empty {
  display: none;
}
.game-callout.jump {
  border-color: #ffe56b;
  color: #ffef99;
}
.game-callout.slide {
  border-color: #83fbf2;
  color: #aaffec;
}
.countdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 34%;
  text-align: center;
  color: #ffde1b;
  font-family: "Arial Black", Impact, system-ui, sans-serif;
  font-size: clamp(90px, 16vw, 160px);
  line-height: 1.1;
  font-weight: 1000;
  -webkit-text-stroke: 2px #fff1ae;
  paint-order: stroke fill;
  text-shadow:
    0 7px 0 #004aa3,
    0 11px 0 #002f71,
    0 15px 25px #00355d99;
  pointer-events: none;
}
.coin-reward {
  position: absolute;
  top: 33%;
  right: 8%;
  padding: 9px 17px;
  border: 2px solid #fff1a3;
  border-radius: 16px;
  background: #0756aee8;
  color: #fff8b6;
  font-size: clamp(18px, 3vw, 27px);
  font-weight: 1000;
  text-shadow: 0 2px 2px #00366b;
  pointer-events: none;
}
.run-footer {
  position: absolute;
  bottom: max(18px, calc(14px + env(safe-area-inset-bottom)));
  left: max(20px, calc(14px + env(safe-area-inset-left)));
  right: max(20px, calc(14px + env(safe-area-inset-right)));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.keyboard-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 2px 4px #345b59;
  background: #004b72a6;
  padding: 9px 16px;
  border-radius: 14px;
}
.keyboard-hint i {
  width: 1px;
  height: 20px;
  background: #fff6;
  margin: 0 9px;
}
.keyboard-hint kbd {
  min-width: 29px;
  height: 29px;
  font-size: 20px;
}
.swipe-hint {
  display: none;
}
.run-dialog {
  z-index: 50;
  width: min(550px, calc(100vw - 28px));
  border-color: #e3ffff;
}
.quick-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 25px 0 18px;
}
.quick-controls > div {
  background: #e3f3fd;
  border: 1px solid #c4e2f4;
  border-radius: 17px;
  padding: 13px 4px;
}
.quick-controls > div > span {
  display: block;
  font-size: 33px;
  font-weight: 900;
  color: #0063bc;
  margin-bottom: 5px;
}
.quick-controls strong {
  color: #06469c;
  font-size: 14px;
}
.quick-controls p {
  color: #4e7895;
  font-size: 14px;
  line-height: 1.5;
  margin: 6px 0 0;
}
.run-stats {
  display: flex;
  justify-content: space-around;
  gap: 10px;
  margin: 24px 0 17px;
}
.run-stats > div {
  display: grid;
  gap: 7px;
}
.run-stats span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #407798;
}
.run-stats strong {
  color: #065bb4;
  font-size: 25px;
}
.run-best {
  color: #4c728c;
  font-size: 14px;
  line-height: 1.5;
  margin: 18px 0 22px;
}
.victory-hero {
  display: block;
  width: min(190px, 45vw);
  height: auto;
  margin: -5px auto -10px;
  filter: drop-shadow(0 8px 5px #0072a825);
}
.run-dialog.victory {
  background: radial-gradient(ellipse at 50% 35%, #fff3ac, #f5fdff 70%);
}
.game-screen.is-over #runner {
  filter: saturate(0.82);
}
@keyframes coin-pop {
  50% {
    transform: scale(1.14);
  }
}
@keyframes victory-dance {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg) scale(1);
  }
  50% {
    transform: translateY(-10px) rotate(4deg) scale(1.02);
  }
}
@media (max-aspect-ratio: 1/1) {
  .game-hud {
    top: max(14px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .hud-left,
  .hud-right {
    gap: 9px;
  }
  .hud-button {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }
  .hud-button svg {
    width: 21px;
    height: 21px;
  }
  .stage-label span {
    font-size: 12px;
    letter-spacing: 1px;
  }
  .stage-label strong {
    font-size: 17px;
  }
  .coin-counter {
    padding: 4px 10px 4px 4px;
    gap: 6px;
  }
  .coin-counter > img {
    width: 31px;
    height: 32px;
  }
  .coin-counter strong {
    font-size: 21px;
    min-width: 22px;
  }
  .run-progress {
    order: 3;
    width: 100%;
    padding: 8px 12px 10px;
    border-radius: 13px;
    margin-top: 7px;
  }
  .run-progress > div {
    margin-bottom: 6px;
  }
  #distance-live {
    font-size: 19px;
  }
  #distance-live small {
    font-size: 14px;
  }
  .best-score {
    top: 137px;
    right: 14px;
    font-size: 12px;
    padding: 5px 9px;
  }
  .game-callout {
    top: 27%;
    padding: 10px 15px;
    font-size: 17px;
    border-radius: 15px;
    width: max-content;
  }
  .run-footer {
    bottom: max(18px, calc(14px + env(safe-area-inset-bottom)));
    left: max(14px, calc(10px + env(safe-area-inset-left)));
    right: max(14px, calc(10px + env(safe-area-inset-right)));
  }
  .keyboard-hint {
    display: none;
  }
  .swipe-hint {
    display: block;
    font-size: 12px;
    font-weight: 900;
    text-shadow: 0 2px 6px #003e70;
    background: #005283a3;
    padding: 8px 14px;
    border-radius: 999px;
    letter-spacing: 0.3px;
  }
  .countdown {
    top: 38%;
  }
  .run-stats strong {
    font-size: 22px;
  }
}
@media (max-width: 350px) {
  .stage-label strong {
    font-size: 15px;
  }
  .hud-left,
  .hud-right {
    gap: 6px;
  }
  .game-hud {
    left: 9px;
    right: 9px;
  }
  .coin-counter {
    padding-right: 7px;
  }
  .swipe-hint {
    font-size: 11px;
  }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .game-hud {
    top: 10px;
    left: 14px;
    right: 14px;
    gap: 12px;
  }
  .stage-label strong {
    font-size: 18px;
  }
  .hud-button {
    width: 40px;
    height: 40px;
  }
  .run-progress {
    padding: 7px 13px 9px;
  }
  .best-score {
    top: 76px;
    right: 72px;
  }
  .run-footer {
    bottom: max(16px, calc(12px + env(safe-area-inset-bottom)));
  }
  .keyboard-hint {
    padding: 5px 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .victory-hero {
    animation: none;
  }
}

.dialog-sound {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  border: 2px solid #9ddbf7;
  border-radius: 13px;
  color: #07539e;
  background: #dceff9;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease,
    filter 0.14s ease,
    transform 0.14s ease;
}
.dialog-sound:hover {
  background: #c5e6f8;
}
.dialog-sound:active {
  transform: translateY(1px);
}
.dialog-sound svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.dialog-sound .icon-sound-off,
.dialog-sound .sound-label {
  display: none;
}
.dialog-sound.is-muted,
.dialog-sound[aria-pressed="false"] {
  background: #e9eff5;
  border-color: #efb29e;
  color: #6b4338;
}
.dialog-sound.is-muted .icon-sound-on,
.dialog-sound[aria-pressed="false"] .icon-sound-on {
  display: none;
}
.dialog-sound.is-muted .icon-sound-off,
.dialog-sound[aria-pressed="false"] .icon-sound-off {
  display: block;
}
.dialog-sound:focus-visible {
  outline: 3px solid #005bcd;
  outline-offset: 3px;
}
.run-dialog .eyebrow {
  padding-inline: 36px;
}
.run-dialog.paused .eyebrow {
  padding-inline: 0;
}
.run-dialog.paused .dialog-sound {
  position: static;
  width: 100%;
  height: auto;
  min-height: 48px;
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: 16px;
  background: linear-gradient(#eefaff, #d5effb);
  border: 2px solid #8bd2f2;
  color: #074790;
  box-shadow: 0 3px 0 #8ec2dc;
  font-size: 16px;
}
.run-dialog.paused .dialog-sound:hover {
  filter: brightness(1.03);
}
.run-dialog.paused .dialog-sound .sound-label {
  display: inline;
}
.run-dialog.paused .dialog-sound.is-muted,
.run-dialog.paused .dialog-sound[aria-pressed="false"] {
  background: linear-gradient(#f2f5f8, #dfe7ef);
  border-color: #e4b2a1;
  color: #5b3b32;
  box-shadow: 0 3px 0 #bcc6d1;
}
@media (max-width: 600px) {
  .run-footer .keyboard-hint,
  .run-footer .swipe-hint {
    max-width: calc(100% - 24px);
    text-align: center;
    font-size: 12px;
  }
}

.game-screen.tunnel .stage-label {
  text-shadow: 0 2px 4px #001b42;
}
.game-screen.tunnel .game-callout {
  background: #07315fe8;
}
.game-screen.swamp .game-callout {
  background: #214d3eea;
}
.game-screen.factory .game-callout {
  background: #233d58ed;
  border-color: #f7d044;
}
.game-screen.city .game-callout {
  background: #104ba5ee;
  border-color: #ffe14e;
}
.run-dialog.loss {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}
.run-dialog.loss h2 {
  font-size: clamp(24px, 5vw, 32px);
  margin-bottom: 12px;
}
.run-dialog.loss .intro {
  font-size: 15px;
  line-height: 1.45;
}
.run-dialog.loss .run-stats {
  margin: 16px 0 12px;
}
.run-dialog.loss .run-best {
  margin: 12px 0 18px;
}
.run-dialog.loss .gold-button {
  min-height: 50px;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.2;
}
.run-dialog.loss .blue-button {
  min-height: 48px;
  margin-top: 12px;
  font-size: 16px;
}
@media (max-height: 650px) {
  .run-dialog.loss {
    padding: 22px;
  }
  .run-dialog.loss .eyebrow {
    margin-bottom: 8px;
  }
  .run-dialog.loss .run-stats {
    margin-block: 12px;
  }
  .run-dialog.loss .run-best {
    margin-block: 10px 14px;
  }
}

@media (pointer: coarse) {
  .run-footer .keyboard-hint {
    display: none;
  }
  .run-footer .swipe-hint {
    display: block;
    font-size: 12px;
    font-weight: 900;
    padding: 8px 14px;
    border-radius: 999px;
    background: #005283a3;
  }
}

.super-pickups {
  position: absolute;
  inset: 0;
  z-index: 28;
  pointer-events: none;
  overflow: hidden;
  perspective: 850px;
}
.super-pickup {
  position: absolute;
  transform-style: preserve-3d;
  filter: drop-shadow(0 0 14px #ffdd69);
  will-change: transform, opacity;
  text-align: center;
}
.super-pickup canvas {
  display: block;
  width: 100%;
  height: auto;
  backface-visibility: visible;
}
.super-pickup strong {
  display: block;
  color: #fff5a9;
  font:
    1000 clamp(22px, 4vw, 44px) / 1.1 "Trebuchet MS",
    Arial;
  text-shadow:
    0 3px #06448b,
    2px 0 #06448b,
    -2px 0 #06448b;
}
.vacation-scene {
  position: fixed;
  inset: 0;
  z-index: 15000;
  background: #87daf6;
  overflow: hidden;
  isolation: isolate;
}
.vacation-scene[hidden] {
  display: none;
}
.vacation-scene.white-in {
  animation: vacation-white 0.9s ease-in-out both;
}
.vacation-art {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transition: opacity 1.3s ease-in-out;
}
.vacation-art canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.vacation-scene.revealed .vacation-art {
  opacity: 1;
}
.vacation-action {
  position: absolute;
  margin: 0;
  border-radius: 999px;
  padding: 0 22px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 0.55s ease,
    transform 0.25s ease,
    filter 0.14s ease;
}
.vacation-action.gold-button {
  font-size: clamp(18px, 2.2vw, 24px);
  letter-spacing: 0.4px;
  box-shadow:
    0 4px 0 #ec8900,
    0 7px 0 #0458b5,
    0 12px 26px rgba(0, 42, 86, 0.38);
}
.vacation-action.blue-button {
  font-size: clamp(15px, 1.8vw, 19px);
  box-shadow:
    0 4px 0 #003e94,
    0 10px 22px rgba(0, 34, 78, 0.34);
}
.vacation-btn-icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
}
.vacation-btn-icon.trophy-icon {
  color: #ffe867;
}
.vacation-scene.controls-ready .vacation-action {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.vacation-scene.instant .vacation-action {
  transition:
    filter 0.14s ease,
    transform 0.14s ease;
}
.vacation-scene.controls-ready .vacation-action:hover {
  filter: brightness(1.07);
  transform: scale(1.025);
}
.vacation-scene.controls-ready .vacation-action:active {
  transform: translateY(2px) scale(0.99);
}
.vacation-action:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px #0062c9;
}
.vacation-action:disabled {
  cursor: default;
}
.vacation-score {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  margin: 0;
  padding: 9px 18px;
  border-radius: 99px;
  background: #004d82d9;
  color: #fff7a8;
  font:
    900 clamp(14px, 2vw, 18px) / 1.2 "Trebuchet MS",
    Arial;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 1.3s;
}
.vacation-scene.mobile .vacation-score {
  left: 50%;
  right: auto;
  top: max(10px, calc(8px + env(safe-area-inset-top)));
  padding: 5px 14px;
  font-size: 14px;
  transform: translateX(-50%);
}
.vacation-scene.revealed .vacation-score {
  opacity: 1;
}
.vacation-scene.instant .vacation-art,
.vacation-scene.instant .vacation-score {
  transition: none;
}
@keyframes vacation-white {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .vacation-scene.white-in {
    animation: none;
  }
  .vacation-art,
  .vacation-score {
    transition-duration: 0.15s;
  }
}

/* Super coin benefits have their own space above the road and survive regular pickups. */
.super-message {
  position: absolute;
  z-index: 29;
  top: max(141px, 20vh);
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 28px));
  box-sizing: border-box;
  padding: 11px 20px 10px;
  border: 2px solid #ffe875;
  border-radius: 20px;
  background: linear-gradient(120deg, #063e8aee, #087bb9f2);
  box-shadow:
    0 5px 0 #003b7f88,
    0 0 25px #ffe16a55;
  text-align: center;
  color: white;
  pointer-events: none;
  font-family: "Trebuchet MS", Arial, sans-serif;
}
.super-message[hidden] {
  display: none;
}
.super-message span {
  display: block;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.25;
  font-weight: 900;
  letter-spacing: 0.4px;
}
.super-message strong {
  display: block;
  color: #ffec72;
  font-size: clamp(22px, 2.8vw, 30px);
  line-height: 1.2;
  font-weight: 1000;
  margin-top: 3px;
}
.super-message small {
  display: block;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 1px;
  margin-top: 5px;
  color: #d4faff;
}
.super-message.arriving {
  animation: super-message-in 0.24s ease-out both;
}
.has-super-message .game-callout {
  top: calc(max(141px, 20vh) + 121px);
}
@keyframes super-message-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}
@media (max-aspect-ratio: 1/1) {
  .super-message {
    top: 173px;
    padding: 10px 12px 9px;
    border-radius: 17px;
  }
  .super-message span {
    font-size: 16px;
    letter-spacing: 0;
  }
  .super-message strong {
    font-size: 24px;
  }
  .super-message small {
    font-size: 14px;
  }
  .has-super-message .game-callout {
    top: 289px;
  }
}
@media (max-height: 500px) and (min-aspect-ratio: 1/1) {
  .super-message {
    top: 87px;
    width: min(450px, calc(100% - 180px));
    padding: 7px 12px;
  }
  .super-message span {
    font-size: 16px;
  }
  .super-message strong {
    font-size: 22px;
  }
  .super-message small {
    font-size: 14px;
    margin-top: 2px;
  }
  .has-super-message .game-callout {
    top: 195px;
    font-size: 16px;
    padding: 7px 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .super-message.arriving {
    animation: none;
  }
}

/* The collection celebration stays in a clipped edge strip at every rotation angle. */
.super-pickup-slot {
  position: absolute;
  overflow: hidden;
  contain: paint;
  pointer-events: none;
  padding: 8px;
  box-sizing: border-box;
}
.super-pickup {
  position: relative;
  inset: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 100%;
  height: 100%;
  transform-origin: center;
  filter: drop-shadow(0 0 5px #ffdd69);
}
.super-pickup canvas {
  width: 100%;
  height: auto;
  max-height: calc(100% - 25px);
  object-fit: contain;
  flex-shrink: 1;
}
.super-pickup strong {
  flex-shrink: 0;
  font-size: clamp(12px, 3.3vw, 20px);
  line-height: 1.2;
  margin-top: 3px;
  white-space: nowrap;
}
/* Cumulative coin values need enough room for millions on narrow phones. */
@media (max-aspect-ratio: 1/1) {
  .game-hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 6px;
    row-gap: 8px;
  }
  .hud-left {
    min-width: 0;
    gap: 6px;
  }
  .hud-right {
    gap: 7px;
  }
  .stage-label {
    min-width: 0;
  }
  .stage-label strong {
    font-size: 15px;
    line-height: 1.1;
  }
  .run-progress {
    grid-column: 1/-1;
    box-sizing: border-box;
    margin-top: 0;
  }
  .coin-counter {
    gap: 5px;
    padding: 4px 8px 4px 4px;
  }
  .coin-counter strong {
    min-width: 0;
    font-size: clamp(16px, 4.8vw, 20px);
  }
}
@media (max-width: 350px) {
  .stage-label strong {
    font-size: 14px;
  }
  .hud-right {
    gap: 5px;
  }
  .coin-counter {
    padding-right: 6px;
  }
}

/* Each intermediate finish shows the live online leader and a route back to the table. */
.stage-leader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  margin: 0 0 20px;
  padding: 12px 15px;
  border: 2px solid #f5cd4a;
  border-radius: 16px;
  background: linear-gradient(120deg, #fff4b8, #fffdf0);
  color: #064b95;
  text-align: left;
}
.stage-leader[hidden] {
  display: none;
}
.stage-leader-label {
  grid-column: 1/-1;
  color: #877019;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.7px;
}
.stage-leader strong {
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  min-width: 0;
}
.stage-leader [data-leader-score] {
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.game-screen.beyond-intro .game-callout,
.game-screen.beyond-intro .keyboard-hint,
.game-screen.beyond-intro .swipe-hint {
  display: none !important;
}
.run-dialog.victory {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
}
.run-dialog.victory .run-best {
  margin-bottom: 14px;
}
.run-dialog.victory #run-leaderboard {
  margin-top: 16px;
}
@media (max-width: 420px) {
  .stage-leader {
    gap: 4px 8px;
    padding: 10px 12px;
  }
  .stage-leader strong {
    font-size: 16px;
  }
  .stage-leader [data-leader-score] {
    font-size: 13px;
  }
}
@media (max-height: 800px) {
  .run-dialog.victory {
    padding: 22px;
  }
  .run-dialog.victory h2 {
    font-size: 28px;
    margin-bottom: 10px;
  }
  .run-dialog.victory .intro {
    font-size: 15px;
    margin-bottom: 10px;
  }
  .run-dialog.victory .victory-hero {
    width: 110px;
  }
  .run-dialog.victory .run-stats {
    margin-block: 12px;
  }
  .run-dialog.victory .run-best {
    margin: 10px 0;
  }
  .run-dialog.victory .stage-leader {
    margin-bottom: 12px;
  }
  .run-dialog.victory .gold-button {
    min-height: 48px;
    padding: 8px 12px;
    font-size: 16px;
  }
  .run-dialog.victory #run-leaderboard {
    min-height: 44px;
    margin-top: 12px;
  }
  .run-dialog.victory .text-button {
    margin-top: 16px;
  }
}

@media (max-height: 650px) {
  .run-dialog.victory {
    padding: 16px;
  }
  .run-dialog.victory h2 {
    font-size: 24px;
  }
  .run-dialog.victory .eyebrow {
    font-size: 11px;
    margin-bottom: 8px;
  }
  .run-dialog.victory .intro {
    display: none;
  }
  .run-dialog.victory .victory-hero {
    width: 80px;
  }
  .run-dialog.victory .run-stats {
    gap: 6px;
    margin-block: 10px;
  }
  .run-dialog.victory .run-stats span {
    font-size: 11px;
    letter-spacing: 0;
    white-space: nowrap;
  }
  .run-dialog.victory .run-stats strong {
    font-size: clamp(13px, 4.5vw, 18px);
    white-space: nowrap;
  }
  .run-dialog.victory .run-best {
    margin-block: 8px;
  }
  .run-dialog.victory .stage-leader {
    padding: 9px 10px;
    margin-bottom: 12px;
  }
  .run-dialog.victory .stage-leader strong {
    font-size: 14px;
  }
  .run-dialog.victory .stage-leader [data-leader-score] {
    font-size: 12px;
  }
}

.run-dialog.loss #run-home {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  margin: 10px 0 0;
  padding: 8px 12px;
  font-size: 15px;
}

/* Clash-style GPU-composited cloud wipe for stage transitions (transform & opacity only). */
.stage-transition {
  position: fixed;
  inset: 0;
  z-index: 16000;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: auto;
  contain: layout style paint;
  --badge-accent: #ffcf1b;
  --badge-border: #fff39e;
  --badge-ink: #06357d;
}
.stage-transition[data-stage="2"] {
  --badge-accent: #3cb8ff;
  --badge-border: #a8ecff;
  --badge-ink: #042b6b;
}
.stage-transition[data-stage="3"] {
  --badge-accent: #38d69a;
  --badge-border: #b4ffdf;
  --badge-ink: #084232;
}
.stage-transition[data-stage="4"] {
  --badge-accent: #ffba26;
  --badge-border: #ffe89e;
  --badge-ink: #173454;
}
.stage-transition[data-stage="5"] {
  --badge-accent: #31baff;
  --badge-border: #b8f1ff;
  --badge-ink: #06317a;
}
.stage-transition[hidden] {
  display: none;
}
.transition-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #56c9ff 0%, #9ce4ff 52%, #d8f6ff 100%);
  opacity: 0;
  transition: opacity 220ms ease-out;
}
.stage-transition.is-closing .transition-veil,
.stage-transition.is-closed .transition-veil {
  opacity: 1;
}
.stage-transition.is-opening .transition-veil {
  opacity: 0;
  transition: opacity 240ms ease-in;
}
.transition-wing {
  position: absolute;
  top: -4%;
  bottom: -4%;
  width: 84%;
  pointer-events: none;
}
.transition-wing svg {
  display: block;
  width: 100%;
  height: 100%;
}
.transition-left {
  left: -14%;
  transform: translate3d(-106%, 0, 0);
}
.transition-right {
  right: -14%;
  transform: translate3d(106%, 0, 0);
}
.stage-transition.is-closing .transition-wing,
.stage-transition.is-closed .transition-wing {
  will-change: transform;
  transform: translate3d(0, 0, 0);
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}
.stage-transition.is-opening .transition-left {
  will-change: transform;
  transform: translate3d(-106%, 0, 0);
  transition: transform 300ms cubic-bezier(0.55, 0, 0.85, 0.35);
}
.stage-transition.is-opening .transition-right {
  will-change: transform;
  transform: translate3d(106%, 0, 0);
  transition: transform 300ms cubic-bezier(0.55, 0, 0.85, 0.35);
}
.transition-badge {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 34px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.82);
  border: 3px solid #fff;
  box-shadow: 0 14px 36px rgba(6, 53, 125, 0.18);
  text-align: center;
  opacity: 0;
  transform: translate3d(0, 10px, 0) scale(0.92);
  transition:
    opacity 150ms ease-out 70ms,
    transform 190ms cubic-bezier(0.22, 1, 0.36, 1) 70ms;
}
.stage-transition.is-closing .transition-badge,
.stage-transition.is-closed .transition-badge {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}
.stage-transition.is-opening .transition-badge {
  opacity: 0;
  transform: translate3d(0, -8px, 0) scale(0.94);
  transition:
    opacity 140ms ease-in,
    transform 160ms ease-in;
}
.transition-emblem {
  width: clamp(72px, 14vw, 96px);
  height: clamp(72px, 14vw, 96px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff8bc, #ffca00 72%, #f49300);
  border: 4px solid #fff;
  box-shadow:
    0 5px 0 #0754b8,
    0 12px 26px rgba(6, 53, 125, 0.28);
}
.transition-emblem img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}
.transition-kicker {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 999px;
  background: var(--badge-accent);
  border: 2px solid var(--badge-border);
  color: var(--badge-ink);
  font:
    900 clamp(12px, 2vw, 15px) / 1.2 "Trebuchet MS",
    Arial,
    sans-serif;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  box-shadow: 0 3px 0 rgba(6, 53, 125, 0.22);
}
.transition-title {
  color: #06357d;
  font-family: "Arial Black", "Trebuchet MS", Arial, sans-serif;
  font-size: clamp(24px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.85);
}
.stage-transition.is-reduced .transition-wing {
  display: none;
}
.stage-transition.is-reduced .transition-veil {
  transition: opacity 160ms ease-out;
}
.stage-transition.is-reduced.is-opening .transition-veil {
  transition: opacity 180ms ease-in;
}
.stage-transition.is-reduced .transition-badge {
  transform: none;
  transition: opacity 140ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .stage-transition .transition-wing {
    display: none;
  }
  .stage-transition .transition-veil {
    transition: opacity 160ms ease-out !important;
  }
  .stage-transition.is-opening .transition-veil {
    transition: opacity 180ms ease-in !important;
  }
  .stage-transition .transition-badge {
    transform: none !important;
    transition: opacity 140ms ease !important;
  }
}
