body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #16213e 25%, #0f1020 50%, #0a0c1a 100%);
  background-attachment: fixed;
  font-family: 'Segoe UI', Arial, sans-serif;
  overflow: hidden;
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  /* Flex column so the HUD takes its natural height and the canvas fills
     all remaining space — no hardcoded pixel arithmetic needed. */
  display: flex;
  flex-direction: column;
  touch-action: none; /* Prevent default touch behaviors */
  -webkit-touch-callout: none; /* Disable iOS callouts */
  -webkit-user-select: none; /* Disable text selection */
  user-select: none;
}

/* Force portrait orientation for mobile devices */
@media (max-width: 768px) and (orientation: landscape) {
  body::after {
    content: 'Please rotate your device to portrait mode for the best gaming experience';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1.2em;
    z-index: 1000;
    padding: 20px;
  }
}

/* Cosmic background effects */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(2px 2px at 20px 30px, #eee, transparent),
    radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 90px 40px, #fff, transparent),
    radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
    radial-gradient(2px 2px at 160px 30px, #fff, transparent);
  background-repeat: repeat;
  background-size: 200px 100px;
  animation: sparkle 20s linear infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes sparkle {
  from { transform: translateY(0px); }
  to { transform: translateY(-100px); }
}

#canvas-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  /* Let the body flexbox drive height: flex: 1 fills all space below the HUD.
     No hardcoded pixel arithmetic — this works correctly at any HUD height and
     in fullscreen mode.  Safe-area padding keeps entities above the Android
     gesture navigation bar without needing env() in a height calc. */
  flex: 1;
  min-height: 0;
  padding: 0 0 env(safe-area-inset-bottom, 0px) 0;
  box-sizing: border-box;
  margin: 0;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

#game {
  background: linear-gradient(135deg, rgba(5,10,20,0.95) 0%, rgba(10,20,35,0.9) 50%, rgba(5,15,25,0.95) 100%);
  outline: none;
  display: block;
  /* Use flex: 1 instead of height: 100% so the canvas fills the
     content-box of the container (which excludes the safe-area padding). */
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none; /* Remove all borders for true fullscreen */
  border-radius: 0; /* Remove border radius for true fullscreen */
  box-shadow: none; /* Remove shadows for true fullscreen */
  overflow: hidden;
  touch-action: none; /* Prevent scrolling/zooming on canvas */
}

/* Desktop: Scale canvas to mobile aspect ratio for consistent gameplay */
@media (min-width: 769px) {
  #canvas-container {
    max-width: 500px; /* Limit width to create mobile-like aspect ratio */
    margin: 0 auto; /* Center the canvas */
  }
}

/* Mobile portrait optimization */
@media (max-width: 768px) and (orientation: portrait) {
  #canvas-container {
    width: 100vw; /* Full width on mobile */
  }
}

#game::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 25% 25%, rgba(138, 246, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(255, 231, 90, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Modern HUD styling - dedicated area above game canvas */
#hud-container {
  position: relative;
  z-index: 101; /* Above overlay to ensure buttons are clickable */
  display: flex;
  justify-content: center;
  background: linear-gradient(135deg, rgba(15,25,45,0.95) 0%, rgba(25,35,55,0.95) 100%);
  border-bottom: 2px solid rgba(79, 172, 254, 0.5);
  backdrop-filter: blur(10px);
  min-height: 70px;
  flex-shrink: 0; /* Prevent HUD from shrinking */
  /* Neon glow effect for top bar */
  box-shadow: 
    0 0 10px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(79, 172, 254, 0.2),
    0 2px 20px rgba(79, 172, 254, 0.1);
}

#hud {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  pointer-events: auto;
  border: none;
  flex-wrap: wrap;
  justify-content: space-between;
  width: 100%;
  max-width: none;
}

/* Mobile portrait HUD optimization */
@media (max-width: 768px) and (orientation: portrait) {
  #hud-container {
    min-height: 80px;
  }
  
  #hud {
    gap: 12px;
    padding: 8px 12px;
    flex-direction: column;
    justify-content: center;
  }
  
  #score-block {
    order: 1;
    width: 100%;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
  }
  
  #hud-buttons {
    order: 2;
    justify-content: center;
    margin-top: 4px;
  }
}

#score-block {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

#level, #score, #best-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1.4em;
  color: #fff;
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.15) 0%, rgba(138, 246, 246, 0.1) 100%);
  padding: 6px 12px;
  border-radius: 10px;
  box-shadow: 
    0 2px 8px rgba(79, 172, 254, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 0 1px rgba(79, 172, 254, 0.3);
  backdrop-filter: blur(3px);
  border: 1px solid rgba(79, 172, 254, 0.2);
  /* Subtle neon glow */
  position: relative;
}

#level::before, #score::before, #best-score::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(45deg, 
    rgba(79, 172, 254, 0.3) 0%, 
    rgba(138, 246, 246, 0.2) 50%, 
    rgba(79, 172, 254, 0.3) 100%);
  border-radius: 11px;
  z-index: -1;
  opacity: 0.5;
}

/* Improved mobile score adjustments */
@media (max-width: 768px) {
  #score-block {
    gap: 8px;
  }
  
  #level, #score, #best-score {
    font-size: 0.95em;
    padding: 4px 8px;
    gap: 4px;
    flex: 1;
    min-width: 0; /* Allow shrinking */
    justify-content: center;
  }
  
  .score-label {
    font-size: 0.65em;
  }
  
  .score-value {
    font-size: 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.score-label {
  font-size: 0.65em;
  color: #4facfe;
  font-weight: 600;
  margin-right: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.score-value {
  font-weight: 800;
  color: #ffe75a;
  text-shadow: 
    0 2px 12px rgba(255, 231, 90, 0.6), 
    0 0 4px #fff,
    0 1px 2px rgba(0,0,0,0.8);
  font-family: 'Courier New', monospace;
}

#hud-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

#hud button, #reduce-effects {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #e8f4f8;
  font-size: 1.1em;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 0 2px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 2px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 8px rgba(79, 172, 254, 0.2);
  display: flex;
  align-items: center;
  pointer-events: auto;
  backdrop-filter: blur(3px);
  position: relative;
  /* Neon glow border effect */
}

#hud button::before, #reduce-effects::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(45deg, 
    rgba(79, 172, 254, 0.4) 0%, 
    rgba(138, 246, 246, 0.3) 50%, 
    rgba(79, 172, 254, 0.4) 100%);
  border-radius: 9px;
  z-index: -1;
  opacity: 0.6;
}

#hud button:hover, #reduce-effects:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%);
  box-shadow: 
    0 6px 20px rgba(79, 172, 254, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 0 15px rgba(79, 172, 254, 0.6);
  transform: translateY(-2px);
  color: #fff;
  border-color: rgba(79, 172, 254, 0.7);
}

#hud button:hover::before, #reduce-effects:hover::before {
  opacity: 0.8;
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.4);
}

#hud button:active, #reduce-effects:active {
  transform: translateY(0px);
  box-shadow: 
    0 2px 8px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(79, 172, 254, 0.4);
}

/* Mobile button adjustments */
@media (max-width: 768px) {
  #hud-buttons {
    gap: 10px;
  }
  
  #hud button, #reduce-effects {
    font-size: 1em;
    padding: 6px 10px;
  }
}

.icon {
  font-size: 1.1em;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}
#reduce-effects {
  gap: 4px;
  font-size: 1em;
  padding-right: 10px;
}

#effects-toggle {
  accent-color: #ffe75a;
  width: 16px; 
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
  filter: drop-shadow(0 2px 4px rgba(255, 231, 90, 0.3));
}

/* Enhanced Overlay styling */
.overlay-content {
  background: linear-gradient(135deg, rgba(15,25,45,0.95) 0%, rgba(25,35,55,0.9) 50%, rgba(10,20,40,0.95) 100%);
  padding: 48px 40px 40px 40px;
  border-radius: 24px;
  color: #fff;
  box-shadow: 
    0 20px 60px rgba(0,0,0,0.5),
    0 0 0 1px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
  text-align: center;
  backdrop-filter: blur(20px);
  border: 1px solid rgba(79, 172, 254, 0.2);
  position: relative;
  overflow: hidden;
}

.overlay-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 30% 20%, rgba(138, 246, 246, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(255, 231, 90, 0.08) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

.overlay-content h1 {
  font-size: 3.5em;
  margin: 0 0 32px 0;
  background: linear-gradient(135deg, #4facfe 0%, #8af6f6 50%, #ffe75a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 4px 16px rgba(79, 172, 254, 0.3);
  font-weight: 800;
  letter-spacing: 2px;
  position: relative;
}

.overlay-content h1::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4facfe, transparent);
  box-shadow: 0 0 8px rgba(79, 172, 254, 0.5);
}

.overlay-content h2 {
  font-size: 2.8em;
  margin: 0 0 24px 0;
  color: #ff6b6b;
  text-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
  font-weight: 700;
}

.overlay-content p {
  font-size: 1.4em;
  margin: 0 0 32px 0;
  color: #b8d4f0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Button styling for start screen */
.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.start-buttons button {
  min-width: 200px;
}

/* Version display on start screen */
.version-display {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1em;
  margin: -16px 0 24px 0;
  font-family: 'Courier New', monospace;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* Info screen styling */
#info-screen {
  max-width: 800px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  text-align: left;
}

#info-screen h2 {
  text-align: center;
  margin-bottom: 24px;
}

.info-content {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}

.info-section h3 {
  color: #4facfe;
  margin: 0 0 8px 0;
  font-size: 1.2em;
  text-shadow: 0 1px 3px rgba(79, 172, 254, 0.5);
}

.info-section p {
  margin: 0 0 8px 0;
  line-height: 1.5;
  font-size: 1em;
}

.info-section p strong {
  color: #ffe75a;
  text-shadow: 0 1px 2px rgba(255, 231, 90, 0.5);
}

/* Mobile responsive info screen */
@media (max-width: 768px) {
  #info-screen {
    padding: 24px 20px;
    max-height: 85vh;
  }
  
  .info-section h3 {
    font-size: 1.1em;
  }
  
  .info-section p {
    font-size: 0.95em;
  }
  
  .start-buttons {
    gap: 12px;
  }
  
  .start-buttons button {
    min-width: 180px;
  }
}
  line-height: 1.6;
  max-width: 500px;
  margin: 0 auto 32px auto !important;
  color: #a8c8e8 !important;
  text-align: center;
}

.overlay-content button {
  background: linear-gradient(135deg, #00ffff 0%, #0080ff 100%) !important;
  border: none !important;
  color: #000 !important;
  padding: 12px 24px !important;
  border-radius: 8px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  margin: 5px !important;
  transition: transform 0.2s ease !important;
  font-size: 1.2em !important;
  min-width: 150px !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  letter-spacing: normal !important;
}

.overlay-content button:hover {
  transform: scale(1.05) !important;
  background: linear-gradient(135deg, #00ffff 0%, #0080ff 100%) !important;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.5) !important;
  color: #000 !important;
}

.overlay-content button::before {
  display: none !important;
}

.overlay-content button:active {
  transform: scale(1.02) !important;
}



#overlay {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#overlay:not(.hidden) {
  background: radial-gradient(ellipse at center, rgba(15,25,45,0.8) 0%, rgba(5,10,25,0.9) 100%);
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

#overlay .overlay-content {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

#joystick {
  position: absolute;
  left: 0;
  top: 0;
  width: 180px;
  height: 180px;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  touch-action: none; /* Prevent scrolling when using joystick */
}

/* Mobile joystick adjustments */
@media (max-width: 768px) {
  #joystick {
    width: 150px;
    height: 150px;
  }
}

#joy-base {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.15);
  border: 2px solid rgba(0, 255, 255, 0.6);
  box-shadow: 
    0 0 20px rgba(0, 255, 255, 0.4),
    inset 0 0 20px rgba(0, 255, 255, 0.1);
  position: absolute;
  left: 15px; 
  top: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile joy-base adjustments */
@media (max-width: 768px) {
  #joy-base {
    width: 120px;
    height: 120px;
    left: 15px;
    top: 15px;
  }
}

#joy-knob {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00ffff 0%, #0080ff 50%, #004080 100%);
  border: 2px solid rgba(0, 255, 255, 0.8);
  box-shadow: 
    0 4px 15px rgba(0, 255, 255, 0.6),
    inset 0 2px 8px rgba(255, 255, 255, 0.3);
  position: absolute;
  left: 60px;
  top: 60px;
  transition: left 0.06s, top 0.06s;
}

/* Mobile joy-knob adjustments */
@media (max-width: 768px) {
  #joy-knob {
    width: 50px;
    height: 50px;
    left: 50px;
    top: 50px;
  }
}

/* Version info styling - hidden during gameplay */
#version-info {
  position: fixed;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  right: 10px;
  z-index: 15;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* During active gameplay, hide version info immediately (no fade) so it
   doesn't flash across the nav-bar area when the game starts. */
body.game-playing #version-info {
  display: none;
}

/* Sales pitch styling */
#sales-pitch {
  margin: 20px 0;
  padding: 15px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 165, 0, 0.1) 100%);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 10px;
  text-align: center;
}

#sales-pitch p {
  margin: 8px 0;
  color: #ffd700;
}

/* Discount code overlay styling */
.discount-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.discount-content {
  background: linear-gradient(135deg, rgba(15,25,45,0.95) 0%, rgba(25,35,55,0.95) 100%);
  border: 3px solid #00ffff;
  border-radius: 15px;
  padding: 30px;
  text-align: center;
  max-width: 400px;
  animation: discount-appear 0.3s ease-out;
}

.discount-content h2 {
  color: #00ffff;
  margin-bottom: 15px;
}

.discount-content p {
  color: #ffffff;
  margin: 10px 0;
}

.discount-code {
  display: inline-block;
  background: #00ffff;
  color: #000;
  padding: 8px 16px;
  border-radius: 5px;
  font-weight: bold;
  font-size: 1.2em;
  margin: 0 5px;
}

.discount-content button {
  background: linear-gradient(135deg, #00ffff 0%, #0080ff 100%);
  border: none;
  color: #000;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 15px;
  transition: transform 0.2s ease;
}

.discount-content button:hover {
  transform: scale(1.05);
}

@keyframes discount-appear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Enhanced discount modal styles */
.catchy-phrase {
  color: #00ff00 !important; /* Bright lime green for attention */
  text-shadow: 0 0 10px #00ff00;
  font-size: 1.8em !important;
  margin-bottom: 20px !important;
  animation: glow 2s ease-in-out infinite alternate;
}

/* Unified modal styling - make all screens look like discount modal */
.overlay-content {
  background: linear-gradient(135deg, rgba(15,25,45,0.95) 0%, rgba(25,35,55,0.95) 100%) !important;
  border: 3px solid #00ffff !important;
  border-radius: 15px !important;
  padding: 30px !important;
  text-align: center !important;
  max-width: 500px !important; /* Increased from 400px for better word wrap */
  animation: discount-appear 0.3s ease-out !important;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3) !important;
}

.overlay-content h1 {
  color: #00ffff !important;
  text-shadow: 0 0 10px #00ffff !important;
  font-size: 2.5em !important;
  margin-bottom: 20px !important;
  background: none !important;
  -webkit-text-fill-color: unset !important;
}

.overlay-content h2 {
  color: #00ffff !important;
  text-shadow: 0 0 10px #00ffff !important;
  font-size: 2em !important;
  margin-bottom: 15px !important;
}

.overlay-content p {
  color: #ffffff !important;
  margin: 10px 0 !important;
}

.overlay-content::before {
  display: none !important;
}

.overlay-content h1::after {
  display: none !important;
}

@keyframes glow {
  from { text-shadow: 0 0 10px #00ff00; }
  to { text-shadow: 0 0 20px #00ff00, 0 0 30px #00ff00; }
}

.discount-text {
  color: #ff6600 !important; /* Bright orange for contrast */
  font-size: 1.3em !important;
  font-weight: bold !important;
}

.code-container {
  position: relative;
  margin: 20px 0;
  padding: 15px;
  background: rgba(0, 255, 255, 0.1);
  border-radius: 10px;
  border: 2px solid rgba(0, 255, 255, 0.3);
}

.emoji-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2em;
  animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce-vertical {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-10px); }
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-10px); }
}

.typewriter {
  border-right: 2px solid #00ffff;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 50% { border-color: #00ffff; }
  51%, 100% { border-color: transparent; }
}



/* Animated ship styles */
.animated-ship {
  position: fixed;
  font-size: 3em;
  z-index: 1001;
  pointer-events: none;
  filter: drop-shadow(0 0 10px #00ffff);
  animation: ship-glow 2s ease-in-out infinite alternate;
}

@keyframes ship-glow {
  from { filter: drop-shadow(0 0 10px #00ffff); }
  to { filter: drop-shadow(0 0 20px #00ffff) drop-shadow(0 0 30px #00ffff); }
}

/* Game over screen enhancements */
.cta-container {
  position: relative;
  margin: 20px 0;
  padding: 20px;
  background: linear-gradient(135deg, rgba(255, 102, 0, 0.1) 0%, rgba(255, 165, 0, 0.1) 100%);
  border: 2px solid rgba(255, 102, 0, 0.3);
  border-radius: 10px;
}

.cta-text {
  color: #ff6600 !important; /* Bright orange for CTA */
  font-size: 1.1em !important;
  font-weight: bold !important;
  text-shadow: 0 0 5px rgba(255, 102, 0, 0.5);
  margin: 0 !important;
  line-height: 1.4;
  word-wrap: break-word !important;
  white-space: normal !important;
  overflow-wrap: break-word !important;
}

.emoji-pointer-gameover {
  position: absolute;
  left: 50%;
  top: -50px;
  transform: translateX(-50%);
  font-size: 2em;
  animation: bounce-vertical 1s ease-in-out infinite;
}

/* Button enhancements */
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

button:disabled:hover {
  transform: none !important;
}

/* Override general overlay button styling with HUD styling */
#gameover-continue-btn,
#replay-btn, 
#gameover-visit-website-btn,
#gameover-share-btn,
#share-btn,
#start-screen .start-buttons button,
#close-info-btn {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%) !important;
  border: 1px solid rgba(79, 172, 254, 0.4) !important;
  color: #e8f4f8 !important;
  font-size: 1.2em !important;
  padding: 12px 24px !important;
  border-radius: 8px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  margin: 5px !important;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
  box-shadow: 
    0 2px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 8px rgba(79, 172, 254, 0.2) !important;
  backdrop-filter: blur(3px) !important;
  position: relative !important;
  min-width: 150px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#gameover-continue-btn::before,
#replay-btn::before, 
#gameover-visit-website-btn::before,
#gameover-share-btn::before,
#share-btn::before,
#start-screen .start-buttons button::before,
#close-info-btn::before {
  content: '' !important;
  position: absolute !important;
  top: -1px !important;
  left: -1px !important;
  right: -1px !important;
  bottom: -1px !important;
  background: linear-gradient(45deg, 
    rgba(79, 172, 254, 0.4) 0%, 
    rgba(138, 246, 246, 0.3) 50%, 
    rgba(79, 172, 254, 0.4) 100%) !important;
  border-radius: 9px !important;
  z-index: -1 !important;
  opacity: 0.6 !important;
  display: block !important;
}

#gameover-continue-btn:hover:not(:disabled),
#replay-btn:hover:not(:disabled), 
#gameover-visit-website-btn:hover,
#gameover-share-btn:hover,
#share-btn:hover,
#start-screen .start-buttons button:hover,
#close-info-btn:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%) !important;
  box-shadow: 
    0 6px 20px rgba(79, 172, 254, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 0 15px rgba(79, 172, 254, 0.6) !important;
  transform: translateY(-2px) !important;
  color: #fff !important;
  border-color: rgba(79, 172, 254, 0.7) !important;
}

#gameover-continue-btn:hover:not(:disabled)::before,
#replay-btn:hover:not(:disabled)::before, 
#gameover-visit-website-btn:hover::before,
#gameover-share-btn:hover::before,
#share-btn:hover::before,
#start-screen .start-buttons button:hover::before,
#close-info-btn:hover::before {
  opacity: 0.8 !important;
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.4) !important;
}

#gameover-continue-btn:active,
#replay-btn:active, 
#gameover-visit-website-btn:active,
#gameover-share-btn:active,
#share-btn:active,
#start-screen .start-buttons button:active,
#close-info-btn:active {
  transform: translateY(0px) !important;
  box-shadow: 
    0 2px 8px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(79, 172, 254, 0.4) !important;
}

#gameover-continue-btn:disabled {
  background: linear-gradient(135deg, rgba(40,50,70,0.4) 0%, rgba(30,40,60,0.5) 100%) !important;
  color: rgba(232, 244, 248, 0.5) !important;
  border-color: rgba(79, 172, 254, 0.2) !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: 
    0 1px 3px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.05),
    0 0 4px rgba(79, 172, 254, 0.1) !important;
}

#gameover-continue-btn:disabled::before {
  opacity: 0.3 !important;
}

/* Apply HUD styling to replay and contact buttons */
#replay-btn, 
#gameover-visit-website-btn {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #e8f4f8;
  font-size: 1.2em;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin: 5px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 2px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 8px rgba(79, 172, 254, 0.2);
  backdrop-filter: blur(3px);
  position: relative;
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#replay-btn::before, 
#gameover-visit-website-btn::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(45deg, 
    rgba(79, 172, 254, 0.4) 0%, 
    rgba(138, 246, 246, 0.3) 50%, 
    rgba(79, 172, 254, 0.4) 100%);
  border-radius: 9px;
  z-index: -1;
  opacity: 0.6;
}

#replay-btn:hover:not(:disabled), 
#gameover-visit-website-btn:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%);
  box-shadow: 
    0 6px 20px rgba(79, 172, 254, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 0 15px rgba(79, 172, 254, 0.6);
  transform: translateY(-2px);
  color: #fff;
  border-color: rgba(79, 172, 254, 0.7);
}

#replay-btn:hover:not(:disabled)::before, 
#gameover-visit-website-btn:hover::before {
  opacity: 0.8;
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.4);
}

#replay-btn:active, 
#gameover-visit-website-btn:active {
  transform: translateY(0px);
  box-shadow: 
    0 2px 8px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(79, 172, 254, 0.4);
}

/* Apply HUD styling to start screen buttons */
#start-screen .start-buttons button {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #e8f4f8;
  font-size: 1.2em;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin: 5px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 2px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 8px rgba(79, 172, 254, 0.2);
  backdrop-filter: blur(3px);
  position: relative;
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#start-screen .start-buttons button::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(45deg, 
    rgba(79, 172, 254, 0.4) 0%, 
    rgba(138, 246, 246, 0.3) 50%, 
    rgba(79, 172, 254, 0.4) 100%);
  border-radius: 9px;
  z-index: -1;
  opacity: 0.6;
}

#start-screen .start-buttons button:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%);
  box-shadow: 
    0 6px 20px rgba(79, 172, 254, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 0 15px rgba(79, 172, 254, 0.6);
  transform: translateY(-2px);
  color: #fff;
  border-color: rgba(79, 172, 254, 0.7);
}

#start-screen .start-buttons button:hover::before {
  opacity: 0.8;
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.4);
}

#start-screen .start-buttons button:active {
  transform: translateY(0px);
  box-shadow: 
    0 2px 8px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(79, 172, 254, 0.4);
}



/* Apply HUD styling to close info button */
#close-info-btn {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #e8f4f8;
  font-size: 1.2em;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin: 5px;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 2px 6px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 8px rgba(79, 172, 254, 0.2);
  backdrop-filter: blur(3px);
  position: relative;
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#close-info-btn::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: linear-gradient(45deg, 
    rgba(79, 172, 254, 0.4) 0%, 
    rgba(138, 246, 246, 0.3) 50%, 
    rgba(79, 172, 254, 0.4) 100%);
  border-radius: 9px;
  z-index: -1;
  opacity: 0.6;
}

#close-info-btn:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%);
  box-shadow: 
    0 6px 20px rgba(79, 172, 254, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.2),
    0 0 15px rgba(79, 172, 254, 0.6);
  transform: translateY(-2px);
  color: #fff;
  border-color: rgba(79, 172, 254, 0.7);
}

#close-info-btn:hover::before {
  opacity: 0.8;
  box-shadow: 0 0 20px rgba(79, 172, 254, 0.4);
}

#close-info-btn:active {
  transform: translateY(0px);
  box-shadow: 
    0 2px 8px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 0 10px rgba(79, 172, 254, 0.4);
}

/* Hide version info when game is active (not on start/game over screens) */
body:not(.game-menu) #version-info {
  opacity: 0;
  /* game-playing class takes over with display:none during active gameplay */
}

#version-info p {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8em;
  margin: 0;
  text-align: right;
  font-family: 'Courier New', monospace;
}

/* Leaderboard Modal Styles */
#leaderboard-screen {
  max-width: 600px;
  width: 90%;
}

#leaderboard-screen h2 {
  color: #4facfe;
  text-shadow: 
    0 2px 12px rgba(79, 172, 254, 0.6),
    0 0 4px #fff;
  margin-bottom: 24px;
}

#leaderboard-content {
  background: rgba(15, 25, 45, 0.3);
  border: 1px solid rgba(79, 172, 254, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin: 20px 0;
  box-shadow: 
    0 4px 16px rgba(79, 172, 254, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.1);
  backdrop-filter: blur(5px);
}

.leaderboard-notice {
  color: #a8c8e8;
  font-style: italic;
  text-align: center;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(79, 172, 254, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(79, 172, 254, 0.2);
}

#local-scores h3 {
  color: #ffe75a;
  margin-bottom: 16px;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.score-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.1) 0%, rgba(138, 246, 246, 0.05) 100%);
  border: 1px solid rgba(79, 172, 254, 0.2);
  border-radius: 8px;
  margin-bottom: 8px;
}

.score-entry .rank {
  color: #4facfe;
  font-weight: bold;
  font-size: 1.2em;
}

.score-entry .player {
  color: #fff;
  flex: 1;
  margin: 0 16px;
}

.score-entry .score {
  color: #ffe75a;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

#close-leaderboard-btn {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #e8f4f8;
  font-size: 1.2em;
  font-weight: 600;
  padding: 12px 32px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 
    0 4px 12px rgba(79, 172, 254, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.1);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 20px;
}

#close-leaderboard-btn:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%);
  box-shadow: 
    0 8px 24px rgba(79, 172, 254, 0.5),
    inset 0 1px 0 rgba(255,255,255,0.2);
  transform: translateY(-2px);
  color: #fff;
}
/* ── Leaderboard panel (inside game-over overlay) ───────────────────────── */
#leaderboard-panel {
  background: rgba(10, 15, 30, 0.75);
  border: 1px solid rgba(79, 172, 254, 0.35);
  border-radius: 12px;
  margin: 14px 0 10px;
  padding: 12px 16px;
  text-align: left;
  max-height: 220px;
  overflow-y: auto;
}

#leaderboard-panel h3 {
  margin: 0 0 8px;
  color: #ffe75a;
  font-size: 1em;
  text-align: center;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.85em;
  color: #e8f4f8;
}

#leaderboard-list li:last-child {
  border-bottom: none;
}

.lb-loading,
.lb-empty {
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.lb-rank {
  width: 22px;
  text-align: right;
  color: rgba(255, 231, 90, 0.8);
  font-weight: bold;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: bold;
  color: #ffe75a;
  font-family: 'Courier New', monospace;
  flex-shrink: 0;
}

.lb-status {
  font-size: 0.78em;
  color: rgba(255, 255, 255, 0.45);
  text-align: center;
  margin: 6px 0 0;
}

/* ── Standalone leaderboard overlay (HUD button) ───────────────────────── */
#leaderboard-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(15,25,45,0.85) 0%, rgba(5,10,25,0.95) 100%);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

#leaderboard-overlay.hidden {
  display: none !important;
}

#leaderboard-modal {
  background: rgba(10, 15, 30, 0.9);
  border: 1px solid rgba(79, 172, 254, 0.45);
  border-radius: 16px;
  padding: 28px 32px;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 40px rgba(79, 172, 254, 0.3);
  text-align: center;
}

#leaderboard-modal h2 {
  margin: 0 0 16px;
  color: #ffe75a;
  font-size: 1.4em;
  letter-spacing: 2px;
  text-transform: uppercase;
}

#leaderboard-overlay-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
  text-align: left;
}

#leaderboard-overlay-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: #e8f4f8;
  font-size: 0.95em;
}

#leaderboard-overlay-list li:last-child {
  border-bottom: none;
}

#close-leaderboard-overlay-btn {
  background: linear-gradient(135deg, rgba(40,50,70,0.8) 0%, rgba(30,40,60,0.9) 100%);
  border: 1px solid rgba(79, 172, 254, 0.4);
  color: #e8f4f8;
  font-size: 1em;
  font-weight: 600;
  padding: 10px 28px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3);
}

#close-leaderboard-overlay-btn:hover {
  background: linear-gradient(135deg, rgba(79, 172, 254, 0.4) 0%, rgba(138, 246, 246, 0.3) 100%);
  transform: translateY(-2px);
  color: #fff;
}

/* Clean up game-over CTA — static, no animation required */
#sales-pitch {
  margin: 8px 0 10px;
}

/* Override legacy .cta-text styles for the game-over static paragraph.
   Using !important to match the specificity of the original .cta-text rule. */
#gameover-screen #sales-pitch .cta-text {
  color: #b0c8e8 !important;
  font-size: 0.95em !important;
  font-weight: normal !important;
  text-shadow: none !important;
  margin: 0 !important;
  line-height: 1.5;
}

/* ── Mobile game-over screen: scrollable so all content is reachable ──── */
@media (max-width: 768px) {
  #gameover-screen {
    max-height: calc(100dvh - 80px - env(safe-area-inset-bottom, 0px) - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px !important;
  }

  /* Reduce oversized heading so it fits on narrow screens */
  #gameover-screen h2 {
    font-size: 1.6em !important;
    margin-bottom: 10px !important;
  }

  #gameover-screen #final-score {
    font-size: 1.1em !important;
    margin: 6px 0 !important;
  }

  /* Compress leaderboard panel on small screens */
  #leaderboard-panel {
    max-height: 160px;
  }
}
