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

:root {
  --red: #e63946;
  --blue: #4d96ff;
  --yellow: #ffd93d;
  --green: #6bcb77;
  --pink: #ff8fab;
  --purple: #c780fa;
  --grass: #a8e6cf;
  --sky: #bde0fe;
  --road: #4a4a4a;
  --white: #ffffff;
  --text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Marker Felt', sans-serif;
  overflow: hidden;
  background: var(--sky);
  user-select: none;
}

#scene-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
}

/* HUD Base */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 10;
}

.hud-panel {
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(4px);
}

/* Top Left: Lap & Timer */
#lap-timer {
  position: fixed;
  top: 20px;
  left: 20px;
  text-align: center;
}

#lap {
  font-size: 20px;
  font-weight: bold;
  color: #333;
  margin-bottom: 4px;
}

#timer {
  font-size: 28px;
  font-weight: bold;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

/* Top Right: Position & Minimap */
#top-right {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

#position {
  font-size: 32px;
  font-weight: bold;
  color: var(--red);
  text-shadow: var(--text-shadow);
  padding: 8px 20px;
}

#minimap {
  padding: 8px;
}

#minimap-canvas {
  border-radius: 8px;
  background: rgba(168, 230, 207, 0.5);
}

/* Left: Standings */
#standings {
  position: fixed;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  min-width: 180px;
}

.standings-title {
  font-size: 14px;
  font-weight: bold;
  color: #666;
  text-align: center;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#standings-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#standings-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

#standings-list li.active {
  background: rgba(230, 57, 70, 0.2);
  font-weight: bold;
}

.driver-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.driver-color.marco { background: var(--red); }
.driver-color.bruno { background: var(--blue); }
.driver-color.stella { background: var(--yellow); }
.driver-color.rex { background: var(--green); }
.driver-color.lulu { background: var(--pink); }
.driver-color.milo { background: var(--purple); }

.driver-name {
  flex: 1;
}

.driver-time {
  font-size: 12px;
  color: #666;
  font-variant-numeric: tabular-nums;
}

/* Bottom Left: Items & Watermark */
#bottom-left {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#items {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
}

.item {
  font-size: 28px;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.2));
  opacity: 0.4;
  transition: all 0.2s ease;
}

.item.active {
  opacity: 1;
  transform: scale(1.2);
  animation: pulse 0.5s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1.2); }
  100% { transform: scale(1.4); }
}

#watermark {
  color: white;
  font-size: 18px;
  font-weight: bold;
  text-shadow: var(--text-shadow);
  padding-left: 8px;
}

/* Bottom Right: Bongo Cat */
#bongo-cat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 120px;
  height: 100px;
  pointer-events: none;
}

.cat-body {
  position: relative;
  width: 100%;
  height: 100%;
}

.cat-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 50px;
  background: white;
  border-radius: 50% 50% 45% 45%;
  border: 2px solid #333;
}

.cat-ear {
  position: absolute;
  top: -8px;
  width: 20px;
  height: 20px;
  background: white;
  border: 2px solid #333;
  border-radius: 50% 50% 0 0;
}

.cat-ear.left {
  left: 2px;
  transform: rotate(-15deg);
}

.cat-ear.right {
  right: 2px;
  transform: rotate(15deg);
}

.cat-eye {
  position: absolute;
  top: 16px;
  width: 6px;
  height: 8px;
  background: #333;
  border-radius: 50%;
}

.cat-eye.left {
  left: 14px;
}

.cat-eye.right {
  right: 14px;
}

.cat-nose {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 4px;
  background: #ff8fab;
  border-radius: 50%;
}

.cat-mouth {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 6px;
  border-bottom: 2px solid #333;
  border-radius: 0 0 50% 50%;
}

.cat-paw {
  position: absolute;
  bottom: 20px;
  width: 18px;
  height: 14px;
  background: white;
  border: 2px solid #333;
  border-radius: 40% 40% 30% 30%;
  animation: bongo 0.3s infinite alternate ease-in-out;
}

.cat-paw.left {
  left: 12px;
  animation-delay: 0s;
}

.cat-paw.right {
  right: 12px;
  animation-delay: 0.15s;
}

@keyframes bongo {
  0% {
    transform: translateY(0) rotate(-5deg);
  }
  100% {
    transform: translateY(-8px) rotate(5deg);
  }
}

.keyboard {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 18px;
  background: #ddd;
  border: 2px solid #333;
  border-radius: 4px;
}

.mouse {
  position: absolute;
  bottom: 4px;
  right: 8px;
  width: 16px;
  height: 22px;
  background: #888;
  border: 2px solid #333;
  border-radius: 40% 40% 50% 50%;
}

/* Popups */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  font-weight: bold;
  color: white;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  z-index: 100;
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#go-popup {
  color: #6bcb77;
  font-size: 140px;
}

@keyframes popIn {
  0% {
    transform: translate(-50%, -50%) scale(0.3);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.popup.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.2);
  }
}

.hidden {
  display: none !important;
}

/* Victory Screen */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: auto;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.victory-card {
  background: white;
  border-radius: 24px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
  0% {
    transform: translateY(50px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.victory-card h1 {
  font-size: 64px;
  color: var(--red);
  margin-bottom: 8px;
  text-shadow: 0 4px 0 #ffd93d;
}

.results-container h2 {
  font-size: 24px;
  color: #666;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

#results-list {
  list-style: none;
  text-align: left;
  margin-bottom: 20px;
}

#results-list li {
  display: flex;
  gap: 20px;
  padding: 8px 16px;
  font-size: 20px;
  border-radius: 8px;
  margin-bottom: 4px;
}

#results-list li:first-child {
  background: rgba(255, 217, 61, 0.3);
  font-weight: bold;
}

.pos {
  width: 50px;
  font-weight: bold;
}

.name {
  flex: 1;
}

.time {
  font-variant-numeric: tabular-nums;
  color: #666;
}

.coins-reward {
  font-size: 28px;
  font-weight: bold;
  color: #ffd93d;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  margin-bottom: 30px;
}

.buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.game-btn {
  padding: 12px 32px;
  font-size: 18px;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
  background: #eee;
  color: #333;
}

.game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.game-btn.primary {
  background: var(--red);
  color: white;
}

.game-btn.primary:hover {
  background: #d62839;
}
