/* Import futuristic font - Must be first */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Custom properties for dynamic viewport */
:root {
  --vh: 1vh; /* Will be updated by JavaScript for mobile */
}

body {
  /* iOS Safari fix - don't use overflow: hidden */
  overflow: visible;
  font-family: 'Orbitron', 'Segoe UI', monospace;
  background-color: #000;
  color: #fff;
  user-select: none;
  /* Better mobile viewport handling */
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  width: 100vw;
  margin: 0;
  padding: 0;
  /* iOS specific fixes */
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Canvas styling */
canvas#webglCanvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  border: 2px solid #00ffff;
  box-shadow: 0 0 20px #00ffff40, inset 0 0 20px #00ffff20;
  /* Mobile optimized sizing */
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important; /* Dynamic viewport height */
  /* iOS specific fixes */
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  /* Prevent iOS zoom on double tap */
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Utility classes */
.hidden {
  display: none !important;
}

/* Overlay Menu System */
.overlay-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height */
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
  overflow-y: auto;
  overflow-x: hidden;
  padding: env(safe-area-inset-top, 20px) 10px env(safe-area-inset-bottom, 20px) 10px;
  /* Enhanced mobile scrolling with iOS fixes */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* Critical for iOS Safari */
  touch-action: pan-y pinch-zoom;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  /* Better iOS handling */
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  /* Prevent iOS bounce */
  overscroll-behavior: contain;
}

.menu-container {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 100, 255, 0.1));
  border: 2px solid #00ffff;
  border-radius: 15px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 0 30px #00ffff40;
  max-width: 90vw;
  width: 100%;
  /* Remove max-height constraints for iOS */
  min-height: auto;
  overflow: visible;
  margin: 10px auto;
  /* Better mobile scrolling */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #00ffff transparent;
  /* iOS safe area support */
  box-sizing: border-box;
  position: relative;
}

/* Custom scrollbar for webkit browsers */
.menu-container::-webkit-scrollbar {
  width: 8px;
}

.menu-container::-webkit-scrollbar-track {
  background: transparent;
}

.menu-container::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, #00ffff, #0080ff);
  border-radius: 4px;
}

.menu-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(45deg, #40ffff, #40a0ff);
}

.game-title {
  font-size: 3em;
  font-weight: 900;
  background: linear-gradient(45deg, #00ffff, #0080ff, #00ff80);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px #00ffff;
  margin-bottom: 30px;
  animation: glow 2s ease-in-out infinite alternate;
}

.menu-title {
  font-size: 2em;
  font-weight: 700;
  color: #00ffff;
  margin-bottom: 30px;
  text-shadow: 0 0 15px #00ffff;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin: 20px 0;
}

.menu-btn {
  padding: 18px 32px;
  font-size: 1.1em;
  font-weight: 700;
  font-family: 'Orbitron', monospace;
  background: linear-gradient(45deg, #001122, #003344);
  color: #00ffff;
  border: 2px solid #00ffff;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
  /* Enhanced mobile touch interaction */
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
  /* Better mobile touch targets */
  min-height: 56px;
  min-width: 120px;
  z-index: 100;
  /* iOS button fix */
  -webkit-appearance: none;
  appearance: none;
}

.menu-btn:disabled, .menu-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: linear-gradient(45deg, #111, #222);
  color: #666;
  border-color: #444;
}

.menu-btn:disabled:hover, .menu-btn.disabled:hover {
  transform: none;
  box-shadow: none;
  background: linear-gradient(45deg, #111, #222);
}

.menu-btn:hover {
  background: linear-gradient(45deg, #003344, #00ffff20);
  box-shadow: 0 0 20px #00ffff40;
  transform: translateY(-2px);
}

.menu-btn.primary {
  background: linear-gradient(45deg, #00ffff, #0080ff);
  color: #000;
  border-color: #00ffff;
}

.menu-btn.primary:hover {
  background: linear-gradient(45deg, #40ffff, #40a0ff);
  box-shadow: 0 0 25px #00ffff80;
}

.menu-btn.danger {
  background: linear-gradient(45deg, #ff2040, #ff6080);
  border-color: #ff4060;
}

.game-description {
  margin-top: 20px;
  font-size: 0.9em;
  color: #aaaaff;
  line-height: 1.6;
}

/* Settings specific styles */
.settings-options {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 20px 0;
  text-align: left;
}

.settings-options label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1em;
  color: #00ffff;
}

.settings-options input[type="text"] {
  background: rgba(0, 255, 255, 0.1);
  border: 1px solid #00ffff;
  border-radius: 5px;
  padding: 8px 12px;
  color: #fff;
  font-family: 'Orbitron', monospace;
  flex: 1;
}

.settings-options input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #00ffff;
}

.settings-options input[type="range"] {
  flex: 1;
  background: rgba(0, 255, 255, 0.1);
  height: 8px;
  border-radius: 4px;
  outline: none;
  accent-color: #00ffff;
}

#volumeValue {
  min-width: 40px;
  text-align: right;
  font-weight: bold;
}

/* Sound test section */
.sound-test-section {
  margin: 20px 0;
  padding: 15px;
  background: rgba(0, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid #00ffff20;
}

.sound-test-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.test-btn {
  padding: 8px 15px;
  font-size: 0.9em;
  background: linear-gradient(45deg, #001122, #003344);
  color: #00ffff;
  border: 1px solid #00ffff40;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Orbitron', monospace;
}

.test-btn:hover {
  background: linear-gradient(45deg, #003344, #00ffff20);
  border-color: #00ffff;
  box-shadow: 0 0 10px #00ffff20;
}

/* Installation instructions */
.install-instructions {
  text-align: left;
  max-height: 400px;
  overflow-y: auto;
  padding: 0 10px;
}

.install-section {
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(0, 255, 255, 0.05);
  border-radius: 10px;
  border: 1px solid #00ffff20;
}

.install-section h3 {
  color: #00ffff;
  margin-bottom: 10px;
  font-size: 1.2em;
}

.install-section ol, .install-section ul {
  margin-left: 20px;
  line-height: 1.6;
}

.install-section li {
  margin-bottom: 8px;
  color: #ccc;
}

.install-benefits {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 255, 0, 0.05));
  border: 1px solid #ffaa0040;
  padding: 15px;
  border-radius: 10px;
}

.install-benefits h4 {
  color: #ffaa00;
  margin-bottom: 10px;
}

.install-benefits ul {
  list-style: none;
  margin-left: 0;
}

.install-benefits li {
  color: #ffcc66;
  margin-bottom: 5px;
}

/* Leaderboard styles */
.leaderboard-list {
  background: rgba(0, 255, 255, 0.05);
  border: 1px solid #00ffff40;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
  max-height: 300px;
  overflow-y: auto;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #00ffff20;
  font-size: 1.1em;
}

.leaderboard-entry:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  font-weight: 700;
  color: #ffaa00;
  min-width: 40px;
}

.leaderboard-name {
  flex: 1;
  text-align: left;
  margin-left: 20px;
}

.leaderboard-score {
  font-weight: 700;
  color: #00ffff;
}

/* Final score display */
.final-score {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 255, 0, 0.1));
  border: 2px solid #ffaa00;
  border-radius: 10px;
  padding: 20px;
  margin: 20px 0;
  font-size: 1.3em;
  color: #ffaa00;
}

/* HUD System */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
  font-family: 'Orbitron', monospace;
}

.hud-section {
  position: absolute;
  pointer-events: auto;
}

/* Top HUD - Consolidated Layout */
#topHud {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 0, 0, 0.3));
  border: 1px solid #00ffff40;
  border-radius: 25px;
  padding: 15px 30px;
  backdrop-filter: blur(10px);
  /* Expanded for consolidated components */
  max-width: 900px;
  width: auto;
  flex-wrap: wrap;
  justify-content: center;
}

/* Left HUD - HIDDEN (Components moved to Top HUD) */
#leftHud {
  display: none;
}

/* Decluttered Top HUD - Minimal and clean */
#topHud.minimal-hud {
  gap: 12px;
  padding: 8px 20px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.08), rgba(0, 0, 0, 0.25));
  border: 1px solid rgba(0, 255, 255, 0.2);
  max-width: 1000px; /* Expanded for all components */
}

.hud-stat.compact {
  min-width: 60px;
  padding: 6px 10px;
  position: relative;
}

.hud-stat.compact .hud-label {
  font-size: 0.65em;
  margin-bottom: 2px;
}

.hud-stat.compact .hud-value {
  font-size: 1.2em;
}

/* Compact Reaction Time in Top HUD */
.reaction-time-compact {
  min-width: 120px;
  flex-direction: column;
  align-items: center;
}

.compact-bar {
  width: 80px;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  margin: 3px 0;
}

.compact-bar .reaction-bar {
  height: 100%;
  background: linear-gradient(90deg, #00ff00, #ffff00, #ff6600, #ff0000);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.reaction-best-compact {
  font-size: 0.6em;
  color: #ffaa00;
  text-shadow: 0 0 5px #ffaa00;
  margin-top: 2px;
}

/* Side HUD - REMOVED (Components moved to Top HUD) */
#sideHud {
  display: none;
}

/* Reaction Time Meter */
.reaction-meter {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 0, 0, 0.3));
  border: 1px solid #00ffff40;
  border-radius: 15px;
  padding: 15px 20px;
  backdrop-filter: blur(10px);
  min-width: 160px;
  text-align: center;
}

.reaction-display {
  font-size: 1.5em;
  font-weight: 900;
  color: #00ffff;
  text-shadow: 0 0 15px #00ffff;
  margin: 5px 0;
}

.reaction-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}

.reaction-bar {
  height: 100%;
  background: linear-gradient(90deg, #00ff00, #ffff00, #ff6600, #ff0000);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.reaction-best {
  font-size: 0.9em;
  color: #ffaa00;
  margin-top: 5px;
}

/* Notification Feed - REMOVED with Side HUD */

.high-score-section {
  position: relative;
}

.feed-title {
  background: linear-gradient(90deg, #00ffff, #0080ff);
  color: #000;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 0.75em;
  padding: 6px 12px;
  text-align: center;
  letter-spacing: 1px;
  border-radius: 8px 8px 0 0;
}

.bonus-notifications {
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.bonus-notification {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 255, 0, 0.1));
  border: 1px solid #ffaa00;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 5px 0;
  font-family: 'Orbitron', monospace;
  font-weight: 600;
  font-size: 0.85em;
  color: #ffaa00;
  text-shadow: 0 0 8px #ffaa0080;
  animation: slideInRight 0.4s ease-out;
  position: relative;
  overflow: hidden;
}

.bonus-notification::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 2s ease-out;
}

.bonus-notification.combo {
  border-color: #ff6600;
  color: #ff6600;
  background: linear-gradient(135deg, rgba(255, 102, 0, 0.15), rgba(255, 150, 50, 0.1));
}

.bonus-notification.reaction {
  border-color: #00ff88;
  color: #00ff88;
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.15), rgba(50, 255, 150, 0.1));
}

.bonus-notification.miss {
  border-color: #ff4444;
  color: #ff4444;
  background: linear-gradient(135deg, rgba(255, 68, 68, 0.15), rgba(255, 100, 100, 0.1));
}

.bonus-notification.penalty {
  border-color: #ff6666;
  color: #ff6666;
  background: linear-gradient(135deg, rgba(255, 102, 102, 0.15), rgba(255, 120, 120, 0.1));
}

/* Notification animations */
@keyframes slideInRight {
  0% { 
    opacity: 0; 
    transform: translateX(100%); 
  }
  100% { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Auto-remove notifications after display time */
.bonus-notification.fade-out {
  animation: slideOutRight 0.3s ease-in forwards;
}

@keyframes slideOutRight {
  0% { 
    opacity: 1; 
    transform: translateX(0); 
  }
  100% { 
    opacity: 0; 
    transform: translateX(100%); 
  }
}

/* Critical Notifications Zone (Top Left HUD) */
.critical-notifications-zone {
  position: fixed;
  top: 80px;
  left: 20px;
  width: 250px;
  max-height: 200px;
  overflow: hidden;
  pointer-events: none;
  z-index: 180;
}

.critical-notification {
  background: linear-gradient(135deg, rgba(255, 102, 0, 0.2), rgba(255, 0, 102, 0.2));
  border: 2px solid #ff6600;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 8px;
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 1.3em;
  color: #ff6600;
  text-shadow: 0 0 15px #ff6600, 0 0 30px #ff660080;
  backdrop-filter: blur(5px);
  animation: criticalSlideIn 0.6s ease-out forwards;
  transform: translateX(-300px);
}

.critical-notification.level {
  border-color: #00ffff;
  color: #00ffff;
  text-shadow: 0 0 15px #00ffff, 0 0 30px #00ffff80;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 128, 255, 0.2));
}

.critical-notification.mega {
  border-color: #ff0066;
  color: #ff0066;
  text-shadow: 0 0 20px #ff0066, 0 0 40px #ff006680;
  background: linear-gradient(135deg, rgba(255, 0, 102, 0.3), rgba(255, 102, 0, 0.3));
  font-size: 1.5em;
  animation: criticalSlideInBig 0.8s ease-out forwards;
}

.critical-notification.miss {
  border-color: #ff4444;
  color: #ff4444;
  text-shadow: 0 0 15px #ff4444, 0 0 30px #ff444480;
  background: linear-gradient(135deg, rgba(255, 68, 68, 0.25), rgba(255, 102, 102, 0.2));
  font-size: 1.3em;
}

@keyframes criticalSlideIn {
  0% { 
    transform: translateX(-300px); 
    opacity: 0; 
  }
  20% { 
    transform: translateX(10px); 
    opacity: 1; 
  }
  30% { 
    transform: translateX(-5px); 
  }
  100% { 
    transform: translateX(0); 
    opacity: 1; 
  }
}

@keyframes criticalSlideInBig {
  0% { 
    transform: translateX(-300px) scale(0.8); 
    opacity: 0; 
  }
  20% { 
    transform: translateX(15px) scale(1.1); 
    opacity: 1; 
  }
  40% { 
    transform: translateX(-5px) scale(1.05); 
  }
  100% { 
    transform: translateX(0) scale(1); 
    opacity: 1; 
  }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Floating Notifications (attached to score display) */
.floating-notifications {
  position: absolute;
  top: -15px;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 200;
}

.floating-notification {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 1.1em;
  color: #00ff88;
  text-shadow: 0 0 15px #00ff88, 0 0 30px #00ff8880;
  animation: floatUp 2s ease-out forwards;
  white-space: nowrap;
}

.floating-notification.bonus {
  color: #ffaa00;
  text-shadow: 0 0 15px #ffaa00, 0 0 30px #ffaa0080;
}

.floating-notification.combo {
  color: #ff6600;
  text-shadow: 0 0 15px #ff6600, 0 0 30px #ff660080;
  font-size: 1.4em;
}

.floating-notification.penalty {
  color: #ff4444;
  text-shadow: 0 0 15px #ff4444, 0 0 30px #ff444480;
  font-size: 1.3em;
}

.floating-notification.critical {
  color: #ff0066;
  text-shadow: 0 0 20px #ff0066, 0 0 40px #ff006680;
  font-size: 1.6em;
  animation: floatUpBig 2s ease-out forwards;
}

@keyframes floatUp {
  0% { 
    opacity: 1; 
    transform: translateX(-50%) translateY(0px) scale(1); 
  }
  20% { 
    transform: translateX(-50%) translateY(-20px) scale(1.1); 
  }
  100% { 
    opacity: 0; 
    transform: translateX(-50%) translateY(-60px) scale(0.8); 
  }
}

@keyframes floatUpBig {
  0% { 
    opacity: 1; 
    transform: translateX(-50%) translateY(0px) scale(0.8); 
  }
  15% { 
    transform: translateX(-50%) translateY(-15px) scale(1.3); 
  }
  30% { 
    transform: translateX(-50%) translateY(-25px) scale(1.1); 
  }
  100% { 
    opacity: 0; 
    transform: translateX(-50%) translateY(-80px) scale(0.7); 
  }
}

/* Combo Display - Enhanced (Top Right HUD) */
.combo-display {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 150;
  pointer-events: none;
  text-align: right;
  transform: translateY(0);
}

.combo-text {
  font-family: 'Orbitron', monospace;
  font-size: 2.2em;
  font-weight: 900;
  color: #ff6600;
  text-shadow: 0 0 20px #ff6600, 0 0 40px #ff660080;
  animation: comboGlow 0.5s ease-out;
  margin-bottom: 5px;
}

.combo-streak {
  font-family: 'Orbitron', monospace;
  font-size: 0.9em;
  font-weight: 700;
  color: #ffaa00;
  text-shadow: 0 0 10px #ffaa00;
  letter-spacing: 2px;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes comboGlow {
  0% { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* Bottom HUD */
#bottomHud {
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 0, 0, 0.3));
  border: 1px solid #00ffff40;
  border-radius: 25px;
  padding: 15px 30px;
  backdrop-filter: blur(10px);
  /* Prevent spanning on large screens */
  max-width: 500px;
  width: auto;
}

/* HUD Components */
.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative; /* Allow floating notifications to position relative to this */
  overflow: visible; /* Don't clip floating notifications */
}

.hud-stat.vertical {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 0, 0, 0.3));
  border: 1px solid #00ffff40;
  border-radius: 15px;
  padding: 15px 20px;
  backdrop-filter: blur(10px);
}

.hud-label {
  font-size: 0.8em;
  color: #00ffff;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 5px;
  text-shadow: 0 0 10px #00ffff;
}

.hud-value {
  font-size: 1.8em;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 15px #00ffff;
  animation: none;
}

.hud-value.updated {
  animation: hudPulse 0.4s ease-out;
  color: #ffaa00;
}

.hud-value.penalty-flash {
  animation: penaltyFlash 0.6s ease-out;
  color: #ff4444;
}

.hud-controls {
  display: flex;
  gap: 15px;
}

.hud-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 0, 0, 0.5));
  border: 2px solid #00ffff40;
  color: #00ffff;
  font-size: 1.2em;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.hud-btn:hover {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.4), rgba(0, 0, 0, 0.7));
  border-color: #00ffff;
  box-shadow: 0 0 20px #00ffff40;
  transform: scale(1.1);
}

.hud-info {
  font-size: 1em;
  color: #00ffff;
  font-weight: 700;
  text-shadow: 0 0 10px #00ffff;
}

/* Progress bar - Enhanced for mobile bottom position */
.progress-container {
  width: 100%; /* Full width on mobile when positioned */
  height: 8px;
  background: rgba(0, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #00ffff40;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #00ffff, #40ffff, #00ffff);
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px #00ffff;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes glow {
  from { text-shadow: 0 0 20px #00ffff; }
  to { text-shadow: 0 0 40px #00ffff, 0 0 60px #00ffff; }
}

@keyframes hudPulse {
  0% { transform: scale(1); color: #fff; }
  50% { transform: scale(1.2); color: #ffaa00; text-shadow: 0 0 20px #ffaa00; }
  100% { transform: scale(1); color: #fff; }
}

@keyframes penaltyFlash {
  0% { transform: scale(1); color: #fff; }
  25% { transform: scale(1.3); color: #ff4444; text-shadow: 0 0 25px #ff4444; }
  50% { transform: scale(1.1); color: #ff6666; text-shadow: 0 0 15px #ff6666; }
  75% { transform: scale(1.2); color: #ff4444; text-shadow: 0 0 20px #ff4444; }
  100% { transform: scale(1); color: #fff; }
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 20px #00ffff40; }
  50% { transform: scale(1.05); box-shadow: 0 0 30px #00ffff80; }
  100% { transform: scale(1); box-shadow: 0 0 20px #00ffff40; }
}

/* PWA Specific Styles - Enhanced Mobile */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    /* Better handling of notches and dynamic islands */
  }
  
  canvas#webglCanvas {
    border-radius: 0;
    border: none;
  }
  
  .game-title {
    margin-top: 20px;
  }
  
  /* PWA Mobile HUD adjustments */
  #topHud {
    top: calc(5px + env(safe-area-inset-top, 0px));
  }
  
  .notification-feed.attached-to-highscore {
    position: relative;
    top: 8px;
    width: 100%;
    max-height: 120px;
    border-radius: 8px;
    margin-top: 8px;
  }
  
  .combo-display {
    top: calc(60px + env(safe-area-inset-top, 0px));
  }
  
  .critical-notifications-zone {
    top: calc(60px + env(safe-area-inset-top, 0px));
  }
  
  #bottomHud {
    bottom: calc(5px + env(safe-area-inset-bottom, 0px));
  }
  
  #leftHud, #sideHud {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}

/* iOS Safari specific */
@supports (-webkit-touch-callout: none) {
  body {
    /* Critical: Allow natural document flow on iOS */
    overflow: auto !important;
    position: static !important;
    height: auto !important;
    /* Enhanced iOS scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  /* iOS Overlay Menu Fixes */
  .overlay-menu {
    /* Critical: Must allow scrolling on iOS */
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    /* Use absolute positioning for iOS compatibility */
    position: absolute !important;
    height: auto !important;
    min-height: 100vh !important;
    /* iOS-specific touch handling */
    touch-action: pan-y !important;
    /* Ensure proper layer composition */
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    will-change: scroll-position;
  }
  
  /* iOS Menu Container Fixes */
  .menu-container {
    /* Remove height constraints on iOS */
    max-height: none !important;
    height: auto !important;
    /* Better iOS scrolling */
    -webkit-overflow-scrolling: touch;
    overflow: visible !important;
    /* Padding adjustments for iOS safe areas */
    padding-top: max(25px, env(safe-area-inset-top, 0px));
    padding-bottom: max(25px, env(safe-area-inset-bottom, 0px));
  }
  
  /* iOS-specific game modes grid */
  .game-modes {
    /* Ensure proper touch scrolling for game mode selection */
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }
}

@keyframes slideDownUpdate {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideUpUpdate {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}

/* Install button animation */
#installButton {
  animation: installPulse 2s ease-in-out infinite;
}

@keyframes installPulse {
  0% { 
    transform: scale(1); 
    box-shadow: 0 0 0 0 rgba(0, 255, 255, 0.7); 
  }
  70% { 
    transform: scale(1.05); 
    box-shadow: 0 0 0 10px rgba(0, 255, 255, 0); 
  }
  100% { 
    transform: scale(1); 
    box-shadow: 0 0 0 0 rgba(0, 255, 255, 0); 
  }
}

/* Responsive design - COMPREHENSIVE Mobile Optimizations */
@media (max-width: 768px) {
  /* Better mobile viewport handling */
  html {
    height: 100dvh;
    height: 100vh; /* Fallback */
    font-size: 16px; /* Prevent iOS zoom */
    -webkit-text-size-adjust: 100%;
  }
  
  body {
    /* iOS scrolling fix */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    /* Better mobile sizing */
    width: 100vw;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Canvas mobile fixes */
  canvas#webglCanvas {
    border: 1px solid #00ffff;
    box-shadow: 0 0 15px #00ffff30;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 0;
  }

  /* Mobile overlay menu fixes */
  .overlay-menu {
    width: 100vw;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: env(safe-area-inset-top, 15px) 10px env(safe-area-inset-bottom, 15px) 10px;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
  }

  .game-title {
    font-size: 2em;
    margin-bottom: 20px;
    line-height: 1.1;
  }
  
  .menu-container {
    padding: 20px 15px;
    max-width: 95vw;
    width: 100%;
    margin: 0 auto;
    min-height: auto;
    box-sizing: border-box;
    position: relative;
    margin-top: 5px;
    margin-bottom: 5px;
    border-radius: 12px;
  }
  
  .menu-buttons {
    gap: 15px;
  }
  
  .menu-btn {
    padding: 20px 28px;
    font-size: 1.0em;
    min-height: 64px;
    border-radius: 14px;
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.4);
    touch-action: manipulation !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    background: linear-gradient(45deg, #002244, #004466);
    border: 3px solid #00ffff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
    z-index: 200 !important;
    position: relative;
    /* iOS button fix */
    -webkit-appearance: none;
    appearance: none;
  }
  
  /* MOBILE HUD SYSTEM - Better positioning and responsiveness */
  
  #hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    pointer-events: none;
    z-index: 100;
    font-family: 'Orbitron', monospace;
    overflow: hidden;
  }
  
  /* Mobile top HUD - Compact and efficient */
  #topHud {
    gap: 6px;
    padding: 4px 8px;
    top: env(safe-area-inset-top, 4px);
    left: 4px;
    right: 4px;
    transform: none;
    max-width: none;
    width: calc(100vw - 8px);
    border-radius: 8px;
    flex-wrap: wrap;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 255, 255, 0.3);
    backdrop-filter: blur(6px);
  }
  
  #topHud.minimal-hud {
    gap: 4px;
    padding: 3px 6px;
    font-size: 0.75em;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.05), rgba(0, 0, 0, 0.2));
    border: 1px solid rgba(0, 255, 255, 0.15);
    border-radius: 6px;
    backdrop-filter: blur(8px);
  }
  
  .hud-stat.compact {
    min-width: 48px;
    padding: 3px 6px;
    border-radius: 4px;
    margin: 1px;
  }
  
  .hud-stat.compact .hud-label {
    font-size: 0.5em;
    margin-bottom: 1px;
    opacity: 0.9;
  }
  
  .hud-stat.compact .hud-value {
    font-size: 0.9em;
    font-weight: 700;
  }
  
  /* Mobile bottom HUD - Enhanced for mobile usage */
  #bottomHud {
    bottom: max(env(safe-area-inset-bottom, 0px), 8px);
    padding: 10px 16px;
    gap: 16px;
    left: 8px;
    right: 8px;
    transform: none;
    border-radius: 12px;
    flex-wrap: nowrap;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 0, 0, 0.85));
    border: 2px solid rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    z-index: 350;
    min-height: 60px;
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Critical for mobile interaction */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    pointer-events: none !important;
  }

  /* Ensure HUD controls are touchable */
  .hud-controls {
    pointer-events: auto !important;
    z-index: 360;
    display: flex;
    gap: 8px;
    align-items: center;
  }
  
  .hud-btn {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    min-width: 52px !important;
    min-height: 52px !important;
    padding: 10px !important;
    border-radius: 8px !important;
    font-size: 1.2em !important;
    transition: all 0.15s ease;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.25), rgba(0, 0, 0, 0.7));
    border: 2px solid rgba(0, 255, 255, 0.5);
    color: #00ffff;
    /* iOS button fix */
    -webkit-appearance: none;
    appearance: none;
  }
  /* Enhanced mobile button interactions */
  .menu-btn:hover, .menu-btn:focus {
    background: linear-gradient(45deg, #003366, #006699);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.6);
    transform: scale(1.02);
  }
  
  .menu-btn:active, .menu-btn:focus:active {
    background: linear-gradient(45deg, #004488, #0088cc);
    transform: scale(0.98);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.8);
    border-color: #66ffff;
  }
  
  .menu-btn.primary {
    background: linear-gradient(45deg, #004422, #006644);
    border-color: #00ff88;
    color: #00ff88;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
  }
  
  .menu-btn.primary:active {
    background: linear-gradient(45deg, #006644, #008866);
    transform: scale(0.98);
    box-shadow: 0 0 35px rgba(0, 255, 136, 0.8);
  }
  
  .hud-btn:active, .hud-btn:focus {
    transform: scale(0.92);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.5), rgba(0, 0, 0, 0.9));
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
  }
  
  .hud-info {
    font-size: 0.8em;
    white-space: nowrap;
  }
  
  /* Compact reaction time display */
  .reaction-time-compact {
    min-width: 85px;
  }
  
  .compact-bar {
    width: 65px;
    height: 3px;
    margin: 2px 0;
  }
  
  .reaction-best-compact {
    font-size: 0.5em;
    margin-top: 1px;
  }
  /* Mobile combo display - Optimized positioning */
  .combo-display {
    top: calc(50px + env(safe-area-inset-top, 0px));
    right: 8px;
    /* Smaller for mobile */
  }
  
  .combo-text {
    font-size: 1.4em;
  }
  
  .combo-streak {
    font-size: 0.7em;
  }
  
  /* Mobile critical notifications - Less intrusive */
  .critical-notifications-zone {
    top: calc(60px + env(safe-area-inset-top, 0px));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: 240px;
    max-height: 70px;
    z-index: 150;
  }
  
  .critical-notification {
    font-size: 0.85em;
    padding: 4px 8px;
    border-radius: 6px;
    margin-bottom: 3px;
    animation-duration: 0.3s !important;
    background: linear-gradient(135deg, rgba(255, 102, 0, 0.1), rgba(255, 0, 102, 0.1)) !important;
    backdrop-filter: blur(3px);
  }
  
  /* Mobile settings and forms */
  .settings-options {
    gap: 12px;
  }
  
  .settings-options label {
    font-size: 0.9em;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .settings-options input[type="text"] {
    padding: 14px 12px;
    font-size: 0.9em;
    min-height: 48px;
    border-radius: 8px;
    /* iOS input fix */
    -webkit-appearance: none;
    appearance: none;
  }
  
  .settings-options input[type="range"] {
    min-height: 48px;
  }
  
  .sound-test-buttons {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  
  .test-btn {
    min-height: 52px;
    font-size: 0.85em;
    padding: 14px 18px;
    border-radius: 10px;
    /* iOS button fix */
    -webkit-appearance: none;
    appearance: none;
  }
  
  /* Installation instructions mobile */
  .install-instructions {
    max-height: 240px;
    font-size: 0.85em;
    -webkit-overflow-scrolling: touch;
  }
  
  .install-section {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 6px;
  }
  
  .install-section h3 {
    font-size: 1em;
  }

/* Portrait orientation specific - Optimized for mobile */
@media (max-width: 480px) and (orientation: portrait) {
  /* Better viewport handling for portrait mobile */
  html, body {
    height: 100dvh;
    height: 100vh; /* Fallback */
    -webkit-text-size-adjust: 100%;
  }
  
  .game-title {
    font-size: 1.8em;
    margin-bottom: 15px;
  }
  
  .menu-container {
    padding: 18px 12px;
    max-height: calc(100dvh - 30px);
    max-height: calc(100vh - 30px); /* Fallback */
  }
  
  #topHud {
    gap: 4px;
    padding: 3px 6px;
    font-size: 0.7em;
    top: env(safe-area-inset-top, 2px);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.02), rgba(0, 0, 0, 0.15));
    border: 1px solid rgba(0, 255, 255, 0.1);
  }
  
  .hud-stat.compact {
    min-width: 42px;
    padding: 2px 4px;
  }
  
  .hud-value {
    font-size: 1.1em;
  }
  
  .hud-label {
    font-size: 0.45em;
  }
  
  .reaction-time-compact {
    min-width: 75px;
  }
  
  #bottomHud {
    padding: 8px 12px;
    gap: 10px;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.25), rgba(0, 0, 0, 0.9));
    border: 2px solid #00ffff;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.6);
    z-index: 400;
  }
  
  .hud-btn {
    width: 48px;
    height: 48px;
    font-size: 1em;
    border-radius: 8px;
    min-width: 48px !important;
    min-height: 48px !important;
  }
  
  .combo-text {
    font-size: 1.2em;
  }
  
  .floating-notification {
    font-size: 0.8em;
  }
  
  .floating-notification.combo {
    font-size: 1.1em;
  }
  
  .floating-notification.critical {
    font-size: 1.3em;
  }
}

/* Very small mobile screens - Enhanced layout */
@media (max-width: 480px) {
  #sideHud {
    top: 75px; /* Slightly higher on very small screens */
    left: 4px;
    right: 4px;
    padding: 6px 8px;
    gap: 6px;
  }
  
  .hud-stat.vertical {
    font-size: 0.75em;
    min-width: 50px;
    padding: 4px 6px;
  }
  
  #progressBarContainer {
    left: 4px;
    right: 4px;
    padding: 6px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px)); /* Above bottom HUD */
  }
  
  #bottomHud {
    left: 4px;
    right: 4px;
    padding: 8px 12px;
    gap: 12px;
    min-height: 56px;
  }
  
  .hud-btn {
    width: 48px;
    height: 48px;
    font-size: 1em;
  }
  
  #mainTimer, #reaction {
    top: 15px;
    padding: 6px 12px;
    font-size: 0.9em;
  }
}

/* Landscape orientation specific - Optimized for phones in landscape */
@media (max-height: 500px) and (orientation: landscape) {
  /* Better landscape mobile handling */
  html, body {
    height: 100dvh;
    height: 100vh; /* Fallback */
  }
  
  .menu-container {
    max-height: calc(100dvh - 15px);
    max-height: calc(100vh - 15px); /* Fallback */
    overflow-y: auto;
    padding: 10px;
  }
  
  .game-title {
    font-size: 1.3em;
    margin-bottom: 8px;
  }
  
  .menu-buttons {
    gap: 6px;
  }
  
  .menu-btn {
    padding: 12px 18px;
    font-size: 0.85em;
    min-height: 48px;
  }
  
  #topHud {
    top: env(safe-area-inset-top, 2px);
    padding: 3px 8px;
    gap: 4px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.02), rgba(0, 0, 0, 0.12));
    border: 1px solid rgba(0, 255, 255, 0.08);
  }
  
  .hud-value {
    font-size: 1.2em;
  }
  
  #bottomHud {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 0, 0, 0.9));
    border: 2px solid #00ffff;
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.5);
    z-index: 380;
  }
  
  .hud-btn {
    width: 46px;
    height: 46px;
    font-size: 0.95em;
  }
  
  .combo-display {
    top: calc(env(safe-area-inset-top, 0px) + 20px);
  }
  
  .combo-text {
    font-size: 1.2em;
  }
  
  .critical-notifications-zone {
    top: calc(env(safe-area-inset-top, 0px) + 20px);
    max-height: 50px;
  }
  
  .critical-notification {
    font-size: 0.9em;
    padding: 4px 8px;
  }
}

/* Large mobile/small tablet - Better use of space and scrolling */
@media (min-width: 481px) and (max-width: 768px) {
  /* Ensure overlay menu scrolling works in this range */
  .overlay-menu {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y pinch-zoom !important;
    /* Prevent conflicts */
    position: fixed !important;
    z-index: 10000 !important;
  }
  
  .notification-feed {
    top: calc(90px + env(safe-area-inset-top, 0px));
    right: 15px;
    width: 220px;
    max-height: 120px;
    z-index: 165; /* Above side HUD */
    border-radius: 8px 8px 0 0; /* Connected styling */
    border-bottom: 1px solid #00ffff20;
  }
  
  #sideHud {
    top: 65%;
    right: 15px;
    transform: translateY(-50%);
  }
  
  .reaction-meter {
    min-width: 140px;
  }
  
  .sound-test-buttons {
    grid-template-columns: 1fr 1fr;
  }
  
  .combo-text {
    font-size: 1.8em;
  }
  
  .hud-value {
    font-size: 1.5em;
  }
}

/* Touch-specific improvements - Enhanced Mobile Touch Targets */
@media (hover: none) and (pointer: coarse) {
  /* Enhanced touch scrolling for all mobile devices */
  .overlay-menu {
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y pinch-zoom !important;
    overflow-y: auto !important;
    scroll-behavior: smooth;
    overscroll-behavior-y: contain;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  /* Enhanced touch targets for better mobile interaction */
  .menu-btn {
    min-height: 64px;
    padding: 20px 28px;
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.25);
    /* Better touch response */
    transition: all 0.2s ease;
  }
  
  .hud-btn {
    min-width: 52px;
    min-height: 52px;
    padding: 12px;
    /* Enhanced touch feedback */
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
  }
  
  .test-btn {
    min-height: 56px;
    padding: 16px 22px;
  }
  
  /* Better button press feedback for touch devices */
  .menu-btn:active {
    transform: scale(0.96);
    background: linear-gradient(45deg, #003366, #00ffff25);
    transition: all 0.1s ease;
  }
  
  .hud-btn:active {
    transform: scale(0.92);
    background: linear-gradient(45deg, #00ffff25, #003366);
    transition: all 0.1s ease;
  }
  
  /* Enhanced bottom HUD visibility and interaction */
  #bottomHud {
    position: fixed !important;
    z-index: 999 !important;
    bottom: max(env(safe-area-inset-bottom, 0px), 12px) !important;
    padding: 12px 20px;
    border: 2px solid #00ffff;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3), rgba(0, 0, 0, 0.9));
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.6);
  }
  
  /* Prevent text selection on touch devices */
  * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  /* Allow selection only for input elements */
  input[type="text"], input[type="range"], textarea {
    -webkit-user-select: auto;
    user-select: auto;
  }
  
  /* Enhanced iOS touch highlighting */
  .menu-btn, .hud-btn, .test-btn {
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.2);
  }
  
  /* Input improvements for touch devices */
  input[type="text"] {
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 48px;
    padding: 14px 16px;
    border-radius: 8px;
  }
  
  input[type="range"] {
    min-height: 48px;
    padding: 12px 0;
  }
}

/* Very small screens - Extreme mobile optimization */
@media (max-width: 360px) {
  .game-title {
    font-size: 1.4em;
  }
  
  .menu-container {
    padding: 10px;
  }
  
  .menu-btn {
    padding: 14px 16px;
    font-size: 0.9em;
  }
  
  #topHud {
    gap: 4px;
    padding: 4px 8px;
  }
  
  .hud-stat {
    min-width: 50px;
  }
  
  .hud-value {
    font-size: 1.1em;
  }
  
  .hud-label {
    font-size: 0.55em;
  }
  
  .notification-feed {
    width: 160px;
    max-height: 100px;
  }
  
  .bonus-notification {
    font-size: 0.6em;
  }
  
  .reaction-meter {
    min-width: 90px;
    padding: 6px 8px;
  }
  
  .combo-text {
    font-size: 1.2em;
  }
}

/* iOS Safari specific improvements - Fixed scrolling */
@supports (-webkit-touch-callout: none) {
  html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
  }
  
  body {
    /* Critical iOS fix - allow natural document flow */
    position: static !important;
    height: auto !important;
    overflow: visible !important;
    -webkit-overflow-scrolling: touch;
    /* Better iOS viewport */
    min-height: 100vh;
    min-height: 100dvh;
    /* iOS touch improvements */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    overscroll-behavior: contain;
  }
  
  .overlay-menu {
    /* Critical for iOS scrolling */
    position: fixed !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y pinch-zoom !important;
    /* Better iOS performance */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  .menu-container {
    /* Remove height constraints on iOS */
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    /* iOS margin fixes */
    margin: env(safe-area-inset-top, 10px) auto env(safe-area-inset-bottom, 10px) auto;
  }
  
  /* Canvas fixes for iOS */
  #webglCanvas {
    position: fixed !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    touch-action: none !important;
  }
  
  /* Better iOS button styling */
  .menu-btn, .hud-btn {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 12px;
  }
}

/* Game Mode Selection Styles - CLEAN IMPLEMENTATION */
.game-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 30px 0;
  max-width: 100%;
  width: 100%;
}

.mode-card {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1));
  border: 2px solid #00ffff40;
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.mode-card:hover {
  border-color: #00ffff;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 128, 255, 0.2));
  box-shadow: 0 0 25px #00ffff40;
  transform: translateY(-5px) scale(1.02);
}

.mode-card:hover::before {
  left: 100%;
}

.mode-card:hover h3 {
  color: #ffffff;
  text-shadow: 0 0 15px #00ffff;
  font-weight: 900;
}

.mode-card:hover p {
  color: #f0f0f0;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

.mode-card:hover .mode-stats {
  background: rgba(0, 255, 255, 0.5);
  color: #ffffff;
  text-shadow: 0 0 10px #00ffff;
  font-weight: 800;
}

.mode-card:hover .mode-icon {
  color: #ffffff;
  text-shadow: 0 0 25px #00ffff;
  transform: scale(1.2);
}

.mode-card.selected {
  border-color: #00ffff;
  box-shadow: 0 0 30px #00ffff60;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 128, 255, 0.2));
}

.mode-card[data-mode="multiplayer"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.mode-card[data-mode="multiplayer"]:hover {
  transform: none;
  box-shadow: none;
}

.mode-icon {
  font-size: 3em;
  margin-bottom: 15px;
  filter: drop-shadow(0 0 10px #00ffff60);
}

.mode-card h3 {
  font-size: 1.3em;
  margin-bottom: 15px;
  color: #00ffff;
  font-weight: 700;
}

.mode-card p {
  font-size: 0.9em;
  line-height: 1.4;
  margin-bottom: 15px;
  color: #ccc;
}

.mode-stats {
  font-size: 0.8em;
  color: #00ffff;
  font-weight: 600;
  background: rgba(0, 255, 255, 0.1);
  padding: 8px 12px;
  border-radius: 20px;
  display: inline-block;
}

/* Mobile Layout - Single Column */
@media (max-width: 768px) {
  .game-modes {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 20px 0;
  }
  
  .mode-card {
    padding: 16px;
    min-height: 140px;
    border-radius: 12px;
  }
  
  .mode-card:active {
    transform: scale(0.98);
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.15), rgba(0, 128, 255, 0.15));
  }
  
  .mode-icon {
    font-size: 2.2em;
    margin-bottom: 10px;
  }
  
  .mode-card h3 {
    font-size: 1.1em;
    margin-bottom: 8px;
  }
  
  .mode-card p {
    font-size: 0.85em;
    line-height: 1.3;
    margin-bottom: 8px;
  }
  
  .mode-stats {
    font-size: 0.75em;
    padding: 6px 10px;
  }
}

/* Desktop Override - Force Grid Layout */
@media (min-width: 769px) {
  .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 20px !important;
    margin: 30px 0 !important;
  }
  
  .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 200px !important;
    padding: 25px !important;
  }
}

/* EMERGENCY OVERRIDE - Maximum CSS Specificity for Desktop */
@media screen and (min-width: 769px) {
  html body .overlay-menu .menu-container .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 20px !important;
    margin: 30px 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
  }
  
  html body .overlay-menu .menu-container .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 200px !important;
    padding: 25px !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1)) !important;
    border: 2px solid #00ffff40 !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  
  html body .overlay-menu .menu-container .mode-card:hover {
    border-color: #00ffff !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3), rgba(255, 255, 255, 0.2)) !important;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.8) !important;
    transform: translateY(-5px) scale(1.05) !important;
  }
  
  html body .overlay-menu .menu-container .mode-card:hover h3 {
    color: #ffffff !important;
    text-shadow: 0 0 20px #00ffff !important;
    font-weight: 900 !important;
  }
  
  html body .overlay-menu .menu-container .mode-card:hover p {
    color: #f0f0f0 !important;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.6) !important;
  }
  
  html body .overlay-menu .menu-container .mode-card:hover .mode-stats {
    background: rgba(0, 255, 255, 0.6) !important;
    color: #ffffff !important;
    text-shadow: 0 0 15px #00ffff !important;
    font-weight: 800 !important;
  }
  
  html body .overlay-menu .menu-container .mode-card:hover .mode-icon {
    color: #ffffff !important;
    text-shadow: 0 0 30px #00ffff !important;
    transform: scale(1.3) !important;
  }
}

/* Large Screens - 2 Column Layout */
@media (min-width: 1200px) {
  .game-modes {
    max-width: 1000px;
    margin: 0 auto;
    grid-template-columns: repeat(2, 1fr);
    gap: 25px;
  }
  
  .mode-card {
    min-height: 220px;
    padding: 30px;
  }
}

/* Very Large Screens - 3 Column Layout */
@media (min-width: 1600px) {
  .game-modes {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
  }
}



@media (max-width: 480px) {
  .overlay-menu {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 3px;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y pinch-zoom !important;
    overscroll-behavior: contain;
    /* Ensure proper stacking */
    z-index: 10000 !important;
    /* Hardware acceleration for smooth scrolling */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* iOS specific fixes */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
  }
  
  .menu-container {
    padding: 12px 8px;
    max-width: 99vw;
    border-radius: 12px;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    /* Force proper box sizing */
    box-sizing: border-box !important;
    /* Ensure proper content flow */
    min-height: auto;
    position: relative;
  }
  
  .game-title {
    font-size: 1.5em;
    margin-bottom: 12px;
    line-height: 1.1;
  }
  
  .menu-title {
    font-size: 1.2em;
    margin-bottom: 12px;
  }
  
  .game-modes {
    gap: 10px;
    margin: 12px 0;
  }
  
  .mode-card {
    padding: 14px;
    min-height: 120px;
  }
  
  .mode-icon {
    font-size: 1.8em;
    margin-bottom: 8px;
  }
  
  .mode-card h3 {
    font-size: 1em;
    margin-bottom: 6px;
  }
  
  .mode-card p {
    font-size: 0.8em;
    margin-bottom: 6px;
  }
  
  .mode-stats {
    font-size: 0.7em;
    padding: 4px 8px;
  }
  
  .menu-btn {
    padding: 14px 16px;
    font-size: 0.9em;
    border-radius: 10px;
  }
}

/* Extra small screens - Ultra compact */
@media (max-width: 360px) {
  .game-title {
    font-size: 1.3em;
    margin-bottom: 10px;
  }
  
  .mode-card {
    padding: 12px;
    min-height: 110px;
  }
  
  .mode-icon {
    font-size: 1.6em;
    margin-bottom: 6px;
  }
  
  .mode-card h3 {
    font-size: 0.95em;
    margin-bottom: 5px;
  }
  
  .mode-card p {
    font-size: 0.75em;
    margin-bottom: 5px;
  }
}

/* Leaderboard mode icon styles */
.leaderboard-mode {
  font-size: 1.2em;
  margin-right: 8px;
  filter: drop-shadow(0 0 5px #00ffff60);
}

/* Multiplayer UI Styles */
.multiplayer-dialog, .waiting-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(15px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
}

.multiplayer-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin: 30px 0;
  max-width: 600px;
}

.multiplayer-option {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1));
  border: 2px solid #00ffff40;
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  transition: all 0.3s ease;
}

.multiplayer-option:hover {
  border-color: #00ffff;
  box-shadow: 0 0 25px #00ffff40;
  transform: translateY(-3px);
}

.multiplayer-option h3 {
  font-size: 1.3em;
  margin-bottom: 10px;
  color: #00ffff;
  font-weight: 700;
}

.multiplayer-option p {
  color: #ccc;
  margin-bottom: 15px;
  line-height: 1.4;
}

.room-code-input {
  width: 100%;
  max-width: 200px;
  padding: 10px 15px;
  margin: 10px 0;
  background: rgba(0, 255, 255, 0.1);
  border: 2px solid #00ffff40;
  border-radius: 8px;
  color: #fff;
  font-family: 'Orbitron', monospace;
  font-size: 1em;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.room-code-input:focus {
  outline: none;
  border-color: #00ffff;
  box-shadow: 0 0 15px #00ffff40;
}

.room-info {
  text-align: center;
  margin: 30px 0;
}

.room-code-display {
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(0, 128, 255, 0.2));
  border: 2px solid #00ffff;
  border-radius: 15px;
  padding: 20px;
  margin: 20px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  flex-wrap: wrap;
}

.room-label {
  color: #ccc;
  font-size: 1em;
}

.room-code {
  font-size: 1.5em;
  font-weight: 700;
  color: #00ffff;
  letter-spacing: 3px;
  font-family: 'Orbitron', monospace;
}

.copy-btn {
  padding: 8px 15px;
  background: rgba(0, 255, 255, 0.2);
  border: 1px solid #00ffff;
  border-radius: 8px;
  color: #00ffff;
  cursor: pointer;
  font-family: 'Orbitron', monospace;
  font-size: 0.9em;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  background: rgba(0, 255, 255, 0.3);
  box-shadow: 0 0 10px #00ffff40;
}

.waiting-indicator {
  text-align: center;
  margin: 30px 0;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.loading-dots span {
  width: 12px;
  height: 12px;
  background: #00ffff;
  border-radius: 50%;
  animation: loadingPulse 1.5s infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loadingPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.opponent-display {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #00ffff40;
  border-radius: 10px;
  padding: 15px;
  color: #fff;
  font-family: 'Orbitron', monospace;
  z-index: 1001;
}

.opponent-name {
  color: #00ffff;
  font-weight: 700;
  margin-right: 15px;
}

.opponent-score {
  color: #ccc;
}

/* Responsive multiplayer styles */
@media (max-width: 768px) {
  .multiplayer-options {
    grid-template-columns: 1fr;
    gap: 15px;
    margin: 20px 0;
  }
  
  .multiplayer-option {
    padding: 20px;
  }
  
  .room-code-display {
    flex-direction: column;
    gap: 10px;
  }
  
  .room-code {
    font-size: 1.3em;
    letter-spacing: 2px;
  }
}

/* XR (VR/AR) Button Styles */
.xr-btn {
  transition: all 0.3s ease !important;
}

.xr-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.xr-btn:active {
  transform: translateY(0) scale(0.98);
}

/* XR Overlay Styles */
#xr-overlay {
  animation: fadeIn 0.5s ease-out;
}

#xr-buttons {
  animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Mobile debugging and accessibility */
@media (hover: none) and (pointer: coarse) {
  body::before {
    content: 'Mobile v19';
    position: fixed;
    top: 5px;
    right: 5px;
    background: rgba(0, 255, 0, 0.8);
    color: white;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 4px;
    z-index: 10000;
    pointer-events: none;
    font-family: 'Orbitron', monospace;
  }
}

/* Mobile Rotation Notification */
.rotate-notification {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-family: 'Orbitron', monospace;
}

.rotate-content {
  text-align: center;
  color: #00ffff;
  padding: 30px;
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 100, 255, 0.1));
  border: 2px solid #00ffff;
  border-radius: 20px;
  max-width: 320px;
}

.rotate-icon {
  font-size: 4em;
  margin-bottom: 20px;
  animation: bounce 1.5s ease-in-out infinite;
}

.rotate-content h3 {
  font-size: 1.3em;
  margin-bottom: 15px;
  color: #00ffff;
  font-weight: 700;
}

.rotate-content p {
  font-size: 1em;
  margin-bottom: 25px;
  color: #ccc;
  line-height: 1.4;
}

.rotate-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-size: 1.5em;
}

.phone-portrait, .phone-landscape {
  transition: transform 0.3s ease;
}

.phone-portrait {
  animation: rotateFromPortrait 2s ease-in-out infinite;
}

.arrow {
  color: #ffaa00;
  font-weight: bold;
  animation: pulse 1s ease-in-out infinite;
}

.phone-landscape {
  animation: rotateToLandscape 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

@keyframes rotateFromPortrait {
  0%, 50% { transform: rotate(0deg); }
  75%, 100% { transform: rotate(90deg); }
}

@keyframes rotateToLandscape {
  0%, 50% { transform: rotate(0deg) scale(1); }
  75%, 100% { transform: rotate(0deg) scale(1.2); color: #00ffff; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

/* Desktop and Tablet Game Mode Grid - CRITICAL FIX FOR VISIBILITY */
@media (min-width: 769px) {
  .overlay-menu .menu-container .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    flex-direction: initial !important;
    gap: 20px !important;
    margin: 30px 0 !important;
  }
  
  .overlay-menu .menu-container .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 200px !important;
    padding: 25px !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1)) !important;
    border: 2px solid #00ffff40 !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
  }
  
  .overlay-menu .menu-container .mode-card:hover {
    border-color: #00ffff !important;
    box-shadow: 0 0 25px #00ffff40 !important;
    transform: translateY(-5px) scale(1.02) !important;
  }
}

/* DEBUG: Force mode cards to be visible and hoverable on all large screens */
@media (min-width: 769px) {
  .game-modes {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
  }
  
  .mode-card {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  /* Force hover state to be visible */
  .mode-card:hover {
    border: 3px solid #00ffff !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.4), rgba(255, 255, 255, 0.1)) !important;
    transform: scale(1.05) translateY(-5px) !important;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.8) !important;
    z-index: 10 !important;
  }
  
  .mode-card:hover * {
    color: #ffffff !important;
    text-shadow: 0 0 15px #00ffff !important;
  }
}

/* EMERGENCY DESKTOP GRID - HIGHEST PRIORITY */
@media (min-width: 769px) {
  .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    flex-direction: row !important;
    gap: 20px !important;
    margin: 30px 0 !important;
  }
  
  .mode-card:hover {
    border-color: #00ffff !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3), rgba(0, 128, 255, 0.3)) !important;
    transform: translateY(-5px) scale(1.05) !important;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.6) !important;
  }
  
  .mode-card:hover h3 {
    color: #ffffff !important;
    text-shadow: 0 0 15px #00ffff !important;
    font-weight: 900 !important;
  }
  
  .mode-card:hover p {
    color: #f0f0f0 !important;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.5) !important;
  }
  
  .mode-card:hover .mode-stats {
    background: rgba(0, 255, 255, 0.5) !important;
    color: #ffffff !important;
    text-shadow: 0 0 10px #00ffff !important;
    font-weight: 800 !important;
  }
  
  .mode-card:hover .mode-icon {
    color: #ffffff !important;
    text-shadow: 0 0 25px #00ffff !important;
    transform: scale(1.2) !important;
    transition: all 0.3s ease !important;
  }
}

/* ULTRA SPECIFIC DESKTOP OVERRIDE - Maximum CSS specificity */
@media screen and (min-width: 769px) {
  body .overlay-menu .menu-container .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    flex-direction: initial !important;
    gap: 20px !important;
    margin: 30px 0 !important;
    width: 100% !important;
  }
  
  body .overlay-menu .menu-container .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 200px !important;
    padding: 25px !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1)) !important;
    border: 2px solid #00ffff40 !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  body .overlay-menu .menu-container .mode-card:hover {
    border-color: #00ffff !important;
    box-shadow: 0 0 25px #00ffff40 !important;
    transform: translateY(-5px) scale(1.02) !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.25), rgba(0, 128, 255, 0.25)) !important;
  }
  
  body .overlay-menu .menu-container .mode-card:hover h3 {
    color: #ffffff !important;
    text-shadow: 0 0 15px #00ffff !important;
    font-weight: 900 !important;
  }
  
  body .overlay-menu .menu-container .mode-card:hover p {
    color: #f5f5f5 !important;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.4) !important;
  }
  
  body .overlay-menu .menu-container .mode-card:hover .mode-stats {
    background: rgba(0, 255, 255, 0.4) !important;
    color: #ffffff !important;
    text-shadow: 0 0 10px #00ffff !important;
    font-weight: 800 !important;
  }
  
  body .overlay-menu .menu-container .mode-card:hover .mode-icon {
    color: #ffffff !important;
    text-shadow: 0 0 20px #00ffff !important;
    transform: scale(1.1) !important;
  }
}

/* Large Screen Optimizations - Prevent UI spanning */
@media (min-width: 1200px) {
  /* Constrain menu container width for better readability */
  .menu-container {
    max-width: 800px;
    padding: 50px;
  }
  
  /* Game modes grid improvement for large screens - FORCE VISIBILITY */
  .game-modes {
    max-width: 1000px !important;
    margin: 0 auto !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 25px !important;
    display: grid !important;
    flex-direction: initial !important;
  }
  
  /* Ensure mode cards are visible and properly sized on large screens */
  .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 220px !important;
    padding: 30px !important;
    border-radius: 15px !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1)) !important;
    border: 2px solid #00ffff40 !important;
  }
  
  /* HUD positioning improvements for large screens */
  #topHud {
    top: 30px;
    max-width: 700px;
    gap: 40px;
  }
  
  #leftHud {
    left: 30px;
    max-width: 300px;
  }
  
  #sideHud {
    right: 30px;
    max-width: 320px;
  }
  
  #bottomHud {
    bottom: 30px;
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: 600px;
    gap: 30px;
    /* Ensure centered positioning is maintained */
    position: fixed !important;
    right: auto !important;
    width: auto !important;
  }
  
  /* Notification positioning for large screens */
  .critical-notifications-zone {
    left: 30px;
    top: 100px;
    max-width: 350px;
  }
  
  .combo-display {
    top: 30px;
    right: 30px;
  }
  
  /* Game title scaling for large screens */
  .game-title {
    font-size: 3.5em;
  }
  
  .menu-title {
    font-size: 2.5em;
  }
}

/* Ultra-wide screen optimizations */
@media (min-width: 1600px) {
  .menu-container {
    max-width: 1000px;
  }
  
  .game-modes {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1200px;
    display: grid !important; /* Ensure visibility */
  }
  
  #topHud {
    max-width: 800px;
  }
  
  #bottomHud {
    max-width: 700px;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
}

/* Desktop HUD positioning - Override mobile styles for screens >= 769px */
@media (min-width: 769px) {
  #bottomHud {
    /* Restore desktop centering - override mobile positioning */
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: auto !important;
    max-width: 500px;
    position: fixed !important;
    bottom: 20px;
    /* Restore desktop styling */
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 0, 0, 0.3));
    border: 1px solid #00ffff40;
    padding: 15px 30px;
    gap: 20px;
  }
  
  /* CRITICAL: Ensure game modes are visible on desktop - override mobile flex */
  .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    flex-direction: initial !important;
    gap: 20px !important;
    margin: 30px 0 !important;
  }
  
  .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 200px !important;
    padding: 25px !important;
    border-radius: 15px !important;
  }
  
  /* Ensure proper hover effects on desktop */
  .mode-card:hover {
    border-color: #00ffff;
    box-shadow: 0 0 25px #00ffff40;
    transform: translateY(-5px) scale(1.02);
  }
}

/* CRITICAL DESKTOP OVERRIDE - Highest specificity to ensure game mode cards show */
@media (min-width: 769px) and (max-width: 9999px) {
  body .overlay-menu .menu-container .game-modes {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    flex-direction: initial !important;
    gap: 20px !important;
    margin: 30px 0 !important;
  }
  
  body .overlay-menu .menu-container .game-modes .mode-card {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    min-height: 200px !important;
    padding: 25px !important;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1), rgba(0, 128, 255, 0.1)) !important;
    border: 2px solid #00ffff40 !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
  }
}