:root { color-scheme: dark; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-synthesis: none; }
* { box-sizing: border-box; }
html { min-height: 100%; background: #0b0d1b; }
body { margin: 0; color: #f7f6ff; background: radial-gradient(ellipse at 12% 6%, rgba(80,71,177,.22),transparent 44%),radial-gradient(ellipse at 90% 50%, rgba(32,116,149,.10), transparent 55%),#0b0d1b; min-height: 100vh; }
.app { max-width: 1110px; padding: 20px clamp(16px,3vw,42px) 32px; margin: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-emblem { color: #e5d5ff; font-size: 24px; line-height: 1; }
.brand-muted { color: #595975; margin: 0 6px; }
.build-separator { color: #ff8d9c; }
.game-heading { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 17px; }
.game-heading > div:first-child { min-width: 0;  }
.eyebrow { font-size: 10px; letter-spacing: 3.3px; color: #b9acd6; font-weight: 800; margin-bottom: 5px; }
.little-star { color: #d7a2ff; }
h1 { display: flex; align-items: baseline; gap: .12em; white-space: nowrap; margin: 0; font-weight: 1000; letter-spacing: -3.7px; line-height: 1.04; font-size: clamp(38px,7vw,68px); }
.rainbow-text { display: inline-block; padding-right: .085em; background-image: linear-gradient(105deg,#ff647c 5%,#ffb55c 23%,#ffec80 38%,#61e9a4 53%,#5dbdf7 70%,#a88eff 88%); color: transparent; background-clip: text; }
.title-white { color: #f3f2ff; }
.title-dot { color: #d18eff; }
.hud { display: flex; gap: 1px; border: 1px solid #33334a; overflow: hidden; background: #292c43; border-radius: 9px 9px 0 0; }
.stat { min-width: 0; background: #15192d; padding: 13px 16px 12px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stat-label { color: #8286a6; font-size: 10px; font-weight: 900; letter-spacing: 1.5px; white-space: nowrap; }
.stat-number { color: #eeeefe; font-size: 24px; letter-spacing: -.6px; font-weight: 950; font-variant-numeric: tabular-nums; }
.hearts-stat { flex: 1; }.hearts { color: #ff7388; letter-spacing: 2px; white-space: nowrap; }
.score-stat { flex: 1.25; }
.combo-stat { flex: 1; }
.best-score { font-size: 10px; line-height: 1.35; color: #8790af; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.best-score #best { font-size: 12px; margin-left: 6px; color: #b6bdd4; letter-spacing: .5px; }
.stage { background: #11162d; position: relative; overflow: hidden; isolation: isolate; touch-action: none; cursor: crosshair; border: 1px solid #363a59; border-top: 0; box-shadow: 0 18px 65px rgba(0,0,0,.36); }
/* Suppress page text/image selection during fast click-and-hold gameplay.
   Regular controls retain their own click handling and focus styles. */
.stage, .stage * { user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.app.is-playing { user-select: none; -webkit-user-select: none; }
.stage canvas { display: block; width: 100%; height: auto; aspect-ratio: 8/5; }
.stage::after { content:""; pointer-events:none; position: absolute; inset:0; box-shadow: inset 0 0 85px rgba(10,12,32,.28); }
.overlay { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; text-align: center; background: linear-gradient(145deg,rgba(12,14,33,.90),rgba(15,18,37,.77)); z-index: 3; }
.overlay[hidden] { display: none; }
.overlay-content { padding: 16px; pointer-events: none; max-width: 690px; }
.overlay h2 { margin: 0 0 16px; font-size: clamp(32px,5.5vw,68px); letter-spacing: -2.7px; line-height: 1.03; font-weight: 1000; }
.overlay h2 .rainbow-text { background-image: linear-gradient(90deg,#ff7c98,#f9c67d,#84efaf,#7fb9ff,#cd9cff);color: transparent; background-clip: text; }
.overlay p { color: #c4c6de; font-weight: 500; font-size: clamp(12px,1.8vw,17px); line-height: 1.65; margin: 0 0 23px; }
.overlay-hint { background: #27243e; border: 1px solid #62517d; color: #f2efff; border-radius: 7px; display: inline-block; padding: 11px 18px; letter-spacing: .5px; font-size: 12px; }
.overlay-hint[hidden], .final-score[hidden], .record-feedback[hidden], .record-achievements[hidden] { display: none; }
.overlay p[hidden] { display: none; }
.final-score { margin: -1px 0 19px; font-size: clamp(31px, 5.7vw, 68px); font-weight: 1000; letter-spacing: -2.4px; line-height: 1.12; white-space: nowrap; }
#final-score-value { background-image: linear-gradient(90deg,#ff7c98,#f9c67d,#84efaf,#7fb9ff,#cd9cff); color: transparent; background-clip: text; font-variant-numeric: tabular-nums; }
.final-score-unit { color: #f6f2ff; }
.mouse-symbol { color: #e2adff; font-size: 19px; vertical-align: middle; margin-right: 8px; }
.floating-status { position: absolute; inset: auto 0 36px; pointer-events:none; display:flex; justify-content:center; z-index:2; color: #ededff; font-weight: 950; font-size: clamp(18px, 2.3vw, 24px); letter-spacing: 1.2px; text-shadow: 0 2px 14px #101326; }
@media (max-width: 640px) { .floating-status { bottom: 26px; font-size: 17px; } }
.arena-footer { display: flex; justify-content: center; align-items: center; gap: 20px; background: #161a2f; padding: 10px 16px; border: 1px solid #363a59; border-top: 0; }
.rainbow-track { display: flex; gap: 7px; flex: 1; justify-content: center; }
.rainbow-mark { width: clamp(14px,3.1vw,32px); height: 9px; opacity: .3; border-radius: 2px; transition: opacity .12s ease, transform .12s ease; }
.rainbow-mark.active { opacity: 1; transform: scaleY(1.4); }
.combo-meter { height: 4px; background: #242640; overflow:hidden; }
.combo-meter div { width: 0%; height: 100%; background:linear-gradient(90deg,#f67690,#ffcf76,#6de8b2,#61b7ff,#c78aff);transition: width .04s linear; }
@keyframes throb { from { opacity:.72 } to { opacity:1 } }
@media (max-width:640px) { .app {padding:13px 10px 20px;} .topbar{font-size:9px;letter-spacing:1px;padding-bottom:14px;} .build-tag{font-size:9px;padding:7px} .game-heading{margin-bottom:13px;align-items:center} h1{letter-spacing:-1.6px;font-size:clamp(27px,7.4vw,40px)} .eyebrow{font-size:8px;letter-spacing:1.4px} .sound-button{padding:10px 8px;font-size:9px} .stat{padding:10px 5px 8px}.stat-label{font-size:8px;letter-spacing:.4px}.stat-number{font-size:clamp(13px,3.2vw,19px)}.hearts{letter-spacing:0}.overlay h2{font-size:clamp(26px,6.2vw,38px);letter-spacing:-1px;margin-bottom:8px}.overlay p{font-size:10px;margin-bottom:10px}.overlay-hint{padding:8px;font-size:9px}.start-cta{margin-top:13px;font-size:10px}.arena-footer{padding:10px}.rainbow-track{gap:4px} }

/* Results: hero score, four metrics with individual PBs, and overall best score. */
.run-summary[hidden] { display: none; }
.run-summary { width: min(630px, 100%); margin: 7px auto 0; }
.run-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.run-stats > div { min-width: 0; border-right: 1px solid #535073;
  padding: 5px 12px; display: flex; flex-direction: column; gap: 5px; }
.run-stats > div:last-child { border-right: 0; }
.run-stats span { color: #a9a5c8; font-size: 10px; letter-spacing: 1px; font-weight: 900; }
.run-stats strong { color: #f9f4ff; font-size: clamp(16px, 2.4vw, 24px); font-weight: 950; }
.run-stats strong.record-beaten:not(#run-combo)::after { content: ' ★'; font-size: 12px; color: #ffdb83; }
.run-stats .run-stat-pb { margin-top: 1px; color: #aaa4c2; font-size: 9px; font-weight: 800;
  line-height: 1.25; letter-spacing: .5px; white-space: nowrap; }
.run-stats .run-stat-pb span { color: #ddd5ec; font-size: inherit; font-weight: 900; letter-spacing: 0; }
.record-panel { border-top: 1px solid rgba(168, 150, 215, .28); margin-top: 19px; padding-top: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; }
.record-heading { color: #c2a6ed; font-size: 10px; font-weight: 900; letter-spacing: 2px; }
#record-score { color: #f9f4ff; font-size: 29px; line-height: 1.2; letter-spacing: -.5px;
  font-weight: 950; font-variant-numeric: tabular-nums; }
.record-feedback { font-size: 11px; font-weight: 950; color: #ffdf88; letter-spacing: 1px; }
.record-achievements { margin-top: 8px; color: #e8d19f; font-size: 11px;
  font-weight: 850; letter-spacing: .5px; }
.app.is-game-over .hud { opacity: .6; }
.app.is-game-over #floating-status { display: none; }

/* Version is a quiet part of the heading, never its own row. */
.build-tag { color: #82859f; opacity: .72; font-size: 10px; font-weight: 700;
  white-space: nowrap; letter-spacing: .8px; margin-right: 5px; }
@media (max-width: 640px) {
  .build-tag { display: none; }
  .game-heading { margin-bottom: 11px; }
  .overlay h2 { margin-bottom: 8px; }
  .final-score { font-size: clamp(24px, 7vw, 36px); letter-spacing: -.9px; margin-bottom: 10px; }
  .run-stats { gap: 0; }
  .run-stats > div { padding: 4px 3px; }
  .run-stats span { font-size: 8px; letter-spacing: .1px; }
  .run-stats strong { font-size: 13px; }
  .run-stats .run-stat-pb { font-size: 8px; letter-spacing: 0; }
  .record-panel { margin-top: 9px; padding-top: 8px; }
  #record-score { font-size: 21px; }
  .start-cta { margin-top: 12px; padding: 9px 18px; font-size: 11px; }
}

/* Pause is outside the combat input layer; resume never fires a dash. */
.header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; margin-left: auto; }
.pause-toggle:disabled { opacity: .38; cursor: not-allowed; }
.pause-overlay { z-index: 5; background: rgba(10, 13, 31, .82); backdrop-filter: blur(3px); }
.pause-panel { width: min(500px, 92%); padding: 40px 34px 30px;
  background: rgba(19, 24, 49, .95); border: 1px solid #68668b;
  border-radius: 12px; box-shadow: 0 14px 58px rgba(0, 0, 0, .5); }
.pause-panel h2 { font-size: clamp(42px, 7vw, 72px); margin: 0 0 28px; }
.pause-actions { display: flex; flex-direction: column; align-items: center; }
.pause-secondary-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(420px, 100%); gap: 12px; margin-top: 30px; }
.pause-shortcut { margin-top: 20px; font-size: 11px; color: #adb3ce; }
@media (max-width: 640px) {
  .header-actions { gap: 4px; }
  .header-actions .sound-button { font-size: 8px; padding: 9px 7px; }
  .pause-panel { padding: 26px 18px 22px; }
  .pause-panel h2 { margin-bottom: 19px; }
  .pause-secondary-actions { margin-top: 22px; gap: 9px; }
  .pause-shortcut { margin-top: 16px; }
}

/* Neon arcade controls: continuous, crisp borders instead of clipped corners.
   Keep the cabinet-like depth and distinct action colors without a broken outline. */
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta) {
  --arcade-edge: #747ebd;
  --arcade-glow: rgba(119, 136, 245, .5);
  --arcade-top: #273051;
  --arcade-bottom: #151b34;
  position: relative;
  isolation: isolate;
  appearance: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid var(--arcade-edge);
  border-radius: 4px;
  color: #f9f6ff;
  background:
    linear-gradient(165deg, rgba(255,255,255,.14), transparent 44%),
    linear-gradient(180deg, var(--arcade-top), var(--arcade-bottom));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.17),
    inset 0 -3px 0 rgba(0,0,0,.25);
  text-shadow: 0 1px 7px rgba(0,0,0,.55);
  font-weight: 950;
  letter-spacing: 1.2px;
  white-space: nowrap;
  transition: transform .13s ease, filter .18s ease, box-shadow .18s ease;
}
/* The subtle animated sheen appears only on hover; no extra rim at rest. */
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta)::after {
  content: '';
  position: absolute;
  pointer-events: none;
  inset: -30% auto -30% -40%;
  width: 38%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.23), transparent);
  transform: skewX(-24deg) translateX(-110%);
  opacity: 0;
  transition: transform .44s ease, opacity .22s ease;
}
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.15) drop-shadow(0 0 8px var(--arcade-glow));
}
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):not(:disabled):hover::after {
  opacity: 1;
  transform: skewX(-24deg) translateX(410%);
}
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):not(:disabled):active {
  transform: translateY(1px) scale(.995);
  filter: brightness(.91);
  box-shadow: inset 0 4px 8px rgba(0,0,0,.38);
}
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px; /* Clear, continuous keyboard focus outside the panel. */
  filter: brightness(1.17) drop-shadow(0 0 10px var(--arcade-glow));
}
:is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):disabled {
  cursor: not-allowed;
  opacity: .4;
  filter: saturate(.45);
}
/* Compact console switches in the heading. */
.sound-button {
  min-height: 41px;
  padding: 10px 16px;
  font-size: 11px;
  --arcade-edge: #586a9f;
  --arcade-glow: rgba(121, 148, 255, .36);
  --arcade-top: #222b49;
  --arcade-bottom: #141b33;
}
.header-actions .sound-button { gap: 7px; }
.header-button-icon {
  display: inline-block; flex: none; font-size: 20px;
  line-height: 1; letter-spacing: 0; text-shadow: 0 1px 8px rgba(255,255,255,.16);
}
.sound-icon { font-size: 22px; }
#sound-toggle {
  --arcade-edge: #9384d2;
  --arcade-glow: rgba(184, 143, 255, .45);
  --arcade-top: #2c244e;
  --arcade-bottom: #191931;
}

/* Compact audio settings popover: only the trigger occupies header space. */
.audio-controls { position: relative; flex-shrink: 0; }
.audio-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 9px);
  right: 0;
  width: min(300px, calc(100vw - 24px));
  padding: 14px;
  display: grid;
  gap: 16px;
  background: #161a31;
  border: 1px solid #817bb5;
  border-radius: 9px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, .57);
}
.audio-menu[hidden] { display: none; }
.audio-menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audio-menu-heading > span { color: #c9c9e9; font-size: 11px; font-weight: 900; letter-spacing: 1px; }
.audio-mute {
  border: 1px solid #8272b3;
  background: #272442;
  color: #f5efff;
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: .4px;
  font-weight: 800;
  cursor: pointer;
  min-height: 31px;
  padding: 5px 9px;
}
.audio-mute:hover { background: #373056; }
.audio-mute:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.audio-menu.is-muted .volume-control { opacity: .65; }
.volume-control {
  display: grid;
  grid-template-columns: 49px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .6px;
  color: #c0c2df;
}
.volume-control input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
  accent-color: #b49aff;
  cursor: pointer;
  touch-action: auto;
}
.volume-control input[type="range"]:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.volume-control output {
  color: #f1eaff;
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 470px) {
  .header-actions { gap: 6px; }
  .audio-menu { padding: 12px; gap: 14px; }
}

/* Prominent centered RESUME above a separate row of equal secondary actions. */
.pause-resume {
  width: min(360px, 100%); min-height: 72px;
  padding: 17px 28px; font-size: 17px;
  --arcade-edge: #79f6cc;
  --arcade-glow: rgba(92, 253, 192, .48);
  --arcade-top: #256357;
  --arcade-bottom: #123c3c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.19),
    inset 0 -3px 0 rgba(0,0,0,.25), 0 8px 24px rgba(31,143,120,.22);
}
.pause-secondary-actions button { width: 100%; min-width: 0; min-height: 49px;
  padding: 12px 14px; font-size: 11px; }
.pause-restart {
  --arcade-edge: #ae9cf6;
  --arcade-glow: rgba(172, 143, 255, .44);
  --arcade-top: #363460;
  --arcade-bottom: #1c213e;
}
.pause-main-menu {
  --arcade-edge: #8e9abe;
  --arcade-glow: rgba(151, 168, 211, .35);
  --arcade-top: #303a59;
  --arcade-bottom: #1c233c;
}
/* Start/Play Again gets the most expressive panel treatment. */
.start-cta { pointer-events: auto; min-height: 53px; padding: 15px 36px;
  margin-top: 25px; font-size: 13px; letter-spacing: 1.7px;
  --arcade-edge: #e5a6ff;
  --arcade-glow: rgba(223, 135, 255, .58);
  --arcade-top: #523269;
  --arcade-bottom: #282047;
}
@media (max-width: 640px) {
  .start-cta { margin-top: 12px; padding: 10px 22px; min-height: 45px; font-size: 11px; }
  .pause-resume { min-height: 60px; padding: 13px 18px; font-size: 15px; }
  .pause-secondary-actions button { min-height: 44px; padding: 10px 8px; font-size: 10px; }
  .header-actions .sound-button { min-height: 36px; padding: 8px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  :is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta),
  :is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta)::after {
    transition: none;
  }
  :is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):not(:disabled):hover,
  :is(.sound-button, .pause-resume, .pause-restart, .pause-main-menu, .start-cta):not(:disabled):active {
    transform: none;
  }
}

/* Damage should be unmistakable without shaking or interrupting gameplay. */
.hearts { display: inline-block; }
@media (max-width: 640px) { .best-score { font-size: 8px; letter-spacing: 0; } .best-score #best { font-size: 10px; margin-left: 3px; } }
.hearts-stat.is-damaged { background: #67243d; box-shadow: inset 0 0 0 1px #ff6984; }
.hearts-stat.is-damaged .stat-label { color: #ffd3dc; }
.hearts-stat.is-damaged .hearts { color: #fff; text-shadow: 0 0 13px #ff4c70, 0 0 22px #ff4c70; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Unobtrusive indication of non-record testing assists. */
.test-status { display: inline-block; color: #ffe0a4; border: 1px solid rgba(255,218,128,.42); border-radius: 5px; padding: 5px 8px; font-size: 10px; font-weight: 800; letter-spacing: .5px; white-space: nowrap; }
.test-status[hidden] { display: none; }

.pause-version { display: none; margin-top: 13px; font-size: 9px; letter-spacing: 1px; color: #8f93b1; }
@media (max-width: 640px) { .pause-version { display: block; } }


/* Title menu: give the single primary START action visual priority, and
   keep the high score and optional learning surfaces lower in the hierarchy. */
.overlay.is-menu .overlay-content { width: 100%; max-width: 690px; padding: 22px 26px; }
.overlay.is-menu h2 {
  margin: 0 0 12px; font-size: clamp(32px, 5vw, 54px);
  letter-spacing: -1.8px; white-space: nowrap;
}
.overlay.is-menu p {
  max-width: 560px; margin: 0 auto 0;
  font-size: clamp(12px, 1.8vw, 15px); line-height: 1.5;
}
.overlay.is-menu .start-cta {
  width: min(320px, 100%);
  min-width: 0; min-height: 64px;
  margin-top: 22px; padding: 16px 28px;
  font-size: 16px; letter-spacing: 1.6px;
  --arcade-edge: #d3a6f0;
  --arcade-glow: rgba(183, 116, 247, .4);
  --arcade-top: #714890;
  --arcade-bottom: #41265c;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.19),
    inset 0 -3px 0 rgba(0,0,0,.24),
    0 7px 23px rgba(92,48,142,.24);
}
.overlay.is-menu .start-cta::before {
  content: "▶"; font-size: 14px; letter-spacing: 0;
  margin-right: 12px; color: #f2cfff;
}
.menu-best {
  display: flex; justify-content: center; align-items: baseline;
  gap: 9px; margin-top: 17px; font-variant-numeric: tabular-nums;
}
.menu-best[hidden] { display: none; }
.menu-best-label {
  color: #9fa5bf; font-size: 10px;
  font-weight: 850; letter-spacing: 1.3px;
}
.menu-best strong { color: #dfe1f4; font-size: 21px; line-height: 1; font-weight: 900; }
.pc-control-picker {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
  gap: 11px; margin: 13px auto 0; pointer-events: auto;
}
.pc-control-label {
  color: #b5b0d1; font-size: 10px; font-weight: 900; letter-spacing: 1.1px;
}
.pc-control-options {
  display: flex; gap: 3px; min-width: 0; max-width: 100%; padding: 3px; border-radius: 7px;
  border: 1px solid rgba(154, 150, 196, .32); background: rgba(21, 23, 46, .82);
}
.pc-control-option {
  flex: 1 1 auto; min-width: 0; min-height: 32px; padding: 7px 10px;
  border: 1px solid transparent; border-radius: 5px; background: transparent;
  color: #b6bbd6; font: inherit; font-size: 10px; font-weight: 900;
  letter-spacing: .35px; cursor: pointer;
}
.pc-control-option[aria-pressed="true"] {
  border-color: #a68ada; background: #40305c; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.pc-control-option:hover { color: #fff; background: #37314e; }
.pc-control-option:focus-visible { outline: 2px solid #e6c9ff; outline-offset: 2px; }
.overlay:not(.is-menu) .pc-control-picker { display: none; }
.overlay.is-menu .overlay-hint {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px; width: min(610px, 100%);
  margin: 18px auto 0; padding: 15px 0 0;
  border: 0; border-top: 1px solid rgba(148, 139, 192, .28);
  background: none; border-radius: 0; letter-spacing: 0;
}
.overlay.is-menu .overlay-hint[hidden] { display: none; }
.control-heading {
  grid-column: 1 / -1; margin-bottom: 4px; text-align: center;
  color: #c9cce3; font-size: 13px; font-weight: 900; letter-spacing: 1.4px;
}
/* How-to-play is read-only guidance, not a row of fake action buttons.
   A flat, borderless instruction strip separates it from real controls. */
.control-step {
  display: grid; grid-template-columns: 38px minmax(0, 1fr);
  align-items: center; min-width: 0; gap: 9px;
  padding: 7px 12px; text-align: left; background: none;
  border: 0; border-radius: 0; cursor: default;
}
.control-step + .control-step {
  border-left: 1px solid rgba(154, 150, 196, .26);
}
.control-step--dash { --control-color: #ff93a7; }
.control-step--move { --control-color: #85d6ff; }
.control-step--recharge { --control-color: #8df0be; }
.control-icon {
  display: grid; place-items: center; flex: 0 0 38px;
  width: 38px; height: 38px; border-radius: 0;
  color: var(--control-color); background: none;
}
.control-icon svg { display: block; width: 24px; height: 24px; }
.control-copy { display: block; min-width: 0; }
.overlay.is-menu .control-copy strong {
  display: block; color: #f8f7ff; font-size: 12px;
  line-height: 1.2; font-weight: 900; letter-spacing: .65px;
}
.control-copy > span {
  display: block; margin-top: 4px; color: #c0c8e0;
  font-size: 12px; line-height: 1.35;
}
/* Reserve identical copy height for every PC scheme, including the longer
   WASD + mouse aim hint, so switching modes never shifts the menu below it. */
.control-copy > .desktop-control { min-height: 4.05em; }
.control-copy > .touch-control { display: none; }
@media (pointer: coarse) {
  .control-copy > .desktop-control { display: none; }
  .control-copy > .touch-control { display: block; }
  .pc-control-picker { display: none; }
}
@media (max-width: 640px) {
  .overlay.is-menu .overlay-content { padding: 14px; }
  .overlay.is-menu h2 { font-size: clamp(28px, 6vw, 38px); letter-spacing: -1.1px; margin-bottom: 10px; }
  .overlay.is-menu p { font-size: 12px; line-height: 1.45; }
  .overlay.is-menu .start-cta {
    width: min(300px, 100%); min-height: 56px;
    margin-top: 17px; padding: 13px 22px; font-size: 14px;
  }
  .menu-best { margin-top: 14px; }
  .menu-best strong { font-size: 19px; }
  .pc-control-picker { gap: 7px; margin-top: 10px; }
  .pc-control-option { padding: 6px 7px; font-size: 9px; }
  .overlay.is-menu .overlay-hint { gap: 7px; margin-top: 15px; padding-top: 12px; }
  .control-heading { font-size: 12px; }
  .control-step { display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 7px 5px; gap: 5px; }
  .control-icon { width: 30px; height: 30px; flex-basis: 30px; }
  .control-icon svg { width: 21px; height: 21px; }
  .overlay.is-menu .control-copy strong { font-size: 11px; }
  .control-copy > span { font-size: 11px; }
}
@media (max-width: 480px) {
  .overlay.is-menu .overlay-content { padding: 14px 12px; }
  .overlay.is-menu h2 { font-size: clamp(24px, 6.8vw, 31px); letter-spacing: -.8px; }
  .overlay.is-menu p { font-size: 12px; }
  .pc-control-picker { flex-direction: column; }
  .pc-control-options { width: min(350px, 100%); }
  .pc-control-option { min-width: 0; padding: 7px 4px; font-size: 9px; }
  .overlay.is-menu .overlay-hint { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .control-step { display: flex; flex-direction: row; justify-content: flex-start; text-align: left; padding: 9px 5px; }
  .control-step + .control-step { border-left: 0; border-top: 1px solid rgba(154, 150, 196, .26); }
  .control-icon { flex-basis: 32px; width: 32px; height: 32px; }
  .control-copy > span { font-size: 12px; }
  /* Single-column instructions have room for longer text on fewer lines. */
  .control-copy > .desktop-control { min-height: 2.7em; }
  .control-heading { grid-column: 1; }
}

/* Handheld landscape: prioritize a complete, undistorted 8:5 arena above
   decorative chrome. The browser toolbars may shrink/grow while playing;
   dynamic viewport units keep the arena inside the usable height. */
.fullscreen-toggle[hidden] { display: none; }
.fullscreen-toggle .fullscreen-icon { display: block; width: 20px; height: 20px; flex: none; pointer-events: none; }
.fullscreen-toggle .fullscreen-label { font-size: 11px; line-height: 1; }
.fullscreen-toggle[aria-pressed="false"] .fullscreen-icon--exit,
.fullscreen-toggle[aria-pressed="true"] .fullscreen-icon--enter { display: none; }
@media (max-width: 860px), (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .fullscreen-toggle .fullscreen-label { display: none; }
}
.app:fullscreen {
  overflow: auto;
  max-width: none;
  width: 100%;
  height: 100%;
  background: #0b0d1b;
}
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .app {
    --phone-arena-width: min(100%, calc((100dvh - 120px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 1.6));
    max-width: none;
    padding:
      max(3px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(3px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }
  .game-heading { min-height: 32px; margin-bottom: 4px; gap: 4px; flex-wrap: nowrap; align-items: center; }
  .game-heading h1 { font-size: clamp(16px, 4.8dvh, 25px); letter-spacing: -.8px; }
  .header-actions { gap: 5px; }
  .header-actions .sound-button { min-height: 32px; padding: 6px 10px; font-size: 10px; }
  .build-tag { display: none; }
  .hud, .stage, .arena-footer, .combo-meter {
    width: var(--phone-arena-width);
    max-width: 100%;
    margin-inline: auto;
  }
  .hud { border-radius: 5px 5px 0 0; }
  .stat { padding: 3px 8px 2px; flex-direction: row; align-items: center; gap: 7px; }
  .stat-label { font-size: 9px; letter-spacing: .3px; }
  .stat-number { font-size: clamp(13px, 4dvh, 18px); }
  .best-score { margin-left: auto; font-size: 8px; letter-spacing: 0; }
  .best-score #best { font-size: 9px; margin-left: 2px; }
  .arena-footer { padding: 3px 6px; }
  .rainbow-track { gap: 3px; }
  .rainbow-mark { height: 5px; width: clamp(11px, 2.5vw, 23px); }
  .combo-meter { height: 3px; }
  .floating-status { bottom: 12px; font-size: 13px; }
  /* Scroll just the menu/results overlay if the short landscape view
     cannot fit every score. Never clip PLAY AGAIN or the pause controls. */
  /* touch-action is intersected with ancestors. Relax the stage only while a
     menu is visible; live canvas input keeps touch-action: none. */
  .stage:has(> .overlay:not([hidden])) { touch-action: pan-y; }
  .overlay { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; align-items: safe center; }
  .overlay-content { max-width: 100%; padding: 4px; }
  .overlay.is-menu .overlay-content { padding: 10px; }
  .overlay.is-menu h2 { font-size: clamp(23px, 5.5dvh, 30px); letter-spacing: -.8px; margin-bottom: 8px; }
  .overlay.is-menu p { font-size: 11px; line-height: 1.35; }
  .overlay.is-menu .overlay-hint { gap: 8px; margin-top: 10px; padding-top: 11px; }
  .overlay.is-menu .menu-best { gap: 6px; margin-top: 10px; }
  .overlay.is-menu .menu-best strong { font-size: 17px; }
  .overlay.is-menu .start-cta {
    width: min(280px, 100%); min-height: 48px;
    margin-top: 11px; padding: 10px 16px; font-size: 13px;
  }
  .overlay h2 { font-size: clamp(18px, 6dvh, 26px); margin-bottom: 4px; }
  .final-score { font-size: clamp(19px, 6dvh, 28px); margin-bottom: 4px; }
  .run-summary { margin: 1px auto 0; }
  .run-stats > div { padding: 2px 4px; gap: 2px; }
  .run-stats span, .run-stats .run-stat-pb { font-size: 7px; }
  .run-stats strong { font-size: 12px; }
  .record-panel { margin-top: 3px; padding-top: 3px; gap: 0; }
  .record-heading, .record-feedback { font-size: 8px; }
  #record-score { font-size: 17px; }
  .overlay .start-cta { min-height: 35px; margin-top: 5px; padding: 6px 14px; }
  .pause-panel { max-height: 100%; overflow-y: auto; padding: 12px 14px; width: min(400px, 96%); }
  .pause-panel h2 { font-size: 27px; margin-bottom: 10px; }
  .pause-resume { width: min(300px, 100%); min-height: 45px; padding: 8px 16px; font-size: 12px; }
  .pause-secondary-actions { width: min(340px, 100%); margin-top: 14px; gap: 8px; }
  .pause-secondary-actions button { min-height: 36px; padding: 7px 8px; font-size: 10px; }
  .pause-shortcut, .pause-version { display: none; }
  .audio-menu { max-height: calc(100dvh - 48px); overflow-y: auto; gap: 9px; padding: 9px; }
}
/* Touch targets must remain usable even when the phone is very short. */
@media (pointer: coarse) {
  .fullscreen-toggle, .pause-toggle, #sound-toggle { min-width: 42px; }
}

/* Prevent vertical gesture scrolling from interfering with normal active play
   outside the short-landscape layout, without blocking result screen gestures. */
@media (pointer: coarse) {
  .stage:has(> .overlay:not([hidden])) { touch-action: pan-y; }
  .stage .overlay:not([hidden]) { touch-action: pan-y; }
}

/* On short landscape phones, scroll the menu rather than shrink instructions
   below legible sizes; keep a large enough touch target to start quickly. */
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .overlay.is-menu .overlay-hint { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .control-step { display: flex; flex-direction: row; text-align: left; padding: 8px; gap: 6px; }
  .control-icon { width: 26px; height: 26px; flex: 0 0 26px; }
  .control-icon svg { width: 19px; height: 19px; }
  .overlay.is-menu .control-copy strong { font-size: 10px; line-height: 1.2; letter-spacing: .1px; }
  .control-copy > span { font-size: 10px; line-height: 1.3; margin-top: 2px; }
  .control-heading { font-size: 11px; }
}

/* Both optional guides are secondary to START GAME. The score explanation
   lives on its own small screen instead of expanding the title-menu layout. */
/* Keep enemy shapes visible near the arena edges, but protect the title,
   record and instructions with a calm, high-contrast center scrim. */
.overlay.is-menu {
  background: radial-gradient(ellipse 66% 80% at 50% 50%,
    rgba(12,14,33,.99) 0%, rgba(12,14,33,.97) 57%, rgba(12,14,33,.78) 100%);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; align-items: safe center;
 }
.menu-secondary-actions {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  width: min(420px, 100%); margin: 17px auto 0;
}
.overlay:not(.is-menu) .menu-secondary-actions { display: flex; }
/* Only the game-over screen offers MAIN MENU; guides remain on the title menu. */
.overlay.is-menu .results-main-menu { display: none; }
.overlay:not(.is-menu) .scoring-open { display: none; }
.menu-info-button {
  pointer-events: auto; flex: 1 1 155px; max-width: 190px; min-height: 46px;
  padding: 11px 14px; border: 1px solid rgba(180,172,218,.58);
  border-radius: 7px; background: rgba(26,30,57,.72);
  color: #d9d5f3; font: inherit; font-size: 12px;
  font-weight: 900; letter-spacing: 1.1px; cursor: pointer;
  transition: border-color .16s, background-color .16s, color .16s;
}
.menu-info-button:hover, .menu-info-button:focus-visible {
  border-color: #d6b3f7; background: #353052; color: #fff;
}
.menu-info-button:focus-visible { outline: 2px solid #d6b3f7; outline-offset: 3px; }

/* A compact modal with its own Back action; it never interrupts live runs. */
body.scoring-active { overflow: hidden; }
.scoring-view {
  position: fixed; inset: 0; z-index: 65; display: grid; place-items: safe center;
  min-height: 100vh; min-height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
  touch-action: pan-y; padding: max(18px,env(safe-area-inset-top))
    max(14px,env(safe-area-inset-right))
    max(18px,env(safe-area-inset-bottom))
    max(14px,env(safe-area-inset-left));
  background: rgba(8,11,26,.94); color: #f6f3ff;
}
.scoring-view[hidden] { display: none; }
.scoring-panel {
  width: min(700px, 100%); max-height: 100%; overflow-y: auto;
  border: 1px solid #63557e; border-radius: 16px;
  padding: clamp(18px,3vw,29px);
  background: linear-gradient(150deg,#25213d,#151c32);
  box-shadow: 0 20px 70px rgba(0,0,0,.46); text-align: left;
}
.scoring-back {
  min-height: 40px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid #8771ad; color: #f0e2ff; background: #2b2546;
  cursor: pointer; font: inherit; font-size: 11px;
  font-weight: 900; letter-spacing: .6px;
}
.scoring-back:hover { background: #403557; color: #fff; }
.scoring-back:focus-visible { outline: 2px solid #f1d1ff; outline-offset: 3px; }
.scoring-panel h2 {
  margin: 8px 0 10px; font-size: clamp(32px,5vw,45px); line-height: 1;
  font-weight: 950; letter-spacing: -1px; color: #edd3ff;
}
.scoring-panel p { margin: 0 0 14px; font-size: 14px; line-height: 1.6; color: #dce0f1; }
.scoring-panel p strong { color: #fff; }
/* Scoring examples are reference material, never action cards. */
.scoring-example {
  display: grid; gap: 10px; margin-top: 0; padding: 16px 0;
  border: 0; border-radius: 0; background: none;
}
.scoring-example-label { font-size: 11px; font-weight: 900; letter-spacing: .85px; color: #c6a5ea; }
.scoring-equation { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(76px, .25fr) auto auto;
  align-items: center; gap: 10px; min-width: 0; font-variant-numeric: tabular-nums; }
.scoring-term { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.scoring-term-label { font-size: 10px; line-height: 1.4; letter-spacing: .65px;
  color: #c5badc; font-weight: 900; }
.scoring-term strong { display: block; font-size: clamp(17px, 2.4vw, 23px);
  line-height: 1.4; color: #ffe59b; overflow-wrap: anywhere; }
.scoring-operator { font-size: 23px; font-weight: 900; color: #c9b2ef; }
.scoring-total { display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 92px; padding: 6px 8px; border: 0;
  border-radius: 0; background: none; }
.scoring-total strong { color: #ffe29c; font-size: clamp(28px, 4vw, 35px); line-height: 1.1;
  font-weight: 950; font-variant-numeric: tabular-nums; }
.scoring-total > span { color: #e9d2a3; font-size: 11px; font-weight: 900; letter-spacing: 1px; }
.scoring-example-description { color: #d8d9ec; font-size: 14px; line-height: 1.6; }
/* Results should fit inside the usual 8:5 arena without a scrollbar. On very
   short screens, retain touch/keyboard scrolling so nothing is clipped, but
   keep the scrollbar track from distracting from the score and actions. */
.app.is-game-over .overlay {
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  align-items: safe center; scrollbar-width: none; -ms-overflow-style: none;
}
.app.is-game-over .overlay::-webkit-scrollbar { display: none; }
.app.is-game-over .menu-secondary-actions { margin-top: 12px; }
.app.is-game-over .menu-info-button { flex: 0 1 170px; min-height: 40px; padding: 8px 12px; }
/* Mirror the title screen's flat How to Play strip: no card outlines/fills. */
.scoring-factors { display: grid; grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 0; margin: 20px 0 14px; }
.scoring-factor { display: flex; flex-direction: column; gap: 7px; min-width: 0; padding: 10px 14px;
  border: 0; border-radius: 0; background: none; cursor: default; }
.scoring-factor + .scoring-factor { border-left: 1px solid rgba(154, 150, 196, .26); }
.scoring-factor-number { color: #bb9cec; font-size: 10px; font-weight: 900; letter-spacing: 1px; }
.scoring-factor > strong { color: #fff; font-size: 14px; font-weight: 950; letter-spacing: 1px; }
.scoring-factor > span:last-child { color: #d4d3eb; font-size: 13px; line-height: 1.5; }
.scoring-section { margin-top: 25px; }
.scoring-section h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  margin: 0 0 12px; color: #f5ecff; font-size: 15px; letter-spacing: 1px; }
.scoring-section h3 span { color: #b5a8d6; font-size: 10px; font-weight: 800; letter-spacing: .5px; }
.scoring-colors { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0; list-style: none; margin: 0; padding: 0; }
.scoring-colors li { display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: 0; padding: 10px 3px; border: 0;
  border-radius: 0; background: none; cursor: default; }
.scoring-colors li + li { border-left: 1px solid rgba(154, 150, 196, .20); }
.scoring-colors li span { color: var(--tier-color); font-size: 10px; font-weight: 900; letter-spacing: .25px; }
.scoring-colors li strong { color: #fff; font-size: 22px; font-variant-numeric: tabular-nums; }
.scoring-panel .scoring-detail { margin: 10px 0 0; color: #cbd1e9; font-size: 14px; }
.scoring-examples { display: grid; gap: 0; }
.scoring-examples .scoring-example { margin: 0; padding: 16px 0; gap: 8px; }
.scoring-examples .scoring-example + .scoring-example {
  border-top: 1px solid rgba(154, 150, 196, .26);
}
.scoring-examples .scoring-equation { margin: 5px 0 2px; }
@media (max-width: 540px) {
    .scoring-factors { grid-template-columns: 1fr; gap: 0; margin-top: 14px; }
  .scoring-factor { display: grid; grid-template-columns: 27px 92px 1fr; align-items: center;
    gap: 7px; padding: 10px 5px; }
  .scoring-factor + .scoring-factor { border-left: 0; border-top: 1px solid rgba(154, 150, 196, .26); }
  .scoring-factor > strong { font-size: 12px; }
  .scoring-factor > span:last-child { font-size: 12px; }
  .scoring-colors { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .scoring-colors li { padding: 8px 2px; }
  .scoring-colors li:nth-child(4n + 1) { border-left: 0; }
  .scoring-section { margin-top: 20px; }
  .scoring-equation { grid-template-columns: minmax(0, 1fr) auto minmax(58px, .25fr);
    align-items: center; column-gap: 8px; row-gap: 10px; }
  .scoring-operator--equals { display: none; }
  .scoring-total { grid-column: 1 / -1; flex-direction: row; gap: 9px;
    justify-content: center; min-width: 0; padding: 8px 12px; }
  .scoring-term strong { font-size: 18px; }
  .scoring-total strong { font-size: 30px; }
}
@media (max-width: 480px) {
  .menu-secondary-actions { gap: 8px; margin-top: 12px; }
  .menu-info-button { flex-basis: 118px; min-height: 44px; font-size: 11px; padding: 9px 7px; }
  .scoring-panel h2 { margin-top: 16px; }
  .scoring-panel p { font-size: 13px; }
}
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .menu-secondary-actions { gap: 8px; margin-top: 12px; }
  .menu-info-button { min-height: 44px; padding: 9px 12px; font-size: 11px; }
  .scoring-view { align-items: safe start; padding: 10px max(16px,env(safe-area-inset-right)) 10px max(16px,env(safe-area-inset-left)); }
  .scoring-panel { width: min(560px, 100%); padding: 14px; }
  .scoring-panel h2 { margin: 12px 0; font-size: 28px; }
  .scoring-panel p { margin-bottom: 8px; font-size: 12px; }
  .scoring-example { margin-top: 12px; padding: 11px; }
}

/* Title-menu field guide. Keep START GAME visually dominant and let players
   inspect every threat without pausing a live run or loading external assets. */
.overlay-content[hidden], .bestiary-view[hidden] { display: none; }
.bestiary-back:focus-visible { outline: 2px solid #d6b3f7; outline-offset: 3px; }
.overlay:not(.is-menu) .bestiary-open { display: none; }

/* Standalone field-guide screen, intentionally outside the arena's clipped
   8:5 stage. Nothing here changes the size or controls of live gameplay. */
body.bestiary-active { overflow: hidden; }
.bestiary-view {
  position: fixed; inset: 0; z-index: 60;
  width: 100%; height: 100vh; height: 100dvh;
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  color: #f7f5ff; text-align: left;
  background:
    radial-gradient(ellipse at 7% 8%, rgba(107,69,177,.19), transparent 35%),
    radial-gradient(ellipse at 96% 25%, rgba(45,103,158,.14), transparent 40%),
    #0c1124;
  scrollbar-color: #73699e #141a30;
}
.bestiary-header {
  position: sticky; top: 0; z-index: 4;
  background: rgba(17,22,42,.97); border-bottom: 1px solid #3e405f;
  box-shadow: 0 8px 28px rgba(4,6,20,.32);
  backdrop-filter: blur(12px);
}
.bestiary-header-inner {
  max-width: 1440px; margin: 0 auto; padding: 16px clamp(16px,3vw,42px) 15px;
  display: grid; grid-template-columns: auto minmax(0,1fr);
  grid-template-areas: "back title" "jump jump";
  align-items: center; gap: 12px 25px;
}
.bestiary-header-inner > div { grid-area: title; min-width: 0; }
.bestiary-back {
  grid-area: back; flex-shrink: 0; padding: 12px 16px; font: inherit;
  font-size: 11px; font-weight: 900; letter-spacing: .6px;
  cursor: pointer; color: #f0e2ff; background: #2b2546;
  border: 1px solid #8771ad; border-radius: 8px; min-height: 44px;
}
.bestiary-back:hover { background: #403557; color: #fff; }
.bestiary-header h2 {
  margin: 0; color: #f5f4ff; font-size: clamp(29px,3.9vw,48px);
  font-weight: 950; line-height: 1.04; letter-spacing: -1.3px;
}
.bestiary-header h2 span { color: #c98cfa; }
.bestiary-jump {
  grid-area: jump; display: flex; flex-wrap: wrap; gap: 7px;
  align-items: center; min-width: 0;
}
.bestiary-jump-button {
  color: var(--entry-color); background: color-mix(in srgb,var(--entry-color) 9%,#171c32);
  border: 1px solid color-mix(in srgb,var(--entry-color) 44%,#33364f);
  border-radius: 6px; cursor: pointer; padding: 8px 14px;
  min-height: 35px; font: inherit; font-size: 10px; font-weight: 900;
  letter-spacing: .8px;
}
.bestiary-jump-button:hover {
  background: color-mix(in srgb,var(--entry-color) 19%,#171c32);
  border-color: var(--entry-color);
}
.bestiary-jump-button[aria-current="location"] {
  background: color-mix(in srgb,var(--entry-color) 27%,#171c32);
  border-color: var(--entry-color);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--entry-color), 0 0 15px color-mix(in srgb,var(--entry-color) 18%,transparent);
}
.bestiary-back:focus-visible,.bestiary-jump-button:focus-visible,
.bestiary-replay:focus-visible,.bestiary-open:focus-visible {
  outline: 2px solid #f1d1ff; outline-offset: 3px;
}
.bestiary-body {
  max-width: 1440px; margin: 0 auto;
  padding: 29px clamp(16px,3vw,42px) max(60px,env(safe-area-inset-bottom));
}
.bestiary-section-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
}
.bestiary-section-heading h3 {
  margin: 0; color: #f2e8ff;
  font-size: 15px; font-weight: 950; letter-spacing: 1.6px;
}
.bestiary-section-heading > span {
  color: #aaa1c6; font-size: 10px; font-weight: 850; letter-spacing: 1.2px;
}
.bestiary-list { display: flex; flex-direction: column; gap: 22px; margin-bottom: 26px; }
.bestiary-entry {
  scroll-margin-top: 170px;
  display: grid; grid-template-columns: minmax(260px,.82fr) minmax(0,1.6fr);
  grid-template-areas: "info scene"; align-items: center; gap: clamp(18px,3vw,50px);
  min-width: 0; min-height: 285px;
  padding: clamp(16px,2vw,28px);
  border: 1px solid color-mix(in srgb,var(--entry-color) 28%,#313b57);
  border-left: 5px solid var(--entry-color); border-radius: 14px;
  background:
    linear-gradient(110deg,color-mix(in srgb,var(--entry-color) 13%,#1b213b) 0%,#161d33 70%);
  box-shadow: 0 15px 35px rgba(3,7,22,.22);
}
.bestiary-entry-copy { grid-area: info; min-width: 0; align-self: center; }
.bestiary-entry-heading {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 18px; margin-bottom: 18px;
}
.bestiary-entry h4 {
  margin: 0; color: var(--entry-color);
  font-size: clamp(27px,3vw,41px); font-weight: 950;
  letter-spacing: -.5px; line-height: 1.05;
}
.bestiary-entry h4 .bestiary-color {
  display: block; margin: 0 0 10px;
  font-size: 12px; color: #d7d9ea; font-weight: 850;
  letter-spacing: 1.8px;
}
.bestiary-entry small {
  color: color-mix(in srgb,var(--entry-color) 52%,#9da5c0);
  font-size: 14px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.bestiary-entry p { margin: 0; max-width: 40ch;
  color: #e0e5f4; font-size: clamp(14px,1.45vw,17px); line-height: 1.65; }
.bestiary-scene {
  grid-area: scene; min-width: 0; position: relative; align-self: stretch;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid color-mix(in srgb,var(--entry-color) 36%,#384361);
  border-radius: 10px; overflow: hidden; background: #11182e;
}
.bestiary-preview {
  display: block; width: 100%; height: auto; aspect-ratio: 24 / 11;
  object-fit: contain; pointer-events: none;
}
.bestiary-scene-status {
  position: absolute; bottom: 0; left: 0; right: 0; min-height: 43px;
  display: flex; gap: 9px; align-items: center; padding: 9px 14px;
  color: #f4f6ff; font-size: 10px; font-weight: 900; letter-spacing: 1.2px;
  background: linear-gradient(0deg,rgba(8,12,27,.94),rgba(8,12,27,.60) 78%,transparent);
  pointer-events: none;
}
.bestiary-replay {
  pointer-events: auto; flex-shrink: 0; padding: 7px 10px;
  margin-left: 5px; min-height: 34px; border-radius: 6px;
  border: 1px solid color-mix(in srgb,var(--entry-color) 50%,#78809d);
  background: #242b46; color: #f4f1ff;
  font: inherit; font-size: 10px; font-weight: 850; letter-spacing: .7px;
  cursor: pointer;
}
.bestiary-replay:hover {
  background: color-mix(in srgb,var(--entry-color) 24%,#242b46);
}
.bestiary-scene-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px;
  background: var(--entry-color); box-shadow: 0 0 8px var(--entry-color);
}
.bestiary-loop-mark {
  color: #9aabc9; font-size: 9px; font-weight: 800; margin-left: auto;
}
@media (max-width: 850px) {
  .bestiary-list { gap: 14px; }
  .bestiary-entry {
    min-height: 0; grid-template-columns: minmax(0,1fr);
    grid-template-areas: "info" "scene";
    gap: 18px;
  }
  .bestiary-entry-heading { margin-bottom: 8px; }
  .bestiary-entry h4 { font-size: clamp(28px,5vw,37px); }
  .bestiary-entry p { max-width: none; }
}
@media (max-width: 560px) {
  .bestiary-header-inner {
    grid-template-columns: 1fr; grid-template-areas: "back" "title" "jump";
    gap: 10px; padding: 12px 14px;
  }
  .bestiary-back { justify-self: start; min-height: 38px; padding: 9px 12px; }
  .bestiary-header h2 { font-size: 30px; }
  .bestiary-jump { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px;
    scrollbar-width: thin; }
  .bestiary-jump-button { padding: 8px 10px; flex: 0 0 auto; }
  .bestiary-body { padding: 18px 12px 40px; }
  .bestiary-entry { scroll-margin-top: 192px; padding: 14px; border-radius: 10px; }
  .bestiary-entry h4 { font-size: 28px; }
  .bestiary-entry h4 .bestiary-color { font-size: 11px; margin-bottom: 7px; }
  .bestiary-entry p { font-size: 13px; line-height: 1.55; }
  .bestiary-entry small { font-size: 12px; }
  .bestiary-scene-status { min-height: 33px; padding: 6px 9px; font-size: 9px; }
  .bestiary-loop-mark { display: none; }
  .bestiary-replay { min-height: 36px; padding: 6px 10px; font-size: 9px; }
  .bestiary-view.is-compact .bestiary-header-inner {
    grid-template-columns: auto minmax(0,1fr);
    grid-template-areas: "back title" "jump jump";
    gap: 5px 10px; padding-block: 7px;
  }
  .bestiary-view.is-compact .bestiary-header h2 {
    font-size: 20px; line-height: 1.15;
  }
  .bestiary-view.is-compact .bestiary-back { padding: 6px 8px; min-height: 32px; font-size: 9px; }
  .bestiary-view.is-compact .bestiary-jump-button { min-height: 30px; padding: 5px 9px; }
  .bestiary-entry { scroll-margin-top: 128px; }

}
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .bestiary-header-inner {
    grid-template-columns: auto minmax(0,1fr);
    grid-template-areas: "back title" "jump jump";
    padding: 7px max(10px,env(safe-area-inset-left));
    gap: 5px 14px;
  }
  .bestiary-back { min-height: 32px; padding: 6px 10px; font-size: 9px; }
  .bestiary-header h2 { font-size: 22px; }
  .bestiary-jump { flex-wrap: nowrap; overflow-x: auto; gap: 5px; }
  .bestiary-jump-button { min-height: 28px; padding: 5px 8px; font-size: 9px; flex-shrink: 0; }
  .bestiary-entry { scroll-margin-top: 105px; }
  .bestiary-body {
    padding: 14px max(16px,env(safe-area-inset-right)) max(36px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));
  }
  .bestiary-loop-mark { display: none; }
  .bestiary-scene-status { min-height: 35px; padding: 5px 8px; }
  .bestiary-replay { min-height: 30px; padding: 5px 8px; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .bestiary-view { scroll-behavior: auto; }
  .bestiary-jump-button, .bestiary-replay { transition: none; }
}

/* Results screen: spread the score, stats and actions without stretching beyond the arena. */
.app.is-game-over .overlay-content { width: min(570px, 100%); max-width: 570px; padding: 16px 20px; }
.app.is-game-over .overlay h2 { margin-bottom: 14px; font-size: clamp(30px, 4.5vw, 44px); }
.app.is-game-over .final-score { display: flex; flex-direction: column; align-items: center; gap: 5px; margin: 0 auto 16px; font-size: clamp(40px, 7vw, 66px); line-height: 1.08; white-space: normal; }
.app.is-game-over .final-score-label { font-size: 11px; letter-spacing: 2.2px; color: #c3b5e2; font-weight: 900; }
.app.is-game-over .final-score-unit { font-size: 12px; letter-spacing: 2px; }
.app.is-game-over .score-best-line { margin-top: 8px; font-size: 11px; letter-spacing: 1px; color: #bcb5d3; font-weight: 800; }
.app.is-game-over .score-best-line strong { color: #fff; font-size: 15px; margin-left: 7px; }
.app.is-game-over .record-feedback { margin-top: 5px; font-size: 12px; }
.app.is-game-over .run-summary { width: min(520px, 100%); margin: 0 auto; }
/* Results stats form a single non-interactive row like the flat HOW TO PLAY strip.
   Center each group and use quiet separators instead of card outlines. */
.app.is-game-over .run-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.app.is-game-over .run-stats > div {
  border: 0; border-radius: 0; background: none; cursor: default;
  align-items: center; justify-content: center; text-align: center;
  padding: 14px 8px; gap: 7px;
}
.app.is-game-over .run-stats > div + div {
  border-left: 1px solid rgba(154, 150, 196, .26);
}
.app.is-game-over .run-stats span { font-size: 10px; letter-spacing: .7px; }
.app.is-game-over .run-stats strong { font-size: clamp(16px, 3vw, 25px); }
.app.is-game-over .run-stats .run-stat-pb { font-size: 10px; white-space: normal; text-align: center; }
/* Record milestones get a typographic accent, never a highlighted card. */
.app.is-game-over .run-stats > div:has(.record-beaten) .run-stat-pb { color: #ebc985; }
.app.is-game-over .record-achievements { margin-top: 13px; line-height: 1.5; }
.app.is-game-over .start-cta {
  width: min(390px, 100%);
  min-width: 0;
  min-height: 70px;
  margin-top: 20px;
  padding: 16px 30px;
  font-size: 19px;
  letter-spacing: 1.6px;
  --arcade-edge: #e5bbff;
  --arcade-glow: rgba(215, 136, 255, .65);
  --arcade-top: #78459d;
  --arcade-bottom: #45265f;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24),
    inset 0 -3px 0 rgba(0,0,0,.26),
    0 8px 28px rgba(128,66,177,.32);
}
.app.is-game-over .start-cta::before {
  content: "▶";
  font-size: 15px;
  margin-right: 14px;
  color: #f9e0ff;
}
@media (max-width: 640px) {
  .app.is-game-over .overlay-content { padding: 10px 12px; }
  .app.is-game-over .overlay h2 { margin-bottom: 8px; }
  .app.is-game-over .score-best-line { margin-top: 5px; }
  .app.is-game-over .run-stats > div { padding: 8px 4px; gap: 4px; }
  .app.is-game-over .run-stats strong { font-size: clamp(13px, 3.4vw, 21px); }
  .app.is-game-over .run-stats span { font-size: clamp(8px, 1.5vw, 10px); letter-spacing: .2px; }
  .app.is-game-over .run-stats .run-stat-pb { font-size: clamp(8px, 1.55vw, 10px); }
  .app.is-game-over .final-score { font-size: clamp(34px, 9vw, 54px); gap: 2px; margin-bottom: 10px; }
  .app.is-game-over .start-cta { width: min(350px, 100%); min-height: 60px; margin-top: 13px; padding: 13px 20px; font-size: 16px; }
  .app.is-game-over .menu-secondary-actions { margin-top: 6px; }
}
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .app.is-game-over .overlay-content { padding: 4px 8px; }
  .app.is-game-over .overlay h2 { margin-bottom: 4px; font-size: clamp(18px, 6dvh, 26px); }
  .app.is-game-over .final-score { gap: 1px; margin-bottom: 4px; font-size: clamp(25px, 6dvh, 36px); }
  .app.is-game-over .final-score-label, .app.is-game-over .final-score-unit { font-size: 9px; }
  .app.is-game-over .score-best-line { margin-top: 2px; font-size: 9px; }
  .app.is-game-over .score-best-line strong { font-size: 13px; }
  .app.is-game-over .run-stats > div { padding: 3px 4px; gap: 2px; }
  .app.is-game-over .run-stats strong { font-size: 12px; }
  .app.is-game-over .run-stats span, .app.is-game-over .run-stats .run-stat-pb { font-size: 8px; }
  .app.is-game-over .overlay .start-cta {
    width: min(310px, 100%);
    min-height: 48px;
    margin-top: 6px;
    padding: 9px 18px;
    font-size: 14px;
  }
  .app.is-game-over .menu-secondary-actions { margin-top: 4px; }
  .app.is-game-over .menu-info-button { min-height: 36px; }
}
@media (prefers-reduced-motion: no-preference) {
  .app.is-game-over .final-score:has(.record-feedback:not([hidden])) #final-score-value { animation: record-reveal .55s ease-out both; }
  @keyframes record-reveal { from { transform: scale(.92); opacity: .55; } to { transform: scale(1); opacity: 1; } }
}
