/* ==========================================================================
 * Definite Dash — shared shell + production gameplay presentation
 * ========================================================================== */

:root {
  --font-game: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --navy-950: #08245a;
  --navy-900: #0b2d6b;
  --blue-700: #16549a;
  --blue-600: #1f69b3;
  --blue-400: #53a9ec;
  --cream: #fff9ee;
  --sand: #f5bb64;
  --green: #45cf66;
  --violet: #9a43da;
  --gold: #ffbb27;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

html { overflow: hidden; }

body {
  overflow: hidden;
  color: #1f2933;
  background: linear-gradient(#64bdf1, #cbe9f7);
  font-family: var(--font-game);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app {
  position: relative;
  width: 100%;
  max-width: 1920px;
  height: 100dvh;
  min-height: 480px;
  margin: 0 auto;
  overflow: hidden;
  background: #77c7ef;
}

.hidden {
  display: none !important;
}

.btn {
  min-height: 44px;
  padding: 10px 20px;
  border: 2px solid #24418a;
  border-radius: 14px;
  background: #fff;
  color: #24418a;
  cursor: pointer;
  font: 800 0.95rem/1 var(--font-game);
  transition: transform 100ms ease, filter 120ms ease, background 120ms ease;
  touch-action: manipulation;
}

.btn:hover:not(:disabled) {
  background: #eef5ff;
  filter: brightness(1.04);
}

.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  border-color: #193f8d;
  background: linear-gradient(180deg, #3e7ce3, #244caa);
  color: #fff;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.35), 0 4px 10px rgba(10, 37, 89, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4a88ed, #2954b6);
}

.btn-small {
  min-height: 34px;
  padding: 7px 12px;
  font-size: 0.82rem;
}

.btn-dev {
  border-color: #b3261e;
  background: #fff5f4;
  color: #b3261e;
  font-size: 0.78rem;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  overflow-y: auto;
}

.screen-error {
  justify-content: center;
  gap: 14px;
  background: #fff1f0;
  text-align: center;
}

.error-title { margin: 0; color: #b3261e; }

.error-message {
  max-width: 48ch;
  margin: 0;
  padding: 14px;
  border: 1px solid #f3c2be;
  border-radius: 12px;
  background: #fff;
  white-space: pre-wrap;
  font: 0.84rem/1.5 ui-monospace, Consolas, monospace;
}

/* ==========================================================================
 * Gameplay shell and projected road
 * ========================================================================== */

.screen-game {
  padding: 0;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  isolation: isolate;
}

.runner {
  position: absolute;
  inset: 0;
  overflow: hidden;
  contain: layout paint size;
  container-type: size;
  touch-action: pan-y pinch-zoom;
  overscroll-behavior-x: none;
  /* Safe first-paint fallbacks; gameplay replaces projected geometry. */
  --scene-horizon-y: 42.5%;
  --scene-collision-y: 82%;
  --player-bottom: 11.5%;
  --lane-x-0: 21%;
  --lane-x-1: 50%;
  --lane-x-2: 79%;
  --lane-marker-width: 10px;
  --lane-marker-height: 78px;
  --road-texture-offset-px: 0px;
}

.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  contain: paint;
  pointer-events: none;
  background-color: #54b6ee;
  background-image: url("../assets/backgrounds/road-desktop.webp");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

/* JS selects the same three projection layouts used by the road geometry. */
.runner[data-road-layout="tablet"] .scene {
  background-image: url("../assets/backgrounds/road-tablet.webp");
}

.runner[data-road-layout="mobile"] .scene {
  background-image: url("../assets/backgrounds/road-mobile-clean-v2.webp");
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(to bottom, rgba(64, 171, 235, 0.08), transparent 34%, rgba(28, 82, 41, 0.04));
  pointer-events: none;
}

/* Native roadside footage owns near/midground motion only. The fixed scene
 * remains the far world and the coded road paints over every inner edge. */
.roadside-world {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  contain: layout paint;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.roadside-panel {
  position: absolute;
  top: 27%;
  bottom: -2%;
  width: clamp(170px, 15vw, 300px);
  overflow: hidden;
  contain: strict;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease-out;
}

.roadside-panel.is-ready { opacity: 1; }

.roadside-panel--left {
  left: 0;
  -webkit-mask-image: linear-gradient(to right, #000 0 68%, rgba(0, 0, 0, 0.72) 80%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0 68%, rgba(0, 0, 0, 0.72) 80%, transparent 100%);
}

.roadside-panel--right {
  right: 0;
  -webkit-mask-image: linear-gradient(to left, #000 0 68%, rgba(0, 0, 0, 0.72) 80%, transparent 100%);
  mask-image: linear-gradient(to left, #000 0 68%, rgba(0, 0, 0, 0.72) 80%, transparent 100%);
}

.roadside-video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  opacity: 1;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, 0.56) 10%, #000 22%);
  mask-image: linear-gradient(to bottom, transparent 0, rgba(0, 0, 0, 0.56) 10%, #000 22%);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  transition: opacity 90ms linear;
}

.roadside-panel--left .roadside-video { object-position: left center; }
.roadside-panel--right .roadside-video { object-position: right center; }

.runner[data-road-layout="tablet"] .roadside-panel {
  top: 27%;
  bottom: -1%;
  width: 15.5%;
}

.runner[data-road-layout="mobile"] .roadside-panel {
  top: 25%;
  bottom: 0;
  width: 11.5%;
  transition-duration: 160ms;
}

.runner[data-road-layout="mobile"] .roadside-panel--left {
  -webkit-mask-image: linear-gradient(to right, #000 0 66%, transparent 100%);
  mask-image: linear-gradient(to right, #000 0 66%, transparent 100%);
}

.runner[data-road-layout="mobile"] .roadside-panel--right {
  -webkit-mask-image: linear-gradient(to left, #000 0 66%, transparent 100%);
  mask-image: linear-gradient(to left, #000 0 66%, transparent 100%);
}

@media (prefers-reduced-motion: reduce) {
  .roadside-world { display: none; }
}

.road-edge,
.road-surface,
.road-shading,
.road-tracks {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  contain: paint;
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent calc(var(--scene-horizon-y) - 0.5%),
    #000 calc(var(--scene-horizon-y) + 5.5%)
  );
  mask-image: linear-gradient(
    to bottom,
    transparent calc(var(--scene-horizon-y) - 0.5%),
    #000 calc(var(--scene-horizon-y) + 5.5%)
  );
  pointer-events: none;
}

/* A soft grass, packed-earth and pale-stone rim joins road to countryside. */
.road-edge {
  background:
    linear-gradient(
      90deg,
      rgba(74, 101, 43, 0.78) 0%,
      rgba(137, 119, 52, 0.76) 9%,
      rgba(224, 177, 94, 0.82) 21%,
      rgba(242, 211, 151, 0.74) 30%,
      rgba(242, 211, 151, 0.74) 70%,
      rgba(224, 177, 94, 0.82) 79%,
      rgba(137, 119, 52, 0.76) 91%,
      rgba(74, 101, 43, 0.78) 100%
    );
}

.road-edge::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      90deg,
      rgba(58, 83, 35, 0.35),
      rgba(255, 231, 177, 0.3) 22%,
      transparent 33%,
      transparent 67%,
      rgba(255, 231, 177, 0.3) 78%,
      rgba(58, 83, 35, 0.35)
    );
  filter: blur(2px);
}

.road-edge::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 13% 68%, rgba(167, 119, 61, 0.17) 0 7%, transparent 25%),
    radial-gradient(ellipse at 87% 34%, rgba(183, 137, 74, 0.15) 0 6%, transparent 23%),
    linear-gradient(90deg, rgba(85, 104, 48, 0.12), transparent 24% 76%, rgba(85, 104, 48, 0.12));
  background-size: 100% 440px;
  background-repeat: repeat-y;
  opacity: 0.44;
}

.road-surface {
  isolation: isolate;
  background:
    radial-gradient(
      ellipse at 50% 88%,
      rgba(255, 226, 151, 0.22) 0 17%,
      rgba(255, 219, 135, 0.08) 36%,
      transparent 58%
    ),
    linear-gradient(
      90deg,
      rgba(108, 61, 26, 0.3) 0%,
      rgba(168, 101, 39, 0.13) 13%,
      transparent 31%,
      rgba(255, 231, 169, 0.13) 46%,
      rgba(255, 231, 169, 0.13) 54%,
      transparent 69%,
      rgba(168, 101, 39, 0.13) 87%,
      rgba(108, 61, 26, 0.3) 100%
    ),
    linear-gradient(180deg, #e7ca8b 0%, #e9b862 46%, #e4a24d 78%, #da9142 100%);
}

.road-surface::before,
.road-surface::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.road-surface::before {
  background:
    radial-gradient(ellipse at 12% 72%, rgba(137, 88, 40, 0.17) 0 3%, rgba(137, 88, 40, 0.055) 7%, transparent 15%),
    radial-gradient(ellipse at 87% 35%, rgba(145, 96, 50, 0.15) 0 2.5%, transparent 13%),
    radial-gradient(ellipse at 22% 18%, rgba(248, 217, 153, 0.18) 0 3%, transparent 14%),
    radial-gradient(ellipse at 78% 84%, rgba(242, 199, 119, 0.15) 0 4%, transparent 17%),
    radial-gradient(ellipse, rgba(155, 99, 44, 0.16) 0%, rgba(155, 99, 44, 0.05) 42%, transparent 72%),
    radial-gradient(ellipse, rgba(255, 224, 158, 0.15) 0%, rgba(255, 224, 158, 0.045) 40%, transparent 70%),
    radial-gradient(ellipse, rgba(170, 119, 67, 0.15) 0 1.2px, rgba(170, 119, 67, 0.045) 2.2px, transparent 3.8px),
    radial-gradient(ellipse, rgba(245, 211, 151, 0.16) 0 1.4px, rgba(245, 211, 151, 0.045) 2.5px, transparent 4px);
  background-position:
    center var(--road-texture-offset-px, 0px),
    center var(--road-texture-offset-px, 0px),
    center var(--road-texture-offset-px, 0px),
    center var(--road-texture-offset-px, 0px),
    17px calc(var(--road-texture-offset-px, 0px) + 29px),
    51px calc(var(--road-texture-offset-px, 0px) + 73px),
    31px calc(var(--road-texture-offset-px, 0px) + 47px),
    67px calc(var(--road-texture-offset-px, 0px) + 101px);
  background-size:
    100% 460px,
    100% 460px,
    100% 460px,
    100% 460px,
    83px 117px,
    127px 163px,
    89px 113px,
    131px 167px;
  background-repeat: repeat-y, repeat-y, repeat-y, repeat-y, repeat, repeat, repeat, repeat;
  opacity: 0.84;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.42) 48%, #000);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.42) 48%, #000);
}

.road-surface::after {
  background:
    radial-gradient(ellipse at 17% 62%, rgba(151, 96, 42, 0.38) 0 5%, rgba(151, 96, 42, 0.12) 12%, transparent 25%),
    radial-gradient(ellipse at 83% 45%, rgba(163, 106, 48, 0.32) 0 6%, rgba(163, 106, 48, 0.1) 13%, transparent 27%),
    radial-gradient(ellipse at 49% 78%, rgba(255, 226, 156, 0.42) 0 9%, rgba(255, 226, 156, 0.13) 18%, transparent 34%),
    linear-gradient(102deg, transparent 17%, rgba(178, 116, 50, 0.16) 31%, transparent 45% 66%, rgba(246, 208, 131, 0.14) 78%, transparent 91%);
  opacity: var(--road-grain-o, 0.14);
}

.road-shading i,
.road-tracks i {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

.road-shading i {
  background: rgba(104, 62, 27, var(--wear-alpha, 0.1));
  filter: blur(5px);
}

.road-shading i:first-child { clip-path: var(--wear-clip-l, none); }
.road-shading i:last-child { clip-path: var(--wear-clip-r, none); }

.road-tracks i {
  background: rgba(118, 76, 35, 0.06);
  filter: blur(7px);
}

.road-tracks i:nth-child(1) { clip-path: var(--track-clip-0, none); }
.road-tracks i:nth-child(2) { clip-path: var(--track-clip-1, none); }
.road-tracks i:nth-child(3) { clip-path: var(--track-clip-2, none); }

.road-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  contain: paint;
  pointer-events: none;
}

.road-layer > *,
.road-detail {
  position: absolute;
  top: 0;
  left: 0;
  contain: layout style;
  transform-origin: center;
}

.road-detail { z-index: 1; }

img.road-detail {
  display: block;
  max-width: none;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

/* js/game.js deactivates surplus detail sprites with el.hidden; without this
 * guard the display:block above would out-specify the UA's [hidden] rule and
 * leak the deactivated rock/debris sprites at the layer's top-left corner. */
img.road-detail[hidden] {
  display: none;
}

.road-detail--flat,
.road-detail--raised,
.road-detail--roadside { filter: none; }

.lane-marker {
  z-index: 100;
  width: var(--lane-marker-width);
  height: var(--lane-marker-height);
  overflow: hidden;
  border-radius: 18% 20% 16% 18%;
  background:
    linear-gradient(108deg, transparent 0 32%, rgba(143, 88, 33, 0.12) 36% 41%, transparent 45% 100%),
    linear-gradient(90deg, rgba(126, 78, 30, 0.1), transparent 24% 76%, rgba(126, 78, 30, 0.1)),
    linear-gradient(180deg, #fff2bd 0%, #f8dda0 54%, #efc878 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 251, 226, 0.28),
    0 1px 1px rgba(91, 56, 23, 0.22);
}

.lane-marker::after {
  content: "";
  position: absolute;
  inset: 8% 13%;
  border-radius: inherit;
  background: linear-gradient(112deg, transparent 0 43%, rgba(131, 80, 31, 0.15) 46% 50%, transparent 53% 100%);
  opacity: 0.56;
}

.runner[data-road-layout="tablet"] .road-surface::before {
  background-size: 100% 500px, 100% 500px, 100% 500px, 100% 500px, 97px 139px, 143px 187px, 103px 137px, 151px 199px;
  opacity: 0.58;
}

.runner[data-road-layout="mobile"] .road-surface::before {
  background-size: 100% 560px, 100% 560px, 100% 560px, 100% 560px, 123px 167px, 169px 223px, 149px 197px, 211px 263px;
  opacity: 0.42;
}

/* JS also selects the mobile road for short landscape viewports (for example
 * 1024×600). Keep the mobile paint budget tied to that actual layout instead
 * of relying only on the narrower max-width media query below. */
.runner[data-road-layout="mobile"] .road-edge { opacity: 0.62; }
.runner[data-road-layout="mobile"] .road-edge::before,
.runner[data-road-layout="mobile"] .road-shading i,
.runner[data-road-layout="mobile"] .road-tracks i { filter: none; }
.runner[data-road-layout="mobile"] .road-edge::after { opacity: 0.28; }
.screen-game[data-road-layout="mobile"] .coin-spark { box-shadow: none; }

.dust-puff {
  border-radius: 50%;
  background: radial-gradient(circle, rgba(230, 199, 144, 0.48), transparent 70%);
}

/* ==========================================================================
 * Collectible coins — sparse road bonus + compact collection feedback
 * ========================================================================== */

.road-coin {
  width: 68px;
  aspect-ratio: 1;
  opacity: 0;
  transform-origin: 50% 100%;
  perspective: 320px;
  pointer-events: none;
}

.road-coin__image,
.coin--collecting {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.road-coin__image {
  transform-style: flat;
  filter: none;
  animation: coin-idle 2400ms ease-in-out infinite;
}

@keyframes coin-idle {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(-1deg) scale(1); }
  50% { transform: translate3d(0, -3px, 0) rotate(1deg) scale(1.035); }
}

.coin-burst {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9;
  width: 0;
  height: 0;
  transform: translate3d(var(--coin-burst-x), var(--coin-burst-y), 0);
  pointer-events: none;
}

.coin-spark {
  position: absolute;
  top: -3px;
  left: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff4a8;
  box-shadow: 0 0 4px rgba(255, 187, 31, 0.72);
  animation: coin-spark 430ms ease-out forwards;
}

.coin-spark:nth-child(even) { background: #ffc928; }

@keyframes coin-spark {
  0% { opacity: 0.95; transform: translate3d(0, 0, 0) scale(0.65); }
  70% { opacity: 0.82; }
  100% {
    opacity: 0;
    transform: translate3d(var(--spark-x), var(--spark-y), 0) scale(0.15);
  }
}

.coin--collecting {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 150;
  width: var(--coin-flight-size);
  height: var(--coin-flight-size);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  filter: drop-shadow(0 4px 5px rgba(127, 72, 7, 0.3));
  animation: coin-to-hud var(--coin-flight-duration, 500ms)
    cubic-bezier(0.2, 0.76, 0.24, 1) forwards;
}

@keyframes coin-to-hud {
  0% {
    opacity: 1;
    transform: translate3d(var(--coin-from-x), var(--coin-from-y), 0)
      translate(-50%, -50%) scale(1);
  }
  18% {
    opacity: 1;
    transform: translate3d(var(--coin-from-x), var(--coin-from-y), 0)
      translate(-50%, -50%) scale(1.14);
  }
  52% {
    opacity: 0.96;
    transform: translate3d(var(--coin-mid-x), var(--coin-mid-y), 0)
      translate(-50%, -50%) scale(0.78);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--coin-to-x), var(--coin-to-y), 0)
      translate(-50%, -50%) scale(0.28);
  }
}

.hud-pill--score.hud-coin--pulse {
  animation: hud-coin-pulse 420ms ease-out;
}

@keyframes hud-coin-pulse {
  42% {
    transform: scale(1.08);
    filter: brightness(1.1) drop-shadow(0 0 7px rgba(255, 205, 55, 0.48));
  }
}

.screen-game:is(.is-coin-paused, .is-world-idle) .road-coin__image,
.screen-game:is(.is-coin-paused, .is-world-idle) .coin-spark,
.screen-game:is(.is-coin-paused, .is-world-idle) .coin--collecting,
.screen-game:is(.is-coin-paused, .is-world-idle) .hud-coin--pulse,
.screen-game:is(.is-coin-paused, .is-world-idle) .player-reaction,
.screen-game:is(.is-coin-paused, .is-world-idle) .score-pop,
.screen-game:is(.is-coin-paused, .is-world-idle) .answer-gate__art,
.screen-game:is(.is-coin-paused, .is-world-idle) .answer-dock__choice,
.screen-game:is(.is-coin-paused, .is-world-idle) .feedback,
.screen-game:is(.is-coin-paused, .is-world-idle) .hud-heart,
.screen-game:is(.is-coin-paused, .is-world-idle) .hud-icon--flame {
  animation-play-state: paused;
}

/* ==========================================================================
 * Answer gates
 * ========================================================================== */

.gates {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.answer-gate {
  position: absolute;
  top: 0;
  left: 0;
  /* Hidden first-paint fallback only — JS sizes every gate to its projected
   * road width in integer pixels each frame. Sizing the element directly
   * (instead of scaling a 960px layer) keeps the raster at display size, so
   * the art never passes through a stale, resampled GPU raster. */
  width: 960px;
  aspect-ratio: 960 / 930;
  opacity: 0;
  cursor: pointer;
  touch-action: manipulation;
  transform: translate(-50%, -100%);
  will-change: transform, opacity;
  container-type: inline-size;
}

.answer-gate__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: none;
}

.answer-gate__label {
  position: absolute;
  top: 37.5%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  color: #fff;
  font: 900 14.5cqw/1 var(--font-game);
  letter-spacing: 0.01em;
  white-space: nowrap;
  text-shadow: 0 0.07em 0 #15326b, 0 0.12em 0.16em rgba(11, 28, 60, 0.42);
  pointer-events: none;
}

.answer-gate[data-category="none"] .answer-gate__label {
  font-size: 12cqw;
}

.answer-gate::after {
  content: "";
  position: absolute;
  bottom: -1%;
  left: 50%;
  width: 66%;
  height: 7%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(21, 32, 45, 0.48), transparent 72%);
  opacity: var(--gate-shadow-o, 0.32);
  transform: translateX(-50%);
  pointer-events: none;
}

.answer-gate .gate-key { display: none; }

body.debug .answer-gate .gate-key {
  position: absolute;
  top: 2%;
  left: 2%;
  z-index: 2;
  display: block;
  padding: 2px 6px;
  border-radius: 6px;
  background: #24418a;
  color: #fff;
  font-size: 0.65rem;
}

/* Feedback glow rides a static pseudo-element behind the art. Routing the art
 * itself through a filter (drop-shadow/saturate) forces it back through an
 * offscreen resampling pass and softens it. */
.answer-gate::before {
  content: "";
  position: absolute;
  inset: 2% 5% 0;
  border-radius: 46% 46% 14px 14px / 42% 42% 14px 14px;
  background: radial-gradient(closest-side, var(--gate-glow, transparent), transparent 78%);
  opacity: 0;
  pointer-events: none;
}

.answer-gate.is-correct::before {
  --gate-glow: rgba(65, 198, 91, 0.66);
  opacity: 1;
}

.answer-gate.is-wrong::before {
  --gate-glow: rgba(230, 91, 45, 0.6);
  opacity: 1;
}

.gates-art-failed .answer-gate__art { display: none; }

.gates-art-failed .answer-gate {
  border: 4px solid rgba(35, 45, 74, 0.8);
  border-radius: 42% 42% 10px 10px / 24% 24% 10px 10px;
}

.gates-art-failed .answer-gate[data-category="definite"] { background: #2674e8; }
.gates-art-failed .answer-gate[data-category="indefinite"] { background: #35b85a; }
.gates-art-failed .answer-gate[data-category="none"] { background: #8b47d4; }

/* ========================================================================== 
 * Flying fox
 * --------------------------------------------------------------------------
 * The outer rig owns transform-only lane travel, the lean layer banks during
 * a turn, and the fixed 1:1 frame carries a single back-view image. The shadow
 * remains outside the rotating layers so it always stays level with the road.
 * ========================================================================== */

.player {
  position: absolute;
  bottom: var(--player-bottom);
  left: 50%;
  z-index: 5;
  width: min(clamp(207px, 15.3vw, 261px), 34cqh);
  aspect-ratio: 1;
  --player-lane-offset: 0px;
  --player-drag-x: 0px;
  --player-drag-lean: 0deg;
  --player-bank-angle: 0deg;
  --player-glide-y: 0px;
  --player-hover-y: 0px;
  --player-flight-y: 0px;
  --player-flight-pitch: -1.25deg;
  --player-flight-lift: -8px;
  --player-shadow-scale: 0.96;
  --player-shadow-opacity: 0.27;
  transform: translate3d(
    calc(-50% + var(--player-lane-offset) + var(--player-drag-x)),
    0,
    0
  );
  will-change: transform;
  pointer-events: none;
}

.player-lean,
.player-reaction,
.player-flight,
.player-frame {
  position: absolute;
  inset: 0;
}

.player-lean {
  transform: translate3d(0, var(--player-glide-y), 0)
    rotate(calc(var(--player-bank-angle) + var(--player-drag-lean)));
  transform-origin: 50% 72%;
  will-change: transform;
}

.player-flight {
  transform: translate3d(0, var(--player-flight-y), 0)
    rotate(var(--player-flight-pitch));
  transform-origin: 50% 72%;
  will-change: transform;
}

.player.is-gate-passing { z-index: 3; }

.player-frame {
  display: grid;
  place-items: center;
  z-index: 1;
  transform: translate3d(0, calc(var(--player-flight-lift) + var(--player-hover-y)), 0);
  will-change: transform;
}

.player-shadow {
  position: absolute;
  bottom: 2%;
  left: 54%;
  width: 54%;
  height: 8.5%;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(43, 36, 31, 0.52) 0%,
    rgba(43, 36, 31, 0.26) 38%,
    rgba(43, 36, 31, 0) 74%
  );
  opacity: var(--player-shadow-opacity);
  transform: translate3d(-50%, 0, 0) scale(var(--player-shadow-scale));
  transform-origin: center;
  will-change: transform, opacity;
}

.player-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 1;
  visibility: visible;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.player-reaction::after {
  content: "";
  position: absolute;
  inset: 18% 13% 8%;
  z-index: 0;
  border-radius: 48%;
  opacity: 0;
  background: radial-gradient(ellipse, rgba(74, 210, 108, 0.26), transparent 68%);
  transition: opacity 150ms ease;
}

.player.player-correct .player-reaction::after { opacity: 1; }
.player.player-wrong .player-reaction::after {
  opacity: 0.72;
  background: radial-gradient(ellipse, rgba(242, 149, 72, 0.2), transparent 68%);
}

.score-pop {
  position: absolute;
  left: 50%;
  bottom: 33%;
  z-index: 8;
  opacity: 0;
  color: #fff7c4;
  font: 900 clamp(1.3rem, 2.4vw, 2.2rem)/1 var(--font-game);
  text-shadow: 0 2px 0 #ba7410, 0 4px 12px rgba(71, 45, 19, 0.38);
  transform: translate(-50%, 12px) scale(0.8);
  pointer-events: none;
}

.score-pop.is-visible { animation: score-pop 900ms cubic-bezier(0.18, 0.8, 0.22, 1) forwards; }

@keyframes score-pop {
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50px) scale(1); }
}

/* ========================================================================== 
 * Top HUD and question card
 * ========================================================================== */

.game-top {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0
    max(18px, env(safe-area-inset-left));
  pointer-events: none;
}

.hud {
  --hud-scale: 1;
  width: min(100%, 1640px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hud-group--main { justify-self: start; }
.hud-group--stats { justify-self: end; }
.hud-pill--progress { justify-self: center; }

.hud-pause,
.hud-pill {
  border: 2px solid rgba(130, 202, 255, 0.82);
  background: linear-gradient(180deg, #2879c5 0%, #155da7 58%, #0c4387 100%);
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.33), inset 0 -8px 14px rgba(4, 26, 71, 0.22), 0 5px 10px rgba(10, 47, 91, 0.32);
  color: #fff;
}

.hud-pause {
  flex: none;
  width: calc(72px * var(--hud-scale));
  height: calc(72px * var(--hud-scale));
  min-width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 28%;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 110ms ease, filter 110ms ease;
}

.hud-pause:hover { filter: brightness(1.08); transform: translateY(-1px); }
.hud-pause:active { transform: translateY(1px) scale(0.97); }

.hud-pause__icon {
  width: 48%;
  height: 48%;
  fill: #fff;
  filter: drop-shadow(0 2px 1px rgba(3, 24, 66, 0.45));
}

.hud-pill {
  flex: none;
  min-height: calc(66px * var(--hud-scale));
  display: flex;
  align-items: center;
  gap: calc(10px * var(--hud-scale));
  padding: calc(9px * var(--hud-scale)) calc(17px * var(--hud-scale));
  border-radius: 999px;
  white-space: nowrap;
}

.hud-icon {
  flex: none;
  width: calc(38px * var(--hud-scale));
  height: calc(38px * var(--hud-scale));
  filter: drop-shadow(0 2px 2px rgba(5, 29, 70, 0.4));
}

.hud-pill__stack {
  min-width: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: calc(5px * var(--hud-scale));
}

.hud-pill__text,
.hud-pill__value,
.hud-streak__label {
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 1px rgba(3, 25, 66, 0.42);
}

.hud-pill__text {
  overflow: hidden;
  font-size: calc(1.18rem * var(--hud-scale));
  text-overflow: ellipsis;
}

.hud-pill__text--strong,
.hud-pill__value {
  font-size: calc(1.3rem * var(--hud-scale));
  font-variant-numeric: tabular-nums;
}

.hud-pill--level { width: calc(230px * var(--hud-scale)); }
.hud-pill--progress { width: calc(350px * var(--hud-scale)); }
.hud-pill--score { min-width: calc(135px * var(--hud-scale)); justify-content: center; }
.hud-pill--streak { min-width: calc(172px * var(--hud-scale)); justify-content: center; }
.hud-pill--lives { min-width: calc(168px * var(--hud-scale)); justify-content: center; }

.hud-level__track {
  width: 100%;
  height: calc(12px * var(--hud-scale));
  overflow: hidden;
  border-radius: 999px;
  background: rgba(5, 31, 72, 0.62);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.34);
}

.hud-level__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(#78ef80, #38c858);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.45);
  transition: width 300ms ease;
}

.hud-progress__segments {
  width: 100%;
  display: flex;
  gap: calc(3px * var(--hud-scale));
}

.hud-progress__segment {
  height: calc(13px * var(--hud-scale));
  flex: 1 1 0;
  border-radius: 999px;
  background: rgba(102, 163, 218, 0.52);
  box-shadow: inset 0 1px 2px rgba(3, 23, 59, 0.36);
}

.hud-progress__segment.is-complete {
  background: linear-gradient(#7bed86, #3ac85b);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.48), 0 0 4px rgba(80, 215, 99, 0.35);
}

.hud-progress__segment.is-current { filter: brightness(1.08); }
.hud-pill--score .hud-pill__value { color: #fff7d0; }

.hud-streak__label {
  color: #ffd25b;
  font-size: calc(1.04rem * var(--hud-scale));
}

.hud-pill--streak.is-hot .hud-icon--flame { animation: flame-flicker 840ms ease-in-out infinite alternate; }
@keyframes flame-flicker { to { transform: scale(1.1) rotate(2deg); } }

.hud-pill--lives { gap: calc(6px * var(--hud-scale)); }

.hud-heart {
  width: calc(35px * var(--hud-scale));
  height: calc(35px * var(--hud-scale));
}

.hud-heart svg { display: block; width: 100%; height: 100%; }

.hud-heart path {
  fill: #6786a7;
  stroke: #294d75;
  stroke-width: 0.8;
  filter: drop-shadow(0 2px 1px rgba(4, 28, 65, 0.35));
}

.hud-heart.is-full path { fill: #ff5574; stroke: #b92d51; }
.hud-heart.just-lost { animation: heart-break 480ms ease; }
@keyframes heart-break { 35% { transform: scale(1.28) rotate(-8deg); } }

.hud-pill.is-pulse { animation: hud-pulse 390ms ease; }
@keyframes hud-pulse { 40% { transform: scale(1.08); filter: brightness(1.12); } }

.sentence-wrap {
  width: clamp(620px, 53vw, 900px);
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 16px 34px 14px;
  border: 3px solid rgba(255, 255, 255, 0.74);
  border-radius: 34px;
  background: rgba(255, 249, 238, 0.97);
  box-shadow: 0 8px 18px rgba(41, 73, 102, 0.24), inset 0 1px #fff;
}

.sentence {
  margin: 0;
  color: var(--navy-950);
  font: 900 clamp(1.65rem, 2.25vw, 2.35rem)/1.15 var(--font-game);
  text-align: center;
  text-wrap: balance;
}

.sentence .blank {
  min-width: 3.3em;
  display: inline-block;
  margin: 0 0.08em;
  border-bottom: 5px solid var(--navy-950);
  color: transparent;
  line-height: 0.9;
}

.sentence-instruction {
  margin: 0;
  color: #5f82aa;
  font: 800 clamp(0.95rem, 1.35vw, 1.22rem)/1.1 var(--font-game);
}

/* Screen-space lane controls: the order is populated from the engine laneMap. */
.answer-dock {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 90;
  width: min(46vw, 760px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 0.7vw, 12px);
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  pointer-events: auto;
}

.answer-dock__choice {
  min-width: 0;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 10px 12px 9px;
  appearance: none;
  border: 1px solid rgba(126, 157, 188, 0.72);
  border-radius: 17px;
  background: linear-gradient(180deg, #173b5c 0%, #0c2744 48%, #07182f 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.18), 0 9px 18px rgba(3, 14, 34, 0.34);
  color: #f8fbff;
  cursor: pointer;
  font-family: var(--font-game);
  text-align: center;
  touch-action: manipulation;
  transition: transform 130ms ease, border-color 150ms ease, background 150ms ease,
    box-shadow 150ms ease;
}

.answer-dock__choice:hover:not(:disabled) {
  border-color: rgba(169, 224, 255, 0.92);
  background: linear-gradient(180deg, #1c496e 0%, #103254 50%, #091d38 100%);
}

.answer-dock__choice:active:not(:disabled) { transform: translateY(1px); }
.answer-dock__choice:disabled { cursor: default; }
.answer-dock__choice:focus-visible { outline-width: 3px; outline-offset: 2px; }

.answer-dock__icon { display: none; }

.answer-dock__label,
.answer-dock__sublabel {
  max-width: 100%;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-dock__label {
  color: #fff;
  font-size: clamp(0.82rem, 1.35vw, 1.15rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.01em;
  text-shadow: 0 2px 1px rgba(1, 13, 31, 0.55);
}

.answer-dock__sublabel {
  color: #94acc3;
  font-size: clamp(0.52rem, 0.68vw, 0.68rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.08em;
}

.answer-dock__choice.is-selected {
  border-color: #54e1ff;
  background: linear-gradient(180deg, #17618a 0%, #0c466d 48%, #082c50 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.26), 0 0 0 2px rgba(84, 225, 255, 0.3),
    0 0 22px rgba(47, 210, 255, 0.45), 0 10px 20px rgba(3, 14, 34, 0.42);
  transform: translateY(-1px) scale(1.01);
}

.answer-dock__choice.is-selected .answer-dock__sublabel { color: #c6f6ff; }

.answer-dock__choice.is-correct {
  border-color: #7ef7d6;
  background: linear-gradient(180deg, #17876f 0%, #0e665c 48%, #084541 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.25), 0 0 0 2px rgba(80, 238, 194, 0.25),
    0 0 23px rgba(45, 225, 185, 0.4), 0 10px 20px rgba(3, 14, 34, 0.4);
  animation: answer-dock-success 460ms ease both;
}

.answer-dock__choice.is-correct .answer-dock__sublabel { color: #c9fff0; }

.answer-dock__choice.is-wrong {
  border-color: #f59a73;
  background: linear-gradient(180deg, #8c3d42 0%, #6e2e38 50%, #4b202d 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.18), 0 0 0 2px rgba(235, 112, 74, 0.2),
    0 8px 18px rgba(45, 9, 18, 0.36);
}

.answer-dock__choice.is-wrong .answer-dock__sublabel { color: #ffd3c2; }

@keyframes answer-dock-success {
  50% { transform: translateY(-1px) scale(1.018); }
}

.answer-dock:not(.hidden) ~ .controls-hint { display: none; }

/* ========================================================================== 
 * In-world supporting UI
 * ========================================================================== */

.world-sign {
  position: absolute;
  z-index: 1;
  width: clamp(190px, 14vw, 240px);
  filter: drop-shadow(0 8px 8px rgba(63, 43, 23, 0.25));
  pointer-events: none;
}

.world-sign > img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.world-sign__copy {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #603013;
  font: 900 clamp(0.76rem, 1vw, 1.05rem)/1.08 var(--font-game);
  text-align: center;
  text-shadow: 0 1px rgba(255, 220, 157, 0.66);
}

.world-sign--left { top: 45%; left: 1.3%; transform: rotate(-3deg); }
.world-sign--left .world-sign__copy { top: 25%; left: 14%; width: 70%; height: 38%; }
.world-sign--right { top: 35%; right: 1.3%; transform: rotate(3deg); }
.world-sign--right .world-sign__copy { top: 23%; left: 11%; width: 70%; height: 37%; }

.tip-card {
  position: absolute;
  bottom: max(108px, calc(env(safe-area-inset-bottom) + 96px));
  left: max(24px, env(safe-area-inset-left));
  z-index: 72;
  width: min(360px, 30vw);
  min-height: 112px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(35, 57, 76, 0.88), rgba(53, 76, 89, 0.82));
  box-shadow: 0 8px 18px rgba(34, 46, 52, 0.28), inset 0 1px rgba(255, 255, 255, 0.15);
  color: #fff;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.tip-card__icon { flex: 0 0 60px; width: 60px; height: 60px; }
.tip-card__icon svg { width: 100%; height: 100%; }

.tip-card__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font: 700 clamp(0.78rem, 1vw, 0.98rem)/1.28 var(--font-game);
}

.tip-card__copy strong { font-size: 1.08em; }

.owl-help {
  position: absolute;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(108px, calc(env(safe-area-inset-bottom) + 96px));
  z-index: 72;
  width: min(470px, 38vw);
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  justify-content: flex-end;
  transition: opacity 150ms ease, transform 150ms ease;
  pointer-events: none;
}

.screen-game.is-decision-focus .tip-card,
.screen-game.is-decision-focus .owl-help {
  opacity: 0.64;
  transform: translateY(4px) scale(0.985);
}

.runner[data-player-lane="0"] .tip-card {
  opacity: 0;
  transform: translateX(-8px);
}

.runner[data-player-lane="2"] .owl-help {
  opacity: 0;
  transform: translateX(8px);
}

.owl-help__mascot {
  flex: 0 0 clamp(118px, 10vw, 154px);
  width: clamp(118px, 10vw, 154px);
  margin-left: -12px;
}

.owl-help__mascot img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 7px 5px rgba(67, 41, 23, 0.22));
  user-select: none;
  -webkit-user-drag: none;
}

.owl-help__bubble {
  position: relative;
  width: min(320px, 27vw);
  min-height: 122px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 18px 22px;
  border: 2px solid #8bc4ed;
  border-radius: 28px;
  background: rgba(241, 250, 255, 0.96);
  box-shadow: 0 8px 18px rgba(34, 70, 102, 0.22), inset 0 1px #fff;
  color: var(--navy-900);
}

.owl-help__bubble::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: 24px;
  width: 28px;
  height: 28px;
  border-bottom: 2px solid #8bc4ed;
  border-right: 2px solid #8bc4ed;
  background: #f1faff;
  transform: rotate(-42deg);
}

.owl-help__bulb { z-index: 1; flex: none; font-size: 2rem; }

.owl-help__bubble p {
  z-index: 1;
  margin: 0;
  font: 800 clamp(0.8rem, 1.05vw, 1rem)/1.25 var(--font-game);
}

.mobile-hint { display: none; }

.controls-hint {
  position: absolute;
  left: 50%;
  bottom: 8px;
  z-index: 70;
  margin: 0;
  color: rgba(33, 65, 93, 0.62);
  font: 700 0.68rem/1 var(--font-game);
  text-shadow: 0 1px rgba(255, 255, 255, 0.74);
  transform: translateX(-50%);
  pointer-events: none;
}

.screen-game.is-feedback .tip-card,
.screen-game.is-feedback .owl-help { opacity: 0; transform: translateY(10px); pointer-events: none; }

/* ==========================================================================
 * Question reading countdown: the approved illustrated card PNG (frame,
 * wooden banner, cream interior, corner plants) with only the dynamic
 * pieces — title, question and the countdown timer — as HTML overlays.
 * It holds the gates while the sentence is read and never blocks lane
 * input (pointer-events: none). All overlay sizing uses container units
 * (cqw) of .qcard so the whole card scales as one piece.
 * ========================================================================== */

.question-countdown {
  position: absolute;
  inset: 0;
  z-index: 105;
  display: grid;
  place-items: center;
  pointer-events: none;
}

/* The card keeps the artwork's intrinsic 1448×1086 (4:3) ratio: roughly 35%
 * of the viewport wide (≈600×450 on a 1734×862 desktop), capped by the free
 * vertical space between the HUD and the answer dock; portrait is
 * width-bound. */
.qcard {
  position: relative;
  container-type: inline-size;
  box-sizing: border-box;
  width: min(35vw, 74vh, 680px);
  aspect-ratio: 1448 / 1086;
  filter: drop-shadow(0 2.2cqw 4.5cqw rgba(10, 40, 80, 0.38));
  animation: qcard-in 240ms cubic-bezier(0.2, 0.78, 0.28, 1) both;
}

@media (orientation: portrait) {
  .qcard { width: min(92vw, 74vh, 680px); }
}

/* The supplied artwork fills the card exactly (same aspect ratio). */
.qcard__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.qcard__banner,
.qcard__sentence,
.qcard__timer { z-index: 1; }

/* The card is centered by the grid parent, so the entrance may only add a
 * gentle offset — never the translate(-50%,-50%) used by .feedback. */
@keyframes qcard-in {
  from { opacity: 0; transform: translateY(2.2cqw) scale(0.955); }
  to { opacity: 1; transform: none; }
}

/* --- Title overlaid on the artwork's wooden banner --- */
.qcard__banner {
  position: absolute;
  top: 4%;
  left: 22%;
  right: 22%;
  height: 11.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.qcard__title {
  font: 800 3.9cqw/1.08 var(--font-game);
  color: #fff;
  letter-spacing: 0.015em;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0.3cqw 0 #5b2d0e, 0 0.6cqw 1.1cqw rgba(40, 18, 2, 0.5);
}

/* --- Question sentence (middle band, inside the artwork's cream area) --- */
.qcard__sentence {
  position: absolute;
  top: 18%;
  left: 11%;
  right: 11%;
  margin: 0;
  font: 700 4.4cqw/1.5 var(--font-game);
  color: #17335c;
  text-align: center;
  text-wrap: balance;
}

/* --- Circular countdown timer (bottom band, above the artwork's plants) --- */
.qcard__timer {
  position: absolute;
  left: 0;
  right: 0;
  top: 47%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qcard__ringwrap {
  position: relative;
  width: 27cqw;
  aspect-ratio: 1;
}

.qcard__ring {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 1cqw 1.6cqw rgba(15, 60, 25, 0.28));
}

.qcard__ring-track {
  fill: #fdf6e2;
  stroke: #e7dcb8;
  stroke-width: 12.5;
}

.qcard__ring-progress {
  fill: none;
  stroke: #43b34e;
  stroke-width: 12.5;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 0;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 120ms linear;
}

.qcard__value {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 900 9.5cqw/1 var(--font-game);
  color: #023d7a;
  text-shadow: 0 0.3cqw 0 rgba(255, 255, 255, 0.85);
}

.qcard__value.is-tick {
  animation: countdown-tick 320ms cubic-bezier(0.2, 0.78, 0.28, 1);
}

@keyframes countdown-tick {
  from { transform: scale(1.26); }
  to { transform: scale(1); }
}

.qcard__rays {
  position: absolute;
  width: 9cqw;
  top: 50%;
  transform: translateY(-70%);
}

.qcard__rays:not(.qcard__rays--flip) { left: 17%; }
.qcard__rays--flip { right: 17%; transform: translateY(-70%) scaleX(-1); }

.qcard__timeleft {
  margin-top: 1.6cqw;
  padding: 0.8cqw 4cqw;
  border: 0.6cqw solid #8ecbe8;
  border-radius: 99cqw;
  background: #c3e8f9;
  font: 800 3.4cqw/1.15 var(--font-game);
  color: #0b5d8a;
  letter-spacing: 0.03em;
  box-shadow: 0 0.6cqw 1.3cqw rgba(20, 80, 130, 0.22);
}

/* While the reading card owns the question, the duplicate sentence strip at
 * the top stays invisible (layout kept, so nothing else shifts). */
.screen-game.is-reading-hold .sentence-wrap { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .qcard { animation: none; }
  .qcard__value.is-tick { animation: none; }
  .qcard__ring-progress { transition: none; }
}

/* ==========================================================================
 * Feedback, overlays and result screens
 * ========================================================================== */

.feedback {
  --feedback-inline-gutter: max(12px, env(safe-area-inset-left), env(safe-area-inset-right));
  position: absolute;
  top: 46%;
  right: auto;
  bottom: auto;
  left: 50%;
  z-index: 110;
  box-sizing: border-box;
  width: min(
    520px,
    calc(100% - var(--feedback-inline-gutter) - var(--feedback-inline-gutter))
  );
  max-height: min(70dvh, 520px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 18px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-left: 7px solid #6f8aa0;
  border-radius: 24px;
  background: rgba(255, 253, 247, 0.97);
  box-shadow: 0 12px 28px rgba(27, 51, 70, 0.28), inset 0 1px #fff;
  text-align: left;
  transform: translate(-50%, -50%);
  transform-origin: center;
  animation: feedback-card-in 220ms cubic-bezier(0.2, 0.78, 0.28, 1) 160ms both;
  pointer-events: auto;
}

.feedback.feedback-correct {
  width: min(
    460px,
    calc(100% - var(--feedback-inline-gutter) - var(--feedback-inline-gutter))
  );
  gap: 5px;
  padding-block: 14px;
  border-left-color: #3cc45c;
  background: rgba(247, 255, 248, 0.98);
}

.feedback.feedback-wrong {
  border-left-color: #e06442;
  background: rgba(255, 250, 246, 0.98);
}
.feedback-title { margin: 0; font-size: 1.26rem; }
.feedback-correct .feedback-title { color: #218745; }
.feedback-wrong .feedback-title { color: #b9482f; }

.feedback-sentence {
  margin: 0;
  color: var(--navy-900);
  font-size: 1rem;
  font-weight: 800;
}

.feedback-sentence .filled {
  color: #2459ae;
  border-bottom: 2px solid #2459ae;
  font-weight: 900;
}

.feedback-detail {
  margin: 0;
  color: #526777;
  font: 700 0.84rem/1.35 var(--font-game);
}

.feedback .btn { align-self: stretch; margin-top: 3px; }
.feedback .btn[hidden] { display: none; }

@keyframes feedback-card-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px)) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: rgba(8, 28, 59, 0.58);
}

.overlay-card,
.result-card {
  width: min(100%, 500px);
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 24px 28px;
  border: 3px solid rgba(255, 255, 255, 0.76);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: 0 18px 44px rgba(7, 26, 58, 0.36), inset 0 1px #fff;
  text-align: center;
}

.overlay-card h2,
.result-card h2 { margin: 0; color: var(--navy-900); }

.overlay-note { margin: 0; color: #526777; font-size: 0.95rem; }

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.screen-complete,
.screen-gameover {
  justify-content: flex-start;
  background: linear-gradient(rgba(219, 243, 253, 0.88), rgba(236, 247, 225, 0.92)),
    url("../assets/backgrounds/road-desktop.webp") center / cover;
}

.screen-complete .result-card,
.screen-gameover .result-card {
  flex: none;
  margin-block: auto;
}

.screen-gameover {
  background: linear-gradient(rgba(255, 239, 232, 0.91), rgba(255, 247, 235, 0.94)),
    url("../assets/backgrounds/road-desktop.webp") center / cover;
}

.result-stars { margin: 0; color: #d99513; font-size: 2rem; letter-spacing: 6px; }

.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-stats li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 12px;
  background: #eef4fb;
}

.result-stats span { color: #677a8e; font-size: 0.72rem; }
.result-stats b { font-size: 1.15rem; }

.weak-rules {
  padding: 11px 14px;
  border: 1px solid #e3c979;
  border-radius: 12px;
  background: #fff8e6;
  text-align: left;
}

.weak-rules h3 { margin: 0 0 6px; color: #6b5312; font-size: 0.9rem; }
.weak-rules ul { margin: 0; padding-left: 18px; font-size: 0.84rem; }

.dev-bar {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.87);
  color: #9fe3b1;
  font: 0.72rem/1 ui-monospace, Consolas, monospace;
}

:focus-visible { outline: 4px solid #ffd23f; outline-offset: 3px; }

/* ========================================================================== 
 * Tablet layout — 681–1100px
 * ========================================================================== */

@media (max-width: 1100px) {
  .runner {
    --player-bottom: 11%;
    --lane-marker-width: 9px;
    --lane-marker-height: 72px;
  }

  .game-top { gap: 9px; padding-top: max(10px, env(safe-area-inset-top)); }

  .hud { --hud-scale: 0.78; gap: 10px; }
  .hud-group { gap: 7px; }
  .hud-pill--level { width: calc(190px * var(--hud-scale)); }
  .hud-pill--progress { width: calc(230px * var(--hud-scale)); }

  .sentence-wrap {
    width: min(72vw, 760px);
    min-height: 104px;
    padding: 14px 28px 13px;
    border-radius: 29px;
  }

  .sentence { font-size: clamp(1.45rem, 3vw, 2rem); }

  .answer-dock {
    width: min(68vw, 680px);
    gap: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .answer-dock__choice { min-height: 68px; }

  .player {
    width: min(clamp(179px, 20.7vw, 244px), 36cqh);
  }

  .world-sign { display: none; }

  .tip-card {
    width: min(290px, 34vw);
    min-height: 96px;
    padding: 12px 14px;
    border-radius: 22px;
  }

  .tip-card__icon { flex-basis: 48px; width: 48px; height: 48px; }
  .owl-help { width: min(360px, 43vw); }
  .owl-help__mascot { flex-basis: 100px; width: 100px; }
  .owl-help__bubble { width: min(255px, 31vw); min-height: 100px; padding: 14px 16px; border-radius: 22px; }
  .feedback { width: min(90%, 500px); }
}

@media (min-width: 681px) and (max-width: 1100px) {
  .answer-gate[data-category="none"] .answer-gate__label {
    width: 70cqw;
    font-size: 14cqw;
    line-height: 0.82;
    white-space: normal;
    text-align: center;
  }
}

/* Medium screens use a deliberate two-row HUD so the Arcade stats never
 * collide with the centered question progress. */
@media (min-width: 681px) and (max-width: 900px) {
  .hud {
    --hud-scale: 0.72;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
  }

  .hud-group--main {
    grid-column: 1;
    grid-row: 1;
  }

  .hud-pill--progress {
    grid-column: 2;
    grid-row: 1;
  }

  .hud-group--stats {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
  }

  .owl-help { width: min(260px, 32vw); }
  .owl-help__mascot { flex-basis: 76px; width: 76px; }
  .owl-help__bubble {
    width: min(182px, 22vw);
    min-height: 90px;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 18px;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .scene {
    background-position: center center;
  }

  .hud { justify-content: center; }
}

/* ========================================================================== 
 * Phone layout — ≤680px
 * ========================================================================== */

@media (max-width: 680px) {
  .app { min-height: 0; }

  .runner {
    --player-mobile-bottom: clamp(100px, 16dvh, 148px);
    --player-bottom: max(
      var(--player-mobile-bottom),
      calc(66px + env(safe-area-inset-bottom))
    );
    --lane-marker-width: 7px;
    --lane-marker-height: 62px;
  }

  .scene {
    background-position: center center;
  }

  .runner[data-road-layout="mobile"] .road-edge { opacity: 0.62; }
  .runner[data-road-layout="mobile"] .road-edge::before { filter: none; }
  .runner[data-road-layout="mobile"] .road-edge::after { opacity: 0.28; }
  .runner[data-road-layout="mobile"] .road-surface {
    filter: none;
  }
  .runner[data-road-layout="mobile"] .road-shading i,
  .runner[data-road-layout="mobile"] .road-tracks i,
  .runner[data-road-layout="mobile"] .road-detail--raised,
  .runner[data-road-layout="mobile"] .road-detail--roadside,
  .runner[data-road-layout="mobile"] .road-coin__image { filter: none; }
  .coin-spark { box-shadow: none; }

  .game-top {
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) 0
      max(7px, env(safe-area-inset-left));
  }

  .hud {
    --hud-scale: 0.62;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 48px 35px;
    gap: 3px 4px;
  }

  .hud-group--main {
    grid-column: 1;
    grid-row: 1;
    gap: 4px;
  }

  .hud-group--stats {
    width: 100%;
    height: 35px;
    display: grid;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: 35px;
    gap: 3px;
    justify-self: stretch;
  }

  .hud-group--stats:has(.hud-pill--lives.hidden) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hud-pill--progress {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
  }

  .hud-pause { width: 44px; height: 48px; }

  .hud-pill {
    min-height: 43px;
    border-width: 1.5px;
  }

  .hud-pill--level { width: 91px; height: 48px; padding-inline: 7px; }
  .hud-pill--progress { width: 86px; height: 48px; padding-inline: 7px; }
  .hud-pill--score {
    min-width: 0;
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
  }
  .hud-pill--streak {
    min-width: 0;
    grid-column: 2;
    grid-row: 1;
    justify-self: stretch;
  }
  .hud-pill--lives {
    min-width: 0;
    grid-column: 3;
    grid-row: 1;
    justify-self: stretch;
  }
  .hud-group--stats > .hud-pill { min-height: 35px; padding: 4px 6px; }
  .hud-pill__text { font-size: 0.76rem; }
  .hud-pill__text--strong,
  .hud-pill__value { font-size: 0.86rem; }
  .hud-streak__label { display: none; }
  .hud-icon { width: 22px; height: 22px; }
  .hud-heart { width: 20px; height: 20px; }
  .hud-level__track { height: 7px; }
  .hud-progress__segment { height: 8px; }

  .sentence-wrap {
    width: 100%;
    max-width: calc(100vw - 20px);
    min-height: 91px;
    gap: 5px;
    padding: 12px 14px 11px;
    border-width: 2px;
    border-radius: 24px;
    box-shadow: 0 6px 14px rgba(41, 73, 102, 0.22), inset 0 1px #fff;
  }

  .sentence { font-size: clamp(1.12rem, 5.2vw, 1.45rem); line-height: 1.18; }
  .sentence .blank { border-bottom-width: 3px; }
  .sentence-instruction { font-size: 0.78rem; }

  .answer-dock {
    right: auto;
    bottom: 0;
    left: 6px;
    width: calc(100% - 12px);
    gap: 5px;
    padding-right: max(0px, calc(env(safe-area-inset-right) - 6px));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(0px, calc(env(safe-area-inset-left) - 6px));
    transform: none;
  }

  .answer-dock__choice {
    min-width: 0;
    min-height: 60px;
    gap: 4px;
    padding: 7px 4px 6px;
    border-radius: 13px;
  }

  .answer-dock__label { font-size: clamp(0.74rem, 3.5vw, 0.96rem); }
  .answer-dock__sublabel {
    font-size: clamp(0.48rem, 2vw, 0.58rem);
    letter-spacing: 0.045em;
  }

  .answer-gate__label { font-size: 15cqw; }
  .answer-gate[data-category="none"] .answer-gate__label {
    font-size: 11.75cqw;
    letter-spacing: -0.01em;
  }

  .player {
    width: min(clamp(142px, 37vw, 176px), 31cqh);
    --player-flight-lift: -6px;
  }

  .world-sign,
  .tip-card,
  .owl-help,
  .controls-hint { display: none; }

  .mobile-hint {
    position: absolute;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 74;
    display: block;
    color: var(--navy-900);
    font-family: var(--font-game);
  }

  .answer-dock:not(.hidden) ~ .mobile-hint {
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 74px));
  }

  .mobile-hint summary {
    min-width: 72px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 12px;
    border: 2px solid #80bce5;
    border-radius: 999px;
    background: rgba(245, 252, 255, 0.95);
    box-shadow: 0 5px 12px rgba(32, 66, 96, 0.22);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 900;
    list-style: none;
  }

  .mobile-hint summary::-webkit-details-marker { display: none; }

  .mobile-hint p {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: min(250px, calc(100vw - 24px));
    margin: 0;
    padding: 12px 14px;
    border: 2px solid #80bce5;
    border-radius: 18px;
    background: rgba(245, 252, 255, 0.98);
    box-shadow: 0 8px 18px rgba(32, 66, 96, 0.24);
    font-size: 0.78rem;
    line-height: 1.3;
  }

  .feedback {
    width: min(
      500px,
      calc(100% - var(--feedback-inline-gutter) - var(--feedback-inline-gutter))
    );
    gap: 5px;
    padding: 14px 16px;
    border-left-width: 5px;
    border-radius: 18px;
  }

  .feedback-title { font-size: 1rem; }
  .feedback-sentence { font-size: 0.9rem; }
  .feedback-detail { font-size: 0.78rem; }
  .feedback .btn { min-height: 44px; padding: 8px 14px; font-size: 0.8rem; }
  .screen-game.is-feedback .mobile-hint { display: none; }
  .score-pop { bottom: 31%; }
}

@media (max-width: 430px) {
  .screen:not(.screen-game):not(.screen-start) {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .result-card { padding: 18px; }
}

@media (max-width: 360px) {
  .hud { --hud-scale: 0.57; }
  .hud { grid-template-columns: minmax(0, 1fr) 78px; }
  .hud-pause { width: 44px; }
  .hud-pill--level { width: 84px; }
  .hud-pill--level .hud-icon { width: 18px; height: 18px; }
  .hud-pill--level .hud-pill__stack { gap: 2px; }
  .hud-pill--level .hud-pill__text { font-size: 0.68rem; }
  .hud-pill--progress { width: 78px; }
  .sentence-wrap { min-height: 84px; }
  .sentence { font-size: 1.05rem; }
  .sentence-instruction { font-size: 0.7rem; }
  .answer-dock { gap: 4px; }
  .answer-dock__choice { min-height: 56px; padding-inline: 3px; }
  .answer-dock__label { font-size: 0.78rem; }
  .answer-dock__sublabel { font-size: 0.46rem; letter-spacing: 0.025em; }
  .player { width: min(136px, 30cqh); }
}

/* ==========================================================================
 * Phone gameplay composition — reference-matched visual production pass
 * --------------------------------------------------------------------------
 * These values intentionally override the earlier compact-phone fallbacks.
 * The road projection and lane map remain owned by game.js; this block only
 * composes the phone HUD, prompt, fox, hint and screen-space answer controls.
 * ========================================================================== */

@media (max-width: 680px) {
  .screen-game {
    --mobile-answer-height: clamp(82px, 10.4dvh, 92px);
    --mobile-answer-gap: clamp(5px, 1.5vw, 7px);
  }

  .runner {
    --player-bottom: clamp(156px, 19.5dvh, 184px);
  }

  .scene { background-position: center center; }

  /* Let the painted road remain the visual source of truth. The projected
   * finish adds moving texture without reading as a second inner trapezoid. */
  .runner[data-road-layout="mobile"] .road-edge { opacity: 0.2; }
  .runner[data-road-layout="mobile"] .road-surface { opacity: 0.3; }
  .runner[data-road-layout="mobile"] .road-shading { opacity: 0.38; }
  .runner[data-road-layout="mobile"] .road-tracks { opacity: 0.46; }

  .game-top {
    gap: 8px;
    padding: max(6px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) 0
      max(7px, env(safe-area-inset-left));
  }

  /* One compact game HUD row: pause + wood level, progress, coin + streak. */
  .hud {
    --hud-scale: 0.62;
    width: 100%;
    grid-template-columns: auto minmax(68px, 1fr) auto;
    grid-template-rows: 50px;
    gap: 4px;
  }

  .hud-group--main {
    grid-column: 1;
    grid-row: 1;
    gap: 3px;
  }

  .hud-pill--progress {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 68px;
    height: 46px;
    align-self: center;
    padding-inline: 6px;
  }

  .hud-group--stats,
  .hud-group--stats:has(.hud-pill--lives.hidden) {
    width: auto;
    height: 42px;
    display: flex;
    grid-column: 3;
    grid-row: 1;
    gap: 3px;
    align-items: center;
    justify-self: end;
  }

  .hud-pause,
  .hud-pill {
    border: 2px solid rgba(157, 222, 255, 0.92);
    background: linear-gradient(180deg, #36a9f6 0%, #087bd7 48%, #0752ad 100%);
    box-shadow:
      inset 0 2px rgba(255, 255, 255, 0.5),
      inset 0 -6px 9px rgba(2, 36, 103, 0.24),
      0 3px 0 rgba(4, 52, 120, 0.82),
      0 5px 9px rgba(5, 43, 94, 0.24);
  }

  .hud-pause {
    width: 48px;
    height: 48px;
    border-radius: 50%;
  }

  .hud-pill {
    min-height: 40px;
    gap: 4px;
  }

  .hud-pill--level {
    width: 70px;
    height: 46px;
    padding: 5px 7px;
    border-color: #8b4f20;
    border-radius: 16px;
    background:
      linear-gradient(96deg, transparent 0 22%, rgba(109, 49, 14, 0.18) 23% 25%, transparent 26% 68%, rgba(255, 224, 139, 0.13) 69% 72%, transparent 73%),
      linear-gradient(180deg, #d98d3c 0%, #ad5c22 53%, #7b3716 100%);
    box-shadow:
      inset 0 2px rgba(255, 225, 159, 0.45),
      inset 0 -6px 8px rgba(76, 27, 8, 0.28),
      0 3px 0 #57240d,
      0 5px 8px rgba(62, 34, 15, 0.25);
  }

  .hud-pill--level .hud-icon { display: none; }
  .hud-pill--level .hud-pill__stack { gap: 3px; }
  .hud-pill--level .hud-pill__text {
    color: #fff4b8;
    font-size: 0.72rem;
    text-shadow: 0 2px 0 #66300f;
  }

  .hud-level__track { height: 5px; background: rgba(65, 24, 8, 0.52); }
  .hud-pill--progress .hud-icon { width: 18px; height: 18px; }
  .hud-pill--progress .hud-pill__stack { gap: 4px; }
  .hud-pill--progress .hud-pill__text--strong { font-size: 0.78rem; }
  .hud-progress__segments { gap: 2px; }
  .hud-progress__segment { height: 7px; }

  .hud-group--stats > .hud-pill {
    min-height: 40px;
    height: 40px;
    padding: 4px 5px;
  }

  .hud-pill--score { width: 48px; min-width: 48px; }
  .hud-pill--streak { width: 52px; min-width: 52px; }
  .hud-pill--lives { width: 58px; min-width: 58px; gap: 1px; }
  .hud-group--stats .hud-icon { width: 20px; height: 20px; }
  .hud-group--stats .hud-pill__value { font-size: 0.78rem; }
  .hud-streak__label { display: none; }
  .hud-heart { width: 16px; height: 16px; }

  /* Arcade adds three hearts; tighten only that HUD variant so all five
   * status groups still share one clean row on a 360px screen. */
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-pause {
    width: 44px;
    height: 46px;
  }

  .hud:has(.hud-pill--lives:not(.hidden)) .hud-group--main { gap: 3px; }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-pill--level { width: 64px; }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-pill--progress {
    min-width: 56px;
    padding-inline: 4px;
  }

  .hud:has(.hud-pill--lives:not(.hidden)) .hud-group--stats { gap: 2px; }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-pill--score {
    width: 42px;
    min-width: 42px;
  }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-pill--streak {
    width: 44px;
    min-width: 44px;
  }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-pill--lives {
    width: 52px;
    min-width: 52px;
  }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-group--stats .hud-icon {
    width: 17px;
    height: 17px;
  }
  .hud:has(.hud-pill--lives:not(.hidden)) .hud-heart {
    width: 14px;
    height: 14px;
  }

  /* Warm stitched prompt card with the same hierarchy as the reference. */
  .sentence-wrap {
    position: relative;
    width: min(100%, calc(100vw - 20px));
    max-width: none;
    min-height: clamp(108px, 13.5dvh, 120px);
    gap: 7px;
    padding: 13px 18px 12px;
    border: 2px solid rgba(228, 199, 151, 0.88);
    border-radius: clamp(24px, 7vw, 28px);
    background: rgba(255, 250, 240, 0.975);
    box-shadow:
      0 7px 0 rgba(129, 85, 36, 0.12),
      0 11px 20px rgba(25, 65, 94, 0.2),
      inset 0 2px rgba(255, 255, 255, 0.92);
  }

  .sentence-wrap::before {
    content: "";
    position: absolute;
    inset: 7px;
    border: 1px dashed rgba(206, 157, 99, 0.52);
    border-radius: calc(clamp(24px, 7vw, 28px) - 7px);
    pointer-events: none;
  }

  .sentence,
  .sentence-instruction { position: relative; z-index: 1; }

  .sentence {
    color: #0c3276;
    font-size: clamp(1.08rem, 5.15vw, 1.42rem);
    line-height: 1.16;
    letter-spacing: -0.012em;
  }

  .sentence .blank {
    min-width: 3.5em;
    border-bottom: 4px solid #0c3276;
  }

  .sentence-instruction {
    color: #5278ad;
    font-size: clamp(0.74rem, 3.15vw, 0.86rem);
    line-height: 1.1;
  }

  .answer-gate__art { filter: none; }
  .answer-gate__label { font-size: 16cqw; }
  .answer-gate[data-category="none"] .answer-gate__label {
    top: 36%;
    width: 70cqw;
    font-size: 14.5cqw;
    line-height: 0.8;
    white-space: normal;
    text-align: center;
  }

  /* The approved rear-facing flight sprite sits clear of the fixed dock. */
  .player {
    width: clamp(110px, 29.5vw, 128px);
    --player-flight-lift: -5px;
  }

  .player-shadow {
    bottom: 4%;
    left: 52%;
    width: 58%;
    height: 8%;
    background: radial-gradient(
      ellipse at center,
      rgba(54, 42, 30, 0.42) 0%,
      rgba(54, 42, 30, 0.2) 40%,
      rgba(54, 42, 30, 0) 74%
    );
  }

  /* The dock is lane-ordered by renderAnswerDock; category data attributes
   * own every color and icon so shuffled questions stay perfectly synced. */
  .answer-dock {
    right: max(7px, env(safe-area-inset-right));
    bottom: 0;
    left: max(7px, env(safe-area-inset-left));
    width: auto;
    gap: var(--mobile-answer-gap);
    padding: 0 0 max(7px, env(safe-area-inset-bottom));
    transform: none;
  }

  .answer-dock__choice {
    --choice-top: #58c8ff;
    --choice-mid: #1e9af4;
    --choice-bottom: #0871d6;
    --choice-border: #0755a9;
    --choice-edge: #064487;
    position: relative;
    isolation: isolate;
    min-width: 0;
    min-height: var(--mobile-answer-height);
    gap: 4px;
    overflow: hidden;
    padding: 7px 3px 8px;
    border: 3px solid var(--choice-border);
    border-radius: clamp(17px, 5vw, 20px);
    background: linear-gradient(
      180deg,
      var(--choice-top) 0%,
      var(--choice-mid) 46%,
      var(--choice-bottom) 100%
    );
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.48),
      inset 0 -7px rgba(3, 31, 94, 0.18),
      0 4px 0 var(--choice-edge),
      0 7px 12px rgba(4, 29, 67, 0.3);
    transition: transform 120ms ease, border-color 140ms ease, box-shadow 140ms ease;
  }

  .answer-dock__choice::before {
    content: "";
    position: absolute;
    top: 4px;
    right: 8px;
    left: 8px;
    z-index: -1;
    height: 28%;
    border-radius: 999px 999px 45% 45%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    opacity: 0.78;
    pointer-events: none;
  }

  .answer-dock__choice[data-category="none"] {
    --choice-top: #b74cff;
    --choice-mid: #8f28e8;
    --choice-bottom: #6e18c8;
    --choice-border: #4a0b93;
    --choice-edge: #38066f;
  }

  .answer-dock__choice[data-category="indefinite"] {
    --choice-top: #57f477;
    --choice-mid: #20c94b;
    --choice-bottom: #0b9e35;
    --choice-border: #067728;
    --choice-edge: #045c1e;
  }

  .answer-dock__choice[data-category="definite"] {
    --choice-top: #58c8ff;
    --choice-mid: #1e9af4;
    --choice-bottom: #0871d6;
    --choice-border: #0755a9;
    --choice-edge: #064487;
  }

  .answer-dock__choice:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.92);
    background: linear-gradient(
      180deg,
      var(--choice-top) 0%,
      var(--choice-mid) 46%,
      var(--choice-bottom) 100%
    );
  }

  .answer-dock__icon {
    position: relative;
    z-index: 1;
    width: clamp(24px, 7vw, 29px);
    height: clamp(24px, 7vw, 29px);
    display: block;
    flex: none;
    color: #fff;
    filter: drop-shadow(0 2px 1px rgba(8, 32, 78, 0.5));
  }

  .answer-dock__icon svg { display: block; width: 100%; height: 100%; }

  .answer-dock__label {
    position: relative;
    z-index: 1;
    overflow: visible;
    color: #fff;
    font-size: 0;
    line-height: 1;
    text-shadow: 0 2px 0 rgba(6, 29, 77, 0.52), 0 3px 4px rgba(6, 23, 55, 0.28);
  }

  .answer-dock__label::after {
    font-size: clamp(0.76rem, 3.45vw, 0.94rem);
    font-weight: 900;
    letter-spacing: -0.015em;
    white-space: nowrap;
  }

  .answer-dock__choice[data-category="none"] .answer-dock__label::after { content: "NO ARTICLE"; }
  .answer-dock__choice[data-category="indefinite"] .answer-dock__label::after { content: "A / AN"; }
  .answer-dock__choice[data-category="definite"] .answer-dock__label::after { content: "THE"; }
  .answer-dock__sublabel { display: none; }

  .answer-dock__choice.is-selected {
    border-color: rgba(255, 255, 255, 0.94);
    background: linear-gradient(
      180deg,
      var(--choice-top) 0%,
      var(--choice-mid) 46%,
      var(--choice-bottom) 100%
    );
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.62),
      inset 0 -7px rgba(3, 31, 94, 0.14),
      0 4px 0 var(--choice-edge),
      0 0 0 2px rgba(255, 246, 137, 0.62),
      0 0 16px rgba(255, 236, 92, 0.54),
      0 8px 13px rgba(4, 29, 67, 0.3);
    transform: translateY(-2px);
  }

  .answer-dock__choice.is-correct {
    border-color: #e8fff0;
    background: linear-gradient(180deg, #61f58a 0%, #20c94b 48%, #07852c 100%);
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.58),
      0 4px 0 #056823,
      0 0 18px rgba(69, 246, 116, 0.72);
  }

  .answer-dock__choice.is-wrong {
    border-color: #ffd7ca;
    background: linear-gradient(180deg, #ff8c6f 0%, #e3483c 52%, #a61e31 100%);
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.46),
      0 4px 0 #761426,
      0 0 14px rgba(230, 65, 55, 0.58);
    animation: answer-dock-wrong 300ms ease both;
  }

  @keyframes answer-dock-wrong {
    0%, 100% { transform: translateX(0); }
    28% { transform: translateX(-3px); }
    62% { transform: translateX(3px); }
  }

  .mobile-hint {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(11px, env(safe-area-inset-bottom));
  }

  .answer-dock:not(.hidden) ~ .mobile-hint {
    bottom: calc(var(--mobile-answer-height) + max(18px, env(safe-area-inset-bottom)));
  }

  .mobile-hint summary {
    min-width: 80px;
    min-height: 46px;
    gap: 6px;
    padding: 8px 13px;
    border: 2px solid #1795e2;
    border-radius: 999px;
    background: rgba(255, 251, 240, 0.98);
    box-shadow:
      inset 0 2px rgba(255, 255, 255, 0.9),
      0 3px 0 rgba(4, 99, 170, 0.84),
      0 7px 12px rgba(24, 62, 91, 0.22);
    color: #0c3276;
    font-size: 0.82rem;
  }

  .mobile-hint p {
    border-color: #1795e2;
    background: rgba(255, 251, 240, 0.985);
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  /* First-paint fallback mirrors the phone-only JS gate-fit size. The live
   * width remains projection-driven so the fox stays centered in every lane. */
  .runner[data-road-layout="mobile"] .player {
    width: clamp(74px, 20.5vw, 90px);
  }
}

@media (max-height: 780px) and (min-width: 681px) {
  .game-top { gap: 7px; padding-top: max(8px, env(safe-area-inset-top)); }
  .hud { --hud-scale: 0.72; }
  .sentence-wrap { min-height: 86px; padding: 10px 26px; border-radius: 26px; }
  .sentence { font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
  .sentence-instruction { font-size: 0.86rem; }
  .answer-dock__choice { min-height: 64px; }
  .player { width: min(clamp(193px, 16.9vw, 254px), 33cqh); }
  .tip-card { width: 300px; min-height: 88px; padding: 10px 13px; }
  .owl-help__mascot { flex-basis: 96px; width: 96px; }
  .owl-help__bubble { min-height: 88px; margin-bottom: 12px; padding: 12px 15px; }
  .world-sign { width: clamp(150px, 12vw, 184px); }
}

@media (max-height: 600px) and (min-width: 681px) {
  .app { min-height: 0; }

  .runner { --player-bottom: max(11%, calc(64px + env(safe-area-inset-bottom))); }

  .game-top {
    gap: 4px;
    padding-top: max(5px, env(safe-area-inset-top));
  }

  .hud { --hud-scale: 0.58; gap: 4px 8px; }
  .hud-group { gap: 5px; }

  .sentence-wrap {
    min-height: 68px;
    padding: 8px 22px;
    border-radius: 22px;
  }

  .sentence { font-size: clamp(1.08rem, 2.2vw, 1.45rem); }
  .sentence-instruction { display: none; }

  .answer-dock {
    width: min(72vw, 620px);
    gap: 6px;
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }

  .answer-dock__choice { min-height: 50px; padding-block: 5px; }
  .player { width: min(clamp(130px, 16.9vw, 197px), 29cqh); }
  .world-sign,
  .tip-card,
  .owl-help,
  .mobile-hint,
  .controls-hint { display: none; }

  .feedback {
    width: min(470px, calc(100% - 24px));
    gap: 4px;
    padding: 10px 14px;
  }
}

/* ==========================================================================
 * Reference desktop composition — isolated from tablet and phone layouts
 * ========================================================================== */

@media (min-width: 1101px) and (min-height: 681px) {
  .runner[data-road-layout="desktop"] {
    --player-bottom: clamp(120px, 16cqh, 175px);
  }

  body:has(.screen-game[data-road-layout="desktop"]) .dev-bar,
  .screen-game[data-road-layout="desktop"] .answer-gate .gate-key {
    display: none;
  }

  .screen-game[data-road-layout="desktop"] .game-top {
    gap: 5px;
    padding: max(10px, env(safe-area-inset-top)) max(18px, 6.5vw) 0;
  }

  .screen-game[data-road-layout="desktop"] .hud {
    --hud-scale: 0.86;
    width: min(86vw, 1640px);
    gap: 18px;
  }

  .screen-game[data-road-layout="desktop"] .hud-group--main { gap: clamp(32px, 2.5vw, 48px); }

  .screen-game[data-road-layout="desktop"] .hud-group--stats {
    gap: clamp(14px, 1vw, 18px);
    margin-right: 3vw;
  }

  .screen-game[data-road-layout="desktop"] .hud-pause,
  .screen-game[data-road-layout="desktop"] .hud-pill {
    border-color: rgba(137, 215, 255, 0.9);
    background: linear-gradient(180deg, #1b8de1 0%, #1268b8 56%, #0a4182 100%);
    box-shadow:
      inset 0 2px rgba(255, 255, 255, 0.38),
      inset 0 -8px 14px rgba(4, 26, 71, 0.2),
      0 5px 10px rgba(10, 47, 91, 0.3);
  }

  .screen-game[data-road-layout="desktop"] .hud-pill--level {
    width: clamp(230px, 17vw, 320px);
  }

  .screen-game[data-road-layout="desktop"] .hud-pill--progress {
    width: clamp(300px, 22vw, 390px);
  }

  .screen-game[data-road-layout="desktop"] .hud-pill--score {
    min-width: clamp(132px, 8.8vw, 166px);
  }

  .screen-game[data-road-layout="desktop"] .hud-pill--streak {
    min-width: clamp(170px, 10.8vw, 205px);
  }

  .screen-game[data-road-layout="desktop"] .sentence-wrap {
    width: clamp(680px, 50.5vw, 970px);
    min-height: clamp(112px, 15.7cqh, 170px);
    gap: 7px;
    padding: 14px 36px 13px;
    border-width: 2px;
    border-radius: 34px;
    box-shadow: 0 8px 20px rgba(35, 70, 103, 0.23), inset 0 1px #fff;
  }

  .screen-game[data-road-layout="desktop"] .sentence {
    font-size: clamp(1.55rem, 2.25vw, 2.35rem);
  }

  .screen-game[data-road-layout="desktop"] .sentence-instruction {
    display: block;
    font-size: clamp(0.95rem, 1.2vw, 1.2rem);
  }

  .screen-game[data-road-layout="desktop"] .player {
    width: min(clamp(207px, 15.7vw, 301px), 34cqh);
  }

  .screen-game[data-road-layout="desktop"] .player-shadow {
    left: 50%;
    width: 60%;
    height: 8%;
  }

  .screen-game[data-road-layout="desktop"] .answer-dock {
    width: clamp(690px, 51.125vw, 980px);
    gap: clamp(10px, 0.8vw, 14px);
    padding-bottom: clamp(28px, 3.7cqh, 42px);
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice {
    --choice-top: #58c8ff;
    --choice-mid: #1e9af4;
    --choice-bottom: #0871d6;
    --choice-border: #0755a9;
    --choice-edge: #064487;
    position: relative;
    isolation: isolate;
    min-height: clamp(80px, 10.25cqh, 110px);
    gap: 6px;
    overflow: hidden;
    padding: 11px 14px 10px;
    border: 3px solid var(--choice-border);
    border-radius: 22px;
    background: linear-gradient(
      180deg,
      var(--choice-top) 0%,
      var(--choice-mid) 47%,
      var(--choice-bottom) 100%
    );
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.5),
      inset 0 -8px rgba(3, 31, 94, 0.17),
      0 4px 0 var(--choice-edge),
      0 9px 16px rgba(4, 29, 67, 0.28);
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice::before {
    content: "";
    position: absolute;
    top: 5px;
    right: 12px;
    left: 12px;
    z-index: -1;
    height: 29%;
    border-radius: 999px 999px 45% 45%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
    opacity: 0.8;
    pointer-events: none;
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice[data-category="none"] {
    --choice-top: #b74cff;
    --choice-mid: #8f28e8;
    --choice-bottom: #6e18c8;
    --choice-border: #6416ae;
    --choice-edge: #42077b;
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice[data-category="indefinite"] {
    --choice-top: #57f477;
    --choice-mid: #20c94b;
    --choice-bottom: #0b9e35;
    --choice-border: #078a31;
    --choice-edge: #045c1e;
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice[data-category="definite"] {
    --choice-top: #58c8ff;
    --choice-mid: #1e9af4;
    --choice-bottom: #0871d6;
    --choice-border: #0874cf;
    --choice-edge: #064487;
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice:hover:not(:disabled),
  .screen-game[data-road-layout="desktop"] .answer-dock__choice.is-selected {
    border-color: rgba(255, 255, 255, 0.95);
    background: linear-gradient(
      180deg,
      var(--choice-top) 0%,
      var(--choice-mid) 47%,
      var(--choice-bottom) 100%
    );
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice.is-selected {
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.64),
      inset 0 -8px rgba(3, 31, 94, 0.13),
      0 4px 0 var(--choice-edge),
      0 0 0 2px rgba(255, 246, 137, 0.64),
      0 0 18px rgba(255, 236, 92, 0.5),
      0 10px 17px rgba(4, 29, 67, 0.3);
    transform: translateY(-2px);
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice.is-correct {
    border-color: #e8fff0;
    background: linear-gradient(180deg, #61f58a 0%, #20c94b 48%, #07852c 100%);
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.58),
      0 4px 0 #056823,
      0 0 18px rgba(69, 246, 116, 0.72);
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__choice.is-wrong {
    border-color: #ffd7ca;
    background: linear-gradient(180deg, #ff8c6f 0%, #e3483c 52%, #a61e31 100%);
    box-shadow:
      inset 0 3px rgba(255, 255, 255, 0.46),
      0 4px 0 #761426,
      0 0 14px rgba(230, 65, 55, 0.58);
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__label {
    font-size: clamp(1.25rem, 1.75vw, 1.9rem);
    text-shadow: 0 2px 0 rgba(6, 29, 77, 0.52), 0 3px 4px rgba(6, 23, 55, 0.28);
  }

  .screen-game[data-road-layout="desktop"] .answer-dock__sublabel {
    color: rgba(255, 255, 255, 0.88);
    font-size: clamp(0.68rem, 0.78vw, 0.84rem);
  }

  .screen-game[data-road-layout="desktop"] .tip-card {
    left: max(18px, env(safe-area-inset-left));
    bottom: clamp(84px, 10.5cqh, 112px);
    width: clamp(330px, 22.2vw, 370px);
    min-height: clamp(106px, 13.8cqh, 130px);
    padding: 15px 18px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(15, 58, 96, 0.95), rgba(23, 73, 111, 0.91));
    box-shadow: 0 8px 18px rgba(17, 43, 68, 0.3), inset 0 1px rgba(255, 255, 255, 0.2);
  }

  .screen-game[data-road-layout="desktop"] .tip-card__copy {
    font-size: clamp(0.82rem, 1vw, 1rem);
  }

  .screen-game[data-road-layout="desktop"] .owl-help {
    right: max(8px, env(safe-area-inset-right));
    bottom: clamp(112px, 14.5cqh, 156px);
    width: clamp(368px, 27vw, 520px);
  }

  .screen-game[data-road-layout="desktop"] .owl-help__mascot {
    flex-basis: clamp(128px, 9.5vw, 184px);
    width: clamp(128px, 9.5vw, 184px);
  }

  .screen-game[data-road-layout="desktop"] .owl-help__bubble {
    width: min(18.1vw, 348px);
    min-height: clamp(100px, 13.2cqh, 145px);
    margin-bottom: clamp(36px, 5cqh, 54px);
    padding: 16px 20px;
  }

  .screen-game[data-road-layout="desktop"] .owl-help__bubble p {
    font-size: clamp(0.8rem, 1vw, 1rem);
  }

  .screen-game[data-road-layout="desktop"] .world-sign {
    width: clamp(180px, 14vw, 230px);
  }

  .screen-game[data-road-layout="desktop"] .world-sign--left { top: 42%; }
  .screen-game[data-road-layout="desktop"] .world-sign--right { top: 38%; }
}

@media (min-width: 1400px) and (min-height: 681px) {
  .screen-game[data-road-layout="desktop"] .hud { --hud-scale: 0.9; }
}

@media (min-width: 1500px) and (min-height: 681px) {
  .screen-game[data-road-layout="desktop"] .hud { --hud-scale: 0.96; }
}

@media (min-width: 1800px) and (min-height: 681px) {
  .screen-game[data-road-layout="desktop"] .hud { --hud-scale: 1.08; }
}

@media (prefers-reduced-motion: reduce) {
  .scene,
  .player,
  .player-lean,
  .player-shadow,
  .hud-level__fill,
  .tip-card,
  .owl-help,
  .hud-pause,
  .btn,
  .answer-dock__choice { transition: none; }

  .player-lean { transform: none; }
  .player-frame { transform: translate3d(0, var(--player-flight-lift), 0); }

  .hud-heart.just-lost,
  .hud-pill.is-pulse,
  .hud-pill--score.hud-coin--pulse,
  .hud-pill--streak.is-hot .hud-icon--flame,
  .answer-dock__choice.is-correct,
  .feedback,
  .score-pop.is-visible,
  .road-coin__image,
  .coin-spark,
  .coin--collecting { animation: none; }

  .dust-puff,
  .coin-burst,
  .coin--collecting { display: none; }
}

/* ==========================================================================
 * Startup loader
 * ========================================================================== */

body.is-loading > #app {
  visibility: hidden;
  pointer-events: none;
}

.game-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  min-width: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  color: #fff;
  background:
    radial-gradient(circle at 50% 39%, rgba(125, 228, 255, 0.36) 0 13%, transparent 38%),
    radial-gradient(circle at 50% 46%, #2b9ddd 0%, #1676c1 48%, #0b3d87 100%);
  isolation: isolate;
  opacity: 1;
  visibility: visible;
  transition: opacity 360ms ease, visibility 0s linear 0s;
}

.game-loader[hidden] { display: none; }

.game-loader::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse at center, transparent 36%, rgba(3, 28, 78, 0.26) 100%);
  pointer-events: none;
}

.game-loader.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 360ms ease, visibility 0s linear 360ms;
}

.game-loader__content {
  width: min(430px, 100%);
  display: grid;
  justify-items: center;
  gap: clamp(8px, 1.4vh, 14px);
  text-align: center;
}

.game-loader__mascot {
  position: relative;
  width: clamp(220px, 23vw, 360px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.game-loader__mascot::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background: conic-gradient(
    from 12deg,
    rgba(255, 214, 56, 0.72),
    rgba(75, 217, 255, 0.3),
    rgba(24, 121, 255, 0.72),
    rgba(255, 214, 56, 0.72)
  );
  filter: blur(20px);
  opacity: 0.46;
  animation: game-loader-orbit 5.4s linear infinite;
}

.game-loader__mascot img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(3, 30, 78, 0.28));
  animation: game-loader-float 1.65s ease-in-out infinite;
}

.game-loader__title {
  margin-top: -2px;
  color: #fff;
  font: 900 clamp(2rem, 3.2vw, 3rem)/1 var(--font-game);
  letter-spacing: -0.035em;
  text-shadow: 0 3px 0 rgba(5, 48, 111, 0.34), 0 8px 18px rgba(4, 35, 83, 0.24);
}

.game-loader__message {
  min-height: 1.5em;
  color: rgba(246, 252, 255, 0.94);
  font: 700 clamp(0.94rem, 1.4vw, 1.08rem)/1.35 var(--font-game);
  text-shadow: 0 2px 5px rgba(3, 34, 85, 0.32);
}

.game-loader__progress {
  width: min(340px, 82vw);
  height: 14px;
  overflow: hidden;
  border: 2px solid rgba(197, 235, 255, 0.56);
  border-radius: 999px;
  background: rgba(5, 42, 100, 0.72);
  box-shadow: inset 0 2px 5px rgba(1, 20, 60, 0.42), 0 5px 14px rgba(3, 34, 85, 0.22);
}

.game-loader__progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd83d 0%, #65e0ff 52%, #2eb4ff 100%);
  box-shadow: 0 0 12px rgba(255, 221, 68, 0.48);
  transition: width 180ms ease-out;
}

.game-loader__percent {
  min-width: 4ch;
  color: #fff7c5;
  font: 900 0.96rem/1 var(--font-game);
  text-shadow: 0 2px 4px rgba(3, 31, 78, 0.4);
}

.game-loader__retry {
  min-width: 150px;
  min-height: 46px;
  margin-top: 4px;
  padding: 10px 22px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  color: #0b3b82;
  background: linear-gradient(180deg, #ffe769, #ffc62f);
  box-shadow: 0 7px 0 #d68a0e, 0 11px 20px rgba(3, 31, 76, 0.3);
  font: 900 1rem/1 var(--font-game);
  cursor: pointer;
}

.game-loader__retry[hidden] { display: none; }

.game-loader__retry:hover { filter: brightness(1.04); }
.game-loader__retry:active { transform: translateY(3px); box-shadow: 0 4px 0 #d68a0e; }
.game-loader__retry:focus-visible { outline: 4px solid rgba(255, 255, 255, 0.9); outline-offset: 4px; }

.game-loader[data-state="error"] .game-loader__progress,
.game-loader[data-state="error"] .game-loader__percent { opacity: 0.42; }

@keyframes game-loader-orbit {
  to { transform: rotate(360deg); }
}

@keyframes game-loader-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.02); }
}

@media (max-width: 1100px) {
  .game-loader__mascot { width: clamp(200px, 30vw, 300px); }
}

@media (max-width: 680px) {
  .game-loader {
    padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  }

  .game-loader__content { width: min(390px, 100%); gap: 9px; }
  .game-loader__mascot { width: clamp(170px, 46vw, 230px); }
  .game-loader__title { font-size: clamp(1.85rem, 8vw, 2.45rem); }
  .game-loader__message { font-size: clamp(0.88rem, 3.8vw, 1rem); }
  .game-loader__progress { width: min(360px, 86vw); height: 13px; }
}

@media (max-height: 620px) {
  .game-loader__content { gap: 6px; }
  .game-loader__mascot { width: clamp(150px, 30vh, 210px); }
  .game-loader__title { font-size: clamp(1.65rem, 5vh, 2.25rem); }
}

@media (prefers-reduced-motion: reduce) {
  .game-loader,
  .game-loader__progress-fill { transition: none; }

  .game-loader__mascot::before,
  .game-loader__mascot img { animation: none; }
}
