:root {
  --bg: #07111f;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --you: #38bdf8;
  --bot: #f97316;
  --accent: #a3e635;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 0%, rgba(56, 189, 248, 0.18), transparent 45%),
    radial-gradient(ellipse at 80% 100%, rgba(249, 115, 22, 0.12), transparent 40%),
    linear-gradient(180deg, #07111f, #0f172a 55%, #111827);
  user-select: none;
  touch-action: manipulation;
}

.header {
  text-align: center;
  padding: 1rem 1rem 0.25rem;
}

.header h1 {
  margin: 0.2rem 0;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.hud {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem 1.4rem;
  margin: 0.6rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.hud strong {
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.score .you strong {
  color: var(--you);
}

.score .bot strong {
  color: var(--bot);
}

.sep {
  margin: 0 0.35rem;
  opacity: 0.5;
}

.stage {
  position: relative;
  width: min(900px, 96vw);
  margin: 0.4rem auto 0.8rem;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 2px #334155, 0 18px 40px rgba(0, 0, 0, 0.45);
  background: #14532d;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1.2rem;
  text-align: center;
  background: rgba(7, 17, 31, 0.82);
  backdrop-filter: blur(4px);
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

#overlay-title {
  margin: 0;
  font-size: 1.6rem;
  color: var(--accent);
}

.hint {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

#start,
.overlay-actions button {
  border: 0;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: #14532d;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.goal-flash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  font-size: clamp(2.5rem, 10vw, 4rem);
  font-weight: 900;
  opacity: 0;
  z-index: 4;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
}

.goal-flash.show {
  animation: goal-pop 1s ease forwards;
}

.goal-flash.you {
  color: var(--you);
}

.goal-flash.bot {
  color: var(--bot);
}

@keyframes goal-pop {
  0% {
    opacity: 0;
    transform: scale(0.4);
  }
  25% {
    opacity: 1;
    transform: scale(1.25);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.1);
  }
}

.controls {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 1rem 0.75rem;
}

.mobile-pad {
  display: none;
  max-width: 900px;
  margin: 0 auto 1.5rem;
  padding: 0 1rem;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-end;
}

.mobile-pad button {
  font: inherit;
  font-weight: 800;
  border: none;
  border-radius: 12px;
  background: #1e293b;
  color: #f8fafc;
  padding: 0.85rem 1rem;
  min-width: 64px;
  min-height: 54px;
  cursor: pointer;
}

#btn-gas {
  background: #16a34a;
  color: #052e16;
}

#btn-boost {
  background: #eab308;
  color: #422006;
}

.pad-steer,
.pad-drive {
  display: flex;
  gap: 0.5rem;
}

.overlay-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.overlay button.secondary {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
}

.shop {
  max-width: 900px;
  margin: 0 auto 2.5rem;
  padding: 0 1rem;
}

.shop h2 {
  text-align: center;
  margin: 0 0 0.35rem;
  color: var(--accent);
}

.shop-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
}

.car-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 0.85rem 0.7rem;
  text-align: center;
}

.car-card.equipped {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(163, 230, 53, 0.35);
}

.car-preview {
  width: 56px;
  height: 28px;
  margin: 0 auto 0.5rem;
  border-radius: 5px;
  border: 2px solid #fff;
  box-shadow: 0 0 10px currentColor;
}

.car-card h3 {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.car-card .price,
.car-card .blurb,
.car-card .stats {
  margin: 0.12rem 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.car-card .price {
  color: #fde68a;
}

.car-btn {
  margin-top: 0.5rem;
  width: 100%;
  padding: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: var(--accent);
  color: #14532d;
}

.car-btn:disabled {
  opacity: 0.65;
  cursor: default;
}

.car-btn.owned {
  background: #38bdf8;
  color: #0f172a;
}

.car-btn.equipped-btn {
  background: #475569;
  color: #e2e8f0;
}

@media (max-width: 900px), (pointer: coarse) {
  .mobile-pad {
    display: flex;
  }
  .controls {
    display: none;
  }
}
