@font-face {
  font-family: 'ComicSans';
  src: url('../Comic-Sans-MS.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #000; overflow: hidden; font-family: 'ComicSans', 'Comic Sans MS', cursive; }

/* MAIN MENU */
#mainMenu {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at center, #1a0033 0%, #000 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
}
#mainMenu h1 {
  font-size: 72px; color: #FFD700;
  text-shadow: 4px 4px 0 #FF0000, 8px 8px 0 #0000AA, -2px -2px 10px #fff;
  letter-spacing: 4px; text-align: center; line-height: 1.1;
}
#mainMenu .subtitle {
  font-size: 22px; color: #fff; letter-spacing: 6px;
  text-shadow: 2px 2px 0 #FF0000; margin-bottom: 10px;
}
.char-select-grid {
  display: flex; gap: 30px; margin: 10px 0;
}
.player-select {
  background: rgba(255,255,255,0.1); border: 3px solid #FFD700;
  border-radius: 12px; padding: 16px 24px; text-align: center; min-width: 200px;
}
.player-select h3 { color: #FFD700; font-size: 20px; margin-bottom: 10px; }
.player-select .char-display {
  width: 100px; height: 100px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.4); border-radius: 8px; overflow: hidden;
}
.player-select .char-display img { max-width: 90px; max-height: 90px; image-rendering: pixelated; }
.player-select .char-name { color: #fff; font-size: 16px; margin-bottom: 10px; }
.player-select .char-controls { display: flex; gap: 8px; justify-content: center; }
.char-btn {
  background: #FFD700; color: #000; border: none; padding: 6px 14px;
  font-family: inherit; font-size: 16px; font-weight: bold; cursor: pointer;
  border-radius: 4px;
}
.char-btn:hover { background: #fff; }
.controls-hint {
  color: #aaa; font-size: 13px; font-family: Arial, sans-serif;
  text-align: center; line-height: 1.6;
}
.controls-hint span { color: #FFD700; }
#startBtn, #startBtnCoop {
  background: linear-gradient(180deg, #FFD700, #FF8C00);
  color: #000; border: none; padding: 18px 60px;
  font-family: inherit; font-size: 32px; font-weight: bold;
  cursor: pointer; border-radius: 8px; letter-spacing: 2px;
  text-shadow: none; box-shadow: 0 6px 0 #8B4500;
  transform: translateY(0); transition: transform 0.1s, box-shadow 0.1s;
}
#startBtn:hover, #startBtnCoop:hover { transform: translateY(3px); box-shadow: 0 3px 0 #8B4500; background: linear-gradient(180deg, #fff700, #FFD700); }
.stars {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; overflow: hidden;
}
.star { position: absolute; border-radius: 50%; background: #fff; animation: twinkle 2s infinite alternate; }

/* MODE SELECT BUTTONS */
.mode-btn-group {
  display: flex; gap: 24px; margin: 10px 0;
}
.mode-btn {
  background: linear-gradient(180deg, #2a0060, #0a0030);
  border: 3px solid #FFD700;
  color: #FFD700;
  font-family: inherit;
  font-size: 22px;
  font-weight: bold;
  padding: 22px 36px;
  cursor: pointer;
  border-radius: 10px;
  letter-spacing: 1px;
  line-height: 1.4;
  text-align: center;
  min-width: 200px;
  box-shadow: 0 6px 0 #8B4500, 0 0 20px rgba(255,215,0,0.2);
  transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
}
.mode-btn:hover {
  transform: translateY(-3px);
  background: linear-gradient(180deg, #4a0090, #1a0060);
  box-shadow: 0 9px 0 #8B4500, 0 0 30px rgba(255,215,0,0.4);
}
.mode-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #8B4500; }
.mode-btn-sub { font-size: 14px; color: #fff; letter-spacing: 3px; display: block; margin-top: 4px; }

/* BACK BUTTON */
.back-btn {
  background: rgba(255,255,255,0.15);
  color: #FFD700;
  border: 2px solid #FFD700;
  padding: 14px 28px;
  font-family: inherit;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  letter-spacing: 1px;
  transition: background 0.15s;
}
.back-btn:hover { background: rgba(255,215,0,0.2); }

/* CPU character panel */
.cpu-select { opacity: 0.85; border-color: #aaa; }
.cpu-select h3 { color: #aaa; }

/* Screen sub-divs inside mainMenu */
#screenModeSelect, #screenCharSolo, #screenCharCoop {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; width: 100%; pointer-events: none;
  display: none; z-index: 10;
}
.player-hud {
  position: absolute; padding: 10px 16px;
  background: rgba(0,0,0,0.6); border: 2px solid #FFD700;
  border-radius: 8px; color: #fff; font-size: 14px; min-width: 160px;
}
#hud1 { top: 10px; left: 10px; }
#hud2 { top: 10px; right: 10px; text-align: right; }
.hud-name { color: #FFD700; font-size: 16px; }
.hud-lap { font-size: 22px; }
.hud-speed { color: #00ff88; }
#raceTimer {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); border: 2px solid #FFD700;
  color: #FFD700; font-size: 28px; padding: 6px 20px; border-radius: 8px;
}
#countdown {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 120px; color: #FFD700; text-shadow: 4px 4px 0 #f00, -2px -2px 0 #000;
  z-index: 20; pointer-events: none; display: none;
}
#finishBanner {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  flex-direction: column; gap: 20px; background: rgba(0,0,0,0.8); z-index: 50;
}
#finishBanner h2 { color: #FFD700; font-size: 60px; text-shadow: 4px 4px 0 #f00; }
#finishBanner p { color: #fff; font-size: 24px; }
#restartBtn {
  background: #FFD700; color: #000; border: none; padding: 14px 40px;
  font-family: inherit; font-size: 24px; cursor: pointer; border-radius: 6px;
}
#restartBtn:hover { background: #fff; }

/* Split screen divider */
#divider {
  position: fixed; top: 0; left: 50%; width: 4px; height: 100%;
  background: #FFD700; z-index: 5; display: none;
  box-shadow: 0 0 10px #FFD700;
}

/* Canvases */
#canvas1, #canvas2 {
  position: fixed; top: 0;
}
#canvas1 { left: 0; }
#canvas2 { left: 50%; }

@keyframes twinkle { from { opacity: 0.2; } to { opacity: 1; } }

/* ── HUB BUTTON ── */
#hub-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background-color: #ffd500;
  padding: 14px 28px;
  font-size: 20px;
  border: 3px solid #fbff00;
  border-radius: 4px;
  color: #505422;
  cursor: pointer;
  z-index: 200;
  text-decoration: none;
  font-family: 'ComicSans', 'Comic Sans MS', cursive;
  font-weight: bold;
  letter-spacing: 1px;
  transition: transform 0.1s;
  box-shadow: 3px 3px 0 #1a0033;
}
#hub-btn:hover { transform: scale(1.1); }

/* ── WIN SCREEN ── */
#winScreen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  background: radial-gradient(ellipse at center, #1a0044 0%, #000 100%);
  overflow: hidden;
}
#winContent {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  z-index: 2;
}
#winTrophy {
  font-size: 100px;
  animation: trophyBounce 0.7s ease-out forwards, trophyFloat 2.5s ease-in-out 0.7s infinite;
  filter: drop-shadow(0 0 30px #FFD700);
}
@keyframes trophyBounce {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg);  opacity: 1; }
  100% { transform: scale(1) rotate(0deg);   opacity: 1; }
}
@keyframes trophyFloat {
  0%, 100% { transform: translateY(0px);   }
  50%       { transform: translateY(-12px); }
}
#winTitle {
  font-size: 58px;
  color: #FFD700;
  text-shadow: 4px 4px 0 #FF0000, 8px 8px 0 #0000AA;
  letter-spacing: 4px;
  animation: winTitlePop 0.5s 0.3s ease-out both;
}
@keyframes winTitlePop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
#winPodium {
  display: flex;
  gap: 40px;
  align-items: flex-end;
  margin-top: 10px;
}
.podium-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: podiumRise 0.6s ease-out both;
}
#podium1st { animation-delay: 0.5s; }
#podium2nd { animation-delay: 0.8s; }
@keyframes podiumRise {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.podium-medal { font-size: 40px; }
.podium-char-img-wrap {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid #FFD700;
  background: #1a0033;
  display: flex;
  align-items: center;
  justify-content: center;
}
#podium2nd .podium-char-img-wrap { border-color: #aaa; width: 72px; height: 72px; }
.podium-char-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.podium-name {
  color: #fff;
  font-size: 18px;
  text-shadow: 1px 1px 0 #000;
  text-align: center;
  max-width: 130px;
}
.podium-time {
  color: #00ff88;
  font-size: 14px;
  font-family: Arial, sans-serif;
}
.podium-block {
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  border-radius: 4px 4px 0 0;
  letter-spacing: 2px;
}
.gold-block   { height: 70px; background: linear-gradient(180deg, #FFD700, #b8860b); color: #000; }
.silver-block { height: 50px; background: linear-gradient(180deg, #cccccc, #888888); color: #000; }
#podium2nd .podium-block { width: 100px; }

#winMenuBtn {
  background: linear-gradient(180deg, #FFD700, #FF8C00);
  color: #000;
  border: none;
  padding: 16px 50px;
  font-family: inherit;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  border-radius: 8px;
  letter-spacing: 2px;
  box-shadow: 0 6px 0 #8B4500;
  transform: translateY(0);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-top: 10px;
  animation: podiumRise 0.5s 1.1s ease-out both;
}
#winMenuBtn:hover { transform: translateY(3px); box-shadow: 0 3px 0 #8B4500; }

/* Confetti particles */
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  z-index: 1;
}
@keyframes confettiFall {
  0%   { transform: translateY(-80px) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(100vh)  rotate(720deg); opacity: 0; }
}