* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  -ms-touch-action: none;
  touch-action: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #0a0e27 0%, #1a1a2e 50%, #0f0f1e 100%);
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  z-index: 100;
  animation: fadeIn 0.4s ease;
  overflow-y: auto;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.screen-content {
  text-align: center;
  color: white;
  max-width: 90%;
  padding: 20px;
  max-height: 100%;
  overflow-y: auto;
}

.game-title {
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 900;
  margin-bottom: 10px;
  text-shadow: 0 0 30px rgba(102, 126, 234, 0.8), 0 0 60px rgba(118, 75, 162, 0.6);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
  from { filter: brightness(1); }
  to { filter: brightness(1.2); }
}

.game-subtitle {
  font-size: clamp(14px, 2.5vw, 18px);
  color: #b0b0b0;
  margin-bottom: 20px;
}

h2 {
  font-size: clamp(28px, 5vw, 42px);
  margin-bottom: 20px;
  color: #fff;
  text-shadow: 0 2px 20px rgba(255, 255, 255, 0.3);
}

h3 {
  font-size: clamp(18px, 3vw, 24px);
  margin-bottom: 15px;
  color: #667eea;
}

.final-score {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: bold;
  color: #ffd700;
  margin: 15px 0 10px 0;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
}

.coins-earned {
  font-size: clamp(20px, 4vw, 32px);
  font-weight: bold;
  color: #4fc3f7;
  margin-bottom: 10px;
  text-shadow: 0 0 15px rgba(79, 195, 247, 0.6);
}

.best-score {
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 600;
  color: #9575cd;
  margin-bottom: 20px;
}

.game-over-reason {
  font-size: clamp(14px, 2vw, 16px);
  color: #ff6b6b;
  margin-bottom: 20px;
}

/* Game Over Stats Row */
.game-over-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 15px 0 20px 0;
}

.game-over-stats .final-score,
.game-over-stats .coins-earned,
.game-over-stats .best-score {
  margin: 0;
}

/* Top Row */
.top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 20px 0;
}

/* Coins Display */
.coins-display {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 215, 0, 0.15);
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 12px;
  padding: 10px 20px;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 700;
  color: #ffd700;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
}

.coin-icon {
  font-size: clamp(24px, 5vw, 32px);
  animation: coinSpin 3s linear infinite;
}

@keyframes coinSpin {
  0%, 100% { transform: rotateY(0deg); }
  50% { transform: rotateY(180deg); }
}

.coin-icon-small {
  font-size: 1.2em;
}

/* Boosters Section */
.boosters-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 20px;
  margin: 20px 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.booster-card {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 15px;
  margin: 15px 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
}

.booster-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
}

.booster-info {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 12px;
}

.booster-icon {
  font-size: clamp(32px, 6vw, 48px);
  filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.3));
}

.booster-name {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 700;
  color: #fff;
  text-align: left;
}

.booster-desc {
  font-size: clamp(12px, 2vw, 14px);
  color: #aaa;
  text-align: left;
}

.booster-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}

.booster-buy-btn {
  padding: 8px 16px;
  font-size: clamp(13px, 2vw, 16px);
  font-weight: 600;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(102, 126, 234, 0.2);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.booster-buy-btn:hover:not(:disabled) {
  background: rgba(102, 126, 234, 0.4);
  border-color: rgba(102, 126, 234, 0.8);
  transform: scale(1.05);
}

.booster-buy-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.booster-buy-btn-large {
  padding: 12px 24px;
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(102, 126, 234, 0.3);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 5px;
}

.booster-buy-btn-large:hover:not(:disabled) {
  background: rgba(102, 126, 234, 0.5);
  border-color: rgba(102, 126, 234, 0.9);
  transform: scale(1.05);
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.booster-buy-btn-large:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.booster-owned {
  font-size: clamp(12px, 2vw, 14px);
  color: #4fc3f7;
  font-weight: 600;
}

/* Post-game boosters */
.postgame-boosters {
  background: rgba(255, 215, 0, 0.1);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 15px;
  margin: 20px 0;
}

.postgame-booster {
  margin: 10px 0;
}

.postgame-booster-title {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 10px;
}

.continue-section {
  background: rgba(243, 156, 18, 0.15);
  border: 2px solid rgba(243, 156, 18, 0.4);
  border-radius: 12px;
  padding: 15px;
  margin: 15px 0;
}

.continue-title {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 700;
  color: #f39c12;
  margin-bottom: 10px;
}

.continue-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.button-group {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
}

.btn {
  padding: 14px 32px;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
  position: relative;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.7);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* Instructions */
.instructions {
  margin-top: 20px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.instructions p {
  font-size: clamp(13px, 2vw, 15px);
  line-height: 1.8;
  color: #d0d0d0;
  margin-bottom: 10px;
}

kbd {
  display: inline-block;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  font-family: monospace;
  font-size: 0.95em;
  margin: 0 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* HUD */
#hud {
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hud-item {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: white;
  font-size: clamp(13px, 2.5vw, 17px);
  font-weight: 700;
  display: flex;
  gap: 10px;
  min-width: 140px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.hud-label {
  color: #aaa;
}

#scoreValue {
  color: #ffd700;
}

#speedValue {
  color: #4fc3f7;
}

#coinsValue {
  color: #ffd700;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Mobile Controls */
#mobile-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  display: none;
  z-index: 60;
  justify-content: space-between;
  padding: 10px;
  pointer-events: none;
}

.steer-btn {
  width: 45%;
  height: 100%;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 30px;
  color: rgba(255, 255, 255, 0.15);
  font-size: 3rem;
  pointer-events: all;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.2s, color 0.2s;
}

.steer-btn:active {
  background: linear-gradient(to top, rgba(102, 126, 234, 0.4), transparent);
  color: #667eea;
}

/* Responsive */
@media (max-width: 1024px) {
  #mobile-controls {
    display: flex;
  }
}

@media (max-width: 600px) {
  .top-row {
    gap: 15px;
    margin: 15px 0;
  }

  .game-over-stats {
    gap: 10px;
    font-size: 0.9em;
  }

  .btn {
    padding: 12px 24px;
    font-size: 14px;
  }
  
  #hud {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  
  .hud-item {
    padding: 8px 14px;
    font-size: 12px;
    min-width: 110px;
  }
}