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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(108, 45, 130, 0.25), transparent 50%),
    radial-gradient(ellipse at 80% 60%, rgba(26, 58, 107, 0.30), transparent 50%),
    linear-gradient(180deg, #06061a 0%, #0d1137 60%, #0a0e2e 100%);
  color: #e0d8f8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

/* ── Character selection (Race style) ── */
#image-selection {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
  text-align: center;
  position: relative;
  z-index: 1;
}

#image-selection button,
#image-selection #mario-button,
#image-selection #luigi-button,
#image-selection #peach-button,
#image-selection #toad-button {
  color: white;
  font-weight: bold;
  font-size: 2em;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.4s;
  min-width: 120px;
  min-height: 40px;
  flex: 1 1 120px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

#image-selection button:not(#mario-button):not(#luigi-button):not(#peach-button):not(#toad-button) {
  background: linear-gradient(90deg, #8b5cf6, #6d28d9);
}

#toad-button {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}
#toad-button:hover {
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.40);
}

#image-selection button:hover {
  color: white;
  transform: translateY(-3px);
}

#mario-button {
  background: linear-gradient(90deg, #ef4444, #dc2626) !important;
}
#mario-button:hover {
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.40) !important;
}

#luigi-button {
  background: linear-gradient(90deg, #22c55e, #16a34a) !important;
}
#luigi-button:hover {
  box-shadow: 0 8px 25px rgba(34, 197, 94, 0.40) !important;
}

#peach-button {
  background: linear-gradient(90deg, #f472b6, #ec4899) !important;
}
#peach-button:hover {
  box-shadow: 0 8px 25px rgba(244, 114, 182, 0.40) !important;
}

/* ── Game wrapper ── */
#game-wrapper {
  width: 100%;
  text-align: center;
}

/* ── HUD ── */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(20, 18, 50, 0.8);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px 12px 0 0;
  font-size: 1rem;
  font-weight: 600;
}

#level-display {
  color: #e040fb;
}

#coin-display {
  color: #ffd700;
}

#lives-display {
  color: #ff6b6b;
}

/* ── Canvas ── */
#gameCanvas {
  width: 100%;
  height: auto;
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-top: none;
  display: block;
  background: #0f0c29;
}

#gameCanvas {
  max-width: 100vw;
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay[hidden] {
  display: none;
}

.overlay-box {
  background: linear-gradient(145deg, #1a1745, #0d1137);
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 20px;
  padding: 36px 48px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.15);
}

.overlay-box h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
  color: #e0d8f8;
}

.overlay-box p {
  color: #a098c8;
  font-size: 1rem;
  margin-bottom: 20px;
}

.overlay-btn {
  padding: 12px 28px;
  background: linear-gradient(135deg, #06d6a0, #05b888);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 15px rgba(6, 214, 160, 0.3);
}

.overlay-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(6, 214, 160, 0.5);
}

/* ── D-Pad styles injected by JS (Race style) ── */
