:root {
  color-scheme: light;
  font-family: Outfit, "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --drive-ink: #182536;
  --drive-muted: #596678;
  --drive-cream: #fff8e6;
  --drive-panel: rgba(255, 250, 232, 0.94);
  --drive-border: rgba(56, 72, 84, 0.22);
  --drive-gold: #f4bf4f;
  --drive-green: #86cf72;
  --drive-red: #ef7b78;
  --drive-blue: #7fcbe6;
  background: #dcecf2;
  color: var(--drive-ink);
}

* {
  box-sizing: border-box;
}

body.driving-body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 248, 214, 0.85), rgba(255, 248, 214, 0) 28%),
    linear-gradient(180deg, #d8f1fb 0%, #f5efd9 46%, #cde6d7 100%);
}

.driving-topbar {
  display: grid;
  grid-template-columns: 118px 148px minmax(0, 1fr) 140px;
  align-items: center;
  gap: 16px;
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 16px 0 12px;
}

.driving-topbar h1 {
  margin: 0;
  color: var(--drive-ink);
  font-size: clamp(1.4rem, 2.8vw, 2.35rem);
  font-weight: 900;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7);
}

.driving-link,
.driving-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 2px solid rgba(38, 52, 68, 0.16);
  border-radius: 8px;
  color: var(--drive-ink);
  background: rgba(255, 250, 232, 0.74);
  box-shadow: 0 8px 18px rgba(73, 91, 100, 0.12);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
}

.driving-link {
  appearance: none;
  width: 100%;
  padding: 0 10px;
  cursor: pointer;
}

.driving-link:last-child {
  justify-self: end;
}

.driving-link:hover,
.driving-controls button:hover {
  border-color: rgba(244, 191, 79, 0.72);
  background: rgba(255, 242, 188, 0.88);
}

#driving-audio-toggle[aria-pressed="false"] {
  border-color: rgba(38, 52, 68, 0.12);
  color: rgba(24, 37, 54, 0.66);
  background: rgba(255, 255, 255, 0.52);
}

.driving-shell {
  display: grid;
  gap: 14px;
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 0 0 22px;
}

.driving-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.driving-choice-group {
  display: grid;
  grid-template-columns: 84px repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  min-height: 54px;
  border: 1px solid rgba(56, 72, 84, 0.18);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 250, 232, 0.76);
  box-shadow: 0 10px 24px rgba(74, 91, 97, 0.12);
}

.driving-choice-group span {
  color: var(--drive-muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.driving-choice-group button {
  min-width: 0;
  min-height: 36px;
  border: 2px solid rgba(38, 52, 68, 0.14);
  border-radius: 8px;
  color: var(--drive-ink);
  background: rgba(255, 255, 255, 0.66);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  cursor: pointer;
}

.driving-choice-group button[aria-pressed="true"] {
  border-color: rgba(244, 191, 79, 0.88);
  background: linear-gradient(180deg, #fff8d2, #ffd978);
  box-shadow: inset 0 -2px 0 rgba(126, 91, 31, 0.16);
}

.driving-stage {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(80, 100, 104, 0.26);
  border-radius: 8px;
  background: #b6dfec;
  box-shadow: 0 18px 48px rgba(72, 91, 93, 0.28);
}

#driving-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

.driving-hud {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  pointer-events: none;
}

.driving-hud span,
.driving-message {
  min-width: 0;
  border: 1px solid var(--drive-border);
  border-radius: 8px;
  color: var(--drive-muted);
  background: var(--drive-panel);
  box-shadow: 0 8px 22px rgba(74, 91, 97, 0.16);
  font-size: clamp(0.72rem, 1.5vw, 0.92rem);
  font-weight: 800;
  line-height: 1.15;
}

.driving-hud span {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
}

.driving-hud strong {
  overflow: hidden;
  color: var(--drive-ink);
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driving-message {
  position: absolute;
  z-index: 2;
  left: 14px;
  bottom: 14px;
  max-width: min(420px, calc(100% - 28px));
  padding: 10px 12px;
  display: grid;
  gap: 3px;
}

.driving-message-kicker,
#driving-progress {
  color: rgba(78, 94, 108, 0.86);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

#driving-objective {
  color: var(--drive-ink);
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  line-height: 1.02;
}

#driving-helper,
#driving-message-text {
  font-size: clamp(0.78rem, 1.6vw, 0.92rem);
  line-height: 1.12;
}

.driving-stage[data-assist-active="true"] .driving-message,
.driving-stage[data-target-mode="dropoff"] .driving-message {
  border-color: rgba(84, 139, 77, 0.34);
  background: rgba(239, 255, 222, 0.95);
}

.driving-stage[data-arrival-pulse="pickup"] {
  border-color: rgba(244, 191, 79, 0.58);
}

.driving-stage[data-arrival-pulse="dropoff"] {
  border-color: rgba(134, 207, 114, 0.58);
}

.driving-stage[data-confetti-burst="active"] {
  border-color: rgba(255, 248, 230, 0.9);
}

.driving-stage[data-road-state="off-road"] {
  border-color: rgba(244, 191, 79, 0.72);
}

.driving-stage[data-road-state="off-road"] .driving-message {
  border-color: rgba(214, 156, 45, 0.48);
  background: rgba(255, 244, 196, 0.96);
}

.driving-stage[data-road-state="off-road"] #driving-helper {
  color: #6d4a0b;
}

@media (prefers-reduced-motion: no-preference) {
  .driving-stage[data-arrival-pulse="pickup"],
  .driving-stage[data-arrival-pulse="dropoff"] {
    animation: driving-arrival-frame 0.58s ease-out;
  }
}

@keyframes driving-arrival-frame {
  0% {
    box-shadow: 0 18px 48px rgba(72, 91, 93, 0.28), 0 0 0 0 rgba(244, 191, 79, 0.36);
  }

  100% {
    box-shadow: 0 18px 48px rgba(72, 91, 93, 0.28), 0 0 0 18px rgba(244, 191, 79, 0);
  }
}

.driving-reward {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255, 250, 232, 0.08), rgba(38, 52, 68, 0.42));
}

.driving-reward.hidden {
  display: none;
}

.driving-reward-card {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: min(540px, 100%);
  border: 2px solid rgba(92, 58, 16, 0.26);
  border-radius: 8px;
  padding: 14px;
  color: #2b1a08;
  background: rgba(255, 244, 196, 0.97);
  box-shadow: 0 18px 44px rgba(74, 56, 30, 0.28);
}

.driving-reward-card img {
  display: block;
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 6px 8px rgba(70, 38, 8, 0.22));
}

.driving-reward-eyebrow,
.driving-reward-card h2,
.driving-reward-card p {
  margin: 0;
}

.driving-reward-eyebrow {
  color: #8b5811;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.driving-reward-card h2 {
  margin-top: 2px;
  color: #24160a;
  font-size: clamp(1.15rem, 2.4vw, 1.65rem);
  line-height: 1.02;
}

.driving-reward-card p {
  margin-top: 6px;
  color: rgba(43, 26, 8, 0.8);
  font-size: clamp(0.84rem, 1.8vw, 0.98rem);
  font-weight: 750;
  line-height: 1.25;
}

.driving-reward-lines {
  display: grid;
  gap: 2px;
}

.driving-reward-line {
  display: block;
}

.driving-reward-next {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  width: fit-content;
  border: 1px solid rgba(43, 26, 8, 0.18);
  border-radius: 8px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.36);
}

.driving-reward-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.driving-reward-actions a,
.driving-reward-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 2px solid rgba(43, 26, 8, 0.24);
  border-radius: 8px;
  padding: 0 12px;
  color: #24160a;
  background: rgba(255, 255, 255, 0.38);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.driving-reward-actions .driving-reward-home {
  color: #172217;
  background: #9be56f;
}

.driving-controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.driving-controls button {
  min-height: 52px;
  cursor: pointer;
  touch-action: none;
}

.driving-controls button[data-driving-control="Gas"] {
  color: #172217;
  background: linear-gradient(180deg, #a3e585, #76c766);
}

.driving-controls button[data-driving-control="Assist"] {
  color: #172217;
  background: linear-gradient(180deg, #b6ec8b, #86cf72);
}

.driving-controls button[data-driving-control="Brake"] {
  color: #2e1316;
  background: linear-gradient(180deg, #f49b98, #e76f73);
}

.driving-reset {
  color: #30230d !important;
  background: linear-gradient(180deg, #f7d46f, #f0bc48) !important;
}

@media (max-width: 720px) {
  .driving-topbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .driving-topbar h1 {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .driving-shell {
    gap: 10px;
  }

  .driving-choice-group {
    grid-template-columns: 1fr repeat(3, minmax(0, 1fr));
    min-height: 48px;
    padding: 6px;
  }

  .driving-choice-group button {
    min-height: 34px;
    padding: 0 6px;
    font-size: 0.86rem;
  }

  .driving-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .driving-hud span {
    padding: 5px 6px;
    font-size: 0.58rem;
    line-height: 1.05;
  }

  .driving-hud strong {
    font-size: 0.72rem;
    line-height: 1.05;
  }

  .driving-message {
    position: static;
    max-width: none;
    margin: 8px;
    padding: 7px 8px;
    gap: 1px;
  }

  .driving-message-kicker,
  #driving-progress {
    font-size: 0.56rem;
    line-height: 1.05;
  }

  #driving-objective {
    font-size: 0.9rem;
    line-height: 1;
  }

  #driving-helper,
  #driving-message-text {
    font-size: 0.66rem;
    line-height: 1.05;
  }

  .driving-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .driving-controls button[data-driving-control="Assist"] {
    grid-column: 1 / -1;
    order: -1;
    min-height: 58px;
  }

  .driving-reset {
    grid-column: 1 / -1;
  }

  .driving-reward-card {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .driving-reward-card img {
    width: 74px;
    height: 74px;
  }

  .driving-reward-actions {
    grid-template-columns: 1fr;
  }
}
