/* ==========================================================================
   PERFECT STOP - Precision Mobile Game Stylesheet
   Modern Cyberpunk / Neon Minimalist Theme - Mobile First & iOS/Android Optimized
   ========================================================================== */

:root {
  --bg-color: #05060e;
  --bg-gradient: radial-gradient(circle at 50% 25%, #161c40 0%, #0b0e24 52%, #05060e 90%);
  --surface-color: rgba(255, 255, 255, 0.08);
  --surface-border: rgba(0, 240, 255, 0.22);
  --surface-glass: rgba(14, 18, 42, 0.9);
  
  --primary-cyan: #00f0ff;
  --primary-cyan-glow: rgba(0, 240, 255, 0.65);
  --primary-cyan-trans: rgba(0, 240, 255, 0);

  --neon-green: #00ff9d;
  --neon-green-glow: rgba(0, 255, 157, 0.65);
  --neon-green-trans: rgba(0, 255, 157, 0);

  --neon-gold: #ffcc00;
  --neon-gold-glow: rgba(255, 204, 0, 0.7);
  --neon-gold-trans: rgba(255, 204, 0, 0);

  --neon-purple: #d946ef;
  --neon-purple-glow: rgba(217, 70, 239, 0.65);
  --neon-purple-trans: rgba(217, 70, 239, 0);

  --neon-coral: #ff1a6b;
  --neon-coral-glow: rgba(255, 26, 107, 0.65);
  --neon-coral-trans: rgba(255, 26, 107, 0);

  --text-main: #ffffff;
  --text-muted: #9fb0d8;
  --text-dark: #040814;

  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --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);
}

/* Wide color gamut enhancement for iOS / Apple OLED screens */
@supports (color: color(display-p3 1 1 1)) {
  :root {
    --primary-cyan: color(display-p3 0 0.94 1);
    --primary-cyan-glow: color(display-p3 0 0.94 1 / 0.65);
    --primary-cyan-trans: color(display-p3 0 0.94 1 / 0);
    --neon-green: color(display-p3 0 1 0.62);
    --neon-green-glow: color(display-p3 0 1 0.62 / 0.65);
    --neon-green-trans: color(display-p3 0 1 0.62 / 0);
    --neon-gold: color(display-p3 1 0.82 0);
    --neon-gold-glow: color(display-p3 1 0.82 0 / 0.7);
    --neon-gold-trans: color(display-p3 1 0.82 0 / 0);
    --neon-coral: color(display-p3 1 0.08 0.4);
    --neon-coral-glow: color(display-p3 1 0.08 0.4 / 0.65);
    --neon-coral-trans: color(display-p3 1 0.08 0.4 / 0);
  }
}

/* Base Reset & Mobile Lock */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-display);
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Container */
#app {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  z-index: 1;
}

/* Canvas Background Layer */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Ambient Background Glow */
.ambient-glow {
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.45) 0%, rgba(0, 240, 255, 0.22) 25%, rgba(0, 240, 255, 0.08) 50%, rgba(0, 240, 255, 0) 70%);
  top: 40%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  -webkit-transform: translate3d(-50%, -50%, 0);
  filter: blur(20px);
  -webkit-filter: blur(20px);
  opacity: 0.7;
  pointer-events: none;
  transition: opacity 0.5s ease, background 0.5s ease;
  z-index: 0;
  will-change: transform, opacity;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.ambient-glow.gold {
  background: radial-gradient(circle, rgba(255, 204, 0, 0.5) 0%, rgba(255, 204, 0, 0.25) 25%, rgba(255, 204, 0, 0.08) 50%, rgba(255, 204, 0, 0) 70%);
  opacity: 0.75;
}

.ambient-glow.danger {
  background: radial-gradient(circle, rgba(255, 26, 107, 0.45) 0%, rgba(255, 26, 107, 0.22) 25%, rgba(255, 26, 107, 0.08) 50%, rgba(255, 26, 107, 0) 70%);
  opacity: 0.7;
}

/* ==========================================================================
   TOP HUD
   ========================================================================== */
.top-hud {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  pointer-events: auto;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.score-container {
  display: flex;
  flex-direction: column;
}

.hud-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hud-value {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  font-family: var(--font-mono);
  color: #ffffff;
  text-shadow: 0 0 16px rgba(0, 240, 255, 0.4), 0 0 30px rgba(0, 240, 255, 0.2);
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hud-value.bump {
  transform: scale(1.18);
  color: var(--neon-gold);
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.8), 0 0 40px rgba(255, 204, 0, 0.4);
}

.hud-sub-stats {
  display: flex;
  gap: 12px;
  margin-top: 2px;
}

.sub-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.sub-stat-item span.highlight {
  color: var(--primary-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

/* Center Combo & Level Pill */
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.level-badge {
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(0, 240, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s ease;
}

.level-badge.boss {
  border-color: var(--neon-gold);
  color: var(--neon-gold);
  box-shadow: 0 0 18px rgba(255, 204, 0, 0.6), 0 4px 15px rgba(0, 0, 0, 0.5);
}

.combo-pill {
  opacity: 0;
  transform: translateY(-8px) scale(0.9);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  background: linear-gradient(135deg, #ff0055 0%, #ff3366 50%, #ff7700 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 12px;
  letter-spacing: 0.5px;
  box-shadow: 0 0 20px rgba(255, 0, 85, 0.75), 0 0 40px rgba(255, 119, 0, 0.4);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 4px;
}

.combo-pill.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.combo-pill.fire {
  background: linear-gradient(135deg, #ff2200 0%, #ff6600 50%, #ffcc00 100%);
  box-shadow: 0 0 25px rgba(255, 204, 0, 0.9), 0 0 45px rgba(255, 34, 0, 0.5);
  animation: pulse-combo 0.6s infinite alternate ease-in-out;
}

@keyframes pulse-combo {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

/* Right HUD Controls & Lives */
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hud-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.9);
  background: rgba(0, 240, 255, 0.2);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-btn.muted {
  color: var(--text-muted);
  border-color: rgba(255, 255, 255, 0.08);
}

/* Lives / Hearts Bar */
.lives-container {
  display: flex;
  gap: 5px;
  align-items: center;
  background: var(--surface-glass);
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.heart-icon {
  width: 14px;
  height: 14px;
  fill: var(--neon-coral);
  filter: drop-shadow(0 0 6px rgba(255, 26, 107, 0.8));
  transition: all 0.3s ease;
}

.heart-icon.lost {
  fill: rgba(255, 255, 255, 0.2);
  filter: none;
  transform: scale(0.85);
}

/* ==========================================================================
   GAMEPLAY CENTER AREA
   ========================================================================== */
.gameplay-area {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 20px 0;
}

/* Modifier Notification Banner */
.modifier-banner {
  margin-bottom: 24px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.45);
  padding: 6px 16px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #00f0ff;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.25);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
  animation: banner-appear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modifier-banner.gold {
  background: rgba(255, 204, 0, 0.16);
  border-color: rgba(255, 204, 0, 0.55);
  color: #ffcc00;
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.3);
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.6);
}

@keyframes banner-appear {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Precision Track Wrapper */
.track-container {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.track-container.slow-mo {
  transform: scale(1.05);
}

/* The physical track bar */
.track-bar {
  width: 100%;
  height: 68px;
  position: relative;
  background: #0b0e22;
  border-radius: 20px;
  border: 2px solid rgba(0, 240, 255, 0.28);
  box-shadow: 
    inset 0 2px 12px rgba(0, 0, 0, 0.8),
    0 10px 30px rgba(0, 0, 0, 0.6),
    0 0 25px rgba(0, 240, 255, 0.12);
  overflow: hidden;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Center guide grid lines inside track */
.track-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.track-center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* Target Zone */
.target-zone {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.38) 0%, rgba(0, 255, 157, 0.28) 100%);
  border: 2px solid #00f0ff;
  box-shadow: 
    0 0 18px rgba(0, 240, 255, 0.6),
    inset 0 0 14px rgba(0, 240, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.target-zone.gold {
  background: linear-gradient(180deg, rgba(255, 204, 0, 0.42) 0%, rgba(255, 140, 0, 0.3) 100%);
  border-color: #ffcc00;
  box-shadow: 0 0 22px rgba(255, 204, 0, 0.75), inset 0 0 14px rgba(255, 204, 0, 0.45);
}

.target-zone.decoy {
  background: rgba(217, 70, 239, 0.25);
  border: 2px dashed #d946ef;
  box-shadow: 0 0 14px rgba(217, 70, 239, 0.5);
}

/* Perfect Center Bullseye Line in Target */
.target-center-bullseye {
  position: absolute;
  width: 4px;
  top: 4px;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border-radius: 2px;
  box-shadow: 0 0 10px #ffffff, 0 0 20px #00f0ff;
}

.target-center-bullseye::before,
.target-center-bullseye::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 10px #ffffff, 0 0 16px #00f0ff;
}

.target-center-bullseye::before { top: -2px; }
.target-center-bullseye::after { bottom: -2px; }

/* Blind Spot Zone (Level Modifier) */
.blind-spot-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    45deg,
    rgba(5, 6, 14, 0.94),
    rgba(5, 6, 14, 0.94) 10px,
    rgba(22, 28, 62, 0.96) 10px,
    rgba(22, 28, 62, 0.96) 20px
  );
  border-left: 2px dashed rgba(0, 240, 255, 0.4);
  border-right: 2px dashed rgba(0, 240, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.65);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  text-transform: uppercase;
  pointer-events: none;
  z-index: 2;
}

/* The Moving Marker Needle */
.marker-needle {
  position: absolute;
  top: -6px;
  bottom: -6px;
  left: 0;
  width: 8px;
  margin-left: -4px;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 
    0 0 14px #ffffff,
    0 0 25px #ffcc00,
    0 0 40px rgba(255, 204, 0, 0.6);
  z-index: 5;
  transition: opacity 0.15s ease;
  pointer-events: none;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

.marker-needle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 12px;
  background: #ffcc00;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 0 8px #ffcc00);
}

.marker-needle::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 12px;
  background: #ffcc00;
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
  filter: drop-shadow(0 0 8px #ffcc00);
}

.marker-needle.ghost {
  opacity: 0 !important;
}

.marker-needle.locked {
  background: #ffffff;
  box-shadow: 0 0 20px #ffffff, 0 0 40px #00f0ff;
}

/* Caliper Measurement Marker Lock Overlay */
.caliper-ruler {
  position: absolute;
  top: -10px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  color: #ffcc00;
  background: rgba(6, 8, 20, 0.95);
  border: 1.5px solid #ffcc00;
  padding: 2px 12px;
  border-radius: 12px;
  box-shadow: 0 0 18px rgba(255, 204, 0, 0.6);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.caliper-ruler.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* Stop Judgement Popups */
.judgement-display {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 24px;
  pointer-events: none;
}

.judgement-text {
  font-size: 46px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1;
  opacity: 0;
  transform: scale(0.5) translateY(20px);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.judgement-text.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.judgement-text.perfect {
  color: #ffcc00;
  text-shadow: 
    0 0 15px rgba(255, 204, 0, 0.95),
    0 0 35px rgba(255, 204, 0, 0.7),
    0 0 60px rgba(255, 140, 0, 0.5);
  animation: slam-impact 0.35s ease-out;
}

.judgement-text.great {
  color: #00f0ff;
  text-shadow: 
    0 0 15px rgba(0, 240, 255, 0.95),
    0 0 35px rgba(0, 240, 255, 0.7),
    0 0 60px rgba(0, 150, 255, 0.5);
}

.judgement-text.good {
  color: #00ff9d;
  text-shadow: 
    0 0 15px rgba(0, 255, 157, 0.95),
    0 0 30px rgba(0, 255, 157, 0.6);
}

.judgement-text.miss {
  color: #ff1a6b;
  text-shadow: 
    0 0 15px rgba(255, 26, 107, 0.95),
    0 0 35px rgba(255, 26, 107, 0.7);
  animation: shake-miss 0.4s ease;
}

@keyframes slam-impact {
  0% { transform: scale(2.2); opacity: 0; }
  60% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake-miss {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.judgement-subtext {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.25s ease 0.08s;
}

.judgement-subtext.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   BOTTOM PROMPT / CONTROLS
   ========================================================================== */
.bottom-area {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tap-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  animation: pulse-tap 1.6s infinite ease-in-out;
}

.tap-prompt-icon {
  width: 32px;
  height: 32px;
  fill: #00f0ff;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.8));
}

.tap-prompt-text {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.4);
}

/* Bottom Stats Ribbon */
.bottom-ribbon {
  display: flex;
  justify-content: space-around;
  width: 100%;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 10px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.ribbon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ribbon-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ribbon-value {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--text-main);
}

/* ==========================================================================
   MODALS & OVERLAYS (Start, Game Over, Pause, Stats)
   ========================================================================== */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 6, 14, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: #0f132b;
  background: linear-gradient(180deg, #181e42 0%, #0c0f24 100%);
  border: 1.5px solid rgba(0, 240, 255, 0.3);
  border-radius: 28px;
  padding: 28px 24px;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.8),
    0 0 35px rgba(0, 240, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

/* Logo & Titles */
.game-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.logo-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #00f0ff;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid rgba(0, 240, 255, 0.4);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.game-title {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: -0.5px;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 15%, #38bdf8 55%, #00f0ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #00f0ff;
  text-shadow: 0 0 30px rgba(0, 240, 255, 0.4);
  text-transform: uppercase;
  display: inline-block;
}

.modal-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
  max-width: 320px;
}

/* Mode Selection Pills */
.mode-selector {
  display: flex;
  width: 100%;
  background: rgba(6, 8, 20, 0.7);
  border-radius: 16px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--surface-border);
}

.mode-tab {
  flex: 1;
  padding: 10px 8px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab.active {
  background: #00f0ff;
  color: #040814;
  font-weight: 900;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.7);
}

/* Modal Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin-bottom: 24px;
}

.stats-card {
  background: rgba(8, 10, 26, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stats-card.highlight {
  border-color: rgba(255, 204, 0, 0.6);
  background: rgba(255, 204, 0, 0.1);
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.2);
}

.stats-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stats-card-value {
  font-size: 22px;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.stats-card.highlight .stats-card-value {
  color: #ffcc00;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

/* Primary Action Buttons */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.btn-primary {
  width: 100%;
  padding: 16px 20px;
  border-radius: 18px;
  border: none;
  background: linear-gradient(135deg, #00f0ff 0%, #00c6ff 50%, #0077ff 100%);
  color: #040814;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.5), 0 0 35px rgba(0, 240, 255, 0.25);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 10px rgba(0, 240, 255, 0.5);
}

.btn-secondary {
  width: 100%;
  padding: 14px 20px;
  border-radius: 18px;
  border: 1px solid rgba(0, 240, 255, 0.3);
  background: rgba(18, 24, 52, 0.85);
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary:active {
  transform: scale(0.96);
  background: rgba(0, 240, 255, 0.2);
}

.btn-secondary svg,
.btn-primary svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* New High Score Banner */
.high-score-banner {
  background: linear-gradient(135deg, rgba(255, 204, 0, 0.3) 0%, rgba(255, 140, 0, 0.3) 100%);
  border: 1.5px solid #ffcc00;
  color: #ffcc00;
  padding: 8px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
  box-shadow: 0 0 22px rgba(255, 204, 0, 0.7);
  animation: pulse-high-score 1s infinite alternate ease-in-out;
}

@keyframes pulse-high-score {
  from { transform: scale(0.98); }
  to { transform: scale(1.02); box-shadow: 0 0 28px rgba(255, 204, 0, 0.9); }
}

/* Instructions Row in Start Modal */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  text-align: left;
  margin-bottom: 20px;
  background: rgba(6, 8, 20, 0.6);
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

.rule-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--primary-cyan);
}

/* Toast Notification (Share clipboard fallback) */
.toast-msg {
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(14, 18, 42, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid #00f0ff;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 240, 255, 0.6);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Screen Flash overlay for PERFECT */
.screen-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  transition: opacity 0.08s ease-out;
}

.screen-flash.flash {
  opacity: 0.35;
}

/* Mobile landscape warning / adapt */
@media (max-height: 500px) and (orientation: landscape) {
  #app {
    padding: 8px 16px;
  }
  .track-bar {
    height: 52px;
  }
  .judgement-display {
    min-height: 70px;
    margin-top: 10px;
  }
  .judgement-text {
    font-size: 32px;
  }
  .hud-value {
    font-size: 28px;
  }
}
