:root {
  --carrot: #ff7a1a;
  --carrot-dark: #e85d04;
  --leaf: #57cc5b;
  --ink: #2b1d12;
  --cream: #fff7ec;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8fd3ff;
  font-family: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

#game { position: fixed; inset: 0; }

#scene { display: block; width: 100%; height: 100%; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud.hidden { display: none; }

.panel {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: rgba(43, 29, 18, 0.55);
  color: var(--cream);
  border-radius: 14px;
  padding: 8px 16px;
  margin: 6px;
  backdrop-filter: blur(4px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  min-width: 74px;
}
.panel .label { font-size: 12px; letter-spacing: 2px; opacity: 0.8; }
.panel span:last-child { font-size: 28px; font-weight: 800; line-height: 1; }
.panel .muted { font-size: 15px; opacity: 0.65; font-weight: 600; }

#hud-top-left { position: absolute; top: 14px; left: 14px; display: flex; }
#hud-top-right { position: absolute; top: 14px; right: 14px; display: flex; }

#speedo {
  position: absolute;
  bottom: 20px;
  right: 24px;
  text-align: center;
  color: var(--cream);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}
#speed-value { font-size: 60px; font-weight: 900; line-height: 0.9; }
.speed-unit { font-size: 14px; letter-spacing: 3px; opacity: 0.85; }

#boost-bar {
  margin: 8px auto 0;
  width: 150px;
  height: 12px;
  border-radius: 8px;
  background: rgba(43, 29, 18, 0.5);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
#boost-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd166, var(--carrot));
  border-radius: 8px;
  transition: width 0.08s linear;
}

#minimap {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(43, 29, 18, 0.35);
  border-radius: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* ---------- Center message ---------- */
#center-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 140px;
  font-weight: 900;
  color: var(--cream);
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.18), 0 12px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
}
#center-message.pop { animation: pop 0.9s ease-out; }
@keyframes pop {
  0% { opacity: 0; transform: scale(0.3); }
  25% { opacity: 1; transform: scale(1.15); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(143, 211, 255, 0.35), rgba(43, 29, 18, 0.72));
  backdrop-filter: blur(3px);
  z-index: 10;
}
.overlay.hidden { display: none; }

.card {
  background: var(--cream);
  border-radius: 24px;
  padding: 34px 42px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  border: 4px solid #ffe0b5;
}
.card h1 { font-size: 40px; color: var(--carrot-dark); margin-bottom: 8px; }
.tagline { font-size: 17px; margin-bottom: 18px; color: #6b543f; }
.hint { font-size: 14px; margin: 16px 0 22px; color: #6b543f; }

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
  text-align: left;
  font-size: 14px;
  margin: 10px auto;
  width: fit-content;
}
.controls > div { display: flex; align-items: center; gap: 6px; }

.key {
  display: inline-block;
  min-width: 24px;
  padding: 3px 7px;
  background: #fff;
  border: 2px solid #d9c3a5;
  border-bottom-width: 4px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

button {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ff9b3d, var(--carrot));
  border: none;
  border-radius: 999px;
  padding: 14px 40px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 6px 0 var(--carrot-dark), 0 10px 20px rgba(232, 93, 4, 0.4);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--carrot-dark); }

#results { text-align: left; margin: 6px auto 18px; width: fit-content; font-size: 16px; }
#results .row { display: flex; justify-content: space-between; gap: 26px; padding: 3px 0; }
#results .me { font-weight: 800; color: var(--carrot-dark); }
