/* ===== UI CSS ===== Subway Surfers Modern UI ===== */

:root {
  --bg-primary: #07070c;
  --bg-secondary: #0f0f18;
  --bg-glass: rgba(15, 15, 24, 0.88);
  --bg-glass-light: rgba(30, 30, 45, 0.6);
  --neon-pink: #ff2a6d;
  --neon-cyan: #05d9e8;
  --neon-gold: #ffd700;
  --neon-green: #00ff88;
  --neon-purple: #b829dd;
  --text-primary: #ffffff;
  --text-secondary: #9a9ab0;
  --text-muted: #5a5a70;
  --border-glow: rgba(255, 42, 109, 0.25);
  --border-cyan: rgba(5, 217, 232, 0.25);
  --shadow-pink: 0 0 25px rgba(255, 42, 109, 0.35);
  --shadow-cyan: 0 0 25px rgba(5, 217, 232, 0.35);
  --shadow-gold: 0 0 20px rgba(255, 215, 0, 0.3);
  --transition-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --font-display: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  font-family: var(--font-display);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ===== Game Container ===== */
#game-stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  z-index: 1;
}

#game-stage canvas {
  display: block;
  border-radius: var(--radius-md);
  box-shadow: 0 0 60px rgba(0,0,0,0.9), 0 0 120px rgba(255,42,109,0.08);
  border: none;
}

/* ===== Screen System ===== */
.ui-screen {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--bg-primary);
  transition: opacity 0.5s var(--transition-normal), visibility 0.5s;
}
.ui-screen.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}

/* ===== Overlay (pause/gameover) ===== */
.ui-overlay {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(7, 7, 12, 0.85);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  transition: opacity 0.35s var(--transition-normal), visibility 0.35s;
}
.ui-overlay.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}
#pause-overlay {
  background: rgba(7, 7, 12, 0.75);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
}
#gameover-overlay {
  background: rgba(7, 7, 12, 0.88);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
}

/* ===== Glass Card ===== */
.glass-card {
  background: var(--bg-glass);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: 40px 48px;
  min-width: 380px;
  text-align: center;
  box-shadow: 
    0 20px 60px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.04);
  position: relative;
  overflow: hidden;
  max-height: calc(100vh - 32px);
}
.glass-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,42,109,0.4), rgba(5,217,232,0.4), transparent);
}

/* ===== Logo / Title ===== */
.game-logo {
  font-size: 68px; font-weight: 900;
  letter-spacing: 3px; text-transform: uppercase;
  line-height: 1;
  background: linear-gradient(180deg, #fff 0%, #e0e0e0 50%, #ff2a6d 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255,42,109,0.4)) drop-shadow(0 0 40px rgba(255,42,109,0.2));
  animation: logo-breathe 3s ease-in-out infinite;
}
@keyframes logo-breathe {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(255,42,109,0.3)) drop-shadow(0 0 40px rgba(255,42,109,0.15)); }
  50% { filter: drop-shadow(0 0 30px rgba(255,42,109,0.5)) drop-shadow(0 0 60px rgba(255,42,109,0.25)); }
}

.game-logo-small {
  font-size: 42px; font-weight: 800;
  letter-spacing: 2px; text-transform: uppercase;
  background: linear-gradient(180deg, #fff 0%, #ccc 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 13px; font-weight: 500;
  letter-spacing: 8px; text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 14px 36px;
  font-size: 15px; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, var(--neon-pink), #ff5a8a);
  border: none; border-radius: var(--radius-md);
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: 0 4px 20px rgba(255,42,109,0.3);
}
.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(255,42,109,0.45);
}
.btn:hover::after {
  transform: translateX(100%);
}
.btn:active {
  transform: translateY(0);
}
.btn-outline {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.12);
  box-shadow: none;
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: rgba(255,42,109,0.4);
  color: #fff;
  box-shadow: 0 0 20px rgba(255,42,109,0.15);
}
.btn-cyan {
  background: linear-gradient(135deg, var(--neon-cyan), #3ee8f5);
  box-shadow: 0 4px 20px rgba(5,217,232,0.3);
}
.btn-cyan:hover {
  box-shadow: 0 6px 30px rgba(5,217,232,0.45);
}
.btn-gold {
  background: linear-gradient(135deg, var(--neon-gold), #ffea55);
  color: #1a1a00;
  box-shadow: 0 4px 20px rgba(255,215,0,0.3);
}
.btn-lg { padding: 16px 48px; font-size: 17px; }
.btn-sm { padding: 10px 24px; font-size: 13px; }

/* ===== Menu Layout ===== */
.menu-buttons {
  display: flex; flex-direction: column;
  gap: 14px; margin-top: 40px;
  width: 100%; max-width: 320px;
}
.menu-buttons .btn { width: 100%; }

/* ===== HUD ===== */
#hud {
  position: fixed; inset: 0;
  z-index: 150;
  pointer-events: none;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 20px 28px;
  opacity: 0;
  transition: opacity 0.4s var(--transition-normal);
}
#hud.visible { opacity: 1; }
#hud > * { pointer-events: auto; }

.hud-top {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.hud-left, .hud-right {
  display: flex; flex-direction: column; gap: 10px;
}

.hud-panel {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 10px;
}

.hud-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted);
}
.hud-value {
  font-size: 24px; font-weight: 800;
  color: #fff;
  transition: transform 0.15s ease-out;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px rgba(255,255,255,0.2);
}
.hud-value-gold {
  color: var(--neon-gold);
  text-shadow: 0 0 10px rgba(255,215,0,0.3);
}

/* Distance progress bar (bottom of screen) */
.distance-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  z-index: 160;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.distance-bar.visible {
  opacity: 1;
}
.distance-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  border-radius: 3px;
  transition: width 0.3s ease-out;
}
.distance-text {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Streak countdown bar */
.streak-bar-wrap {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.streak-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-cyan));
  border-radius: 2px;
  transition: width 0.1s linear;
}

.hud-pause-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-size: 18px;
  transition: all var(--transition-fast);
}
.hud-pause-btn:hover {
  background: rgba(255,42,109,0.15);
  border-color: rgba(255,42,109,0.3);
  box-shadow: 0 0 15px rgba(255,42,109,0.2);
}

/* Power-up indicators */
.hud-powers {
  display: flex; gap: 8px;
}
.power-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 18px;
  opacity: 0.25;
  transition: all var(--transition-fast);
  position: relative;
}
.power-icon.active {
  opacity: 1;
  box-shadow: 0 0 12px var(--shadow-color, rgba(255,255,255,0.1));
}
.power-icon.active[data-type="boots"] {
  border-color: rgba(255,170,0,0.4);
  background: rgba(255,170,0,0.08);
  --shadow-color: rgba(255,170,0,0.2);
}
.power-icon.active[data-type="fly"] {
  border-color: rgba(5,217,232,0.4);
  background: rgba(5,217,232,0.08);
  --shadow-color: rgba(5,217,232,0.2);
}
.power-icon.active[data-type="hover"] {
  border-color: rgba(0,255,136,0.4);
  background: rgba(0,255,136,0.08);
  --shadow-color: rgba(0,255,136,0.2);
}
.power-icon.warning {
  animation: powerWarning 0.4s ease-in-out infinite alternate;
}
@keyframes powerWarning {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.15); opacity: 0.6; }
}
.power-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.power-bar {
  width: 28px; height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.3s;
}
.power-wrap.active .power-bar {
  opacity: 1;
}
.power-fill {
  width: 100%; height: 100%;
  background: var(--fill-color, #fff);
  border-radius: 2px;
  transform-origin: left;
  transition: transform 0.1s linear;
}
#fill-boots { --fill-color: #ffaa00; }
#fill-fly    { --fill-color: #05d9e8; }
#fill-hover  { --fill-color: #00ff88; }

/* ===== Game Over / Win Screen ===== */
.result-title {
  font-size: 48px; font-weight: 900;
  letter-spacing: 2px; text-transform: uppercase;
  margin-bottom: 8px;
}
.result-title.lose {
  color: var(--neon-pink);
  text-shadow: 0 0 20px rgba(255,42,109,0.4);
}
.result-title.win {
  color: var(--neon-gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.4);
}

.result-stats {
  display: flex; gap: 40px;
  justify-content: center;
  margin: 28px 0;
}
.stat-item {
  text-align: center;
}
.stat-value {
  font-size: 36px; font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== How to Play Modal ===== */
.modal-content {
  max-width: 520px;
}
.controls-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 20px;
  text-align: left;
  margin: 24px 0;
}
.key-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 28px;
  padding: 0 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  font-size: 12px; font-weight: 700;
  color: var(--text-primary);
  font-family: monospace;
}
.control-desc {
  font-size: 14px; color: var(--text-secondary);
  align-self: center;
}

/* ===== Volume Slider ===== */
.volume-row {
  display: flex; align-items: center; gap: 14px;
  margin: 20px 0;
  justify-content: center;
}
.volume-slider {
  -webkit-appearance: none; appearance: none;
  width: 160px; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--neon-pink);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255,42,109,0.4);
  transition: transform var(--transition-fast);
}
.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.volume-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--neon-pink);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ===== Decorative elements ===== */
.bg-grid {
  position: fixed; inset: 0;
  z-index: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}
.bg-orb {
  position: fixed; border-radius: 50%;
  filter: blur(100px);
  pointer-events: none; z-index: 0;
  opacity: 0.4;
  animation: orb-float 8s ease-in-out infinite;
}
.bg-orb.pink {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,42,109,0.15), transparent 70%);
  top: -10%; right: -10%;
  animation-delay: 0s;
}
.bg-orb.cyan {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(5,217,232,0.12), transparent 70%);
  bottom: -10%; left: -10%;
  animation-delay: -4s;
}
@keyframes orb-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ===== Countdown overlay ===== */
.countdown-overlay {
  position: fixed; inset: 0;
  z-index: 250;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7,7,12,0.3);
  pointer-events: none;
}
.countdown-number {
  font-size: 120px; font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(255,42,109,0.5), 0 0 80px rgba(255,42,109,0.3);
  animation: count-pop 0.8s ease-out forwards;
}
@keyframes count-pop {
  0% { transform: scale(2); opacity: 0; }
  50% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* ===== Toggle Switch ===== */
.toggle-row {
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  font-size: 14px; color: var(--text-secondary);
}
.toggle-row input {
  display: none;
}
.toggle-slider {
  width: 44px; height: 24px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.toggle-row input:checked + .toggle-slider {
  background: var(--neon-pink);
}
.toggle-row input:checked + .toggle-slider::after {
  transform: translateX(20px);
}
.toggle-label {
  user-select: none;
}

/* ===== Theme Indicator ===== */
#hud-theme {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 151;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 12px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
#hud-theme.visible {
  opacity: 1;
}
#hud-theme.city { color: var(--neon-cyan); border-color: rgba(5,217,232,0.3); }
#hud-theme.neon { color: var(--neon-pink); border-color: rgba(255,42,109,0.3); }

/* ===== High Score Badge ===== */
.hud-highscore {
  position: fixed; top: 20px; right: 28px;
  z-index: 151;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.4s;
}
#hud.visible ~ .hud-highscore,
.hud-highscore.visible {
  opacity: 1;
}
.hud-highscore .hud-label {
  font-size: 9px; letter-spacing: 2px;
  color: var(--neon-gold);
}
.hud-highscore .hud-value {
  font-size: 18px; font-weight: 700;
  color: var(--neon-gold);
}

/* ===== Score pop animation ===== */
@keyframes score-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.score-pop {
  animation: score-pop 0.3s ease-out;
}

/* ===== New Record Celebration ===== */
.new-record-burst {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.new-record-burst::before {
  content: '';
  position: absolute; top: 50%; left: 50%;
  width: 0; height: 0;
  background: radial-gradient(circle, rgba(255,215,0,0.3), transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: burst-expand 0.8s ease-out forwards;
}
@keyframes burst-expand {
  0% { width: 0; height: 0; opacity: 1; }
  100% { width: 600px; height: 600px; opacity: 0; }
}
.new-record-text {
  font-size: 18px; font-weight: 700;
  letter-spacing: 4px; text-transform: uppercase;
  color: var(--neon-gold);
  text-shadow: 0 0 15px rgba(255,215,0,0.5);
  animation: record-bounce 0.6s ease-out;
}
@keyframes record-bounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== FPS Counter ===== */
#fps-counter {
  position: fixed; bottom: 12px; left: 12px;
  z-index: 151;
  font-size: 11px; font-weight: 600;
  font-family: monospace;
  color: var(--text-muted);
  background: rgba(0,0,0,0.4);
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}
#fps-counter.visible {
  opacity: 1;
}

/* ===== Touch Controls ===== */
.touch-controls {
  position: fixed; bottom: max(20px, env(safe-area-inset-bottom)); left: 0; right: 0;
  z-index: 152;
  display: flex; justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.touch-controls.visible {
  opacity: 1;
}
.touch-controls > * { pointer-events: auto; }
.touch-row {
  display: flex; align-items: center; gap: 16px;
}
.touch-col {
  display: flex; flex-direction: column; gap: 12px;
}
.touch-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.1s;
  touch-action: manipulation;
}
.touch-btn:active {
  background: rgba(255,42,109,0.25);
  border-color: rgba(255,42,109,0.4);
  transform: scale(0.92);
}
/* Hide touch controls only on mouse-first desktop devices. */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
  .touch-controls { display: none !important; }
}

/* ===== Background Particles ===== */
.bg-particles {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ===== Screen transitions ===== */
.ui-screen {
  transform: scale(1.02);
}
.ui-screen.hidden {
  transform: scale(0.98);
}

/* ===== Button ripple effect ===== */
.btn {
  position: relative; overflow: hidden;
}
.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0);
  animation: ripple-anim 0.5s linear;
  pointer-events: none;
}
@keyframes ripple-anim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ===== Achievement Toast ===== */
@keyframes toast-in {
  0% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-out {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.stat-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
}
.stat-box-value {
  font-size: 22px; font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stat-box-label {
  font-size: 10px; font-weight: 600;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Achievements ===== */
.achievements-list {
  display: flex; flex-direction: column;
  gap: 8px;
}
.achievement-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  transition: all 0.3s;
}
.achievement-item.unlocked {
  border-color: rgba(255,215,0,0.2);
  background: rgba(255,215,0,0.04);
}
.achievement-icon {
  font-size: 22px;
  opacity: 0.3;
  transition: opacity 0.3s;
}
.achievement-item.unlocked .achievement-icon {
  opacity: 1;
}
.achievement-info {
  flex: 1; text-align: left;
}
.achievement-name {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
}
.achievement-item.unlocked .achievement-name {
  color: #fff;
}
.achievement-desc {
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Loading Spinner ===== */
.loader-ring {
  width: 40px; height: 40px;
  margin: 0 auto;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--neon-pink);
  border-radius: 50%;
  animation: loader-spin 0.8s linear infinite;
}
@keyframes loader-spin {
  to { transform: rotate(360deg); }
}

/* ===== Key Hint Overlay ===== */
.key-hint {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 152;
  display: flex; gap: 20px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}
.key-hint.visible {
  opacity: 1;
}
.key-hint-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-secondary);
}
.key-hint-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  font-size: 12px; font-weight: 700;
  color: #fff;
  font-family: monospace;
}

/* ===== Responsive canvas sizing ===== */
@media (max-width: 1320px) {
  #game-stage canvas {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
  }
}

@media (max-width: 640px) {
  .glass-card {
    min-width: 0;
    width: calc(100vw - 32px);
    padding: 28px 20px !important;
    overflow-y: auto;
  }
  .game-logo {
    font-size: 42px;
    letter-spacing: 1px;
  }
  .game-logo-small {
    font-size: 28px;
    letter-spacing: 1px;
  }
  .logo-sub {
    letter-spacing: 4px;
  }
  .menu-buttons {
    max-width: none;
    margin-top: 28px;
  }
  .result-stats {
    gap: 16px;
    flex-wrap: wrap;
  }
  .key-hint {
    bottom: 110px;
    gap: 10px;
    padding: 10px 12px;
    max-width: calc(100vw - 24px);
    flex-wrap: wrap;
    justify-content: center;
  }
  .hud-top {
    align-items: flex-start;
    gap: 8px;
  }
  .hud-left {
    flex-wrap: wrap;
    gap: 8px;
  }
  .hud-panel {
    min-width: 76px;
    padding: 8px 10px;
  }
  .touch-btn {
    width: 58px;
    height: 58px;
  }
}

/* ===== Combo floating text animation ===== */
@keyframes comboFloat {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(1.0); }
}

/* Confetti animation for new record */
.confetti {
  position: fixed;
  top: -10px;
  width: 8px;
  height: 8px;
  z-index: 400;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Record pulse animations */
@keyframes recordPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@keyframes nearRecordPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
.record-pulse {
  animation: recordPulse 0.6s ease-in-out infinite;
}
.near-record-pulse {
  animation: nearRecordPulse 0.8s ease-in-out infinite;
}

/* Score popup (+1, +2, etc) */
.score-popup {
  position: fixed;
  transform: translate(-50%, -50%);
  font-size: 22px;
  font-weight: 900;
  text-shadow: 0 0 10px currentColor;
  pointer-events: none;
  z-index: 300;
  animation: scorePopupAnim 0.9s ease-out forwards;
}
@keyframes scorePopupAnim {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
  25%  { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1.0); }
}
