/* ============================================================
   METRO RUSH — game UI
   Scene-first layout: floating HUD, no card collage.
   ============================================================ */

:root {
  --navy: #081826;
  --navy-2: #10283e;
  --ink: #eaf5ff;
  --muted: #a9c1d6;
  --yellow: #ffc93c;
  --yellow-deep: #f0a91b;
  --cyan: #63ddff;
  --red: #ff5f4a;
  --line: rgba(214, 235, 255, 0.22);
  --font: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #6fb6e8;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { overscroll-behavior: none; touch-action: none; }

button { font-family: inherit; }

.hidden { display: none !important; }

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
}

/* ---------- speed wash ---------- */
.speed-wash {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(ellipse at 50% 52%, transparent 42%, rgba(255, 255, 255, 0.22) 78%, rgba(255, 244, 205, 0.55) 100%);
  transition: opacity 0.35s ease;
  mix-blend-mode: screen;
}
.speed-wash.hit {
  background:
    radial-gradient(ellipse at 50% 50%, transparent 34%, rgba(255, 88, 64, 0.35) 76%, rgba(255, 44, 28, 0.72) 100%);
  animation: wash-hit 0.42s ease-out both;
}
@keyframes wash-hit {
  0% { opacity: 1; }
  100% { opacity: 0.22; }
}

/* ---------- loading ---------- */
.loading-screen {
  z-index: 60;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 700px at 50% 10%, #1b4266 0%, transparent 62%),
    linear-gradient(180deg, #0c2034 0%, #07131f 100%);
}
.loading-center {
  width: min(360px, 78vw);
  text-align: center;
}
.loading-logo {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.loading-logo span {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.42em;
  color: var(--cyan);
}
.loading-track {
  position: relative;
  height: 3px;
  margin: 30px 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.loading-track i {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), #fff0b0);
  transition: width 0.35s ease;
}
.loading-status {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* ---------- top bars ---------- */
.menu-top {
  position: absolute;
  z-index: 2;
  top: calc(20px + var(--safe-top));
  left: calc(24px + var(--safe-left));
  right: calc(24px + var(--safe-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.menu-top > * { pointer-events: auto; }

.menu-logo {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
}
.logo-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--yellow);
  color: #12212f;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
}
.logo-text {
  display: flex;
  flex-direction: column;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.logo-text small {
  margin-top: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.7);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(9, 25, 41, 0.42);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.16s ease, transform 0.16s ease;
}
.icon-btn:hover { background: rgba(9, 25, 41, 0.66); transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.sound-on, .sound-off { display: inline-flex; }
body.is-muted .sound-on { display: none; }
body:not(.is-muted) .sound-off { display: none; }

/* ---------- menu ---------- */
.menu-screen {
  z-index: 22;
  background:
    linear-gradient(90deg, rgba(5, 17, 29, 0.84) 0%, rgba(5, 17, 29, 0.56) 32%, rgba(5, 17, 29, 0.1) 56%, transparent 70%);
}
.menu-panel {
  position: absolute;
  left: clamp(26px, 7vw, 108px);
  top: 50%;
  transform: translateY(-50%);
  width: min(430px, 42vw);
  padding-top: 24px;
}
.panel-kicker {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--yellow);
  text-transform: uppercase;
}
.menu-panel h1 {
  margin: 0;
  font-size: clamp(42px, 5.4vw, 72px);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 6px 34px rgba(0, 0, 0, 0.4);
}
.menu-sub {
  max-width: 360px;
  margin: 18px 0 0;
  font-size: 14px;
  line-height: 1.65;
  font-weight: 500;
  color: rgba(231, 243, 255, 0.78);
}
.menu-stats {
  display: flex;
  gap: 34px;
  margin: 28px 0 0;
}
.menu-stats > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.menu-stats small {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(205, 226, 247, 0.62);
}
.menu-stats b {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.menu-stats b em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--yellow);
}

.big-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(300px, 100%);
  margin: 30px 0 0;
  padding: 16px 20px 16px 24px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffd45a 0%, var(--yellow) 46%, var(--yellow-deep) 100%);
  color: #14212e;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(240, 169, 27, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}
.big-btn em {
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.2em;
  opacity: 0.52;
}
.big-btn:hover { transform: translateY(-2px); filter: brightness(1.04); box-shadow: 0 14px 32px rgba(240, 169, 27, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
.big-btn:active { transform: translateY(0) scale(0.99); }

.mission-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 20px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: rgba(221, 238, 253, 0.68);
}
.mission-strip > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mission-strip > span + span::before {
  content: "";
  width: 3px;
  height: 3px;
  margin-right: 8px;
  border-radius: 50%;
  background: rgba(255, 201, 60, 0.7);
}

.coin-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1a8 0%, #ffc93c 45%, #d88f10 100%);
  box-shadow: inset 0 -1px 1px rgba(120, 70, 0, 0.35);
}

.menu-ctrl {
  margin: 22px 0 0;
  font-size: 11px;
  line-height: 1.8;
  color: rgba(196, 219, 240, 0.52);
}
.menu-footer {
  position: absolute;
  left: clamp(26px, 7vw, 108px);
  bottom: calc(20px + var(--safe-bottom));
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: rgba(210, 232, 250, 0.42);
}

/* ---------- countdown ---------- */
.countdown {
  position: absolute;
  inset: 0;
  z-index: 26;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(5, 15, 26, 0.18), rgba(5, 15, 26, 0.48));
}
#countdown-number {
  display: block;
  font-size: clamp(88px, 15vw, 150px);
  line-height: 1;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 8px 0 rgba(8, 24, 38, 0.28), 0 18px 60px rgba(0, 0, 0, 0.45);
}
#countdown-copy {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--yellow);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
.countdown-hint {
  position: absolute;
  bottom: calc(12% + var(--safe-bottom));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.countdown.pop #countdown-number { animation: count-pop 0.48s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes count-pop {
  0% { opacity: 0; transform: scale(1.5); }
  40% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.hud-left {
  position: absolute;
  top: calc(18px + var(--safe-top));
  left: calc(18px + var(--safe-left));
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.hud-left .icon-btn {
  width: 38px;
  height: 38px;
  background: rgba(7, 21, 35, 0.34);
}
.hud-left .icon-btn svg { width: 18px; height: 18px; }
.sound-btn { display: inline-grid; }

.hud-right {
  position: absolute;
  top: calc(16px + var(--safe-top));
  right: calc(20px + var(--safe-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  min-width: 190px;
  text-align: right;
  text-shadow: 0 2px 12px rgba(4, 16, 27, 0.5);
}
.hud-score {
  font-size: clamp(30px, 4.4vw, 46px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.015em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.hud-unit {
  margin-top: 1px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: rgba(226, 244, 255, 0.62);
}
.hud-chips {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  background: rgba(7, 21, 35, 0.34);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: none;
}
.hud-chip.mult { color: var(--yellow); }
.hud-chip.coins { color: #fff; }
.hud-chip .coin-dot { width: 10px; height: 10px; }
.hud-sub {
  display: flex;
  gap: 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(236, 247, 255, 0.78);
}
.hud-sub b { font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.mission-hud { width: 142px; margin-top: 2px; }
.mission-row {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: rgba(229, 244, 255, 0.66);
}
.mission-row b { color: var(--yellow); }
.mission-bar {
  height: 2px;
  margin-top: 5px;
  background: rgba(255, 255, 255, 0.24);
  overflow: hidden;
}
.mission-bar i {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--yellow);
  transition: width 0.25s linear;
}

/* power chips */
.power-list {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-top: 5px;
}
.power-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 102px;
  padding: 4px 10px 5px 6px;
  border-left: 2px solid var(--power, var(--yellow));
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(5, 16, 26, 0.82), rgba(5, 16, 26, 0.3));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(5px);
  text-shadow: none;
  animation: chip-in 0.18s ease-out both;
}
@keyframes chip-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
.power-symbol {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--power, var(--yellow)) 16%, transparent);
  color: var(--power, var(--yellow));
}
.power-symbol svg, .power-symbol img { display: block; width: 24px; height: 24px; object-fit: contain; }
.power-meta { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.power-meta strong {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #eaf6ff;
}
.power-time {
  display: block;
  height: 2px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}
.power-time i { display: block; height: 100%; width: 100%; background: var(--power, var(--cyan)); }
.power-chip.is-expiring .power-time i { background: var(--red); animation: blink 0.65s steps(2, end) infinite; }
.power-chip.is-expiring { border-left-color: var(--red); }
@keyframes blink { 50% { opacity: 0.35; } }

/* chase meter */
.chase-meter {
  position: absolute;
  top: calc(18px + var(--safe-top));
  left: 50%;
  transform: translate(-50%, -6px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 7px;
  background: rgba(7, 21, 35, 0.38);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.25s ease;
  pointer-events: none;
}
.chase-meter.show { opacity: 1; transform: translate(-50%, 0); }
.chase-meter.is-hot { background: rgba(92, 18, 14, 0.55); }
.chase-name {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: rgba(236, 247, 255, 0.78);
}
.chase-track {
  position: relative;
  width: 86px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  overflow: hidden;
}
.chase-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
  transition: width 0.2s linear, background 0.2s ease;
}
.chase-meter.is-hot .chase-track i { background: var(--red); }
.chase-meter b {
  min-width: 20px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  text-align: right;
}
.chase-meter.is-hot .chase-name { color: #ffd9d4; }

/* combo + tips */
.combo-toast {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translate(-50%, 6px);
  font-size: clamp(17px, 2.4vw, 24px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  opacity: 0;
  text-shadow: 0 3px 18px rgba(5, 18, 30, 0.65);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.combo-toast.show { opacity: 1; transform: translate(-50%, 0); }

.touch-tip {
  position: absolute;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 8px);
  padding: 7px 13px;
  border-radius: 6px;
  background: rgba(7, 21, 35, 0.4);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(240, 250, 255, 0.82);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}
.touch-tip.show { opacity: 1; transform: translate(-50%, 0); }
.touch-tip i { margin: 0 5px; font-style: normal; color: var(--yellow); }

.touch-controls {
  position: absolute;
  right: calc(18px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  gap: 10px;
  pointer-events: none;
}
.touch-btn {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(7, 21, 35, 0.34);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}
.touch-btn span { font-size: 18px; line-height: 1; font-weight: 800; }
.touch-btn small { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; opacity: 0.72; }
.touch-btn:active { background: rgba(255, 201, 60, 0.28); }

/* ---------- modals ---------- */
.modal-screen {
  z-index: 30;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  background:
    radial-gradient(ellipse at 50% 50%, rgba(13, 32, 48, 0.55), rgba(4, 12, 20, 0.82));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.panel {
  width: min(390px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 26px 28px 24px;
  border: 1px solid rgba(197, 225, 248, 0.16);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(17, 38, 57, 0.94), rgba(8, 22, 35, 0.96));
  box-shadow: 0 36px 80px rgba(0, 0, 0, 0.4);
  text-align: left;
  animation: panel-in 0.2s ease-out both;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.panel h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #fff;
}
.panel-copy {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}
.panel .big-btn { width: 100%; margin-top: 22px; }
.ghost-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border: 1px solid rgba(205, 230, 250, 0.18);
  border-radius: 8px;
  background: transparent;
  color: rgba(230, 243, 255, 0.82);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.ghost-btn:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(205, 230, 250, 0.34); }
.panel-ctrl {
  margin: 18px 0 0;
  font-size: 10px;
  line-height: 1.6;
  color: rgba(190, 214, 236, 0.46);
  text-align: center;
}

/* results */
.record-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 201, 60, 0.55);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--yellow);
}
.result-main {
  display: flex;
  flex-direction: column;
  margin: 20px 0 16px;
}
.result-main small { font-size: 10px; font-weight: 700; letter-spacing: 0.14em; color: var(--muted); }
.result-main b {
  margin-top: 4px;
  font-size: 52px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--yellow);
}
.result-main span { margin-top: 6px; font-size: 10px; font-weight: 600; color: rgba(205, 226, 245, 0.6); }
.result-main em { font-style: normal; color: #fff; }
.result-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:8px 0;border:0;background:transparent}
.result-grid>div{display:flex;flex-direction:column;gap:8px;padding:14px 16px;background:rgba(255,255,255,.035);border:0;border-radius:14px;min-width:0}
.result-grid>div[hidden]{display:none}
.result-grid small{font-size:11px;font-weight:500;letter-spacing:.02em;color:var(--ui-muted,#9dafc7)}
.result-grid b{display:flex;align-items:baseline;gap:8px;font-size:25px;line-height:1.2;font-weight:650;font-variant-numeric:tabular-nums;color:#edf3ff}
.result-grid .result-stat-unit{font-size:12px;font-weight:500;color:var(--ui-muted,#9dafc7)}
.result-grid .coin-dot{width:12px;height:12px;align-self:center;flex:none}
@media(max-width:480px){.result-grid>div{padding:12px 14px}.result-grid b{font-size:23px}}
.result-quote {
  margin: 16px 0 0;
  font-size: 11px;
  line-height: 1.7;
  color: rgba(190, 214, 236, 0.58);
  text-align: center;
}
.share-btn { border-style: dashed; }

/* toast */
.toast {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: calc(88px + var(--safe-top));
  bottom: auto;
  transform: translate(-50%, -6px);
  max-width: min(86vw, 420px);
  padding: 10px 15px;
  border-left: 3px solid var(--yellow);
  border-radius: 6px;
  background: rgba(8, 23, 37, 0.9);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  font-size: 12px;
  line-height: 1.5;
  color: #eaf6ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--yellow); }

/* misc */
.rotate-note { display: none; }
.nojs {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--navy);
  color: #fff;
  font-size: 15px;
  text-align: center;
}

/* ---------- responsive ---------- */
@media (pointer: coarse) {
  .touch-btn { display: flex; }
  .sound-btn { display: inline-grid; }
  .touch-tip { bottom: calc(88px + var(--safe-bottom)); }
}

@media (max-width: 900px) {
  .menu-screen {
    background:
      linear-gradient(180deg, rgba(5, 17, 29, 0.34) 0%, rgba(5, 17, 29, 0.1) 30%, rgba(5, 17, 29, 0.72) 68%, rgba(5, 17, 29, 0.93) 100%);
  }
  .menu-panel {
    left: calc(22px + var(--safe-left));
    right: calc(22px + var(--safe-right));
    top: auto;
    bottom: calc(28px + var(--safe-bottom));
    width: auto;
    transform: none;
  }
  .menu-panel h1 { font-size: clamp(34px, 8vw, 48px); }
  .menu-sub { margin-top: 12px; font-size: 12px; }
  .menu-stats { margin-top: 18px; gap: 26px; }
  .menu-stats b { font-size: 21px; }
  .big-btn { width: 100%; margin-top: 20px; }
  .mission-strip { margin-top: 14px; }
  .menu-ctrl { margin-top: 14px; font-size: 10px; }
  .menu-footer { display: none; }
  .menu-logo .logo-text { font-size: 13px; }
  .menu-top { top: calc(14px + var(--safe-top)); left: calc(16px + var(--safe-left)); right: calc(16px + var(--safe-right)); }

  .hud-right { top: calc(12px + var(--safe-top)); right: calc(14px + var(--safe-right)); min-width: 150px; gap: 5px; }
  .hud-score { font-size: 32px; }
  .hud-chip { height: 22px; font-size: 11px; padding: 0 7px; }
  .hud-sub { gap: 9px; font-size: 9px; }
  .mission-hud { display: block; width: 142px; }
  /* Keep the chase strip off the runner's body. On a phone the centre of the
     lower third is exactly where the character and inspector sit. */
  .chase-meter {
    top: calc(62px + var(--safe-top));
    bottom: auto;
    left: calc(16px + var(--safe-left));
    transform: translate(0, -6px);
  }
  .chase-meter.show { transform: translate(0, 0); }
  .chase-track { width: 64px; }

  .panel { padding: 22px 22px 20px; border-radius: 12px; }
  .panel h2 { font-size: 25px; }
  .result-main b { font-size: 44px; }
  .toast { top: calc(118px + var(--safe-top)); bottom: auto; }
}

@media (max-width: 900px) and (max-height: 560px) and (orientation: landscape) {
  .menu-screen {
    background: linear-gradient(90deg, rgba(5, 17, 29, 0.9) 0%, rgba(5, 17, 29, 0.55) 40%, transparent 66%);
  }
  .menu-panel {
    left: calc(24px + var(--safe-left));
    right: auto;
    top: 50%;
    bottom: auto;
    width: min(360px, 52vw);
    transform: translateY(-50%);
  }
  .menu-panel h1 { font-size: 38px; }
  .menu-sub { display: none; }
  .menu-stats { margin-top: 14px; }
  .big-btn { margin-top: 16px; padding: 12px 16px; font-size: 15px; }
  .mission-strip { display: none; }
  .menu-ctrl { display: none; }
  .menu-top { top: calc(12px + var(--safe-top)); }
  .countdown-hint { display: none; }
  .panel { width: min(440px, 82vw); max-height: 94%; padding: 18px 22px; }
  .panel h2 { font-size: 22px; }
  .panel .big-btn { margin-top: 14px; padding: 12px 16px; }
  .result-main { margin: 12px 0; }
  .result-main b { font-size: 38px; }
  .ghost-btn { padding: 9px 14px; }
  .panel-ctrl { display: none; }
}

@media (max-width: 560px) {
  .hud-left .icon-btn { width: 34px; height: 34px; }
  .hud-left .icon-btn svg { width: 16px; height: 16px; }
  .hud-score { font-size: 28px; }
  .touch-controls { right: calc(14px + var(--safe-right)); bottom: calc(16px + var(--safe-bottom)); }
  .touch-btn { width: 54px; height: 54px; }
  .countdown-hint { width: 84%; text-align: center; line-height: 1.6; }
}

@media (max-height: 620px) and (orientation: portrait) {
  .menu-panel h1 { font-size: 34px; }
  .menu-sub { display: none; }
  .menu-stats { margin-top: 14px; }
  .menu-strip { display: none; }
  .menu-ctrl { display: none; }
  .menu-footer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Keep all menu actions inside the viewport, including short desktop windows. */
.menu-panel { max-height:calc(100dvh - 110px - var(--safe-top) - var(--safe-bottom)); overflow-y:auto; padding-top:0; scrollbar-width:thin; }
.menu-actions { display:grid;grid-template-columns:1fr 1fr;gap:9px;margin-top:22px; }
.menu-actions > .big-btn { grid-column:1 / -1;width:100%;margin:0; }
.menu-actions > .ghost-btn { width:100%;margin:0;min-height:44px;padding:10px 8px; }
@media (orientation:landscape) and (max-height:650px) {
  .menu-panel { left:clamp(24px,5vw,64px);right:auto;top:70px;bottom:18px;transform:none;width:min(430px,55vw);max-height:none;padding:0 8px 0 0; }
  .menu-panel .panel-kicker { margin-bottom:7px;font-size:9px; }
  .menu-panel h1 { font-size:clamp(34px,4.8vw,48px);line-height:1.1; }
  .menu-sub { display:block;margin-top:8px;font-size:12px;line-height:1.4; }
  .menu-stats { margin-top:12px;gap:30px; }
  .menu-stats b { font-size:22px; }
  .menu-actions { margin-top:14px; }
  .menu-actions > .big-btn { min-height:46px;padding:11px 16px;font-size:16px; }
  .menu-actions > .ghost-btn { font-size:12px; }
  .menu-panel .mission-strip { display:flex;margin-top:12px;font-size:10px; }
  .menu-panel .menu-ctrl { display:block;margin-top:10px;font-size:10px;line-height:1.4; }
  .menu-footer { display:none; }
}
@media (max-width:480px) { .menu-actions { gap:8px; }.menu-actions > .ghost-btn { font-size:11px; } }
#music-hud-btn { line-height: 1; touch-action: manipulation; }

/* Clear hierarchy: one primary action, compact secondary actions, no overlay prose. */
[hidden]{display:none!important}
.control-chips{display:flex;gap:16px;align-items:center;margin-top:20px;color:#c4d5e2;font-size:11px}
.control-chips>span{display:flex;align-items:center;gap:6px}
kbd{font:700 12px inherit;display:inline-grid;place-items:center;min-width:24px;height:24px;padding:0 5px;border:1px solid #ffffff26;border-radius:5px;background:#ffffff0c;color:#f5f8fa}
.wallet-chip{display:inline-flex;gap:5px;align-items:center;margin-left:6px;color:#ffd263;font-variant-numeric:tabular-nums}
.wallet-chip .coin-dot{width:9px;height:9px}
.menu-panel .menu-stats{margin-top:24px;gap:36px}
.menu-panel .menu-actions{margin-top:24px;gap:10px}
.menu-actions>.ghost-btn{background:#10283c60;min-height:44px;font-size:13px}
.panel{padding:26px;width:min(390px,100%);border-radius:18px}
.panel>.ghost-btn{min-height:42px}
#pause-screen .panel{display:grid;grid-template-columns:1fr 1fr;gap:10px}
#pause-screen h2,#pause-screen .big-btn{grid-column:1/-1}
#pause-screen .big-btn{margin:12px 0 4px}
#pause-screen .ghost-btn{margin:0;padding:11px 8px}
#gameover-screen .panel{display:grid;grid-template-columns:1fr 1fr;gap:10px}
#gameover-screen h2,#gameover-screen .record-badge,#gameover-screen .result-main,#gameover-screen .result-grid,#gameover-screen .big-btn{grid-column:1/-1}
#gameover-screen .record-badge{justify-self:start;margin:0}
#gameover-screen .result-main{margin:4px 0}
#gameover-screen .big-btn{margin:4px 0 0}
#gameover-screen .ghost-btn{margin:0;min-height:40px;padding:10px}
#gameover-screen .share-btn{grid-column:1/-1;border:0;padding:5px;min-height:30px;color:#b5c9d9}
.hud-right{gap:5px}.hud-sub{justify-content:flex-end}.mission-hud{margin-top:3px}.hud-score{line-height:1}
@media(orientation:landscape) and (max-height:650px){
 .menu-panel{top:108px;bottom:24px;width:min(380px,43vw);padding:0}
 .menu-panel h1{font-size:44px}.menu-panel .menu-stats{margin-top:18px}.menu-panel .menu-actions{margin-top:18px}
 .control-chips{margin-top:16px;gap:12px}
 .modal-screen{padding:16px}.panel{padding:22px}.panel h2{font-size:26px}
 #gameover-screen .result-main b{font-size:42px}
}
@media(max-width:560px){
 .menu-panel{left:24px;right:24px;bottom:calc(28px + var(--safe-bottom));max-height:calc(100dvh - 120px)}
 .menu-panel .menu-stats{margin-top:20px}.menu-panel .menu-actions{margin-top:20px}
 .menu-panel h1{font-size:42px}.control-chips{justify-content:center;font-size:11px;gap:14px}
 .panel{padding:22px}.modal-screen{padding:18px}
 .hud-left{gap:6px}.hud-right{min-width:125px}.mission-row{font-size:9px}
}
@media(pointer:coarse){.control-chips kbd{border:0;background:none;padding:0;min-width:16px}.control-chips{color:#bdd0df}}
@media(max-height:440px){.menu-panel{top:84px;bottom:12px}.menu-panel h1{font-size:34px}.control-chips{display:none}.menu-panel .menu-stats,.menu-panel .menu-actions{margin-top:12px}}

/* Focus uses the control's fill rather than an operating-system ring. */
:where(button, a, input, select, textarea, summary, [tabindex]):focus,
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none !important;
  outline-offset: 0 !important;
}
:where(button, a, [role="tab"]):focus-visible { filter: brightness(1.12); }
.music-view-tabs button[aria-selected="true"] {
  border-bottom-color: transparent !important;
  background: rgba(115, 229, 192, .1);
  border-radius: 9px;
}
/* Compact radio shortcuts stay in the HUD margin, away from the runner. */
.hud-radio{position:absolute;top:calc(64px + var(--safe-top));left:calc(18px + var(--safe-left));display:flex;align-items:center;gap:2px;width:204px;max-width:calc(100vw - 190px);height:34px;padding:2px 3px 2px 7px;border-radius:9px;background:rgba(7,21,35,.46);pointer-events:auto;color:#eaf4fb;box-sizing:border-box;backdrop-filter:blur(4px)}
.hud-radio button{border:0;background:transparent;color:inherit;height:28px;width:26px;border-radius:6px;display:flex;align-items:center;justify-content:center;cursor:pointer;touch-action:manipulation;padding:0;flex-shrink:0}.hud-radio button:hover{background:#ffffff13}.hud-radio button:disabled{opacity:.28;cursor:default}.hud-radio .hud-radio-title{min-width:0;width:auto;flex:1;justify-content:flex-start;gap:7px;font:600 11px system-ui;text-align:left}.hud-radio-title span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.hud-radio-title i{width:5px;height:5px;border-radius:50%;background:#9bb1c6;flex-shrink:0}.hud-radio[data-state=playing] i{background:#71e4ba}.hud-radio[data-state=muted] i{background:#d6b76b}.hud-radio[data-state=loading] i{background:#71e4ba;animation:hud-radio-pulse .65s ease-in-out infinite alternate}.hud-radio svg{width:17px;height:17px;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;fill:none}@keyframes hud-radio-pulse{to{opacity:.25}}
@media(max-width:700px){.hud-radio{top:calc(96px + var(--safe-top));left:calc(16px + var(--safe-left));width:190px;max-width:calc(100vw - 165px);height:34px}.hud-radio .hud-radio-title{font-size:10px}}
@media(orientation:landscape) and (max-height:500px){.hud-radio{top:calc(58px + var(--safe-top));width:180px}}
/* Phone radio controls share the HUD buttons' material, without a second panel. */
@media(max-width:700px){
 .hud-radio{width:186px;max-width:calc(100vw - 165px);height:34px;padding:0;gap:5px;background:transparent;backdrop-filter:none;border-radius:0}
 .hud-radio .hud-radio-title{height:32px;padding:0 8px;border:1px solid #ffffff1c;border-radius:14px;background:rgba(7,21,35,.34);font-size:10px;font-weight:500;gap:5px;color:#f5f9fc;text-shadow:0 1px 2px #0008;backdrop-filter:blur(3px)}
 .hud-radio>button:not(.hud-radio-title){width:32px;height:32px;border:1px solid #ffffff2a;border-radius:50%;background:rgba(7,21,35,.34);color:#f0f7fc;backdrop-filter:blur(3px)}
 .hud-radio>button:not(.hud-radio-title):hover{background:rgba(7,21,35,.5)}
 .hud-radio svg{width:16px;height:16px;stroke-width:1.8}
 .hud-radio-title i{width:4px;height:4px}
}

/* Keep the mobile route clear; music sits in the lower corner. */
@media(max-width:700px),(pointer:coarse){
 .touch-controls,.touch-tip,#music-hud-btn{display:none}
 .hud-radio{top:auto;bottom:calc(18px + var(--safe-bottom));left:calc(14px + var(--safe-left));width:158px;max-width:calc(100vw - 28px);height:32px;gap:3px;padding:0;background:transparent;backdrop-filter:none}
 .hud-radio .hud-radio-title{height:30px;padding:0 6px;font-size:10px;border:0;border-radius:12px;background:rgba(7,21,35,.28);gap:4px}
 .hud-radio>button:not(.hud-radio-title){width:30px;height:30px;border:0;background:rgba(7,21,35,.28)}
 .hud-radio svg{width:14px;height:14px}
}

/* Game notices occupy their own lower safe zone, away from status counters. */
.toast{top:auto;bottom:calc(28px + var(--safe-bottom));max-width:min(86vw,360px);padding:8px 12px;border:0;border-radius:12px;background:rgba(7,21,35,.66);box-shadow:none;backdrop-filter:blur(5px);font-size:11px;font-weight:500;line-height:1.4;transform:translate(-50%,6px);text-wrap:balance}
.toast::before{content:"";display:inline-block;width:4px;height:4px;border-radius:50%;background:var(--toast-accent,#ffd84a);margin-right:7px;vertical-align:2px}
.toast b{color:#f4f8fc;font-weight:650}
@media(max-width:700px),(pointer:coarse){.toast{top:auto;bottom:calc(64px + var(--safe-bottom));max-width:calc(100vw - 36px);font-size:10px;padding:7px 10px;border-radius:10px}}
/* Music is a quiet label until requested; expanded controls expire after idle. */
.hud-radio{width:auto;max-width:calc(100vw - 28px);height:34px;gap:4px;padding:0;background:transparent;backdrop-filter:none;border-radius:0}
.hud-radio .hud-radio-title{flex:none;width:110px;height:32px;box-sizing:border-box;padding:0 8px;gap:5px;border:0;border-radius:16px;background:rgba(7,21,35,.32);font-size:10px;font-weight:500;backdrop-filter:blur(3px);text-shadow:0 1px 2px #0008}
.hud-radio-actions{display:flex;align-items:center;gap:4px}.hud-radio-actions[hidden]{display:none!important}
.hud-radio .hud-radio-actions button{width:32px;height:32px;border-radius:50%;background:rgba(7,21,35,.32);border:0;backdrop-filter:blur(3px)}
.hud-radio .hud-radio-actions button:hover{background:rgba(7,21,35,.5)}
.hud-radio[data-state=loading] .hud-radio-title i{width:9px;height:9px;box-sizing:border-box;border:1.5px solid #ffffff3b;border-top-color:#8aefc9;background:none;border-radius:50%;animation:hud-radio-spin .65s linear infinite}
@keyframes hud-radio-spin{to{transform:rotate(360deg)}}
@media(max-width:700px),(pointer:coarse){.hud-radio{width:auto;max-width:calc(100vw - 28px);height:34px}.hud-radio .hud-radio-title{width:110px;height:32px;padding:0 8px;border-radius:16px}.hud-radio svg{width:15px;height:15px}}

/* Keep score, coins and distance unobstructed; equipment status lives on its icon. */
.mission-hud[hidden],.power-list[hidden]{display:none!important}
