:root { --floor-height: 36px; }
/* The hidden attribute must always win over display rules (e.g. the ask
   modal uses display:flex when shown). */
[hidden] {
  display: none !important;
}

/* Interim palette: --blh-* tokens copied from the public site
   (businesslogixllc.com Oxygen variables.css, inspected 2026-11-10).
   PROVISIONAL pending the authoritative Design Guidelines v2.0 (B02). */
:root {
  --blh-navy: #05407a;
  --blh-ink: #18234b;
  --blh-accent: #48bcf6;
  --blh-accent-light: #69d1f9;
  --blh-text: #111827;
  --blh-body-text: #404040;
  --blh-muted: #526176;
  --blh-surface: #f4f6f9;
  --blh-line: #dce3eb;
  --blh-primary: #1cdaff;
  --blh-secondary: #6483f7;
  --blh-btn-bg: #0569a3;
  --blh-white: #ffffff;
}

#game {
  max-width: 1100px;
  margin: 0 auto;
  color: var(--blh-body-text);
}

/* Everything lives inside the game screen. The top bar is a game-style
   window matching the bottom strip: dark, pixel font, white border. */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(24, 35, 75, 0.94);
  border-bottom: 2px solid #ffffff;
  color: #ffffff;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
}

/* Battery-shaped energy meter with a nub on the right; fill color goes
   green -> yellow -> red as the battery drains. */
.energy {
  position: relative;
  width: 92px;
  height: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid #ffffff;
  border-radius: 3px;
}

.energy::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 8px;
  background: #ffffff;
  border-radius: 1px;
}

#energy-fill {
  height: 100%;
  width: 100%;
  background: #22c55e;
  transition: width 0.3s ease, background 0.3s ease;
}

.energy.mid #energy-fill {
  background: #eab308;
}

.energy.low #energy-fill {
  background: #ef4444;
  animation: energy-pulse 0.7s ease-in-out infinite;
}

@keyframes energy-pulse {
  50% { opacity: 0.45; }
}

.progress {
  flex: 1;
  height: 12px;
  background: var(--blh-line);
  border-radius: 4px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0;
  background: var(--blh-accent);
  transition: width 0.3s ease;
}

/* The game screen: big playfield on top, and a dedicated text-window strip
   at the bottom (1990s RPG style) holding the robot dialog and the question
   menu, so text never covers the gameplay.
   Per-level theme variables (--lv-*) are set from JS per dimension; the
   fallbacks keep the brand-tinted default. Game view only — UI chrome keeps
   the --blh-* palette (interim, provisional pending B02). */
.level-view {
  --ui-strip: 300px;
  position: relative;
  height: 780px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--lv-sky1, var(--blh-accent-light)) 0%, var(--lv-sky2, var(--blh-surface)) 62%, var(--lv-hill, #9db8d2) 145%);
  border: 1px solid var(--blh-line);
  border-radius: 4px;
}

/* Bottom text-window strip. */
.level-view::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--ui-strip);
  background: rgba(24, 35, 75, 0.94);
  border-top: 2px solid #ffffff;
  z-index: 2;
  pointer-events: none;
}

.level-view.menu-open .world {
  filter: brightness(0.8);
}

.level-banner {
  position: absolute;
  top: 48px;
  left: 0.8rem;
  z-index: 3;
  background: var(--blh-ink);
  color: var(--blh-white);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-family: "Press Start 2P", monospace;
}

/* World 2 three-layer parallax background (owner PNGs), behind the playable
   terrain. Sky is fixed (scroll 0.00); volcanoes 0.20 and lava pits 0.55 of
   camera travel; vertical parallax disabled. Layers are 170% wide and tile
   horizontally (repeat-x) so the shifted view stays covered; volcano/lava
   anchor to the bottom of the view. Nearest-neighbor keeps pixels sharp.
   The damaging lava stays in .world (the ground), i.e. at world speed 1.00. */
.plx {
  position: absolute;
  top: 44px;
  bottom: var(--ui-strip);
  left: 0;
  display: none;
  pointer-events: none;
  background-repeat: repeat-x;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.plx-sky { width: 100%; background-size: cover; background-position: top center; background-repeat: no-repeat; }
.plx-mid, .plx-front { width: 170%; background-size: auto 100%; background-position: left bottom; }

/* W4 lightning: fixed layer (scroll 0.00) between the storm sky and the
   mountains, so the ridges cover its lower part. Hidden (opacity 0) until
   JS adds .flash for ~0.15s; JS also varies background-position-x per flash. */
.plx-bolt {
  width: 100%;
  background-size: auto 100%;
  background-position: bottom;
  background-repeat: no-repeat;
  opacity: 0;
}
.plx-bolt.flash { opacity: 1; }

.level-view.plx-world .plx { display: block; }
/* the bolt layer only shows in worlds that ship a lightning asset (W4) */
.level-view.plx-world .plx.plx-bolt { display: none; }
.level-view.plx-bolt-world .plx.plx-bolt { display: block; }

/* W5: the distant swell strip tiles at one image per view width (58.82% of
   the 170% layer) and drifts by exactly one tile on its own slow timer, so
   the repeat joins seamlessly and the ocean moves even when the camera is
   stopped. The animation is on background-position, so it never fights the
   camera transform on the layer. */
.plx-mid.plx-grid-mid { background-size: 58.82% 100%; }

/* W6 distant snowfall: particle layer at scroll 0.30 between mountains and
   ridge (no background image; JS flakes are its children). */
.plx-snowback { width: 170%; }
.level-view.plx-world .plx.plx-snowback { display: none; }
.level-view.plx-snow-world .plx.plx-snowback { display: block; }

/* W6 foreground snowfall: screen-space overlay above the world (flakes pass
   in front of the robot) but inside the level view, i.e. below the HUD. */
.snow-fg {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
  z-index: 6;
}
.level-view.plx-snow-world .snow-fg { display: block; }

.snow-flake {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.level-view.plx-drift .plx-mid.plx-grid-mid { animation: swell-drift 18s linear infinite; }
@keyframes swell-drift {
  from { background-position: 0% bottom; }
  to { background-position: -58.82% bottom; }
}

/* W5 breaking waves: 2x2 atlas (768x512 cells) in a 240x160 box, 1.6s loop,
   reading order rising -> curling -> breaking -> foam. The per-frame y
   offsets (24px / -139px) put every frame's art bottom on the box bottom,
   so the crop stays steady between frames. */
.w5-wave {
  position: absolute;
  bottom: 0;
  width: 240px;
  height: 160px;
  transform: translateX(-50%);
  background-image: url("/static/sprites/w5-breaking-waves.webp");
  background-size: 480px 320px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: w5-wave 1.6s steps(1, end) infinite;
}
@keyframes w5-wave {
  0% { background-position: 0 24px; }
  25% { background-position: -240px 24px; }
  50% { background-position: 0 -139px; }
  75% { background-position: -240px -139px; }
}
.level-view.plx-world .world .clouds,
.level-view.plx-world .world .hills,
.level-view.plx-world .world .decor { display: none; }

/* Match the robot's 0.6s walk between W1 duel stops. Hopper worlds continue
   updating their scenery every physics frame without CSS interpolation. */
.level-view.w1-scrolling .plx-mid,
.level-view.w1-scrolling .plx-front { transition: transform 0.6s ease; }
.level-view.w1-scrolling.switching .plx { transition: none; }
.level-view.w1-scrolling .world .clouds { display: block; }

/* W1: the near skyline tiles at a fixed % of the 170% layer (100/1.7) so the
   neon signs and window lights can be positioned in image-% and repeat with
   the layer. W2 keeps auto 100% tiling. */
.plx-front.plx-grid { background-size: 58.82% 100%; }

/* W1 neon signs on the near-skyline billboard mounts: 4 cols x 2 rows sheet
   (top row lit, bottom row unlit), 384x512 cells; JS swaps background-position. */
.w1-sign {
  position: absolute;
  width: 64px;
  height: 85px;
  /* anchor at the panel center (63.7% of the cell height) so the sign sits
     centered on the billboard mount in both lit and unlit states */
  transform: translate(-50%, -63.7%);
  background-image: url("/static/sprites/w1-signs.webp");
  background-size: 256px 170px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* W1 window lights: small pixel-aligned overlays in selected dark window bays;
   .off hides the overlay so the dark window underneath shows through. */
.w1-bay {
  position: absolute;
  width: 6px;
  height: 8px;
  transform: translate(-50%, -50%);
  opacity: 0.95;
  transition: opacity 0.15s linear;
}
.w1-bay.off { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .w1-bay { transition: none; } }

/* Parallax layers: clouds drift on their own and all layers counter-move
   against the camera at different speeds (set from JS in updateCamera). */
.clouds {
  position: absolute;
  top: 8px;
  left: 0;
  width: 100%;
  height: 76px;
  pointer-events: none;
  transition: transform 0.6s ease;
}

.clouds svg {
  width: 100%;
  height: 100%;
  animation: cloud-drift 46s ease-in-out infinite alternate;
}

@keyframes cloud-drift {
  from { transform: translateX(-4%); }
  to { transform: translateX(6%); }
}

.hills {
  position: absolute;
  inset: 0;
  transition: transform 0.6s ease;
  pointer-events: none;
}

.hills span {
  position: absolute;
  bottom: var(--floor-height);
  width: 130px;
  height: 60px;
  background: var(--lv-hill, var(--blh-line));
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.28), inset 0 -10px 0 rgba(0, 0, 0, 0.15);
  opacity: 0.75;
}

.hills span:nth-child(1) { left: 4%; }
.hills span:nth-child(2) { left: 38%; height: 84px; }
.hills span:nth-child(3) { left: 72%; }
.hills span:nth-child(4) { left: 90%; width: 150px; height: 70px; }
.hills span:nth-child(5) { left: 20%; width: 170px; height: 52px; }
.hills span:nth-child(6) { left: 58%; width: 120px; height: 64px; }

/* World scenery (skyline / castle / forest / village / crystals / peaks),
   themed per dimension. */
.decor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--floor-height);
  height: 90px;
  opacity: 0.85;
  pointer-events: none;
  transition: transform 0.6s ease;
}

.decor svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* The world is twice as wide as the viewport; the camera (transform on
   .world, driven by JS) scrolls as the robot advances. */
.world {
  position: absolute;
  top: 44px;
  bottom: var(--ui-strip);
  left: 0;
  width: 200%;
  transition: transform 0.6s ease, opacity 0.35s ease, filter 0.3s ease;
}
.world.tactical-world { width: 100%; transform: none !important; }
.world.auto-run-world { transition: opacity 0.35s ease, filter 0.3s ease; }
.world.auto-run-world .traveler, .world.auto-run-world .clouds, .world.auto-run-world .hills, .world.auto-run-world .decor { transition: none; }
.tactical-world .clouds, .tactical-world .hills, .tactical-world .decor { transform: none !important; }

.level-view.switching .world {
  opacity: 0;
}

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--floor-height);
  box-sizing: border-box; /* keep the 3px top border inside the 36px so sprites anchored at bottom:36px stand exactly on the surface */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 7px),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0, 0, 0, 0.22) 46px 49px),
    repeating-linear-gradient(90deg, var(--lv-g1, var(--blh-navy)) 0 24px, var(--lv-g2, #064a8c) 24px 48px);
  border-top: 3px solid var(--blh-ink);
}

/* Question stops are battery icons; the battery drains and the icon
   disappears once the question is answered. */
.stop {
  position: absolute;
  bottom: var(--floor-height);
  transform: translateX(-50%);
  transition: opacity 0.5s ease 0.4s;
}

.stop .batt {
  display: block;
  position: relative;
  width: 16px;
  height: 24px;
  border: 2px solid #ffffff;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.3);
}

.stop .batt::after {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 4px;
  background: #ffffff;
  border-radius: 1px 1px 0 0;
}

.stop .batt i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  height: 85%;
  background: #22c55e;
  transition: height 0.5s ease, background 0.3s ease;
}

.stop .qid {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-family: "Press Start 2P", monospace;
  color: #ffffff;
  text-shadow: 1px 1px 0 var(--blh-ink);
  white-space: nowrap;
}

.stop.current .batt i {
  animation: batt-blink 1s steps(1) infinite;
}

@keyframes batt-blink {
  50% { opacity: 0.4; }
}

.stop.done .batt i,
.stop.drained .batt i {
  height: 0;
  background: #ef4444;
}

.stop.drained {
  opacity: 0;
}

/* Drained robot: slumped, desaturated, sweating. */
.traveler.tired .guide {
  animation: tired-slump 1.8s ease-in-out infinite;
  filter: saturate(0.65) brightness(0.95);
}

@keyframes tired-slump {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(3px) rotate(3deg); }
}

.traveler.tired::after {
  content: "";
  position: absolute;
  top: 4px;
  right: -5px;
  width: 4px;
  height: 7px;
  background: #7dd3fc;
  border-radius: 0 0 2px 2px;
  animation: sweat-drip 1.2s ease-in infinite;
}

@keyframes sweat-drip {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(20px); opacity: 0; }
}

.rocket {
  position: absolute;
  bottom: var(--floor-height);
  width: 128px;
  transform: translateX(-50%);
  transition: left 0.8s ease;
  z-index: 2;
  pointer-events: none;
}

/* Spaceship sprite sheet (owner PNG): 4 cols x 3 rows of 362px cells in a
   128px box (background-size 512x384). The outer box clips each frame while
   JS positions the selected row and applies its vertical compensation. */
.ship-sheet {
  display: block;
  width: 128px;
  height: 128px;
  overflow: hidden;
}

.ship-frame {
  width: 128px;
  height: 128px;
  background-image: url("/static/sprites/spaceship.webp");
  background-size: 512px 384px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Dust/smoke puffs when the saucer lands or takes off. */
.dust {
  position: absolute;
  bottom: 30px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d6c9b0;
  transform: translateX(-50%);
  animation: dust-puff 1.9s ease-out forwards;
  pointer-events: none;
  z-index: 1;
}

@keyframes dust-puff {
  to {
    transform: translate(calc(-50% + var(--dx, 0px)), -44px) scale(2.4);
    opacity: 0;
  }
}

.rocket.landing .ship-sheet {
  animation: rocket-land 2.2s ease;
}

.rocket.takeoff .ship-sheet {
  animation: rocket-takeoff 2.4s ease forwards;
}

/* Pre-launch: the saucer shakes, glows and kicks up dust before lifting off. */
.rocket.launching .ship-sheet {
  animation: launch-shake 0.12s linear infinite;
  filter: drop-shadow(0 0 14px #f59e0b);
}

@keyframes launch-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, -2px); }
}

@keyframes rocket-land {
  0% { transform: translateY(-260px); }
  55% { transform: translateY(0); }
  70% { transform: translateY(0); }
  85% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

@keyframes rocket-takeoff {
  0% { transform: translate(0, 0) rotate(0deg); }
  30% { transform: translate(1%, -90px) rotate(2deg); }
  100% { transform: translate(6%, -420px) rotate(8deg); opacity: 0.8; }
}

.minion {
  position: absolute;
  bottom: var(--floor-height);
  width: 48px;
  transform: translateX(-50%);
  transition: left 1.1s linear;
  z-index: 1;
  pointer-events: none;
}

.minion svg {
  display: block;
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}
.tactical-enemy { width: 96px; bottom: var(--floor-height); z-index: 2; }
.tactical-enemy svg { width: 96px; height: 96px; }

/* Owner-supplied alien sprite sheet (planet 1): 4 cols x 3 rows of 362px
   cells shown in a 96px box; pixelated = nearest-neighbor, sharp pixels.
   Bottom-anchored box keeps the feet planted; .flip mirrors to face left. */
.alien-sheet {
  --sprite-size: 96px;
  position: relative;
  top: calc(var(--sprite-size) * var(--foot-offset, 0));
  width: 96px;
  height: 96px;
  background-image: url("/static/sprites/alien-1.webp");
  background-size: 400% 300%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.alien-sheet.flip {
  transform: scaleX(-1);
}

/* W3/W6 duel aliens render larger (owner request). The container stays
   bottom-anchored on the floor and .alien-sheet's top offset is
   calc(--sprite-size * --foot-offset), so the visible feet stay planted
   on the floor line at any box size. */
.tactical-enemy.lg { width: 192px; }
.alien-sheet.lg { --sprite-size: 192px; width: 192px; height: 192px; }

/* Walk shuffle while the move row loops (0.48s = 4 frames x 120ms). Uses
   the `translate` property so it never fights the flip's `transform`, and
   only moves horizontally — the feet stay planted on the ground line. */
.alien-sheet.walking {
  animation: alien-walk 0.48s linear infinite;
}

@keyframes alien-walk {
  0%, 100% { translate: 0 0; }
  50% { translate: -4px 0; }
}

/* Contact shadows ground the characters and separate them from the
   background; sprites themselves get a dark outline (see sprite() in
   play.js and the .guide filter above). */
.traveler::before,
.minion::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 78%;
  height: 9px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0) 70%);
  z-index: -1;
}
/* Name tag floats ABOVE the enemy's head so the sprite's feet stay on the
   ground (the container is bottom-anchored; an in-flow label would lift the
   sprite and make it look like it floats). */
.enemy-name { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); margin-top: 0; white-space: nowrap; color: #fff; background: #18234b; border: 1px solid #fff; text-align: center; font: 8px "Press Start 2P", monospace; padding: 4px 2px; text-shadow: 1px 1px #000; }
.duel-result { position: absolute; top: 24%; left: 50%; transform: translateX(-50%); z-index: 4; width: max-content; max-width: 90%; padding: 0.7rem 1rem; border: 4px solid #fff; box-shadow: 0 8px 0 #18234b, 0 0 24px currentColor; background: #18234b; text-align: center; font: 16px "Press Start 2P", monospace; line-height: 1.5; pointer-events: none; }
.duel-result.win { color: #86efac; }
.duel-result.lose { color: #fca5a5; }
.duel-result.draw { color: #fde68a; }

/* Locally hosted pixel font (Press Start 2P, OFL, from google/fonts). */
@font-face {
  font-family: "Press Start 2P";
  src: url("/static/fonts/press-start-2p.ttf") format("truetype");
  font-display: swap;
}

/* Bottom text window: one full-width phase at a time — intro (robot
   instructions), fight (defend!), question (answer to recharge). */
#phase-window {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--ui-strip);
  z-index: 4;
  pointer-events: none;
}

.phase {
  pointer-events: auto;
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  max-height: calc(var(--ui-strip) - 16px);
  overflow: auto;
}

/* Intro / robot dialog (full width, classic message window). */
.guide-say {
  padding: 0.7rem 0.9rem;
  background: rgba(24, 35, 75, 0.6);
  border: 2px solid #ffffff;
  border-radius: 4px;
  color: #ffffff;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  line-height: 1.8;
  text-transform: uppercase;
  cursor: pointer;
}

/* Fight phase banner. */
.phase-fight {
  text-align: center;
  padding-top: 3.2rem;
  color: #ffffff;
  font-family: "Press Start 2P", monospace;
}

.fight-text {
  font-size: 11px;
  color: #f87171;
  animation: prompt-blink 0.8s steps(1) infinite;
}

.fight-count {
  display: block;
  margin-top: 0.8rem;
  font-size: 9px;
  color: var(--blh-accent-light);
}

.tactical-panel { padding-top: 1.1rem; }
.tactical-panel strong { color: #facc15; font-size: 12px; line-height: 1.7; }
.tactical-panel p { font-size: 10px; line-height: 1.7; }
.tactical-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; }
.tactical-actions button { padding: 0.8rem 1rem; min-width: 145px; color: #fff; border: 2px solid #fff; font: inherit; cursor: pointer; }
.tactical-actions button:disabled { opacity: 0.55; cursor: wait; }
.skip-fight { background: #475569 !important; color: #fff; border: 2px solid #fff !important; }
#skip-fight { display: block; margin: 0.6rem auto 0; padding: 0.6rem 1rem; font: 10px "Press Start 2P", monospace; cursor: pointer; }
#tactical-rock { background: #b91c1c; }
#tactical-paper { background: #1d4ed8; }
#tactical-scissors { background: #6d28d9; }
.tactical-enemy.move-rock svg { filter: drop-shadow(0 0 10px #f43f5e); transform: translateX(-14px); }
.tactical-enemy.move-paper svg { filter: drop-shadow(0 0 10px #60a5fa); transform: scale(1.2); }
.tactical-enemy.move-scissors svg { filter: drop-shadow(0 0 10px #facc15); transform: rotate(-12deg); }
.traveler.move-rock .guide { transform: translateX(14px); }
.traveler.move-paper .guide { transform: scale(1.1); }
.traveler.move-scissors .guide { transform: rotate(12deg); }
.traveler.move-pick .guide { transform: scale(1.12) translateY(-4px); }
.tactical-enemy.move-pick svg { animation: enemy-lunge 0.5s ease; }

@keyframes enemy-lunge {
  40% { transform: translateX(-16px) scale(1.06); }
}

/* Guessing-duel panel (Worlds 3 & 6): number buttons 1-5 + skip. */
.guess-panel .guess-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.guess-panel .guess-actions button { min-width: 52px; padding: 0.55rem 0.7rem; }
.guess-panel #guess-target { color: #facc15; }

/* Water world (World 5): blue animated water instead of lava, gray rocks. */
.auto-run-world.water-world .ground {
  border-top-color: #7dd3fc;
  box-shadow: inset 0 8px 22px rgba(125, 211, 252, 0.5);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0) 0 34px, rgba(255, 255, 255, 0.35) 34px 40px, rgba(255, 255, 255, 0) 40px 74px),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0, 20, 60, 0.25) 46px 49px),
    repeating-linear-gradient(90deg, var(--lv-g1, var(--blh-navy)) 0 24px, var(--lv-g2, #064a8c) 24px 48px);
  animation: wave-flow 1.6s linear infinite;
}

@keyframes wave-flow {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 74px 0, 49px 0, 0 0; }
}

.auto-run-world.water-world .land {
  background: linear-gradient(180deg, #94a3b8 0 4px, #475569 4px 70%, #1e293b 100%);
  border-top-color: #cbd5e1;
}

.water-drop {
  position: absolute;
  bottom: calc(var(--floor-height) - 2px);
  width: 5px;
  height: 9px;
  border-radius: 50% 50% 40% 40%;
  background: #e0f7ff;
  border: 1px solid #38bdf8;
  pointer-events: none;
  z-index: 3;
  animation: water-drop-arc 0.65s ease-out forwards;
}

.water-ripple {
  position: absolute;
  bottom: calc(var(--floor-height) - 3px);
  width: 12px;
  height: 4px;
  border: 2px solid #e0f7ff;
  border-radius: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 3;
  animation: water-ripple-spread 0.65s ease-out forwards;
}

@keyframes water-drop-arc {
  45% { transform: translate(var(--splash-x), calc(-1 * var(--splash-rise))); opacity: 1; }
  100% { transform: translate(var(--splash-x), 4px); opacity: 0; }
}

@keyframes water-ripple-spread {
  to { width: 100px; height: 8px; opacity: 0; }
}
.traveler.low-battery .guide { filter: sepia(1) saturate(8) hue-rotate(315deg) drop-shadow(1px 0 0 #0b1026) drop-shadow(-1px 0 0 #0b1026) drop-shadow(0 1px 0 #0b1026) drop-shadow(0 -1px 0 #0b1026) drop-shadow(0 0 9px #ef4444); }

.run-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.45rem; }
.run-controls button { min-width: 78px; padding: 0.6rem; touch-action: none; }
#jump { background: #6d28d9; color: #fff; }
/* World 2 lava-hop: basalt rocks the robot lands on; question rocks glow. */
.land {
  position: absolute;
  bottom: var(--floor-height);
  height: 16px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #57534e 0 4px, #292524 4px 70%, #0c0a09 100%);
  border: 2px solid #0b1026;
  border-top: 3px solid #a8a29e;
  box-shadow: 0 4px 10px rgba(249, 115, 22, 0.45);
}

.land-q {
  border-top-color: #fbbf24;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.85), 0 4px 10px rgba(249, 115, 22, 0.45);
}

/* World 2 ground is animated lava (theme colors + flowing glow). */
.auto-run-world .ground {
  border-top-color: #f97316;
  box-shadow: inset 0 8px 22px rgba(249, 115, 22, 0.55);
  background:
    repeating-linear-gradient(90deg, rgba(251, 191, 36, 0) 0 30px, rgba(251, 191, 36, 0.4) 30px 37px, rgba(251, 191, 36, 0) 37px 66px),
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(0, 0, 0, 0.25) 46px 49px),
    repeating-linear-gradient(90deg, var(--lv-g1, var(--blh-navy)) 0 24px, var(--lv-g2, #064a8c) 24px 48px);
  animation: lava-flow 1.1s linear infinite;
}

@keyframes lava-flow {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 66px 0, 49px 0, 0 0; }
}

.dust.splash {
  background: #f97316;
  box-shadow: 0 0 10px #fbbf24;
}

.fight-attack {
  display: block;
  margin: 0.8rem auto 0;
  padding: 0.7rem 1.6rem;
  background: #b91c1c;
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 4px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.warn {
  position: absolute;
  top: calc(100% + 1.6rem);
  right: 8px;
  max-width: min(360px, 75%);
  padding: 0.45rem 0.6rem;
  background: #18234b;
  border: 2px solid #ffffff;
  line-height: 1.5;
  color: #ef4444;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
}

/* Speaker icon: waves when sound is on, red slash when muted. */
.snd-icon {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 4px;
}

.snd-icon .slash {
  display: none;
}

#sound-toggle:not(.muted) .slash {
  display: none;
}

#sound-toggle:not(.muted) .waves {
  display: block;
}

#sound-toggle.muted .waves {
  display: none;
}

#sound-toggle.muted .slash {
  display: block;
}


.guide-say .prompt {
  display: block;
  margin-top: 0.5rem;
  color: var(--blh-accent-light);
  animation: prompt-blink 1s steps(1) infinite;
}

.guide-say .typing::after {
  content: "▌";
  color: var(--blh-accent-light);
  animation: prompt-blink 0.7s steps(1) infinite;
}

@keyframes prompt-blink {
  50% { opacity: 0; }
}

.minion.attack svg {
  animation: minion-lunge 0.3s ease;
}

.minion.flee {
  opacity: 0.6;
}

.minion.hit svg {
  filter: invert(1) brightness(1.6);
}

.minion.defeated svg {
  animation: poof 0.4s ease forwards;
}

@keyframes poof {
  to { transform: scale(0) rotate(90deg); opacity: 0; }
}

@keyframes minion-lunge {
  40% { transform: translateX(-14px) scale(1.15); }
}

.traveler.hit .guide {
  animation: hit-flash 0.3s ease;
}

.traveler.charging .guide {
  animation: charge-glow 0.85s ease-out;
}

.traveler.charging::after {
  content: "+ BATTERY";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  color: #86efac;
  font: 8px "Press Start 2P", monospace;
  white-space: nowrap;
  text-shadow: 1px 1px #064e3b;
  animation: charge-label 0.85s ease-out forwards;
}

@keyframes charge-glow {
  0% { filter: drop-shadow(0 0 0 #4ade80); }
  40% { filter: drop-shadow(0 0 14px #4ade80) drop-shadow(0 0 6px #67e8f9); }
  100% { filter: drop-shadow(0 0 0 #4ade80); }
}

@keyframes charge-label {
  to { transform: translate(-50%, -18px); opacity: 0; }
}

.traveler.reboot .guide {
  animation: reboot 1s ease;
}

@keyframes hit-flash {
  30% { filter: invert(1); transform: translateX(6px); }
}

@keyframes reboot {
  0%, 100% { filter: none; transform: none; }
  25% { filter: grayscale(1) brightness(0.6); transform: rotate(-10deg); }
  75% { filter: grayscale(1) brightness(1.4); transform: rotate(10deg); }
}

.traveler {
  position: absolute;
  left: 15%;
  bottom: var(--floor-height);
  width: 80px;
  transform: translateX(-50%);
  transition: left 0.6s ease;
  pointer-events: none;
  z-index: 2;
}

.traveler .guide {
  width: 80px;
  height: 80px;
  display: block;
}

.traveler.aboard {
  opacity: 0; /* robot is inside the saucer until it lands */
}

/* Boarding: the robot shrinks and fades into the saucer before launch. */
.traveler.boarding {
  animation: board 0.8s ease forwards;
}

@keyframes board {
  to {
    transform: translateX(-50%) translateY(-34px) scale(0.15);
    opacity: 0;
  }
}

.traveler.running .guide {
  animation: run-bob 0.18s linear infinite;
}

.traveler.running .guide.robot-sheet {
  animation: none; /* the sheet's run row (row 1) drives the animation */
}

@keyframes run-bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}

.guide {
  image-rendering: pixelated;
  animation: idle-bob 2s ease-in-out infinite;
  /* dark contour around the robot so it never blends into the scenery */
  filter: drop-shadow(1px 0 0 #0b1026) drop-shadow(-1px 0 0 #0b1026) drop-shadow(0 1px 0 #0b1026) drop-shadow(0 -1px 0 #0b1026);
}

/* Owner-supplied robot sprite sheet (Sprites/Robot.png -> static/sprites/):
   4 cols x 3 rows of 362px cells in an 80px bottom-anchored box (feet planted,
   pivot consistent); pixelated = nearest-neighbor. Row 0 idle/blink loop,
   row 1 run loop, row 2 jump (played once). Front-facing, so no flip needed. */
.robot-sheet {
  --sprite-size: 80px;
  position: relative;
  top: calc(var(--sprite-size) * var(--foot-offset, 0.09669));
  width: 80px;
  height: 80px;
  background-image: url("/static/sprites/robot.webp");
  background-size: 400% 300%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.traveler .guide.robot-sheet:not(.celebrate) {
  animation: none; /* the sheet's own frames drive idle/run; CSS bob would double it */
}

.guide .eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 4s infinite;
}

.guide.celebrate {
  animation: celebrate-jump 0.6s ease;
}

/* Question menu docked inside the game screen (turn-based RPG style). */
.game-menu {
  padding: 0.7rem 0.9rem;
  background: rgba(24, 35, 75, 0.6);
  border: 2px solid #ffffff;
  border-radius: 4px;
  color: #ffffff;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 1.6;
}

/* Answers in two columns so the whole question fits in the strip. */
#anchors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.6rem;
}

.dimension {
  color: var(--blh-accent-light);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.35rem;
}

#q-text {
  font-size: 10px;
  line-height: 1.6;
  margin: 0 0 0.5rem;
}

.anchor {
  display: block;
  width: 100%;
  margin: 0.25rem 0;
  padding: 0.35rem 0.5rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 3px;
  color: #ffffff;
  font: inherit;
  font-size: 8px;
  line-height: 1.5;
  cursor: pointer;
  touch-action: manipulation;
}

.anchor[aria-checked="true"] {
  border-color: var(--blh-accent);
  background: rgba(72, 188, 246, 0.3);
}

.anchor .key {
  display: inline-block;
  min-width: 1.2em;
  font-weight: 700;
  color: var(--blh-accent-light);
}

.nav {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.game-menu .nav button {
  font-size: 9px;
  padding: 0.4rem 0.7rem;
}

.game-menu .hint {
  font-size: 7px;
  opacity: 0.75;
}

.nav button,
#motion-toggle,
#sound-toggle,
#save {
  padding: 0.5rem 1rem;
  background: var(--blh-btn-bg);
  color: var(--blh-white);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation; /* no double-tap zoom delay on phones */
  font: inherit;
}

.hud button {
  font-family: inherit;
  font-size: 0.8rem;
}

#attack {
  background: #b91c1c;
}

/* Ask-the-guide sits in its own row, in a help-green that is neither the
   primary nor the secondary brand color. */
.ask-row {
  margin-top: 0.5rem;
  text-align: right;
}

#ask-open {
  padding: 0.45rem 0.9rem;
  background: #64748b; /* low-tone blue: help action, not a primary action */
  color: #ffffff;
  border: 1px solid #ffffff;
  border-radius: 4px;
  font: inherit;
  font-size: 9px;
  cursor: pointer;
  touch-action: manipulation;
}

/* Next is the prominent action: green. */
#next {
  background: #16a34a;
  font-weight: 700;
}

#next:disabled {
  background: var(--blh-line);
  color: var(--blh-muted);
}

/* Phones / narrow screens: smaller stage and sprites, wrapping HUD. */
@media (max-width: 640px) {
  .hud {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .level-view {
    --ui-strip: 300px;
    height: 880px;
  }

  .game-menu {
    width: calc(100% - 16px);
    max-height: calc(var(--ui-strip) - 16px);
  }

  .guide-say {
    max-width: calc(100% - 16px);
  }

  :root { --floor-height: 28px; }

  .traveler {
    width: 56px;
    bottom: var(--floor-height);
  }

  .traveler .guide {
    width: 56px;
    height: 56px;
  }

  .minion {
    width: 40px;
    bottom: var(--floor-height);
  }

  .minion svg {
    width: 40px;
    height: 40px;
  }
  .tactical-enemy { width: 72px; }
  .alien-sheet { --sprite-size: 72px; width: 72px; height: 72px; }
  .tactical-enemy.lg { width: 138px; }
  .alien-sheet.lg { --sprite-size: 138px; width: 138px; height: 138px; }
  .robot-sheet { --sprite-size: 56px; }
  .tactical-enemy svg { width: 72px; height: 72px; }
  .enemy-name { font-size: 6px; }
  .duel-result { font-size: 12px; }
  .tactical-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tactical-actions button { min-width: 0; padding: 0.65rem 0.2rem; font-size: 9px; }

  .rocket {
    width: 128px;
    bottom: var(--floor-height);
  }

  .ground {
    height: 28px;
  }

  .guide-say {
    font-size: 8px;
    line-height: 1.6;
  }

  .anchor {
    font-size: 0.9rem;
  }
}

.nav button:disabled {
  background: var(--blh-line);
  cursor: default;
}

.hint {
  color: var(--blh-muted);
  font-size: 0.8rem;
}

#save {
  padding: 0.4rem 0.8rem;
  background: var(--blh-white);
  color: var(--blh-btn-bg);
  border: 1px solid var(--blh-btn-bg);
  border-radius: 4px;
  cursor: pointer;
}

#resume-link {
  word-break: break-all;
}

#result .dim-bar {
  flex: 1;
  height: 10px;
  background: var(--blh-line);
  border-radius: 4px;
  overflow: hidden;
}

#result .dim-bar div {
  height: 100%;
  background: var(--blh-secondary);
}

.dim-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 0.3rem 0;
}

.result-level {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--blh-navy);
}

.cta {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  background: var(--blh-surface);
  border-left: 4px solid var(--blh-btn-bg);
  font-weight: 600;
  color: var(--blh-ink);
}

.cta a {
  color: var(--blh-btn-bg);
}

/* Ending screen: a proper game-over style overlay — dark starfield, pixel
   font, saucer flying across, game-window cards. */
.reveal {
  position: absolute;
  inset: 44px 8px 8px 8px;
  z-index: 6;
  padding: 1.2rem;
  background: #0b1026;
  border: 2px solid #ffffff;
  border-radius: 4px;
  overflow: auto;
  color: #ffffff;
  font-family: "Press Start 2P", monospace;
}

.end-saucer {
  position: absolute;
  top: 18px;
  left: -90px;
  animation: end-fly 7s linear infinite;
  pointer-events: none;
}

/* The ending-screen saucer loops the fly row (row 0) of the sheet. */
.end-saucer .ship-frame {
  animation: ship-end-fly 0.48s steps(4) infinite;
}

@keyframes ship-end-fly {
  from { background-position: 0 0; }
  to { background-position: -512px 0; }
}

@keyframes end-fly {
  to { left: 105%; }
}

.reveal .reveal-eyebrow {
  text-align: center;
  font-size: 16px;
  color: var(--blh-accent-light);
  animation: prompt-blink 2s steps(1) infinite;
  margin-top: 1rem;
}

.reveal .result-level {
  color: #ffffff;
  font-family: inherit;
  font-size: 24px;
  text-align: center;
}

.reveal p {
  font-size: 9px;
  text-align: center;
  color: #cbd5e1;
}

#result .dim-row span {
  color: #cbd5e1;
  font-size: 8px;
}

#result .dim-bar {
  background: rgba(255, 255, 255, 0.15);
}

#result .dim-bar div {
  background: var(--blh-accent);
}

.reveal h3 {
  font-size: 10px;
  color: var(--blh-accent-light);
}

.missions .mission {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.mission h3 {
  color: #ffffff;
  font-size: 10px;
}

.mission p {
  color: #cbd5e1;
  font-size: 8px;
  text-align: left;
}

.mission .path {
  color: var(--blh-accent-light);
}

.reveal .cta {
  background: rgba(22, 163, 74, 0.15);
  border-left: 4px solid #16a34a;
  color: #ffffff;
  font-family: inherit;
  font-size: 10px;
  text-align: left;
}

.reveal .cta a {
  color: #4ade80;
}

.reveal .result-note {
  background: transparent;
  border-left-color: #64748b;
  color: #94a3b8;
  font-size: 7px;
}

.reveal .again {
  display: block;
  margin: 0.8rem auto 0;
  font-family: inherit;
}

.combo {
  color: #facc15;
  font-size: 9px;
}

.pickup {
  position: absolute;
  bottom: 44px;
  animation: pickup-bob 1s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes pickup-bob {
  50% { transform: translateY(-6px); }
}

.minion.flyer {
  bottom: auto;
  top: 70px;
}

.reveal-eyebrow {
  color: var(--blh-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

.reveal .result-level {
  font-size: 2.4rem;
}

.missions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}

.mission {
  padding: 0.9rem;
  background: var(--blh-surface);
  border: 1px solid var(--blh-line);
  border-radius: 4px;
}

.mission h3 {
  margin: 0 0 0.4rem;
  color: var(--blh-ink);
  font-size: 1rem;
}

.mission .path {
  color: var(--blh-muted);
  font-size: 0.8rem;
  text-transform: capitalize;
}

.again {
  padding: 0.5rem 1rem;
  background: var(--blh-btn-bg);
  color: var(--blh-white);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.confetti-layer span {
  position: absolute;
  top: -8px;
  width: 8px;
  height: 8px;
  background: var(--blh-accent);
  animation: confetti-fall 1.6s ease-in forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(420px) rotate(540deg);
    opacity: 0;
  }
}

.result-note {
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  background: var(--blh-surface);
  border-left: 4px solid var(--blh-accent);
  color: var(--blh-muted);
  font-size: 0.85rem;
}

/* Ask-the-guide opens as a modal window over the game screen, so the bottom
   strip stays short. */
.ask-modal {
  position: absolute;
  inset: 44px 8px 8px 8px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.ask-window {
  width: min(520px, 92%);
  max-height: 100%;
  overflow: auto;
  padding: 1rem;
  background: rgba(24, 35, 75, 0.97);
  border: 2px solid #ffffff;
  border-radius: 4px;
  color: #ffffff;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 1.7;
}

.ask-window h2 {
  margin: 0 0 0.5rem;
  font-size: 11px;
  color: var(--blh-accent-light);
}

.ask-window .disclosure {
  color: rgba(255, 255, 255, 0.75);
  font-size: 8px;
  margin: 0.4rem 0;
}

.ask-window textarea {
  width: 100%;
  box-sizing: border-box;
  margin: 0.4rem 0;
  padding: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font: inherit;
}

@media (pointer: coarse) {
  .ask-window textarea { font: 16px/1.4 system-ui, sans-serif; }
}

.ask-window label {
  display: block;
  font-size: 8px;
  margin-bottom: 0.5rem;
}

.ask-window .nav button {
  font-size: 9px;
  padding: 0.4rem 0.8rem;
}

#ask-reply p {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  font-size: 9px;
}

#ask-reply .degraded {
  opacity: 0.75;
}

@keyframes idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

@keyframes celebrate-jump {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-14px); }
}

@media (prefers-reduced-motion: reduce) {
  .guide,
  .guide .eye,
  .alien-sheet.walking,
  .guide.celebrate,
  #progress-fill,
  #energy-fill,
  .confetti-layer span,
  .traveler,
  .traveler.running .guide,
  .traveler.hit .guide,
  .traveler.charging .guide,
  .traveler.charging::after,
  .traveler.reboot .guide,
  .traveler.boarding,
  .traveler.tired .guide,
  .traveler.tired::after,
  .stop .batt i,
  .rocket,
  .rocket .ship-sheet,
  .rocket.landing .ship-sheet,
  .rocket.takeoff .ship-sheet,
  .rocket.launching .ship-sheet,
  .end-saucer .ship-frame,
  .w5-wave,
  .level-view.plx-drift .plx-mid.plx-grid-mid,
  .dust,
  .water-drop,
  .water-ripple,
  .plx,
  .clouds svg,
  .hills,
  .decor,
  .minion,
  .minion.attack svg,
  .tactical-enemy.move-attack svg,
  .tactical-enemy.move-dodge svg,
  .tactical-enemy.move-pick svg,
  .traveler.move-pick .guide,
  .minion.defeated svg,
  .pickup,
  .end-saucer,
  .guide-say .prompt,
  .auto-run-world .ground,
  .auto-run-world.water-world .ground,
  .level-view .world {
    animation: none !important;
    transition: none !important;
  }
}

body.reduced-motion .guide,
body.reduced-motion .guide .eye,
body.reduced-motion .guide.celebrate,
body.reduced-motion #progress-fill,
body.reduced-motion #energy-fill,
body.reduced-motion .confetti-layer span,
body.reduced-motion .traveler,
body.reduced-motion .traveler.running .guide,
body.reduced-motion .traveler.hit .guide,
body.reduced-motion .traveler.charging .guide,
body.reduced-motion .traveler.charging::after,
body.reduced-motion .traveler.reboot .guide,
body.reduced-motion .traveler.boarding,
body.reduced-motion .traveler.tired .guide,
body.reduced-motion .traveler.tired::after,
body.reduced-motion .stop .batt i,
body.reduced-motion .rocket,
body.reduced-motion .rocket .ship-sheet,
body.reduced-motion .rocket.landing .ship-sheet,
body.reduced-motion .rocket.takeoff .ship-sheet,
body.reduced-motion .rocket.launching .ship-sheet,
body.reduced-motion .end-saucer .ship-frame,
body.reduced-motion .w5-wave,
body.reduced-motion .level-view.plx-drift .plx-mid.plx-grid-mid,
body.reduced-motion .dust,
body.reduced-motion .water-drop,
body.reduced-motion .water-ripple,
body.reduced-motion .plx,
body.reduced-motion .clouds svg,
body.reduced-motion .hills,
body.reduced-motion .decor,
body.reduced-motion .minion,
body.reduced-motion .minion.attack svg,
body.reduced-motion .tactical-enemy.move-attack svg,
body.reduced-motion .tactical-enemy.move-dodge svg,
body.reduced-motion .tactical-enemy.move-pick svg,
body.reduced-motion .traveler.move-pick .guide,
body.reduced-motion .alien-sheet.walking,
body.reduced-motion .minion.defeated svg,
body.reduced-motion .pickup,
body.reduced-motion .end-saucer,
body.reduced-motion .guide-say .prompt,
body.reduced-motion .auto-run-world .ground,
body.reduced-motion .auto-run-world.water-world .ground,
body.reduced-motion .level-view .world {
  animation: none !important;
  transition: none !important;
}

/* Personal AI Journey (D023): anchor labels + descriptions, rank tiers,
   planet bars and the repair mission on the ending screen. */
.anchor {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.anchor .key {
  flex: 0 0 1.4em;
}

.anchor-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.anchor-body strong {
  font-weight: 700;
  color: #ffffff;
}

.anchor-body small {
  color: #a5b4cf;
  font-size: 7px;
  line-height: 1.5;
}

.reveal .reveal-eyebrow {
  animation: none;
  color: #7dd3fc;
  font-size: 10px;
  margin-top: 0.4rem;
}

.reveal .next-step p {
  text-align: left;
}

.reveal .next-step .next-step-dim {
  margin: 0 0 0.3rem;
  color: #ffffff;
  font-size: 10px;
}

/* The ending screen takes the whole game view: the in-game HUD (XP, question
   count) is no longer relevant once the assessment is done. */
.level-view.finished .hud {
  display: none;
}

.level-view.finished .reveal {
  inset: 8px;
}

.reveal .result-lead {
  color: #cbd5e1;
  font-size: 9px;
  line-height: 1.8;
}

.reveal .result-sub {
  color: var(--blh-accent-light);
  font-size: 9px;
}

.reveal .game-status {
  color: #ffffff;
  font-size: 10px;
  line-height: 1.8;
}

.reveal .tier-summary,
.reveal .tier-next {
  max-width: 62ch;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.reveal .tier-next {
  margin-top: 0.8rem;
  padding: 0.5rem 0.7rem;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--blh-accent-light);
}

/* The one planet worth naming on the ending screen: where the person scored
   lowest, framed as the next thing to work on rather than a place to visit. */
.reveal .next-step {
  max-width: 62ch;
  margin: 1rem auto 0;
  padding: 0.8rem 0.9rem;
  background: rgba(28, 218, 255, 0.08);
  border: 2px solid var(--blh-accent-light);
  border-radius: 4px;
  text-align: left;
}

.reveal .next-step h3 {
  margin: 0 0 0.4rem;
}

.reveal .next-step-dim {
  color: #ffffff;
  font-size: 10px;
}

.reveal .diagnostic {
  color: #fde68a;
}

/* Rank and level stated together, once (D025): "The Explorer · Level 2 of 5". */
.reveal .result-level-num {
  display: block;
  color: #7dd3fc;
  font-size: 10px;
  margin-top: 0.4rem;
}

/* The one community block on the ending screen: how finished journeys spread
   across the five levels, with the player's own row marked. No score number,
   no planet bars - this is the only extra block. */
.reveal .spread {
  max-width: 62ch;
  margin: 1rem auto 0;
  padding: 0.8rem 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(125, 211, 252, 0.35);
  border-radius: 4px;
  text-align: left;
}

.reveal .spread h3 {
  margin: 0 0 0.5rem;
}

.reveal .spread-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reveal .spread-list li {
  display: grid;
  grid-template-columns: 11rem 1fr 3.5rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 9px;
  padding: 0.2rem 0.3rem;
}

.reveal .spread-list li.is-mine {
  background: rgba(28, 218, 255, 0.14);
  border-left: 3px solid var(--blh-accent-light);
  color: #ffffff;
}

.reveal .spread-rank {
  color: #cbd5e1;
}

.reveal .spread-list li.is-mine .spread-rank {
  color: #7dd3fc;
}

.reveal .spread-bar {
  display: block;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.reveal .spread-bar i {
  display: block;
  height: 100%;
  background: var(--blh-accent-light);
}

.reveal .spread-pct {
  text-align: right;
  color: #ffffff;
}

.reveal .spread-note {
  margin: 0.5rem 0 0;
  color: #94a3b8;
  font-size: 8px;
}

/* Share: level and rank only, no score, no resume token (D025). */
.reveal .share-row {
  margin: 1rem 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.reveal .share {
  font-family: inherit;
  font-size: 10px;
  padding: 0.5rem 1rem;
  background: rgba(28, 218, 255, 0.12);
  color: #7dd3fc;
  border: 2px solid var(--blh-accent-light);
  border-radius: 4px;
  cursor: pointer;
}

.reveal .share:hover {
  background: rgba(28, 218, 255, 0.22);
}

.reveal .share-note {
  color: #fde68a;
  font-size: 9px;
}

/* Contrast fixes for the personal ending screen: the older base .mission h3
   rule sets a dark ink color, which is unreadable over the reveal overlay. */
.reveal h3 {
  color: #7dd3fc;
}

/* Keep the five labelled anchors a little tighter so the answer card scrolls
   less on desktop; the card itself already scrolls on small screens. */
.anchor {
  padding: 0.28rem 0.45rem;
  line-height: 1.4;
}

.anchor-body small {
  line-height: 1.35;
}

/* Cover screen (PJ-06): animated cover over the owner's art, shown until the
   player picks a language; the game below stays hidden and does not boot. */
.cover {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  background: var(--blh-surface, #101a33);
  border: 1px solid var(--blh-line, #ffffff);
  border-radius: 4px;
  text-align: center;
}

.cover-art {
  position: relative;
  aspect-ratio: 1424 / 752;
  border: 2px solid #ffffff;
  border-radius: 4px;
  overflow: hidden;
}

.cover-bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: pixelated;
}

/* Animated cover sprites from the owner's sheets (4x3 cells of 362px in a
   1448x1086 sheet): the top row is the idle/move loop, stepped with CSS. */
.cover-sprite {
  position: absolute;
  bottom: 2%;
  image-rendering: pixelated;
  pointer-events: none;
  overflow: hidden;
}

.cover-robot {
  left: 6%;
  width: 362px;
  height: 362px;
  background: url("/static/img/cover-robot.png") 0 0 / 1448px 362px no-repeat;
  transform: scale(0.55);
  transform-origin: bottom left;
  animation: cover-sprite-row 0.9s steps(4) infinite;
}

@keyframes cover-sprite-row {
  from { background-position-x: 0; }
  to { background-position-x: -1448px; }
}

@media (prefers-reduced-motion: reduce) {
  .cover-robot { animation: none; }
}

/* Story intro (second screen after the language pick): Star-Wars-style crawl
   over the six-planets art. */
.intro {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  height: 720px;
  border: 1px solid var(--blh-line, #ffffff);
  border-radius: 4px;
  overflow: hidden;
  background: #04060f url("/static/img/planets.webp") center / cover no-repeat;
}

.intro-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, transparent 50%, black 63%);
}

.intro-crawl {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 100%;
  color: #ffe81f; /* Star Wars crawl yellow */
  font-family: "Press Start 2P", monospace; /* same pixel font as the game */
  line-height: 1.8;
  text-align: center;
  transform-origin: center top;
  font-size: clamp(15px, 2.2vw, 26px);
  animation: intro-crawl 32s linear forwards;
}

@keyframes intro-crawl {
  from { top: 100%; transform: scale(1); }
  to { top: 50%; transform: scale(.64) translateY(-100%); }
}

.crawl-line { display: block; }
.crawl-line + .crawl-line { margin-top: 1em; }

@media (prefers-reduced-motion: reduce) {
  .intro-stars { mask-image: none; overflow: auto; inset: 48px 0 65px; }
  .intro-crawl { position: static; margin: 1em auto; width: 85%; animation: none; }
}

.intro-skip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  margin: 0;
  text-align: center;
  color: #cfe3ff;
  font-family: "Press Start 2P", monospace; /* same pixel font as the game */
  font-size: 15px;
  line-height: 1.8;
  animation: blink 1.2s steps(2) infinite;
}

.cover-buttons {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22%;
  display: flex;
  gap: 16px;
  justify-content: center;
}

.cover-buttons button {
  font-family: inherit;
  font-size: 18px;
  padding: 10px 28px;
  background: #ffe477;
  box-shadow: 0 0 0 3px #10182c;
  color: #10182c;
  border: 2px solid #ffffff;
  border-radius: 4px;
  cursor: pointer;
}

.cover-buttons button:hover,
.cover-buttons button:focus-visible {
  filter: brightness(1.15);
}

#new-player {
  margin: 10px 4px 0;
  padding: 10px 16px;
  min-height: 44px;
  background: #ffe477;
  color: #10182c;
  border: 2px solid #fff;
  border-radius: 4px;
  font: 700 13px system-ui, sans-serif;
  cursor: pointer;
}

.cover-music {
  margin-top: 10px;
  padding: 8px 12px;
  color: #fff;
  background: #172744;
  border: 1px solid #8298bc;
  border-radius: 3px;
  font: 10px "Press Start 2P", monospace;
  cursor: pointer;
}

.cover-music[aria-pressed="true"] { color: #ffe46b; border-color: #ffe46b; }

.cover-disclaimer,
.cover-privacy,
.cover-credit {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.cover-disclaimer {
  font-weight: bold;
}

/* One credit at a time: hide the below-screen credit while the cover is open. */
#game:has(> .cover:not([hidden])) .ai-credit {
  display: none;
}

/* PJ-06: keep the music control separate from click-to-begin. */
.intro > .cover-music { position: absolute; top: 12px; right: 12px; z-index: 3; }
.game-loading { padding: 32px; text-align: center; background: #101a33; color: #fff; }
.game-loading:not([hidden]) ~ .level-view { pointer-events: none; }


#cover .cover-music { background: #bcecff; color: #10182c; border-color: white; }
#cover button:focus-visible { outline: 3px solid white; outline-offset: 5px; }
.reveal .result-switch { display: flex; justify-content: center; gap: 6px; margin: 10px 0; }
.result-switch button { border: 1px solid #83a7c2; background: #12243a; color: white; padding: 7px 12px; cursor: pointer; }
.result-switch button[aria-pressed="true"] { background: #bcecff; color: #10182c; }
.reveal .result-page { max-width: 690px; margin: auto; }
.reveal .result-page p { font: 15px/1.4 system-ui, sans-serif; margin-block: 5px; }
.reveal .spread, .reveal .next-step { margin: 8px auto; padding: 8px 12px; }
.reveal .result-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: 8px; }
.reveal .result-actions > * { margin: 0; }
.reveal .spread-list li { grid-template-columns: minmax(0, 1.5fr) 1fr 4em; }
.level-view.finished .reveal { padding: 10px; overflow-x: hidden; text-align: center; }
.reveal .result-level { font-size: clamp(16px, 2.3vw, 26px); line-height: 1.25; margin: 6px 0; }
.reveal .result-level-num { font-size: 12px; line-height: 1.3; margin: 4px 0; }
.reveal .game-status, .reveal .result-lead { font: 14px/1.3 system-ui, sans-serif; margin: 4px auto; max-width: 65ch; }
.reveal .reveal-eyebrow { margin: 2px 0; }
.reveal .result-page .next-step, .reveal .result-page .spread { max-width: none; }
.reveal .result-page .next-step h3 { font: bold 17px/1.3 system-ui, sans-serif; }
.result-sky, .reveal .confetti-layer { position: absolute; inset: 0; overflow: clip; pointer-events: none; }
.reveal .result-actions button { font: 600 14px/1.3 system-ui, sans-serif; padding: 6px 10px; }
@media (min-width: 740px) and (max-height: 750px) {
  .result-page:not([hidden]):is(#focus-page, #rank-page) { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-items: center; }
  #rank-page .spread { grid-column: 2; grid-row: 1 / 3; width: 100%; box-sizing: border-box; }
}
.reveal .next-step-invite { margin: 8px auto 4px; font: 14px/1.4 system-ui, sans-serif; }
.reveal .result-link { display: inline-block; text-decoration: none; margin: 4px auto 10px; }
.reveal .result-switch button, .reveal .tier-picker button, .reveal .result-actions button, .reveal .result-link { font: 10px "Press Start 2P", monospace; text-transform: uppercase; color: #ffe477; background: #14233d; border: 3px solid #8bdcf5; box-shadow: 0 3px 0 #050914, inset 0 0 0 1px #314d72; padding: 9px 12px; cursor: pointer; }
.reveal .result-switch button[aria-pressed="true"], .reveal .tier-picker button[aria-pressed="true"] { color: #10182c; background: #ffe477; border-color: #fff2a6; }
.reveal .tier-picker { display:flex; flex-wrap:wrap; justify-content:center; gap:6px; margin:8px auto; }
.reveal .tier-details { border:2px solid #536b8f; background:#0c1728; padding:8px 12px; margin:6px auto; max-width:62ch; }
.reveal dialog { max-width: min(32rem, 82vw); color: white; background: #101b2d; border: 2px solid #8bdcf5; font: 16px/1.4 system-ui; }
.reveal dialog::backdrop { background: #030817bb; }
.reveal dialog p { font: inherit; }
.reveal dialog button, .reveal .focus-open { font: 10px/1.5 "Press Start 2P", monospace; color: #ffe477; background: #14233d; border: 3px solid #8bdcf5; padding: 6px; cursor: pointer; }
.reveal .result-note { font: 11px/1.2 system-ui; padding: 0; margin: 4px; }
.reveal .tier-picker button { padding: 5px; }
@media (min-width: 740px) {
  .reveal #rank-page:not([hidden]) { display:grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-items:center; }
  #rank-page .spread { grid-column:2; grid-row:1 / 5; }
}
.reveal .spread-fold { position: relative; grid-column: 2; grid-row: 1 / 5; }
.reveal .spread-fold summary { cursor: pointer; color: #ffe477; font: 10px/1.5 "Press Start 2P", monospace; }
@media (max-height: 720px) {
 .reveal .result-switch, .reveal .result-actions { margin: 4px auto; }
 .level-view.finished .reveal { padding: 5px; }
 .reveal .result-level { margin: 2px 0; }
 .reveal .result-link { margin: 2px auto; }
}
@media (max-width: 600px) and (max-height: 720px) {
 .spread-fold[open] .spread { position:absolute; bottom:100%; inset-inline:0; z-index:2; background:#101b2d; }
}
