:root {
  --ink: #1e293b;
  --text: #f8fafc;
  --sky: #6eb8e0;
  /* Stage ratio — used on wide / desktop only */
  --stage-ar-w: 11;
  --stage-ar-h: 16;
}

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

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  overflow: hidden;
  background: var(--sky);
  font-family: "Kantumruy Pro", system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  min-height: -webkit-fill-available;
  display: grid;
  place-items: stretch;
  overflow: hidden;
  background: var(--sky);
}

/* Mobile-first: fill the whole screen (no letterbox bars) */
.stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  overflow: hidden;
  background: #5ec8f0;
}

/* Desktop / large screens: keep a portrait stage frame centered */
@media (min-width: 900px) {
  #app {
    place-items: center;
  }

  .stage {
    width: min(100vw, calc(100dvh * var(--stage-ar-w) / var(--stage-ar-h)));
    height: min(100dvh, calc(100vw * var(--stage-ar-h) / var(--stage-ar-w)));
    max-width: 100vw;
    max-height: 100dvh;
    aspect-ratio: var(--stage-ar-w) / var(--stage-ar-h);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
  }
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #7ec8e8 0%, #b8dfe8 55%, #d4ebf0 100%);
  cursor: default;
  z-index: 1;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
}

.overlay.hidden,
.hidden {
  display: none !important;
}

#gameover.overlay {
  display: grid;
  place-items: center;
  background: rgba(20, 40, 30, 0.5);
  backdrop-filter: blur(3px);
}

/* ── Home fills the shared stage ── */

.home-screen {
  display: grid;
  place-items: stretch;
  width: 100%;
  height: 100%;
  background: transparent;
}

.home-frame {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  max-height: none;
  overflow: hidden;
  box-shadow: none;
}

.home-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Bottom dock: GARAGE · START · STAGES */

.menu-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(1.5rem, 6vh, 3rem));
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  justify-items: center;
  gap: clamp(0.65rem, 4vw, 1.1rem);
  padding: 0.75rem 5% calc(0.75rem + env(safe-area-inset-bottom, 0px));
  width: auto;
  max-width: min(520px, 96vw);
  margin-inline: auto;
}

.menu-dock .shop-btn:first-child {
  justify-self: end;
}

.menu-dock .shop-btn:last-child {
  justify-self: start;
}

.shop-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #fff;
}

.shop-icon {
  width: clamp(56px, 15vw, 72px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 3px solid #fff;
  background: linear-gradient(180deg, #5b8def 0%, #3b6fd4 55%, #2a4f9e 100%);
  box-shadow: 0 4px 0 #1e3a6e, 0 6px 12px rgba(15, 40, 80, 0.3);
}

.shop-icon svg {
  width: 70%;
  height: 70%;
  display: block;
}

.shop-label {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(0.7rem, 3vw, 0.85rem);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 #0f172a, 0 2px 4px rgba(0, 0, 0, 0.35);
}

.shop-btn.is-active .shop-icon {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow: 0 4px 0 #1e3a6e, 0 0 0 3px #fbbf24, 0 6px 12px rgba(15, 40, 80, 0.3);
}

.shop-btn:hover .shop-icon,
.shop-btn:focus-visible .shop-icon {
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.upgrade-card.is-hidden,
.upgrade-vehicles.is-hidden {
  display: none !important;
}

.upgrade-card.is-focus {
  flex: 1 1 auto;
  max-width: 220px;
  margin-inline: auto;
  transform: scale(1.04);
}

.upgrade-panel[data-mode="tire"] .upgrade-rack,
.upgrade-panel[data-mode="suspension"] .upgrade-rack {
  justify-content: center;
  max-width: 280px;
}

.shop-btn:active .shop-icon {
  transform: translateY(1px);
}

.menu-start {
  position: relative;
  justify-self: center;
  width: auto;
  min-width: clamp(128px, 36vw, 168px);
  min-height: clamp(52px, 12vw, 60px);
  padding: 0.55rem 1.35rem 0.65rem;
  border: 4px solid #fff;
  border-radius: 999px;
  background: linear-gradient(180deg, #7aef62 0%, #3dcc3a 42%, #22a01f 100%);
  color: #fff;
  cursor: pointer;
  box-shadow:
    0 0 14px rgba(90, 220, 70, 0.45),
    0 5px 0 #14532d,
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease, filter 0.15s ease;
  animation: start-bob 2.4s ease-in-out infinite;
}

.menu-start-shine {
  position: absolute;
  inset: 4px 8px auto 8px;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent);
  pointer-events: none;
}

.menu-start-label {
  position: relative;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  letter-spacing: 0.1em;
  text-shadow: 0 2px 0 #14532d;
}

.menu-start:hover,
.menu-start:focus-visible {
  filter: brightness(1.06);
  transform: translateY(-2px) scale(1.02);
  outline: none;
  animation: none;
}

.menu-start:active {
  transform: translateY(2px) scale(0.98);
}

@keyframes start-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

button {
  font-family: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.btn-start {
  width: 100%;
  padding: 0.85rem 1.6rem 0.95rem;
  border-radius: 999px;
  border: 5px solid #fff;
  background: linear-gradient(180deg, #7aef62 0%, #3dcc3a 45%, #22a01f 100%);
  color: #fff;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(1.15rem, 3.5vw, 1.5rem);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 #14532d;
  box-shadow: 0 6px 0 #14532d, 0 10px 20px rgba(20, 80, 30, 0.35);
}

.btn-start--wide {
  border-radius: 16px;
}

.btn-start:hover {
  filter: brightness(1.05);
}

button.secondary {
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: #fff;
  color: #475569;
  border: 3px solid #1e293b;
  box-shadow: 0 3px 0 #1e293b;
  font-size: 1rem;
}

button.secondary:hover {
  background: #f8fafc;
}

/* Shop panels (legacy small cards) */

.shop-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(15, 30, 20, 0.45);
  backdrop-filter: blur(3px);
}

.shop-card {
  width: min(360px, 90vw);
  padding: 1.4rem 1.15rem 1.15rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  border: 4px solid #1e293b;
  box-shadow: 0 12px 0 #1e293b;
  text-align: center;
}

.shop-card h2 {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.85rem;
}

/* ── Stage selection grid ── */

.stages-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.55rem, 1.5vh, 0.85rem);
  padding:
    calc(env(safe-area-inset-top, 0px) + 0.75rem)
    4%
    calc(env(safe-area-inset-bottom, 0px) + 0.85rem);
  background:
    radial-gradient(ellipse at 50% 0%, #4a6a9a 0%, transparent 55%),
    linear-gradient(180deg, #5ec8f0 0%, #8ed4a0 100%);
  overflow-y: auto;
}

.stages-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 0.55rem);
  right: 0.65rem;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 3px solid #0f172a;
  border-radius: 12px;
  background: linear-gradient(180deg, #f87171, #dc2626);
  color: #fff;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 #7f1d1d;
  font-family: inherit;
}

.stages-coins {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
  padding: 0.35rem 0.95rem 0.4rem 0.55rem;
  border: 3px solid #0f172a;
  border-radius: 999px;
  background: linear-gradient(180deg, #1e293b, #0f172a);
  color: #fde68a;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  letter-spacing: 0.04em;
  box-shadow: 0 4px 0 #020617;
}

.stages-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.5rem, 2vw, 0.75rem);
  width: min(720px, 100%);
}

.level-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0;
  border: none;
  background: transparent;
  color: #0f172a;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease;
}

.level-card:hover:not(.is-locked) {
  transform: translateY(-2px);
}

.level-frame {
  border: 5px solid #1a2332;
  border-radius: 14px;
  overflow: hidden;
  background: #1a2332;
  box-shadow: 0 6px 0 #0f172a;
}

.level-card.selected .level-frame {
  border-color: #fbbf24;
  box-shadow: 0 0 0 3px #fbbf24, 0 6px 0 #92400e;
}

.level-art {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #87ceeb;
}

.level-art img,
.level-art svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.level-art--faded {
  opacity: 0.45;
  filter: grayscale(0.2) saturate(0.75);
}

.level-lock-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.15);
  pointer-events: none;
}

.level-lock-overlay svg {
  width: clamp(52px, 22%, 72px);
  height: auto;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35));
}

.level-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.65rem;
  background: #fff;
  border-top: 4px solid #0f172a;
}

.level-lock svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
}

.level-lock.is-hidden {
  display: none;
}

.level-name {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(0.68rem, 2.6vw, 0.88rem);
  letter-spacing: 0.05em;
  line-height: 1.1;
  color: #0f172a;
}

.level-record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.15rem 0.35rem 0;
  min-height: 1.35rem;
}

.level-record.is-hidden {
  display: none;
}

.level-check svg {
  width: 18px;
  height: 18px;
  display: block;
}

.level-distance {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: 0.72rem;
  color: #15803d;
  letter-spacing: 0.03em;
}

.level-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  border: 4px solid #0f172a;
  border-radius: 10px;
  background: linear-gradient(180deg, #334155, #1e293b);
  color: #fde68a;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 0 #0f172a;
}

.level-price.is-hidden {
  display: none;
}

.level-price .upgrade-coin-icon {
  width: 1em;
  height: 1em;
}

.level-price.is-affordable {
  background: linear-gradient(180deg, #475569, #334155);
  color: #fef08a;
}

.level-card.is-locked .level-lock-overlay {
  display: grid;
}

.level-card:not(.is-locked) .level-lock-overlay {
  display: none;
}

/* ── Upgrade shop (full overlay) ── */

.upgrade-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.5rem, 1.5vh, 0.9rem);
  padding:
    calc(env(safe-area-inset-top, 0px) + 0.75rem)
    3%
    calc(env(safe-area-inset-bottom, 0px) + 0.75rem);
  background:
    radial-gradient(ellipse at 50% 0%, #3d4a6b 0%, transparent 55%),
    linear-gradient(180deg, #2a3148 0%, #3a3550 42%, #2c2a3a 100%);
  overflow: hidden;
}

.upgrade-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 0.55rem);
  right: 0.65rem;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 3px solid #0f172a;
  border-radius: 12px;
  background: linear-gradient(180deg, #f87171, #dc2626);
  color: #fff;
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 #7f1d1d;
  font-family: inherit;
}

.upgrade-coins {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.15rem;
  padding: 0.35rem 0.95rem 0.4rem 0.55rem;
  border: 3px solid #0f172a;
  border-radius: 999px;
  background: linear-gradient(180deg, #1e293b, #0f172a);
  color: #fde68a;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(1.05rem, 4.5vw, 1.35rem);
  letter-spacing: 0.04em;
  box-shadow: 0 4px 0 #020617, inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.upgrade-coin-icon,
.upgrade-buy-coin {
  display: inline-block;
  width: 1.35em;
  height: 1.35em;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff7ae, #fbbf24 45%, #d97706 100%);
  border: 2px solid #92400e;
  box-shadow: inset 0 -2px 0 rgba(146, 64, 14, 0.35);
  flex-shrink: 0;
}

.upgrade-buy-coin {
  width: 1.05em;
  height: 1.05em;
}

/* Blue rack — flex row of 4 upgrade cards */
.upgrade-rack {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: clamp(0.35rem, 1.5vw, 0.7rem);
  width: min(920px, 100%);
  padding: clamp(0.55rem, 1.6vw, 0.85rem);
  border: 4px solid #0f172a;
  border-radius: 18px;
  background: linear-gradient(180deg, #4aa3e8 0%, #2b7fc7 55%, #1d6aaf 100%);
  box-shadow: 0 8px 0 #0c4a7a, inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.upgrade-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.45rem 0.35rem 0.5rem;
  border: 3px solid #0f172a;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  box-shadow: 0 4px 0 #0f172a;
  text-align: center;
}

.upgrade-level {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(0.7rem, 2.4vw, 0.9rem);
  color: #0f172a;
  letter-spacing: 0.02em;
}

.upgrade-icon {
  width: clamp(44px, 12vw, 64px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.upgrade-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.upgrade-name {
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(0.55rem, 2vw, 0.78rem);
  letter-spacing: 0.04em;
  color: #0f172a;
  line-height: 1.1;
}

.upgrade-buy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  margin-top: auto;
  padding: 0.4rem 0.3rem;
  border: 3px solid #0f172a;
  border-radius: 10px;
  background: linear-gradient(180deg, #86ef65 0%, #22c55e 55%, #15803d 100%);
  color: #fff;
  font-family: "Black Ops One", system-ui, sans-serif;
  font-size: clamp(0.65rem, 2.2vw, 0.85rem);
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 3px 0 #14532d, inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: filter 0.12s ease, transform 0.12s ease;
}

.upgrade-buy:hover:not(:disabled),
.upgrade-buy:focus-visible:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.upgrade-buy:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #14532d;
}

/* Affordable but pricey look */
.upgrade-buy.is-warn {
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 55%, #c2410c 100%);
  box-shadow: 0 3px 0 #7c2d12, inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Not enough coins — grey/red, disabled */
.upgrade-buy:disabled,
.upgrade-buy.is-locked {
  background: linear-gradient(180deg, #94a3b8 0%, #64748b 55%, #475569 100%);
  box-shadow: 0 3px 0 #334155;
  color: #e2e8f0;
  cursor: not-allowed;
  filter: grayscale(0.25);
  opacity: 0.92;
}

.upgrade-buy.is-max {
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  color: #0f172a;
  box-shadow: 0 3px 0 #92400e;
  cursor: default;
}

.upgrade-stage {
  position: relative;
  flex: 1 1 auto;
  width: min(720px, 100%);
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.5rem 0.5rem 0.25rem;
  border: 4px solid #0f172a;
  border-radius: 18px;
  background: linear-gradient(180deg, #3a3550 0%, #2a2838 60%, #1e1c28 100%);
  box-shadow: 0 8px 0 #0f0e14, inset 0 0 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.upgrade-flags {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background:
    repeating-linear-gradient(
      -18deg,
      transparent 0 18px,
      rgba(255, 255, 255, 0.07) 18px 22px
    ),
    repeating-linear-gradient(
      18deg,
      transparent 0 22px,
      rgba(0, 0, 0, 0.12) 22px 26px
    );
  pointer-events: none;
}

.upgrade-jeep {
  position: relative;
  z-index: 1;
  width: min(280px, 70%);
  margin-bottom: 0.15rem;
  filter: drop-shadow(0 8px 0 rgba(0, 0, 0, 0.35));
  animation: jeep-idle 2.8s ease-in-out infinite;
}

.garage-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  display: block;
}

.upgrade-jeep svg,
.garage-car-fallback svg {
  width: 100%;
  height: auto;
  display: block;
}

@keyframes jeep-idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.upgrade-vehicles {
  position: relative;
  z-index: 1;
  width: min(280px, 90%);
  margin-bottom: 0.35rem;
}

.upgrade-vehicles .vehicle-card {
  padding: 0.55rem 0.4rem;
  background: rgba(248, 250, 252, 0.92);
}

.upgrade-vehicles .vehicle-name {
  font-size: 1rem;
  font-family: "Kantumruy Pro", system-ui, sans-serif;
  font-weight: 700;
}

.vehicle-shop {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  width: min(100%, 320px);
  margin-inline: auto;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.15rem;
}

.vehicle-shop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.55rem 0.35rem 0.5rem;
  border-radius: 12px;
  border: 3px solid #1e293b;
  background: #f8fafc;
  cursor: pointer;
  color: #0f172a;
  box-shadow: 0 3px 0 #1e293b;
  transition: transform 0.12s ease, background 0.12s ease;
}

.vehicle-shop-card:hover {
  transform: translateY(-2px);
}

.vehicle-shop-card.is-selected {
  background: linear-gradient(180deg, #fff7d6, #ffe08a);
  box-shadow: 0 3px 0 #92400e;
}

.vehicle-shop-card.is-locked {
  opacity: 0.92;
  background: #e2e8f0;
}

.vehicle-shop-card.is-locked:not(.is-affordable) {
  cursor: not-allowed;
  opacity: 0.7;
}

.vehicle-shop-swatch {
  width: 36px;
  height: 22px;
  border-radius: 7px;
  border: 2px solid #0f172a;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.vehicle-shop-name {
  font-family: "Kantumruy Pro", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.vehicle-shop-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #334155;
}

.vehicle-shop-card.is-affordable .vehicle-shop-meta {
  color: #b45309;
}

.vehicle-shop-card .upgrade-coin-icon {
  width: 12px;
  height: 12px;
}

.vehicle-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.vehicle-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 0.5rem;
  border-radius: 14px;
  border: 3px solid #1e293b;
  background: #f1f5f9;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 0 #1e293b;
  transition: transform 0.15s ease, background 0.15s ease;
}

.vehicle-card:hover {
  transform: translateY(-2px);
}

.vehicle-card.selected {
  background: linear-gradient(180deg, #fff7d6, #ffe08a);
  box-shadow: 0 4px 0 #92400e;
}

.vehicle-name {
  font-weight: 700;
  font-size: 1rem;
}

.vehicle-desc {
  font-size: 0.72rem;
  color: #64748b;
}

.controls-hint {
  list-style: none;
  text-align: left;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.7;
  margin-bottom: 1rem;
}

kbd {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: #e2e8f0;
  border: 1px solid #94a3b8;
  font-size: 0.72rem;
  text-align: center;
}

/* Game over */

.menu-panel,
.gameover-panel {
  width: min(400px, 92vw);
  padding: 2rem 1.75rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  border: 4px solid #1e293b;
  box-shadow: 0 12px 0 #1e293b;
  text-align: center;
}

.gameover-panel h2 {
  font-family: "Black Ops One", "Kantumruy Pro", sans-serif;
  font-size: 1.65rem;
  margin-bottom: 0.65rem;
}

#final-distance,
#final-coins {
  color: #64748b;
  margin-bottom: 0.4rem;
  font-size: 1.1rem;
}

#final-coins {
  margin-bottom: 1.2rem;
  color: #c2410c;
  font-weight: 700;
}

/* HUD */

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  display: block;
  padding: calc(env(safe-area-inset-top, 0px) + 0.7rem) 0.85rem 1rem;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(8, 20, 14, 0.55), transparent);
  color: var(--text);
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.55rem 0.85rem;
  padding-right: 6.5rem;
}

.hud-actions {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 0.55rem);
  right: 0.7rem;
  z-index: 9;
  display: flex;
  gap: 0.45rem;
  pointer-events: auto;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 72px;
}

.hud-stat .label {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.hud-stat span:last-child {
  font-size: 1.1rem;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hud-stat.coins span:last-child {
  color: #ffd60a;
}

.hud-btn,
.sound-toggle {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
  border-radius: 14px;
  background: rgba(8, 20, 14, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

.pause-toggle {
  background: rgba(185, 28, 28, 0.72);
  border-color: rgba(254, 202, 202, 0.55);
}

.hud-btn:hover,
.sound-toggle:hover,
.pause-toggle:hover {
  filter: brightness(1.1);
}

.sound-toggle.muted {
  opacity: 0.5;
}

.hud-stat.fuel {
  flex: 1 1 140px;
  max-width: 220px;
  align-items: stretch;
}

.pause-overlay {
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 12;
}

.pause-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  min-width: min(280px, 78vw);
  padding: 1.4rem 1.25rem 1.25rem;
}

.pause-panel h2 {
  text-align: center;
  margin-bottom: 0.35rem;
  color: #f8fafc;
  font-family: "Black Ops One", system-ui, sans-serif;
  letter-spacing: 0.06em;
}

.pause-panel .secondary {
  margin-top: 0.15rem;
}

.fuel-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  margin-top: 0.35rem;
}

#fuel-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e85d04, #f4a261, #90be6d);
  transition: width 0.1s linear;
}

/* On-screen drive pedals (brake / gas) */

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem;
  padding: 0 6% calc(0.85rem + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.touch-pedal {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: grid;
  place-items: center;
  width: clamp(64px, 18vw, 84px);
  height: clamp(80px, 23vw, 104px);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
  transition: transform 0.1s ease, filter 0.1s ease, opacity 0.1s ease;
  opacity: 0.95;
  transform-origin: 50% 88%;
}

.touch-pedal__svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  overflow: visible;
}

.touch-pedal.is-held,
.touch-pedal:active {
  transform: translateY(8px) scale(0.93);
  opacity: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) brightness(1.15);
}

.touch-pedal--brake.is-held,
.touch-pedal--brake:active {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) brightness(1.12) saturate(1.25);
}

.touch-pedal--gas.is-held,
.touch-pedal--gas:active {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) brightness(1.18) saturate(1.3);
}

@media (hover: hover) and (pointer: fine) {
  .touch-pedal {
    opacity: 0.85;
  }

  .touch-pedal:hover {
    opacity: 1;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)) brightness(1.06);
  }
}

@media (max-width: 700px) {
  .home-art {
    object-position: center center;
  }

  .menu-dock {
    gap: clamp(0.5rem, 3.5vw, 0.85rem);
    max-width: min(460px, 96vw);
    bottom: calc(env(safe-area-inset-bottom, 0px) + clamp(1.25rem, 5vh, 2.5rem));
    padding: 0.65rem 4% calc(0.55rem + env(safe-area-inset-bottom, 0px));
  }

  .shop-icon {
    width: clamp(60px, 17vw, 76px);
  }

  .menu-start {
    min-height: 54px;
    min-width: clamp(120px, 34vw, 160px);
  }

  .upgrade-rack {
    flex-wrap: wrap;
  }

  .upgrade-card {
    flex: 1 1 calc(50% - 0.35rem);
    max-width: calc(50% - 0.35rem);
  }

  #hud {
    padding: calc(env(safe-area-inset-top, 0px) + 0.65rem) 0.75rem 1rem;
  }

  .hud-stats {
    padding-right: 6.25rem;
    gap: 0.45rem 0.65rem;
  }

  .hud-stat.fuel {
    flex: 1 1 100%;
    max-width: none;
    width: 100%;
  }

  .hud-actions {
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: 0.55rem;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .home-art {
    object-position: center 22%;
  }

  .menu-dock {
    max-width: 480px;
  }

  .upgrade-panel {
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 0.6rem;
  }

  .upgrade-coins {
    width: 100%;
    justify-content: center;
  }

  .upgrade-rack {
    width: min(58%, 560px);
    flex-wrap: nowrap;
  }

  .upgrade-card {
    flex: 1 1 0;
    max-width: none;
  }

  .upgrade-stage {
    width: min(38%, 340px);
    flex: 0 1 auto;
    min-height: 200px;
  }

  .upgrade-jeep {
    width: min(220px, 85%);
  }

  .stages-grid {
    width: min(85%, 820px);
    gap: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-start,
  .upgrade-jeep {
    animation: none;
  }
}
