/* Snow Boarder — UI Styles (GDD §7: DOM overlay, crisp text) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body { 
  overflow: hidden; 
  background: #000; 
  font-family: 'Inter', system-ui, sans-serif;
  color: white;
  user-select: none;
}

input, select, textarea {
  user-select: text;
  -webkit-user-select: text;
}

canvas {
  display: block;
  border-radius: 12px;
  box-shadow:
    0 0 40px rgba(0, 255, 100, 0.08),
    0 0 80px rgba(0, 255, 100, 0.04),
    inset 0 0 30px rgba(0, 0, 0, 0.3);
}

/* ── UI Root ──────────────────────────────────────── */
#ui-root {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
}
#ui-root > div { pointer-events: auto; }

/* ── Loading Screen ──────────────────────────────── */
#loading-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #1a2a3a 0%, #0a1530 100%);
  flex-direction: column;
  z-index: 100;
}
#loading-content { text-align: center; }
#loading-content h1 {
  font-size: 52px; font-weight: 900; letter-spacing: 6px;
  color: #b8e4ff;
  text-shadow:
    0 0 20px rgba(100,200,255,0.4),
    0 0 60px rgba(80,160,255,0.2),
    0 2px 0 #0a1628;
  margin-bottom: 8px;
  position: relative;
}
#loading-content h1::after {
  content: '✦'; display: block; font-size: 18px;
  color: rgba(150,220,255,0.4); letter-spacing: 0; margin-top: -4px;
}
#loading-content .sub {
  font-size: 11px; color: rgba(150,200,255,0.35);
  letter-spacing: 8px; text-transform: uppercase;
  margin-bottom: 30px;
}
#loading-bar-track {
  width: 240px; height: 4px; background: rgba(255,255,255,0.08);
  border-radius: 2px; overflow: hidden; margin: 0 auto 12px;
}
#loading-bar-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, #4488cc, #88ddff, #4488cc);
  background-size: 200% 100%;
  border-radius: 2px; transition: width 0.3s ease;
}
#loading-text {
  font-size: 12px; color: rgba(255,255,255,0.3); letter-spacing: 2px;
}

/* ── Menu Screen ─────────────────────────────────── */
#menu-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 90;
  pointer-events: auto;
  /* PSX-era: subtle CRT scanlines over the whole menu */
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0,0,0,0.06) 0px,
      rgba(0,0,0,0.06) 1px,
      transparent 1px,
      transparent 3px
    );
}
#menu-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 40%, rgba(120,90,220,0.10) 0%, transparent 70%);
  z-index: 0;
}
#menu-content {
  text-align: center;
  /* PSX dither gradient — no blur, hard dithered bands */
  background:
    repeating-conic-gradient(
      rgba(20,28,64,0.96) 0% 25%,
      rgba(16,22,52,0.96) 0% 50%
    ) 0 0 / 4px 4px,
    linear-gradient(180deg, #1a1e3c 0%, #12142c 100%);
  border: 4px solid #3a4a8a;
  outline: 2px solid #0c0e1e;
  padding: 32px 40px 28px;
  box-shadow:
    0 0 0 2px #181c34,
    inset 0 0 0 2px #242a50,
    0 12px 0 rgba(0,0,0,0.45),
    0 20px 40px rgba(0,0,0,0.5);
  max-width: 440px;
  max-height: 92vh;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  image-rendering: pixelated;
  scrollbar-width: thin;
}
#menu-content::-webkit-scrollbar { width: 4px; }
#menu-content::-webkit-scrollbar-thumb { background: #3a4a8a; }
#menu-content::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 4px);
  pointer-events: none;
}
#menu-content h1 {
  font-family: 'PressStart', monospace;
  font-size: 26px; font-weight: 400; letter-spacing: 4px;
  color: #e8ecff;
  /* classic PSX raised title */
  text-shadow:
    2px 2px 0 #241a6e,
    -1px -1px 0 #6a5cff,
    0 0 24px rgba(120,100,255,0.45);
  margin-bottom: 2px;
  position: relative;
}
#menu-content .frost-symbol {
  font-size: 16px; color: rgba(160,170,255,0.4);
  letter-spacing: 0; margin-bottom: 6px;
}
#menu-content .tagline {
  font-family: 'PressStart', monospace;
  font-size: 8px; color: #8a9adc;
  letter-spacing: 3px; text-transform: uppercase;
  text-shadow: 1px 1px 0 #0c0e1e;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid #242a50;
}
#menu-seed-row, #menu-tier-row, #menu-name-row {
  margin: 10px 0; font-family: 'PressStart', monospace;
  font-size: 9px; color: #9aa8e0;
}
#menu-seed-row label, #menu-tier-row label, #menu-name-row label {
  margin-right: 8px; color: #6a76b8;
}
#menu-seed-input, #menu-name-input {
  background: #0c0e1e;
  border: 2px solid #3a4a8a;
  outline: 2px solid #10132a;
  color: #e8ecff; padding: 8px 10px; width: 140px;
  font-family: 'VT323', monospace; font-size: 18px;
  text-transform: uppercase; letter-spacing: 1px;
  touch-action: manipulation;
}
#menu-seed-input:focus, #menu-name-input:focus {
  border-color: #6a5cff;
  outline-color: #241a6e;
}
#menu-tier-select {
  background: #0c0e1e; border: 2px solid #3a4a8a;
  outline: 2px solid #10132a; color: #e8ecff;
  padding: 6px 8px; font-family: 'VT323', monospace; font-size: 16px;
}
#menu-buttons {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 26px; align-items: center;
}
#menu-buttons button {
  width: 240px; padding: 14px 0;
  /* PSX bevel button — raised 3D edge, flat center */
  background: linear-gradient(180deg, #4a58a8 0%, #3a4890 45%, #2c3670 55%, #242c60 100%);
  border: 3px solid;
  border-color: #8a94e8 #1a1e40 #1a1e40 #8a94e8;
  color: #f0f2ff;
  font-family: 'PressStart', monospace; font-size: 11px;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #161a3a;
  cursor: pointer;
  image-rendering: pixelated;
  transition: none;
}
#menu-buttons button:hover {
  background: linear-gradient(180deg, #5a68c0 0%, #4a58a8 45%, #384490 55%, #303c80 100%);
  border-color: #a4b0ff #20244c #20244c #a4b0ff;
}
#menu-buttons button:active {
  transform: translate(1px, 2px);
  border-color: #1a1e40 #8a94e8 #8a94e8 #1a1e40; /* pressed — inverted bevel */
  box-shadow: none;
}
#menu-buttons button::before {
  content: '▶ '; color: #ffd75e; font-size: 9px;
}
#menu-buttons button:hover::before {
  animation: psxBlink 0.8s steps(2) infinite;
}
@keyframes psxBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}
#menu-best-daily {
  margin-top: 14px; font-family: 'PressStart', monospace;
  font-size: 8px; color: #ffd75e; text-shadow: 1px 1px 0 #0c0e1e;
}
#menu-footer { margin-top: 22px; }
.small-btn {
  background: linear-gradient(180deg, #3a4890 0%, #2c3670 100%);
  border: 2px solid;
  border-color: #6a76b8 #1a1e40 #1a1e40 #6a76b8;
  color: #c8d0f8; padding: 8px 20px;
  font-family: 'PressStart', monospace; font-size: 9px;
  text-transform: uppercase; letter-spacing: 1px;
  cursor: pointer; image-rendering: pixelated;
}
.small-btn:hover { background: linear-gradient(180deg, #4a58a8 0%, #384490 100%); color: #ffffff; }
.small-btn:active {
  transform: translate(1px, 1px);
  border-color: #1a1e40 #6a76b8 #6a76b8 #1a1e40;
}

/* ── Settings ────────────────────────────────────── */
#settings-panel {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,5,12,0.92);
  z-index: 95;
}
#settings-content {
  background:
    repeating-conic-gradient(rgba(20,28,64,0.96) 0% 25%, rgba(16,22,52,0.96) 0% 50%) 0 0 / 4px 4px,
    linear-gradient(180deg, #1a1e3c 0%, #12142c 100%);
  border: 4px solid #3a4a8a; outline: 2px solid #0c0e1e;
  padding: 28px 32px; min-width: 280px; max-width: 90vw; text-align: left;
  box-shadow: 0 0 0 2px #181c34, 0 12px 0 rgba(0,0,0,0.45);
}
#settings-content h2 {
  font-family: 'PressStart', monospace;
  font-size: 16px; font-weight: 400; margin-bottom: 20px;
  text-align: center; color: #e8ecff;
  text-shadow: 2px 2px 0 #241a6e;
}
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-family: 'PressStart', monospace; font-size: 9px;
  gap: 16px; color: #9aa8e0;
}
.setting-row label { flex: 1; }
.setting-row input[type="range"] { flex: 2; accent-color: #6a5cff; }
.setting-row select {
  background: #0c0e1e; border: 2px solid #3a4a8a;
  color: #e8ecff; padding: 4px 8px;
  font-family: 'VT323', monospace; font-size: 14px;
}
#btn-settings-done {
  width: 100%; margin-top: 20px;
}

/* ── Countdown ───────────────────────────────────── */
#countdown-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
#countdown-number {
  font-size: 120px; font-weight: 900; color: white;
  text-shadow: 0 0 40px rgba(100,180,255,0.8);
  animation: countPulse 0.8s ease-out;
}
@keyframes countPulse {
  0% { transform: scale(1.5); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── HUD ─────────────────────────────────────────── */
#hud { pointer-events: none; }
#hud-top-right {
  position: fixed; top: 16px; right: 20px;
  text-align: right; z-index: 30;
  background: linear-gradient(180deg, rgba(12,16,40,0.85) 0%, rgba(8,10,28,0.85) 100%);
  border: 3px solid #3a4a8a; outline: 2px solid #0c0e1e;
  padding: 8px 14px 10px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.45);
  image-rendering: pixelated;
}
#hud-score {
  font-family: 'PressStart', monospace;
  font-size: 22px; font-weight: 400;
  color: #e8f4ff;
  text-shadow: 2px 2px 0 #241a6e;
}
#hud-multiplier {
  font-family: 'PressStart', monospace;
  font-size: 10px; color: #ffd75e;
  text-shadow: 1px 1px 0 #4a3800;
}
#hud-bottom-center {
  position: fixed; bottom: 34px; left: 50%; transform: translateX(-50%);
  text-align: center; z-index: 30;
  background: linear-gradient(180deg, rgba(12,16,40,0.85) 0%, rgba(8,10,28,0.85) 100%);
  border: 3px solid #3a4a8a; outline: 2px solid #0c0e1e;
  padding: 8px 22px 12px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.45);
}
#hud-speed {
  font-family: 'PressStart', monospace;
  font-size: 26px; font-weight: 400;
  color: #ffffff;
  text-shadow: 2px 2px 0 #241a6e;
  letter-spacing: 1px;
}
#hud-boost-track {
  width: 180px; height: 8px;
  margin: 8px auto 0;
  background: #0c0e1e;
  border: 2px solid #3a4a8a;
  outline: 1px solid #0c0e1e;
}
#hud-boost-fill {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, #2a6ac0, #44ccff);
  transition: width 0.2s ease;
}
#hud-health {
  position: fixed; bottom: 140px; left: 50%; transform: translateX(-50%);
  font-size: 20px; z-index: 30;
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.6));
  display: flex; gap: 8px;
}

/* ── PSX pixel hearts (box-shadow pixel art) ─────── */
.psx-heart {
  width: 11px; height: 10px;
  position: relative;
  display: inline-block;
  image-rendering: pixelated;
}
/* 11×10 pixel heart mask via box-shadow (4px pixels) */
.psx-heart::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 4px;
  box-shadow:
    /* row 0:  .XX.XX.  */
    4px 0 0 var(--heart-color, #ff2244),
    8px 0 0 var(--heart-color, #ff2244),
    /* row 1: XXXXXXX  */
    0px 4px 0 var(--heart-color, #ff2244),
    4px 4px 0 var(--heart-color, #ff2244),
    8px 4px 0 var(--heart-color, #ff2244),
    /* row 2: XXXXXXX  */
    0px 8px 0 var(--heart-color, #ff2244),
    4px 8px 0 var(--heart-color, #ff2244),
    8px 8px 0 var(--heart-color, #ff2244),
    /* row 3: .XXX.X.  */
    4px 12px 0 var(--heart-color, #ff2244),
    8px 12px 0 var(--heart-color, #ff2244),
    /* row 4: ..XX..   */
    4px 16px 0 var(--heart-color, #ff2244);
}
.psx-heart.empty::before {
  box-shadow:
    4px 0 0 rgba(255,255,255,0.18),
    8px 0 0 rgba(255,255,255,0.18),
    0px 4px 0 rgba(255,255,255,0.18),
    4px 4px 0 rgba(255,255,255,0.18),
    8px 4px 0 rgba(255,255,255,0.18),
    0px 8px 0 rgba(255,255,255,0.18),
    4px 8px 0 rgba(255,255,255,0.18),
    8px 8px 0 rgba(255,255,255,0.18),
    4px 12px 0 rgba(255,255,255,0.18),
    8px 12px 0 rgba(255,255,255,0.18),
    4px 16px 0 rgba(255,255,255,0.18);
}
.psx-heart.full::before {
  filter: drop-shadow(2px 2px 0 rgba(0,0,0,0.5));
}

/* ── Distance meter (center of screen) ───────────── */
#hud-distance {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 30;
  font-family: 'PressStart', monospace;
  font-size: 13px; letter-spacing: 1px;
  color: #e8f4ff;
  text-shadow: 2px 2px 0 #241a6e;
  background: linear-gradient(180deg, rgba(12,16,40,0.85) 0%, rgba(8,10,28,0.85) 100%);
  border: 3px solid #3a4a8a; outline: 2px solid #0c0e1e;
  padding: 5px 14px 7px;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.45);
  image-rendering: pixelated;
}
#hud-trick-toast {
  position: fixed; top: 35%; left: 50%; transform: translateX(-50%);
  font-family: 'PressStart', monospace;
  font-size: 18px; font-weight: 400; color: #ffcc44;
  text-shadow: 2px 2px 0 #6a4a00;
  opacity: 0; transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30; white-space: nowrap;
}
#hud-trick-toast.visible {
  opacity: 1; transform: translateX(-50%) translateY(-10px);
}
#hud-combo-toast {
  position: fixed; top: 28%; left: 50%; transform: translateX(-50%);
  font-family: 'PressStart', monospace;
  font-size: 24px; font-weight: 400; color: #ffcc00;
  text-shadow: 3px 3px 0 #8a4a00;
  opacity: 0; transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 30; white-space: nowrap; pointer-events: none;
}
#hud-combo-toast.visible {
  opacity: 1; transform: translateX(-50%) translateY(-12px);
}
#hud-gate-indicator {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 30;
}
#hud-zen-recover {
  position: fixed; bottom: 45%; left: 50%; transform: translateX(-50%);
  text-align: center; z-index: 35; display: none;
}
#hud-zen-text {
  font-family: 'PressStart', monospace;
  font-size: 20px; font-weight: 400; color: #cc88ff;
  text-shadow: 2px 2px 0 #3a1050;
  display: block; margin-bottom: 8px;
}
#hud-zen-bar {
  width: 200px; height: 16px;
  background: #0c0e1e;
  border: 3px solid #5a4a9a;
  outline: 2px solid #0c0e1e;
  margin: 0 auto;
  overflow: hidden;
}
#hud-zen-fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(90deg, #9944ff 0 8px, #44ccff 8px 16px);
  transition: width 0.1s linear;
}

/* ── Pause ───────────────────────────────────────── */
#pause-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(5,8,20,0.75);
  backdrop-filter: blur(8px);
  z-index: 70;
}
#pause-content {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background:
    repeating-conic-gradient(rgba(20,28,64,0.96) 0% 25%, rgba(16,22,52,0.96) 0% 50%) 0 0 / 4px 4px,
    linear-gradient(180deg, #1a1e3c 0%, #12142c 100%);
  border: 4px solid #3a4a8a; outline: 2px solid #0c0e1e;
  padding: 40px 48px;
  text-align: center; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 0 0 2px #181c34, 0 12px 0 rgba(0,0,0,0.45);
}
#pause-content h2 {
  font-family: 'PressStart', monospace;
  font-size: 20px; font-weight: 400; margin-bottom: 8px;
  color: #e8ecff; letter-spacing: 4px;
  text-shadow: 2px 2px 0 #241a6e;
}
#pause-content button {
  width: 220px; padding: 12px 0;
  background: linear-gradient(180deg, #3a4890 0%, #2c3670 100%);
  border: 3px solid;
  border-color: #6a76b8 #1a1e40 #1a1e40 #6a76b8;
  color: #c8d0f8; font-family: 'PressStart', monospace;
  font-size: 10px; letter-spacing: 1px;
  cursor: pointer; image-rendering: pixelated;
  text-shadow: 1px 1px 0 #161a3a;
}
#pause-content button:hover {
  background: linear-gradient(180deg, #4a58a8 0%, #384490 100%);
  color: #ffffff;
}
#pause-content button:active {
  transform: translate(1px, 2px);
  border-color: #1a1e40 #6a76b8 #6a76b8 #1a1e40;
}
#pause-content button:last-child {
  margin-top: 8px;
  background: linear-gradient(180deg, #303040 0%, #242430 100%);
  border-color: #585870 #141420 #141420 #585870;
  color: #9aa0b8;
  font-size: 9px;
}
#pause-content button:last-child:hover {
  background: linear-gradient(180deg, #484058 0%, #383048 100%);
  border-color: #8878a8 #1a1428 #1a1428 #8878a8;
  color: #ffb0a0;
}

/* ── Crash ───────────────────────────────────────── */
#crash-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(60,0,0,0.55); z-index: 55;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0 1px, transparent 1px 3px),
    rgba(60,0,0,0.55);
}
#crash-content {
  text-align: center; animation: crashIn 0.15s steps(3) both;
}
@keyframes crashIn {
  0% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
#crash-content h2 {
  font-family: 'PressStart', monospace;
  font-size: 30px; font-weight: 400; color: #ff4455;
  text-shadow: 3px 3px 0 #4a0000, -1px -1px 0 #ff8899;
}
#crash-content p {
  margin-top: 14px; font-family: 'PressStart', monospace;
  font-size: 10px; color: rgba(255,255,255,0.65);
  text-shadow: 1px 1px 0 #000;
}
#crash-content button#btn-revive {
  margin-top: 16px;
  background: linear-gradient(180deg, #c0a028 0%, #a08018 45%, #806010 55%, #6a5010 100%);
  border: 3px solid;
  border-color: #ffe87a #4a3800 #4a3800 #ffe87a;
  color: #fff8d0; font-family: 'PressStart', monospace; font-size: 10px;
  padding: 12px 18px; cursor: pointer;
  text-shadow: 2px 2px 0 #4a3800;
  animation: psxBlink 1s steps(2) infinite;
}

/* ── Score Screen ────────────────────────────────── */
#score-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,12,24,0.88);
  z-index: 70;
  overflow: hidden;
}
#score-scanlines {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  pointer-events: none; z-index: 1;
}
#score-bg-image {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: url('assets/snow-bg.png') center/cover no-repeat;
  opacity: 0.10; z-index: 1;
  filter: blur(2px);
}
#score-card {
  position: relative;
  z-index: 2;
  background:
    repeating-conic-gradient(rgba(14,20,44,0.96) 0% 25%, rgba(10,14,34,0.96) 0% 50%) 0 0 / 4px 4px,
    linear-gradient(180deg, #141838 0%, #0e1230 100%);
  border: 4px solid #3a4a8a; outline: 2px solid #0c0e1e;
  padding: 32px 40px;
  text-align: center;
  min-width: 520px;
  max-width: 600px;
  max-height: 90vh;
  box-sizing: border-box;
  box-shadow:
    0 0 0 2px #181c34,
    0 12px 0 rgba(0,0,0,0.45),
    0 20px 50px rgba(0,0,0,0.5);
  overflow-y: auto;
  image-rendering: pixelated;
}
#score-card::-webkit-scrollbar { width: 4px; }
#score-card::-webkit-scrollbar-track { background: transparent; }
#score-card::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
#score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid #242a50;
}
#score-grade {
  font-family: 'PressStart', monospace;
  font-size: 56px; font-weight: 400;
  letter-spacing: 0;
  text-shadow: 3px 3px 0 #0c0e1e;
}
#score-title {
  font-family: 'PressStart', monospace;
  font-size: 12px; font-weight: 400; letter-spacing: 3px;
  color: #6a76b8;
  text-shadow: 1px 1px 0 #0c0e1e;
}
#score-subtitle {
  font-family: 'PressStart', monospace;
  font-size: 7px; font-weight: 400; color: #3a4470;
  letter-spacing: 4px; text-transform: uppercase;
  margin-top: 4px;
}
#score-total {
  font-family: 'PressStart', monospace;
  font-size: 42px; font-weight: 400;
  color: #e8f4ff;
  text-shadow: 3px 3px 0 #241a6e, -1px -1px 0 #6a5cff;
  margin: 10px 0 4px;
  letter-spacing: 2px;
}
#score-new-best {
  display: none;
  font-family: 'PressStart', monospace;
  font-size: 10px; font-weight: 400; letter-spacing: 2px;
  color: #ffd75e;
  text-shadow: 2px 2px 0 #6a4a00;
  margin-bottom: 12px;
  animation: psxBlink 0.9s steps(2) infinite;
}
#score-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 24px;
  margin: 12px auto 16px;
  max-width: 460px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  font-size: 12px; color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
}
.score-row .score-icon { width: 20px; text-align: center; margin-right: 4px; }
.score-row .score-label { flex: 1; text-align: left; font-size: 11px; letter-spacing: 1px; font-weight: 600; color: rgba(255,255,255,0.35); }
.score-row .score-value { font-family: monospace; font-weight: 700; font-size: 14px; color: rgba(255,255,255,0.65); }
.score-row.bonus { background: rgba(255,200,100,0.03); }
.score-row.bonus .score-value { color: rgba(255,200,100,0.7); }
#score-best {
  font-size: 12px; color: rgba(255,255,255,0.25);
  margin: 4px 0 8px;
  letter-spacing: 1px;
}
#score-seed {
  font-size: 12px; color: rgba(255,255,255,0.3);
  margin-bottom: 10px;
}
#score-leaderboard {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(100,180,255,0.08);
}
#lb-title {
  font-size: 12px; font-weight: 700; letter-spacing: 3px;
  color: rgba(100,180,255,0.45);
  margin-bottom: 6px;
}
#lb-entries {
  max-height: 110px;
  overflow-y: auto;
}
#lb-entries::-webkit-scrollbar { width: 3px; }
#lb-entries::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
.lb-entry {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  border-radius: 3px;
}
.lb-entry:nth-child(odd) { background: rgba(255,255,255,0.02); }
.lb-highlight {
  background: rgba(255,204,0,0.08) !important;
  color: #ffcc44 !important;
  font-weight: 700;
}
.lb-rank { width: 26px; text-align: center; }
.lb-name { flex: 1; text-align: left; margin-left: 6px; font-weight: 600; }
.lb-score { font-family: monospace; }
.lb-empty { color: rgba(255,255,255,0.3); font-style: italic; text-align: center; padding: 6px; }
#score-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid #242a50;
}
#score-buttons button {
  padding: 10px 18px;
  background: linear-gradient(180deg, #3a4890 0%, #2c3670 100%);
  border: 3px solid;
  border-color: #6a76b8 #1a1e40 #1a1e40 #6a76b8;
  color: #c8d0f8;
  font-family: 'PressStart', monospace; font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; image-rendering: pixelated;
  text-shadow: 1px 1px 0 #161a3a;
  min-width: 90px;
}
#score-buttons button:hover {
  background: linear-gradient(180deg, #4a58a8 0%, #384490 100%);
  color: #ffffff;
}
#score-buttons button:active {
  transform: translate(1px, 2px);
  border-color: #1a1e40 #6a76b8 #6a76b8 #1a1e40;
}
#btn-retry {
  background: linear-gradient(180deg, #2a7a50 0%, #1e5c3c 100%);
  border-color: #54b884 #0c2818 #0c2818 #54b884;
  color: #a0f0c0;
}
#btn-retry:hover {
  background: linear-gradient(180deg, #349060 0%, #286c48 100%);
  border-color: #70d89c #102c1c #102c1c #70d89c;
  color: #ffffff;
}
#btn-new-seed { background: rgba(100,180,255,0.05); border-color: rgba(100,180,255,0.12); }
#btn-new-seed:hover { background: rgba(100,180,255,0.12); }
#btn-score-menu { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.08); color: rgba(255,255,255,0.35); }
#btn-score-menu:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.6); }
#btn-heli-gallery { background: rgba(200,150,80,0.08); border-color: rgba(200,150,80,0.15); color: rgba(255,200,100,0.6); font-size:13px; }
#btn-heli-gallery:hover { background: rgba(200,150,80,0.18); color: #ffcc66; }

/* ── Heli Gallery ────────────────────────────────── */
#heli-gallery-header button {
  font-family: inherit; font-size: 12px; cursor: pointer;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: #ccc; padding: 4px 12px; border-radius: 4px;
}
#heli-gallery-header button:hover {
  background: rgba(255,255,255,0.15); color: #fff;
}
#heli-gallery-grid img {
  image-rendering: auto; /* photos should be smooth */
}
#heli-gallery-grid::-webkit-scrollbar { width: 6px; }
#heli-gallery-grid::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
#heli-gallery-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* ── Dev Overlay ─────────────────────────────────── */
/* ── Mobile Touch Controls ─────────────────────── */
#mobile-controls {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 80;
  display: none; /* hidden on desktop; the (hover: none) rule below shows it */
  pointer-events: none;
  /* Both panels live in ONE full-width flex row. Flexbox cannot overlap its own
     children, so the panels can no longer collide at narrow widths. They did:
     fixed 140/160/110px buttons need 614px of width, and every phone gives the
     cabinet less than that (390x219 in portrait, 513x289 in landscape), so the
     left and right panels ran into each other and across the game. */
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  box-sizing: border-box;
  padding: 0 max(10px, 2.5vw) max(10px, 2.5vh);
}
#mobile-controls * { pointer-events: auto; }

.touch-panel {
  display: flex;
  align-items: flex-end;
  min-width: 0;
  gap: clamp(6px, 1.6vw, 16px);
}

.touch-btn {
  border: 4px solid;
  border-radius: 50%;
  font-family: 'PressStart', monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* `none`, not `manipulation`: a gesture the browser claims for panning or zooming
     fires pointercancel instead of pointerup, and the button stays stuck down. */
  touch-action: none;
  user-select: none;
  image-rendering: pixelated;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
}

.dir-btn {
  /* Sized as a share of the cabinet's OWN width, capped at the original 140px.
     vw inside the game measures the game, so this holds whether the cabinet is
     running full-screen or letterboxed inside the arcade's iframe. */
  width: clamp(56px, 19vw, 140px); height: clamp(56px, 19vw, 140px);
  background: linear-gradient(180deg, #2a3050 0%, #1a1e38 60%, #14182e 100%);
  border-color: #5a68a8 #10142c #10142c #5a68a8;
  color: #c8d0f8; font-size: clamp(20px, 6vw, 40px);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), inset 0 0 0 2px #14182e;
}
.dir-btn:active {
  background: linear-gradient(180deg, #14182e 0%, #1a1e38 60%, #2a3050 100%);
  border-color: #10142c #5a68a8 #5a68a8 #10142c;
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

.jump-btn {
  width: clamp(64px, 22vw, 160px); height: clamp(64px, 22vw, 160px);
  background: linear-gradient(180deg, #2a4a8a 0%, #1e3670 60%, #182c60 100%);
  border-color: #5a8ae8 #101c40 #101c40 #5a8ae8;
  color: #aaccff; font-size: clamp(11px, 3.4vw, 18px); letter-spacing: clamp(1px, 0.5vw, 3px);
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), inset 0 0 0 2px #182c60;
}
.jump-btn:active {
  background: linear-gradient(180deg, #182c60 0%, #1e3670 60%, #2a4a8a 100%);
  border-color: #101c40 #5a8ae8 #5a8ae8 #101c40;
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

.boost-btn {
  width: clamp(46px, 15vw, 110px); height: clamp(46px, 15vw, 110px);
  background: linear-gradient(180deg, #8a4a28 0%, #6a3418 60%, #582a14 100%);
  border-color: #e8a868 #301608 #301608 #e8a868;
  color: #ffbb88; font-size: 24px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4), inset 0 0 0 2px #582a14;
}
.boost-btn:active {
  background: linear-gradient(180deg, #582a14 0%, #6a3418 60%, #8a4a28 100%);
  border-color: #301608 #e8a868 #e8a868 #301608;
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.4);
}

/* ── Mobile: smaller HUD, bigger controls ─────── */
@media (hover: none) and (pointer: coarse) {
  #mobile-controls { display: flex; }
  #hud-speed { font-size: 28px !important; }
  #hud-health { font-size: 14px !important; bottom: 130px !important; }
  #hud-score { font-size: 22px !important; }
  #hud-multiplier { font-size: 12px !important; }
}

/* ── Mobile death/score screen — swipe-up panel ─── */
@media (hover: none) and (pointer: coarse) {
  #score-screen {
    align-items: flex-end;
    background: rgba(5,8,20,0.8);
  }
  #score-card {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 28px 20px 36px;
    background: rgba(12,18,36,0.96);
    border: none;
    border-top: 2px solid rgba(100,180,255,0.15);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
  }
  #score-header { flex-direction: row; }
  #score-grade { font-size: 48px !important; }
  #score-title { font-size: 13px !important; }
  #score-total { font-size: 36px !important; }
  #score-breakdown { grid-template-columns: 1fr; max-width: 100%; margin: 10px auto; }
  .score-row { font-size: 13px !important; padding: 5px 10px !important; }
  #score-buttons { flex-direction: row; gap: 8px; flex-wrap: wrap; justify-content: center; }
  #score-buttons button {
    width: auto; min-width: 80px; padding: 12px 16px !important;
    font-size: 13px !important; font-weight: 700;
    border-radius: 8px;
  }
  #btn-retry { background: rgba(68,200,120,0.2) !important; border-color: rgba(68,200,120,0.3) !important; }
  #score-best { font-size: 11px !important; }
  #score-new-best { font-size: 13px !important; }
  #lb-title { font-size: 11px !important; }
  .lb-entry { font-size: 11px !important; }
}

/* ── Floating score popups ─────────────────────── */
.score-popup {
  position: fixed;
  font-size: 22px; font-weight: 800;
  color: #ffcc44;
  text-shadow: 0 0 10px rgba(255,200,50,0.5), 0 2px 4px rgba(0,0,0,0.5);
  pointer-events: none; z-index: 50;
  opacity: 1; transform: translateY(0);
  transition: all 1s ease-out;
}
.score-popup.fly {
  opacity: 0; transform: translateY(-60px);
}
.score-popup.gate-pop { color: #88ccff; }
.score-popup.trick-pop { color: #ffcc44; font-size: 28px; }

/* ── Endless milestone flash ────────────────────── */
#hud-milestone {
  position: fixed; top: 30%; left: 50%; transform: translateX(-50%);
  text-align: center; pointer-events: none; z-index: 45;
  opacity: 0;
}
#hud-milestone.show {
  animation: msFlash 1.8s steps(6) both;
}
#hud-milestone .ms-main {
  font-family: 'PressStart', monospace;
  font-size: 34px; color: #ffd75e;
  text-shadow: 3px 3px 0 #6a4a00, -1px -1px 0 #fff0c0;
  letter-spacing: 2px;
}
#hud-milestone .ms-sub {
  font-family: 'PressStart', monospace;
  font-size: 11px; color: #c8d0f8;
  text-shadow: 2px 2px 0 #241a6e;
  margin-top: 8px; letter-spacing: 3px;
}
@keyframes msFlash {
  0% { opacity: 0; transform: translateX(-50%) scale(2.4); }
  15% { opacity: 1; transform: translateX(-50%) scale(1); }
  70% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1); }
}
  #pause-content { padding: 28px 36px !important; }
  #pause-content h2 { font-size: 24px !important; }
  #pause-content button { width: 180px !important; padding: 10px 0 !important; font-size: 13px !important; }
  #hud-trick-toast { font-size: 20px !important; }
  #hud-combo-toast { font-size: 24px !important; }
  #menu-content h1 { font-size: 28px !important; }
  #menu-content button { padding: 8px 16px !important; font-size: 13px !important; }
  #menu-content { max-width: 95vw; max-height: 90vh; overflow-y: auto; }
  #menu-seed-row, #menu-tier-row, #menu-name-row { font-size: 13px !important; }
  #menu-seed-row input, #menu-tier-row select, #menu-name-row input { font-size: 14px !important; padding: 6px !important; }
  #loading-content h1 { font-size: 28px !important; }
  #settings-content { max-width: 90vw; padding: 16px !important; }
  #settings-content h2 { font-size: 22px !important; }
  .setting-row { font-size: 13px !important; }
}

/* Landscape phone.
   Button sizes are deliberately NOT set here any more. clamp() on the buttons already scales
   with the cabinet's width, and a second set of fixed pixel values would contradict it on
   exactly the screens that need the scaling most — a landscape phone is 390-500px tall, so
   this block always applied there. */
@media (max-height: 500px) {
  #mobile-controls { padding-bottom: max(8px, 2vh); }
}

/* ── Error Screen ────────────────────────────────── */
#error-screen {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: #1a0a0a; z-index: 200; text-align: center;
}
#error-content h2 { font-size: 24px; color: #ff4444; margin-bottom: 12px; }
#error-content p { font-size: 14px; color: rgba(255,255,255,0.6); margin-bottom: 20px; }
#btn-reload {
  padding: 10px 30px; background: #4488cc; border: none; border-radius: 6px;
  color: white; font-family: inherit; font-size: 14px; cursor: pointer;
}

#menu-high-scores {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 8px; font-size: 13px; color: #aabbcc;
}
#menu-high-scores span { opacity: 0.8; }
#btn-copy-seed {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px; color: white; padding: 4px 8px;
  cursor: pointer; font-size: 14px;
}
#btn-copy-seed:hover { background: rgba(255,255,255,0.2); }
