/* Slingstar shell styles (PLAN.md §6, §7). No web fonts, no images. */

:root {
  --bg: #05060f;
  --ink: #f5f9ff;
  --muted: rgba(214, 228, 255, 0.74);
  --faint: rgba(214, 228, 255, 0.5);
  --accent: #6fe3ff;
  --accent-rgb: 111, 227, 255;
  --gold: #ffd36a;
  --glass: rgba(7, 9, 26, 0.46);
  --glass-strong: rgba(6, 8, 22, 0.74);
  --line: rgba(170, 205, 255, 0.24);
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  /* Dark halo first (legible over a bright bloomed scene), then the glow. */
  --legible: 0 0 1px rgba(0, 0, 0, 0.9), 0 1px 3px rgba(0, 0, 0, 0.7), 0 0 12px rgba(0, 0, 0, 0.45);
  --font: ui-rounded, -apple-system, system-ui, "SF Pro Rounded", sans-serif;
  /* The game column: the whole window on a phone; a centred portrait column on wider windows
     (see "wide / desktop" below). Sizes that used vw use this instead. */
  --cw: 100vw;
  --cx: 0px;
  color-scheme: dark;
}

html, body {
  position: fixed; inset: 0; margin: 0; padding: 0; overflow: hidden; overscroll-behavior: none;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  background: var(--bg); color: var(--ink); font-family: var(--font);
  width: 100%; height: 100vh; height: 100dvh;
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
[hidden] { display: none !important; }

#game {
  position: absolute; left: var(--cx); top: 0; display: block; z-index: 0;
  width: var(--cw); height: 100vh; height: 100dvh; background: var(--bg);
}
#hud, #screens {
  position: absolute; left: var(--cx); top: 0; width: var(--cw); height: 100vh; height: 100dvh;
  pointer-events: none; overflow: hidden;
}
#hud { z-index: 1; }
#screens { z-index: 2; }
#debug { z-index: 3; }
[data-ui] { pointer-events: auto; cursor: pointer; }

/* ============================================================== boot splash */
#boot {
  position: fixed; inset: 0; z-index: 10; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  transition: opacity 0.28s ease-out;
}
#boot.out { opacity: 0; pointer-events: none; }
.boot-mark {
  font-weight: 800; font-size: 20px; letter-spacing: 0.42em; padding-left: 0.42em;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9), 0 0 30px rgba(var(--accent-rgb), 0.5);
}
.boot-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 10px 3px rgba(var(--accent-rgb), 0.9);
  animation: boot-pulse 1s ease-in-out infinite alternate;
}
@keyframes boot-pulse { from { opacity: 0.3; } to { opacity: 1; } }
/* Renderer failed (no WebGL2 / shader error): a readable message instead of a black screen. */
.fatal {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 32px; box-sizing: border-box; text-align: center; background: var(--bg); color: var(--ink);
}
.fatal-title { font-weight: 900; font-size: 26px; letter-spacing: 0.3em; padding-left: 0.3em; margin-bottom: 18px;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9); }
.fatal p { margin: 0 0 10px; font-size: 16px; line-height: 1.45; }
.fatal .fatal-sub { color: var(--muted); font-size: 14px; }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; color: var(--muted); }

/* ============================================================== HUD */
#hud { transition: opacity 0.2s; }
#hud.off { opacity: 0; }
/* On the title only the first-run prompt shows (the live game is behind the title screen). */
#hud.title-mode .hud-top, #hud.title-mode .hud-zone, #hud.title-mode .hud-perfect { display: none; }
#hud.title-mode .hud-prompt { bottom: calc(var(--sab) + 7vh + 44px); }

.hud-top {
  position: absolute; top: calc(var(--sat) + 8px); left: var(--sal); right: var(--sar); height: 54px;
}
/* Soft dark pool behind the score keeps it readable over the brightest bloom. */
.hud-top::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 280px; height: 120px;
  transform: translate(-50%, -55%); z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(3, 4, 14, 0.45), rgba(3, 4, 14, 0));
}
.hud-score {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center;
  font-weight: 800; font-size: 38px; line-height: 1; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums; white-space: pre; color: #fff;
  text-shadow: var(--legible), 0 0 18px rgba(var(--accent-rgb), 0.55);
}
.hud-score.long { font-size: 31px; }
.hud-mult {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%); min-width: 34px; text-align: center;
  font-weight: 800; font-size: 18px; line-height: 1; padding: 6px 8px 5px; border-radius: 999px;
  border: 1.5px solid currentColor; background: rgba(4, 6, 18, 0.42);
  box-shadow: 0 0 12px -2px currentColor, inset 0 0 8px -3px currentColor;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.8), 0 0 10px currentColor;
  transition: color 0.25s, opacity 0.25s;
}
.hud-mult.t1 { opacity: 0.72; }
.hud-combo {
  position: absolute; right: 62px; top: 50%; margin-top: -17px; display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1; text-shadow: var(--legible); transition: opacity 0.2s; transform-origin: right center;
}
.hud-combo.off { opacity: 0; }
.hud-combo-n { font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; white-space: pre; color: #fff; }
.hud-combo-l { font-weight: 700; font-size: 9px; letter-spacing: 0.2em; color: var(--muted); margin-top: 2px; margin-right: -0.2em; }
.hud-combo.pop { animation: combo-pop 0.34s cubic-bezier(.2, 1.6, .4, 1); }
.hud-combo.pop2 { animation: combo-pop-b 0.34s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes combo-pop {
  0% { transform: scale(1.35); color: var(--accent); }
  100% { transform: scale(1); }
}
@keyframes combo-pop-b {
  0% { transform: scale(1.35); color: var(--accent); }
  100% { transform: scale(1); }
}

.hud-perfect {
  position: absolute; left: 0; right: 0; top: calc(var(--sat) + 74px); text-align: center;
  font-weight: 900; font-size: 22px; letter-spacing: 0.34em; padding-left: 0.34em; color: #fffbe8;
  text-shadow: var(--legible), 0 0 10px var(--gold), 0 0 26px rgba(255, 190, 80, 0.8);
  opacity: 0;
}
.hud-perfect.on { animation: perfect-flash 0.95s ease-out forwards; }
.hud-perfect.on2 { animation: perfect-flash-b 0.95s ease-out forwards; }
.hud-brace-cue { color: #fff; text-shadow: var(--legible), 0 0 10px #ff6a3d, 0 0 26px rgba(255, 90, 50, 0.9); }
.hud-braced { color: #fffbe8; }
.hud-hull {
  /* Under the multiplier, clear of the PERFECT / BRACE flashes. */
  position: absolute; left: calc(var(--sal) + 16px); top: calc(var(--sat) + 112px);
  display: flex; align-items: center; gap: 8px; transition: opacity 0.3s;
  font-weight: 800; font-size: 9px; letter-spacing: 0.24em; color: var(--muted); text-shadow: var(--legible);
}
.hud-hull.off { opacity: 0; }
.hud-hull-track {
  position: relative; width: 96px; height: 6px; border-radius: 3px; overflow: hidden;
  background: rgba(255, 255, 255, 0.12); border: 1px solid var(--line);
}
.hud-hull-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--gold);
  box-shadow: 0 0 8px rgba(255, 196, 77, 0.8); transition: width 0.25s;
}
.hud-hull.low .hud-hull-fill { background: #ff6a3d; box-shadow: 0 0 8px rgba(255, 90, 50, 0.9); }
.hud-hull-tick { position: absolute; top: 0; bottom: 0; width: 1.5px; margin-left: -0.75px; background: rgba(3, 4, 14, 0.85); }
#hud.title-mode .hud-hull { display: none; }
.hud-sling { color: #fff; text-shadow: var(--legible), 0 0 10px var(--accent), 0 0 26px rgba(var(--accent-rgb), 0.85); }
@keyframes perfect-flash {
  0% { opacity: 0; transform: scale(1.35); }
  12% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}
@keyframes perfect-flash-b {
  0% { opacity: 0; transform: scale(1.35); }
  12% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

.hud-zone {
  position: absolute; left: 0; right: 0; top: calc(var(--sat) + 21vh); text-align: center;
  color: var(--zone, var(--accent)); opacity: 0;
}
.hud-zone.on { animation: zone-banner 2.6s ease-out forwards; }
.hud-zone.on2 { animation: zone-banner-b 2.6s ease-out forwards; }
.hud-zone-n {
  font-weight: 800; font-size: 13px; letter-spacing: 0.5em; padding-left: 0.5em;
  text-shadow: var(--legible), 0 0 10px currentColor;
}
.hud-zone-name {
  margin-top: 6px; font-weight: 900; font-size: 34px; letter-spacing: 0.06em; color: #fff;
  text-shadow: var(--legible), 0 0 14px var(--zone, var(--accent)), 0 0 36px var(--zone, var(--accent));
}
.hud-zone-rule {
  margin: 10px auto 0; width: 64%; max-width: 280px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  box-shadow: 0 0 10px currentColor;
}
@keyframes zone-banner {
  0% { opacity: 0; transform: translateY(10px) scale(0.97); letter-spacing: 0.02em; }
  14% { opacity: 1; transform: none; }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}
@keyframes zone-banner-b {
  0% { opacity: 0; transform: translateY(10px) scale(0.97); letter-spacing: 0.02em; }
  14% { opacity: 1; transform: none; }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-6px); }
}

.hud-prompt {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 17vh); transform: translateX(-50%);
  white-space: nowrap; padding: 10px 20px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  font-weight: 600; font-size: 15px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
  text-shadow: var(--legible); opacity: 0; transition: opacity 0.25s;
}
.hud-prompt.on { opacity: 1; animation: breathe 1.8s ease-in-out infinite alternate; }
.hud-prompt b { color: #fff; font-weight: 900; text-shadow: var(--legible), 0 0 10px rgba(var(--accent-rgb), 0.9); }
@keyframes breathe { from { opacity: 0.72; } to { opacity: 1; } }

/* ============================================================== screens */
.screen {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center;
  padding: var(--sat) var(--sar) var(--sab) var(--sal); box-sizing: border-box; text-align: center;
}
.screen.on { display: flex; animation: fade-in 0.22s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.icon-btn {
  position: absolute; top: calc(var(--sat) + 6px); right: calc(var(--sar) + 8px);
  width: 48px; height: 48px; padding: 0; border: 0; background: none;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn > span {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 0 14px -4px rgba(var(--accent-rgb), 0.6);
  transition: transform 0.1s, background 0.15s;
}
.icon-btn:active > span { transform: scale(0.9); background: rgba(var(--accent-rgb), 0.2); }
.icon-btn svg { width: 20px; height: 20px; display: block; filter: drop-shadow(0 0 3px rgba(var(--accent-rgb), 0.7)); }
.pause-btn { z-index: 1; }
.pause-btn > span { width: 34px; height: 34px; }
.pause-btn svg { width: 14px; height: 14px; }

/* ---------------------------------------------------- title */
.s-title { justify-content: flex-start; }
.title-top { margin-top: calc(12vh - 10px); display: flex; flex-direction: column; align-items: center; }
.wordmark {
  position: relative; font-weight: 900; font-size: min(calc(var(--cw) * 0.132), 64px); line-height: 1;
  letter-spacing: 0.07em; padding-left: 0.07em; color: #fff;
  text-shadow: 0 0 2px #fff, 0 0 10px rgba(var(--accent-rgb), 1), 0 0 28px rgba(var(--accent-rgb), 0.75),
    0 0 64px rgba(140, 90, 255, 0.65), 0 2px 4px rgba(0, 0, 0, 0.6);
}
/* A thin orbit arc swinging under the wordmark. */
.wordmark-orbit {
  width: 104%; height: 30px; margin-top: -6px; border-radius: 50%;
  border-bottom: 2px solid rgba(var(--accent-rgb), 0.9); border-left: 1px solid transparent; border-right: 1px solid transparent;
  -webkit-mask-image: linear-gradient(90deg, transparent 4%, #000 40%, #000 70%, transparent 98%);
  mask-image: linear-gradient(90deg, transparent 4%, #000 40%, #000 70%, transparent 98%);
  filter: drop-shadow(0 0 4px rgba(var(--accent-rgb), 0.9));
  transform: rotate(-3deg);
}
.best {
  margin-top: 16px; font-weight: 700; font-size: 14px; letter-spacing: 0.2em; color: var(--muted);
  text-shadow: var(--legible); font-variant-numeric: tabular-nums; min-height: 1.2em;
}
.best b { color: #fff; font-weight: 800; letter-spacing: 0.06em; margin-left: 0.4em; font-size: 17px; }

.chips {
  margin-top: 22px; display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.chip {
  min-width: 112px; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  background: transparent; font-weight: 800; font-size: 14px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); text-shadow: var(--legible); transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.chip.sel {
  color: #fff; background: rgba(var(--accent-rgb), 0.2); border-color: rgba(var(--accent-rgb), 0.75);
  box-shadow: 0 0 16px -3px rgba(var(--accent-rgb), 0.85), inset 0 0 10px -4px rgba(var(--accent-rgb), 0.9);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.9), var(--legible);
}
.chip:active { transform: scale(0.96); }
.chip-sub { display: block; font-size: 9.5px; letter-spacing: 0.14em; font-weight: 700; opacity: 0.7; margin-top: 1px; }

.title-hint {
  position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 7vh);
  font-weight: 700; font-size: 14px; letter-spacing: 0.24em; padding-left: 0.24em; text-transform: uppercase;
  color: #fff; text-shadow: var(--legible), 0 0 12px rgba(var(--accent-rgb), 0.8);
  animation: breathe 1.6s ease-in-out infinite alternate;
}
.title-hint small {
  display: block; margin-top: 8px; font-size: 11px; letter-spacing: 0.18em; color: var(--muted); font-weight: 600;
}

/* ---------------------------------------------------- shared panels & buttons */
.scrim {
  pointer-events: auto; justify-content: center;
  background: radial-gradient(120% 80% at 50% 45%, rgba(4, 5, 16, 0.45), rgba(2, 3, 10, 0.78));
  -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2);
}
.panel { display: flex; flex-direction: column; align-items: stretch; gap: 12px; width: min(300px, calc(var(--cw) * 0.8)); }
.heading {
  font-weight: 900; font-size: 30px; letter-spacing: 0.3em; padding-left: 0.3em; margin-bottom: 14px; color: #fff;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9), 0 0 30px rgba(var(--accent-rgb), 0.5);
}
.btn {
  min-height: 52px; padding: 0 20px; border-radius: 16px; border: 1px solid var(--line);
  background: rgba(20, 26, 60, 0.55); font-weight: 800; font-size: 16px; letter-spacing: 0.14em;
  text-transform: uppercase; color: #fff; display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 0.1s, background 0.15s;
}
.btn:active { transform: scale(0.97); background: rgba(var(--accent-rgb), 0.18); }
.btn svg { width: 18px; height: 18px; }
.btn.primary {
  min-height: 60px; font-size: 18px; border-color: rgba(var(--accent-rgb), 0.85);
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.32), rgba(var(--accent-rgb), 0.14));
  box-shadow: 0 0 22px -4px rgba(var(--accent-rgb), 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9);
}
.btn.ghost { min-height: 44px; background: transparent; font-size: 13px; color: var(--muted); border-color: rgba(170, 205, 255, 0.16); }
.btn .state { color: var(--accent); font-weight: 900; }
.version { margin-top: 18px; font-size: 11px; letter-spacing: 0.16em; color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------- game over */
.s-over { justify-content: flex-start; background: radial-gradient(90% 60% at 50% 32%, rgba(2, 3, 10, 0.62), rgba(2, 3, 10, 0.25)); }
.over-top { margin-top: calc(13vh); display: flex; flex-direction: column; align-items: center; }
.label { font-weight: 800; font-size: 12px; letter-spacing: 0.4em; padding-left: 0.4em; color: var(--muted); text-shadow: var(--legible); }
.over-score {
  margin-top: 6px; font-weight: 900; font-size: min(calc(var(--cw) * 0.22), 92px); line-height: 1; color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 2px #fff, 0 0 16px rgba(var(--accent-rgb), 0.9), 0 0 44px rgba(var(--accent-rgb), 0.5), 0 3px 6px rgba(0, 0, 0, 0.6);
}
.newbest {
  margin-top: 14px; padding: 7px 16px 6px; border-radius: 999px; font-weight: 900; font-size: 13px;
  letter-spacing: 0.3em; padding-left: calc(16px + 0.3em); color: #2a1600;
  background: linear-gradient(100deg, #ffe7a3, #ffc44d 45%, #fff2c8 55%, #ffb733);
  box-shadow: 0 0 22px rgba(255, 196, 77, 0.75), 0 0 2px #fff inset;
  animation: newbest 1.4s ease-in-out infinite alternate;
}
@keyframes newbest { from { box-shadow: 0 0 12px rgba(255, 196, 77, 0.5); } to { box-shadow: 0 0 30px rgba(255, 196, 77, 0.95); } }
.over-best { margin-top: 14px; font-weight: 700; font-size: 14px; letter-spacing: 0.2em; color: var(--muted); text-shadow: var(--legible); }
.over-best b { color: #fff; letter-spacing: 0.06em; margin-left: 0.4em; font-size: 17px; }
.stats { margin-top: 30px; display: flex; gap: 12px; width: min(330px, calc(var(--cw) * 0.86)); }
.stat {
  flex: 1; padding: 14px 10px 13px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.stat-v { margin-top: 6px; font-weight: 900; font-size: 30px; line-height: 1; color: #fff; text-shadow: 0 0 12px var(--zone, rgba(var(--accent-rgb), 0.8)); font-variant-numeric: tabular-nums; }
.stat-s { margin-top: 6px; font-weight: 700; font-size: 12px; letter-spacing: 0.06em; color: var(--zone, var(--accent)); }
.label.small { font-size: 10px; letter-spacing: 0.26em; padding-left: 0.26em; }
.over-hint {
  position: absolute; left: 0; right: 0; bottom: calc(var(--sab) + 8vh);
  font-weight: 700; font-size: 14px; letter-spacing: 0.24em; padding-left: 0.24em; text-transform: uppercase;
  color: #fff; text-shadow: var(--legible), 0 0 12px rgba(var(--accent-rgb), 0.8);
  animation: breathe 1.6s ease-in-out infinite alternate;
}
.s-over.armed .over-hint { opacity: 0.25; animation: none; }

/* ---------------------------------------------------- resume / rotate */
.resume-ring {
  width: 104px; height: 104px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(var(--accent-rgb), 0.9);
  box-shadow: 0 0 30px -2px rgba(var(--accent-rgb), 0.8), inset 0 0 22px -6px rgba(var(--accent-rgb), 0.9);
  animation: ring-pulse 1.4s ease-in-out infinite alternate;
}
.resume-ring svg { width: 40px; height: 40px; margin-left: 6px; filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.9)); }
@keyframes ring-pulse { from { box-shadow: 0 0 16px -4px rgba(var(--accent-rgb), 0.6), inset 0 0 18px -8px rgba(var(--accent-rgb), 0.8); } to { box-shadow: 0 0 40px 0 rgba(var(--accent-rgb), 0.9), inset 0 0 26px -6px rgba(var(--accent-rgb), 1); } }
.big-text { margin-top: 26px; font-weight: 900; font-size: 24px; letter-spacing: 0.2em; padding-left: 0.2em; text-transform: uppercase; text-shadow: var(--legible), 0 0 16px rgba(var(--accent-rgb), 0.7); }
.sub-text { margin-top: 10px; font-weight: 600; font-size: 13px; letter-spacing: 0.12em; color: var(--muted); }

.s-rotate { justify-content: center; background: var(--bg); pointer-events: auto; }
.phone {
  width: 46px; height: 80px; border-radius: 11px; border: 3px solid #fff; position: relative;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.8), inset 0 0 10px rgba(var(--accent-rgb), 0.5);
  animation: rotate-phone 2.4s ease-in-out infinite;
}
.phone::after { content: ""; position: absolute; left: 50%; bottom: 6px; width: 14px; height: 3px; margin-left: -7px; border-radius: 2px; background: #fff; }
@keyframes rotate-phone { 0%, 25% { transform: rotate(-90deg); } 55%, 100% { transform: rotate(0deg); } }

/* ---------------------------------------------------- missions */
.missions {
  width: min(340px, calc(var(--cw) * 0.88)); box-sizing: border-box; padding: 10px 14px 8px; border-radius: 18px; text-align: left;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); pointer-events: none;
}
.missions[hidden], .mission[hidden] { display: none; }
.missions-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px;
  font-weight: 800; font-size: 10px; letter-spacing: 0.26em; color: var(--muted); text-shadow: var(--legible);
}
.missions-stars { color: var(--gold); letter-spacing: 0.08em; font-size: 12px; }
.mission {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 6px 0 8px;
  font-weight: 650; font-size: 13px; line-height: 1.2; color: var(--ink); text-shadow: var(--legible);
}
.mission-check {
  flex: none; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;
  border: 1.5px solid rgba(var(--accent-rgb), 0.75);
}
.mission-text { flex: 1; }
.mission-value { flex: none; font-weight: 800; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mission-bar { position: absolute; left: 21px; right: 0; bottom: 2px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); }
.mission-bar > span { display: block; height: 100%; width: 0; border-radius: 2px; background: rgba(var(--accent-rgb), 0.85); }
.mission:not(.started):not(.done) .mission-bar { visibility: hidden; }
.mission.done .mission-check { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 8px rgba(255, 196, 77, 0.8); }
.mission.done .mission-text { color: var(--muted); }
.mission.done .mission-bar > span { background: var(--gold); }
.mission.fresh .mission-text { color: #fff; }
.mission.fresh .mission-value { color: var(--gold); text-shadow: var(--legible), 0 0 10px rgba(255, 196, 77, 0.8); }
.title-missions { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--sab) + 7vh + 58px); }
.first-run .title-missions { display: none; }
.over-missions { margin-top: 14px; }

.hud-mission {
  /* Under the zone banner: a "reach zone N" mission finishes on the zone-change frame. */
  position: absolute; left: 0; right: 0; top: calc(var(--sat) + 21vh + 96px); text-align: center; opacity: 0;
  text-shadow: var(--legible);
}
.hud-mission-k { font-weight: 900; font-size: 12px; letter-spacing: 0.3em; padding-left: 0.3em; color: var(--gold); text-shadow: var(--legible), 0 0 10px rgba(255, 190, 80, 0.8); }
.hud-mission-t { margin-top: 4px; font-weight: 700; font-size: 15px; color: #fff; }
.hud-mission.on { animation: zone-banner 2.6s ease-out forwards; }
.hud-mission.on2 { animation: zone-banner-b 2.6s ease-out forwards; }
#hud.title-mode .hud-mission { display: none; }

/* First run: the HUD prompt "RELEASE to fling" is the one title instruction (no duplicate hint). */
.first-run .title-hint { display: none; }
.first-run #hud.title-mode .hud-prompt { bottom: calc(var(--sab) + 7vh - 8px); }

/* ============================================================== debug overlay */
#debug {
  position: absolute; left: calc(var(--sal) + 6px); top: calc(var(--sat) + 64px);
  pointer-events: none; padding: 6px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.6);
  font: 600 11px/1.35 ui-monospace, Menlo, monospace; color: #b8ffcf; white-space: pre;
  font-variant-numeric: tabular-nums;
}
#debug .warn { color: #ffb36b; }

/* ============================================================== wide / desktop */
/* Wider than a phone (laptops, desktops, tablets): the playfield is a fixed 1000 units wide and
   the camera fits it to the column, so a full-width landscape view would show far less of the
   climb ahead. The game runs in a centred portrait column instead (1:2, about a phone's shape);
   the window around it shows a dimmed backdrop and, where there is room, a how-to-play card.
   Mouse-and-keyboard devices only: a phone in Safari with its toolbars showing can be wider than
   11:20 too, and touch devices keep the full screen (landscape gets the rotate overlay). */
@media (min-aspect-ratio: 11/20) and (hover: hover) and (pointer: fine) {
  /* Half the height, but never narrower than 340px (short windows) or wider than the window. */
  :root { --cw: min(100vw, max(50vh, 340px)); --cx: calc((100vw - var(--cw)) / 2); }
  @supports (height: 100dvh) { :root { --cw: min(100vw, max(50dvh, 340px)); } }
  #debug { left: calc(var(--cx) + 6px); }
  body {
    background:
      radial-gradient(60% 70% at 18% 30%, rgba(var(--accent-rgb), 0.10), transparent 70%),
      radial-gradient(55% 65% at 85% 75%, rgba(120, 70, 220, 0.12), transparent 70%),
      var(--bg);
    transition: background 0.6s;
  }
  #game { box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.18), 0 0 60px -10px rgba(var(--accent-rgb), 0.35); }
}
.side-help { display: none; }
@media (min-aspect-ratio: 11/10) and (min-width: 880px) and (hover: hover) and (pointer: fine) {
  .side-help {
    display: block; position: absolute; z-index: 1; top: 50%; transform: translateY(-50%);
    left: calc(var(--cx) + var(--cw) + 40px); width: min(260px, calc(var(--cx) - 64px));
    pointer-events: none; text-align: left; color: var(--muted); text-shadow: var(--legible);
  }
  .side-help h2 {
    margin: 0 0 14px; font-weight: 800; font-size: 11px; letter-spacing: 0.3em; color: var(--muted);
  }
  .side-help dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: baseline; }
  .side-help dt { font-weight: 800; font-size: 12px; letter-spacing: 0.08em; color: #fff; white-space: nowrap; }
  .side-help dd { margin: 0; font-size: 13px; line-height: 1.4; }
  .side-help kbd {
    display: inline-block; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--glass); font: inherit; font-size: 11px; color: #fff;
  }
  .side-help p { margin: 18px 0 0; font-size: 12px; line-height: 1.45; color: var(--faint); }
}
@media (min-aspect-ratio: 3/4) {
  .title-hint, .over-hint { bottom: calc(var(--sab) + 6vh); }
  .title-missions { bottom: calc(var(--sab) + 6vh + 58px); }
}
/* Very short windows: the title's mission list would cover the comet (it still shows on game over). */
@media (max-height: 640px) {
  .title-missions { display: none; }
}
/* Short screens (iPhone SE and landscape laptops): tighten the game-over card so the list fits. */
@media (max-height: 720px) {
  .over-top { margin-top: 7vh; }
  .over-score { font-size: min(calc(var(--cw) * 0.18), 72px); }
  .stats { margin-top: 18px; }
  .stat { padding: 10px 8px 9px; }
  .mission { padding: 4px 0 6px; }
}

/* ============================================================== reduced motion: opacity only */
@media (prefers-reduced-motion: reduce) {
  .hud-combo.pop { animation: combo-glow 0.34s ease-out; }
  .hud-combo.pop2 { animation: combo-glow-b 0.34s ease-out; }
  @keyframes combo-glow { from { color: var(--accent); } to { color: inherit; } }
  @keyframes combo-glow-b { from { color: var(--accent); } to { color: inherit; } }
  .hud-perfect.on { animation: fade-flash 0.95s ease-out forwards; }
  .hud-perfect.on2 { animation: fade-flash-b 0.95s ease-out forwards; }
  .hud-zone.on { animation: fade-hold 2.6s ease-out forwards; }
  .hud-zone.on2 { animation: fade-hold-b 2.6s ease-out forwards; }
  .hud-mission.on { animation: fade-hold 2.6s ease-out forwards; }
  .hud-mission.on2 { animation: fade-hold-b 2.6s ease-out forwards; }
  @keyframes fade-flash { 0% { opacity: 0; } 12%, 70% { opacity: 1; } 100% { opacity: 0; } }
  @keyframes fade-flash-b { 0% { opacity: 0; } 12%, 70% { opacity: 1; } 100% { opacity: 0; } }
  @keyframes fade-hold { 0% { opacity: 0; } 14%, 78% { opacity: 1; } 100% { opacity: 0; } }
  @keyframes fade-hold-b { 0% { opacity: 0; } 14%, 78% { opacity: 1; } 100% { opacity: 0; } }
  .phone { animation: none; transform: rotate(-90deg); }
  .btn:active, .chip:active, .icon-btn:active > span { transform: none; }
}
