/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #ffffff;
  min-height: 100vh;
  width: 100vw;
  position: relative;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

canvas {
  display: block;
  background-color: #0a0a0a;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Screen Overlays */
.screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(230, 243, 255, 0.4) 0%, rgba(179, 217, 255, 0.4) 100%);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn 0.6s ease-out;
}

.screen-overlay.hidden {
  display: none;
}

/* Modal Container */
.modal-container {
  width: 100%;
  max-width: 500px;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: rgba(0, 0, 0, 0.09);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 30px;
  width: 100%;
  max-width: 450px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}


/* Modal Header */
.modal-header {
  text-align: center;
  margin-bottom: 30px;
  position: relative;
}

.game-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 3.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea, #764ba2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}

.game-over-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 3.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ff4757, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
}

.title-accent {
  width: 100px;
  height: 4px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  margin: 0 auto;
  border-radius: 2px;
}

.game-over-modal .title-accent {
  background: linear-gradient(135deg, #ff4757, #ff6b6b);
}

/* Modal Body */
.modal-body {
  margin-bottom: 25px;
}

.info-section {
  margin-bottom: 25px;
}

.info-section h3 {
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 12px;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.info-section p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #34495e;
  margin-bottom: 8px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

/* Controls */
.controls {
  display: flex;
  flex-direction: row;
  gap: 12px;
  justify-content: space-between;
  flex-wrap: wrap;
}



.control-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex: 1;
  min-width: 0;
}

.key {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 50px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.description {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}

/* Score Display */
.score-display {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.score-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-over-modal .score-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-label {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.game-over-modal .score-label {
  color: #2c3e50;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.score-value {
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: #4ecdc4;
  text-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
}

.game-over-modal .score-value {
  color: #ffffff;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

/* Game Over Message */
.game-over-message {
  text-align: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 20px;
}

.game-over-message p {
  font-size: 1rem;
  color: #34495e;
  font-weight: 600;
  margin: 0;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
  line-height: 1.5;
}

/* Enhanced Game Over Modal Styling */
.game-over-modal {
  position: relative;
  overflow: hidden;
}

.game-over-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(255, 71, 87, 0.1) 0%, 
    rgba(255, 107, 107, 0.05) 50%, 
    rgba(255, 71, 87, 0.1) 100%);
  pointer-events: none;
  z-index: 1;
}

.game-over-modal .modal-header,
.game-over-modal .modal-body,
.game-over-modal .modal-footer {
  position: relative;
  z-index: 2;
}

/* Game Over Title Animation */
.game-over-title {
  animation: gameOverPulse 2s ease-in-out infinite;
}

@keyframes gameOverPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 10px rgba(255, 71, 87, 0.3));
  }
  50% {
    transform: scale(1.02);
    filter: drop-shadow(0 0 20px rgba(255, 71, 87, 0.5));
  }
}

/* Enhanced Score Display for Game Over */
.game-over-modal .score-item {
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.game-over-modal .score-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.1), 
    transparent);
  transition: left 0.6s ease;
}

.game-over-modal .score-item:hover::before {
  left: 100%;
}

.game-over-modal .score-item:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 8px 25px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Enhanced Button for Game Over */
.game-over-modal .btn {
  position: relative;
  overflow: hidden;
}

.game-over-modal .btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.2), 
    transparent);
  transition: left 0.6s ease;
}

.game-over-modal .btn:hover::after {
  left: 100%;
}

/* Modal Footer */
.modal-footer {
  text-align: center;
}

/* Buttons */
.btn {
  position: relative;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 16px;
  padding: 16px 32px;
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: white;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 
    0 8px 25px rgba(102, 126, 234, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  letter-spacing: 1px;
  text-transform: uppercase;
  min-width: 180px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 35px rgba(102, 126, 234, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.2);
}

.btn:active {
  transform: translateY(0);
}

.btn-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.btn:hover .btn-glow {
  left: 100%;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}



/* Game UI Overlay */
.game-ui {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  font-family: 'Orbitron', monospace;
}

.ui-panel {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0 0 12px 12px;
  padding: 12px 20px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Game UI row layout */
.ui-row {
  display: flex;
  gap: 24px;
  align-items: center;
}


@keyframes panelGlow {
  0% {
    box-shadow: 
      0 12px 40px rgba(0, 0, 0, 0.4),
      0 0 0 1px rgba(255, 255, 255, 0.05),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
  100% {
    box-shadow: 
      0 12px 40px rgba(0, 0, 0, 0.4),
      0 0 0 1px rgba(78, 205, 196, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
}

.ui-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 6px;
  position: relative;
  transition: all 0.3s ease;
  min-width: 70px;
}

.ui-stat:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

.ui-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  text-align: center;
}

.ui-value {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
  transition: all 0.3s ease;
  text-align: center;
}

.ui-value.score {
  color: #00ff88;
  text-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
  animation: scorePulse 2s ease-in-out infinite;
}

.ui-value.level {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.ui-value.speed {
  color: #ff6b6b;
  text-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
}

.ui-value.police {
  color: #ff4757;
  text-shadow: 0 0 20px rgba(255, 71, 87, 0.6);
}

@keyframes scorePulse {
  0%, 100% {
    text-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
  }
  50% {
    text-shadow: 0 0 25px rgba(0, 255, 136, 0.9);
  }
}

/* Floating Points Animation */
.floating-point {
  position: absolute;
  font-family: 'Orbitron', monospace;
  font-weight: 800;
  font-size: 18px;
  color: #4ecdc4;
  text-shadow: 
    0 0 15px rgba(78, 205, 196, 0.9),
    0 0 30px rgba(78, 205, 196, 0.5);
  pointer-events: none;
  z-index: 20;
  animation: floatUp 1.2s ease-out forwards;
  transform-origin: center;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translateY(-10px) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(1.3);
  }
}

/* Level Stars */
.level-stars {
  display: inline-block;
  margin-left: 8px;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  animation: starGlow 2s ease-in-out infinite alternate;
}

@keyframes starGlow {
  0% {
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
  }
  100% {
    text-shadow: 0 0 20px rgba(255, 215, 0, 1);
  }
}

/* Speed Bar */
.speed-bar {
  width: 50px;
  height: 4px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.speed-fill {
  height: 100%;
  background: linear-gradient(90deg, #4ecdc4 0%, #45b7d1 50%, #ff6b6b 100%);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 0 10px rgba(78, 205, 196, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
}

.speed-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.3) 50%, 
    transparent 100%);
  animation: speedShimmer 2s ease-in-out infinite;
}

@keyframes speedShimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}


/* Mobile Controls */
.mobile-controller {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  z-index: 100;
  pointer-events: none;
  display: none; /* Hidden by default, shown on mobile */
}

.controller-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 120px;
  max-width: 400px;
  margin: 0 auto;
  pointer-events: auto;
}

.steering-controls {
  display: flex;
  gap: 20px;
}

.steer-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 8px 25px rgba(102, 126, 234, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.steer-btn:active {
  transform: scale(0.95);
  box-shadow: 
    0 4px 15px rgba(102, 126, 234, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.2);
}

.steer-btn.left-btn {
  background: linear-gradient(135deg, #ff6b6b, #ff8e8e);
  box-shadow: 
    0 8px 25px rgba(255, 107, 107, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.steer-btn.right-btn {
  background: linear-gradient(135deg, #4ecdc4, #45b7d1);
  box-shadow: 
    0 8px 25px rgba(78, 205, 196, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1);
}

.drift-btn {
  width: 100px;
  height: 70px;
  border-radius: 35px;
  border: none;
  background: linear-gradient(135deg, #ffd700, #ffed4e);
  color: #333;
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 8px 25px rgba(255, 215, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.drift-btn:active {
  transform: scale(0.95);
  box-shadow: 
    0 4px 15px rgba(255, 215, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.2);
}

.btn-icon {
  font-size: 28px;
  line-height: 1;
}

.btn-text {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* Show mobile controls only on mobile devices */
@media (max-width: 768px) {
  .mobile-controller {
    display: block;
  }
  
  .desktop-controls {
    display: none;
  }
  
  .mobile-controls-info {
    display: flex;
  }
}

@media (min-width: 769px) {
  .mobile-controller {
    display: none;
  }
  
  .desktop-controls {
    display: flex;
  }
  
  .mobile-controls-info {
    display: none;
  }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  
  /* Prevent zoom on double tap for mobile */
  * {
    touch-action: manipulation;
  }
  
  /* Responsive modal adjustments */
  .modal-container {
    padding: 10px;
    min-height: 100vh;
  }
  
  .modal-content {
    padding: 25px 20px;
    margin: 10px;
    max-width: calc(100vw - 20px);
    overflow-x: hidden;
  }
  
  .game-title {
    font-size: 2.5rem;
    letter-spacing: 2px;
  }
  
  .game-over-title {
    font-size: 2.2rem;
  }
  
  /* Game Over Modal Mobile Adjustments */
  .game-over-modal .modal-content {
    padding: 25px 20px;
    margin: 10px;
    max-width: calc(100vw - 20px);
  }
  
  .game-over-modal .game-over-title {
    font-size: 2.2rem;
    letter-spacing: 2px;
  }
  
  .game-over-modal .score-item {
    padding: 10px 12px;
  }
  
  .game-over-modal .score-label {
    font-size: 0.85rem;
  }
  
  .game-over-modal .score-value {
    font-size: 1.1rem;
  }
  
  .game-over-modal .btn {
    padding: 14px 24px;
    font-size: 0.9rem;
    min-width: 150px;
  }
  
  .controls {
    gap: 10px;
    flex-direction: column;
  }
  
  .control-item {
    padding: 10px 12px;
    justify-content: flex-start;
  }
  
  
  /* Left align controls section on mobile */
  .info-section h3 {
    text-align: left;
  }
  
  
  .key {
    padding: 6px 8px;
    font-size: 0.75rem;
    min-width: 40px;
  }
  
  .description {
    font-size: 0.8rem;
  }
  
  .control-item {
    padding: 8px 10px;
    gap: 8px;
  }
  
  /* Mobile UI layout */
  .ui-panel {
    top: 0;
    left: 0;
    right: 0;
    transform: none;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
      0 8px 32px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.1);
  }
  
  /* Responsive UI row on mobile - single row, no wrapping */
  .ui-row {
    gap: 12px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: hidden;
  }
  
  .ui-stat {
    min-width: 60px;
    flex-shrink: 0;
    padding: 6px 8px;
  }
  
  .ui-label {
    font-size: 10px;
    line-height: 1.1;
  }
  
  .ui-value {
    font-size: 14px;
    line-height: 1.1;
  }
  
  .speed-bar {
    width: 50px;
    height: 4px;
  }
  
  /* Mobile control adjustments */
  .mobile-controller {
    padding: 15px;
  }
  
  .controller-container {
    height: 100px;
  }
  
  .steer-btn {
    width: 60px;
    height: 60px;
  }
  
  .btn-icon {
    font-size: 24px;
  }
  
  .drift-btn {
    width: 90px;
    height: 60px;
    border-radius: 30px;
  }
  
  .btn-text {
    font-size: 12px;
  }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
  .modal-container {
    padding: 30px;
    max-width: 700px;
  }
  
  .modal-content {
    padding: 35px 30px;
    max-width: 600px;
  }
  
  .game-title {
    font-size: 3rem;
  }
  
  .game-over-title {
    font-size: 3rem;
  }
  
  .controls {
    gap: 15px;
    flex-direction: row;
    justify-content: space-around;
  }
  
  .control-item {
    padding: 12px 16px;
    flex: 1;
    max-width: 200px;
  }
  
  .info-section h3 {
    font-size: 1.2rem;
  }
  
  .info-section p {
    font-size: 1rem;
  }
  
  .btn {
    padding: 18px 36px;
    font-size: 1.1rem;
    min-width: 200px;
  }
}

/* Large desktop screens */
@media (min-width: 1200px) {
  .modal-container {
    max-width: 600px;
  }
  
  .modal-content {
    padding: 40px 35px;
    max-width: 550px;
  }
  
  .game-title {
    font-size: 3.5rem;
  }
  
  .game-over-title {
    font-size: 3.5rem;
  }
  
  .info-section h3 {
    font-size: 1.2rem;
  }
  
  .info-section p {
    font-size: 1rem;
  }
  
  .btn {
    padding: 18px 36px;
    font-size: 1.1rem;
    min-width: 200px;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .mobile-controller {
    padding: 15px;
  }
  
  .controller-container {
    height: 100px;
  }
  
  .steer-btn {
    width: 60px;
    height: 60px;
  }
  
  .btn-icon {
    font-size: 24px;
  }
  
  .drift-btn {
    width: 90px;
    height: 60px;
    border-radius: 30px;
  }
  
  .btn-text {
    font-size: 12px;
  }
  
  /* Adjust UI panel for smaller screens */
  .ui-panel {
    left: 0;
    right: 0;
    transform: none;
    padding: 8px 12px;
  }
  
  .ui-row.mobile-first-row,
  .ui-row.mobile-second-row {
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: hidden;
  }
  
  .ui-stat {
    min-width: 50px;
    flex-shrink: 0;
    padding: 4px 6px;
  }
  
  .ui-label {
    font-size: 9px;
    line-height: 1.1;
  }
  
  .ui-value {
    font-size: 12px;
    line-height: 1.1;
  }
  
  /* Extra small modal adjustments */
  .modal-container {
    padding: 5px;
  }
  
  .modal-content {
    padding: 20px 15px;
    margin: 5px;
    max-width: calc(100vw - 10px);
  }
  
  .game-title {
    font-size: 2rem;
    letter-spacing: 1px;
  }
  
  .game-over-title {
    font-size: 1.8rem;
  }
  
  /* Game Over Modal Extra Small Screen Adjustments */
  .game-over-modal .modal-content {
    padding: 20px 15px;
    margin: 5px;
    max-width: calc(100vw - 10px);
  }
  
  .game-over-modal .game-over-title {
    font-size: 1.8rem;
    letter-spacing: 1px;
  }
  
  .game-over-modal .score-item {
    padding: 8px 10px;
  }
  
  .game-over-modal .score-label {
    font-size: 0.8rem;
  }
  
  .game-over-modal .score-value {
    font-size: 1rem;
  }
  
  .game-over-modal .btn {
    padding: 12px 20px;
    font-size: 0.8rem;
    min-width: 130px;
  }
  
  /* Enhanced mobile touch targets */
  .game-over-modal .btn {
    min-height: 44px;
    touch-action: manipulation;
  }
  
  /* Better spacing for very small screens */
  .game-over-modal .modal-header {
    margin-bottom: 20px;
  }
  
  .game-over-modal .modal-body {
    margin-bottom: 20px;
  }
  
  .game-over-modal .score-display {
    gap: 8px;
    margin-bottom: 15px;
  }
  
  .game-over-modal .game-over-message {
    padding: 12px;
    margin-top: 15px;
  }
  
  .info-section h3 {
    font-size: 1rem;
  }
  
  .info-section p {
    font-size: 0.85rem;
  }
  
  .btn {
    padding: 14px 24px;
    font-size: 0.9rem;
    min-width: 150px;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-controller {
    padding: 10px 20px;
  }
  
  .controller-container {
    height: 80px;
  }
  
  .steer-btn {
    width: 55px;
    height: 55px;
  }
  
  .btn-icon {
    font-size: 20px;
  }
  
  .drift-btn {
    width: 80px;
    height: 55px;
    border-radius: 27px;
  }
  
  .btn-text {
    font-size: 11px;
  }
  
  /* Landscape UI panel adjustments */
  .ui-panel {
    left: 0;
    right: 0;
    transform: none;
    padding: 6px 12px;
  }
  
  .ui-row.mobile-first-row,
  .ui-row.mobile-second-row {
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: hidden;
  }
  
  .ui-stat {
    min-width: 50px;
    flex-shrink: 0;
    padding: 4px 6px;
  }
  
  .ui-label {
    font-size: 9px;
    line-height: 1.1;
  }
  
  .ui-value {
    font-size: 12px;
    line-height: 1.1;
  }
  
  /* Landscape modal adjustments */
  .modal-container {
    padding: 10px;
    align-items: flex-start;
    padding-top: 20px;
  }
  
  .modal-content {
    padding: 20px 25px;
    margin: 10px;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .game-title {
    font-size: 2rem;
  }
  
  .game-over-title {
    font-size: 2rem;
  }
  
  .info-section {
    margin-bottom: 15px;
  }
  
  .info-section h3 {
    font-size: 1rem;
  }
  
  .info-section p {
    font-size: 0.85rem;
  }
  
  .controls {
    flex-direction: row;
    gap: 8px;
  }
  
  .control-item {
    padding: 8px 10px;
  }
  
  .btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    min-width: 140px;
  }
  
  /* Landscape game over modal adjustments */
  .game-over-modal .modal-content {
    padding: 15px 20px;
    margin: 5px;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .game-over-modal .game-over-title {
    font-size: 1.6rem;
    margin-bottom: 8px;
  }
  
  .game-over-modal .modal-header {
    margin-bottom: 15px;
  }
  
  .game-over-modal .modal-body {
    margin-bottom: 15px;
  }
  
  .game-over-modal .score-display {
    gap: 6px;
    margin-bottom: 10px;
  }
  
  .game-over-modal .score-item {
    padding: 6px 8px;
  }
  
  .game-over-modal .score-label {
    font-size: 0.75rem;
  }
  
  .game-over-modal .score-value {
    font-size: 0.9rem;
  }
  
  .game-over-modal .game-over-message {
    padding: 8px;
    margin-top: 10px;
  }
  
  .game-over-modal .game-over-message p {
    font-size: 0.8rem;
  }
  
  .game-over-modal .btn {
    padding: 10px 16px;
    font-size: 0.8rem;
    min-width: 120px;
    min-height: 40px;
  }
}

/* Ultra-wide screens (21:9 and wider) */
@media (min-width: 1920px) and (min-aspect-ratio: 21/9) {
  .modal-container {
    max-width: 800px;
  }
  
  .modal-content {
    padding: 50px 45px;
    max-width: 750px;
  }
  
  .game-title {
    font-size: 4rem;
    letter-spacing: 4px;
  }
  
  .game-over-title {
    font-size: 4rem;
  }
  
  .info-section h3 {
    font-size: 1.4rem;
  }
  
  .info-section p {
    font-size: 1.1rem;
  }
  
  .btn {
    padding: 20px 40px;
    font-size: 1.2rem;
    min-width: 220px;
  }
  
  .ui-panel {
    padding: 16px 24px;
  }
  
  .ui-stat {
    min-width: 90px;
    padding: 8px 12px;
  }
  
  .ui-label {
    font-size: 12px;
  }
  
  .ui-value {
    font-size: 18px;
  }
  
  .speed-bar {
    width: 60px;
    height: 5px;
  }
}

/* Large desktop screens (1440px+) */
@media (min-width: 1440px) and (max-width: 1919px) {
  .modal-container {
    max-width: 650px;
  }
  
  .modal-content {
    padding: 45px 40px;
    max-width: 600px;
  }
  
  .game-title {
    font-size: 3.8rem;
  }
  
  .game-over-title {
    font-size: 3.8rem;
  }
  
  .ui-panel {
    padding: 14px 22px;
  }
  
  .ui-stat {
    min-width: 80px;
  }
  
  .ui-label {
    font-size: 11px;
  }
  
  .ui-value {
    font-size: 17px;
  }
}

/* Medium tablets (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .modal-container {
    padding: 20px;
    max-width: 90vw;
  }
  
  .modal-content {
    padding: 30px 25px;
    max-width: 85vw;
  }
  
  .game-title {
    font-size: 2.8rem;
    letter-spacing: 2px;
  }
  
  .game-over-title {
    font-size: 2.8rem;
  }
  
  .ui-panel {
    padding: 12px 18px;
  }
  
  .ui-row.desktop-row {
    gap: 20px;
  }
  
  .ui-stat {
    min-width: 65px;
  }
  
  .ui-label {
    font-size: 10px;
  }
  
  .ui-value {
    font-size: 15px;
  }
  
  .speed-bar {
    width: 45px;
    height: 4px;
  }
}

/* Small tablets (600px - 768px) */
@media (min-width: 600px) and (max-width: 767px) {
  .modal-container {
    padding: 15px;
    max-width: 95vw;
  }
  
  .modal-content {
    padding: 25px 20px;
    max-width: 90vw;
  }
  
  .game-title {
    font-size: 2.2rem;
    letter-spacing: 1.5px;
  }
  
  .game-over-title {
    font-size: 2.2rem;
  }
  
  .ui-panel {
    padding: 10px 14px;
  }
  
  .ui-row.mobile-first-row,
  .ui-row.mobile-second-row {
    gap: 12px;
  }
  
  .ui-stat {
    min-width: 55px;
  }
  
  .ui-label {
    font-size: 9px;
  }
  
  .ui-value {
    font-size: 13px;
  }
  
  .speed-bar {
    width: 40px;
    height: 3px;
  }
  
  .mobile-controller {
    padding: 18px;
  }
  
  .controller-container {
    height: 110px;
  }
  
  .steer-btn {
    width: 65px;
    height: 65px;
  }
  
  .btn-icon {
    font-size: 26px;
  }
  
  .drift-btn {
    width: 95px;
    height: 65px;
    border-radius: 32px;
  }
  
  .btn-text {
    font-size: 13px;
  }
}

/* Prevent zoom on double tap for all mobile devices */
@media (max-width: 768px) {
  * {
    touch-action: manipulation;
  }
  
  /* Ensure canvas takes full screen on mobile */
  canvas {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
  }
}

/* Very small screens (320px - 480px) */
@media (max-width: 320px) {
  .mobile-controller {
    padding: 10px;
  }
  
  .controller-container {
    height: 90px;
  }
  
  .steer-btn {
    width: 50px;
    height: 50px;
  }
  
  .btn-icon {
    font-size: 20px;
  }
  
  .drift-btn {
    width: 80px;
    height: 50px;
    border-radius: 25px;
  }
  
  .btn-text {
    font-size: 10px;
  }
  
  .ui-panel {
    left: 0;
    right: 0;
    transform: none;
    padding: 6px 10px;
  }
  
  .ui-row.mobile-first-row,
  .ui-row.mobile-second-row {
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: hidden;
  }
  
  .ui-stat {
    min-width: 45px;
    flex-shrink: 0;
    padding: 3px 4px;
  }
  
  .ui-label {
    font-size: 8px;
    line-height: 1.1;
  }
  
  .ui-value {
    font-size: 11px;
    line-height: 1.1;
  }
  
  .modal-container {
    padding: 3px;
  }
  
  .modal-content {
    padding: 18px 12px;
    margin: 3px;
    max-width: calc(100vw - 6px);
    overflow-x: hidden;
  }
  
  .game-title {
    font-size: 1.8rem;
    letter-spacing: 1px;
  }
  
  .game-over-title {
    font-size: 1.6rem;
  }
  
  .info-section h3 {
    font-size: 0.9rem;
  }
  
  .info-section p {
    font-size: 0.8rem;
  }
  
  .btn {
    padding: 12px 20px;
    font-size: 0.8rem;
    min-width: 130px;
  }
  
  /* Extra responsive controls for very small screens */
  .controls {
    flex-direction: column;
    gap: 8px;
  }
  
  .control-item {
    padding: 6px 8px;
    gap: 6px;
  }
  
  .key {
    padding: 4px 6px;
    font-size: 0.7rem;
    min-width: 35px;
  }
  
  .description {
    font-size: 0.75rem;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .ui-value {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  
  .game-title,
  .game-over-title {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Foldable devices */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
  .modal-container {
    padding: 15px;
    align-items: flex-start;
    padding-top: 30px;
  }
  
  .modal-content {
    padding: 25px 30px;
    margin: 15px;
    max-height: 85vh;
    overflow-y: auto;
  }
  
  .game-title {
    font-size: 2.5rem;
  }
  
  .game-over-title {
    font-size: 2.5rem;
  }
  
  .ui-panel {
    padding: 8px 16px;
  }
  
  .ui-row.desktop-row {
    gap: 18px;
  }
  
  .ui-stat {
    min-width: 70px;
  }
}

/* Accessibility improvements for reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .floating-point {
    animation: none;
  }
  
  .btn-glow {
    transition: none;
  }
  
  .btn:hover .btn-glow {
    left: -100%;
  }
}

/* Enhanced touch and accessibility for game over modal */
@media (max-width: 768px) {
  .game-over-modal .btn {
    /* Ensure minimum touch target size */
    min-height: 44px;
    min-width: 44px;
    
    /* Improve touch feedback */
    -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
    
    /* Better touch interaction */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
  }
  
  .game-over-modal .btn:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
  
  /* Prevent text selection on mobile */
  .game-over-modal {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  /* Allow text selection for important content */
  .game-over-modal .score-value,
  .game-over-modal .game-over-message p {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
  }
  
  /* Better focus indicators for accessibility */
  .game-over-modal .btn:focus {
    outline: 2px solid rgba(102, 126, 234, 0.8);
    outline-offset: 2px;
  }
  
  /* High contrast mode support */
  @media (prefers-contrast: high) {
    .game-over-modal .modal-content {
      border: 2px solid #ffffff;
      background: rgba(0, 0, 0, 0.8);
    }
    
    .game-over-modal .score-item {
      border: 1px solid #ffffff;
      background: rgba(255, 255, 255, 0.1);
    }
    
    .game-over-modal .btn {
      border: 2px solid #ffffff;
    }
  }
}



/* Print styles */
@media print {
  .game-ui,
  .screen-overlay {
    display: none !important;
  }
  
  canvas {
    width: 100% !important;
    height: auto !important;
  }
}