:root {
  color-scheme: dark;
  --bg: #101820;
  --panel: #f5f1e8;
  --ink: #1c2526;
  --muted: #697579;
  --road: #30383b;
  --line: #f2c94c;
  --accent: #2f80ed;
  --good: #219653;
  --bad: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.drive-view {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  background: linear-gradient(#8ecae6 0 36%, #d9ead3 36% 49%, #56635f 49% 100%);
}

.skyline {
  position: absolute;
  inset: auto 0 49% 0;
  height: 110px;
  background:
    linear-gradient(90deg, transparent 0 8%, #d35400 8% 18%, transparent 18% 25%, #315c6f 25% 34%, transparent 34% 43%, #8e5f38 43% 57%, transparent 57% 66%, #315c6f 66% 78%, transparent 78%),
    linear-gradient(#f8f0d9, #f8f0d9);
  background-size: 100% 80px, 100% 18px;
  background-position: bottom, bottom;
  background-repeat: no-repeat;
}

.road {
  position: absolute;
  inset: 48% -12% -8%;
  background: var(--road);
  clip-path: polygon(39% 0, 61% 0, 100% 100%, 0 100%);
}

.lane {
  position: absolute;
  top: 8%;
  bottom: 0;
  width: 8px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 58px, transparent 58px 108px);
  opacity: 0.9;
}

.lane-left { left: 44%; transform: rotate(8deg); }
.lane-right { right: 44%; transform: rotate(-8deg); }

.crosswalk {
  position: absolute;
  left: 27%;
  right: 27%;
  top: 22%;
  height: 90px;
  transform: perspective(220px) rotateX(42deg);
  background: repeating-linear-gradient(90deg, #fff 0 32px, transparent 32px 56px);
  opacity: 0.92;
}

.traffic-sign {
  position: absolute;
  left: 29%;
  top: 12%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 5px solid #d33;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-weight: 900;
}

.car {
  position: absolute;
  width: 74px;
  height: 38px;
  border-radius: 7px 12px 8px 8px;
  background: #eb5757;
  box-shadow: 0 12px 18px rgb(0 0 0 / 25%);
}

.car::before {
  content: "";
  position: absolute;
  inset: 7px 17px 14px 22px;
  background: #bde0fe;
  border-radius: 5px 8px 3px 3px;
}

.car-a { left: 23%; top: 43%; transform: rotate(10deg); }
.car-b { right: 20%; top: 58%; background: #f2994a; transform: rotate(-13deg) scale(1.18); }

.pedestrian {
  position: absolute;
  left: 51%;
  top: 28%;
  width: 18px;
  height: 40px;
  border-radius: 999px 999px 6px 6px;
  background: #7a3cff;
}

.pedestrian::before {
  content: "";
  position: absolute;
  left: 3px;
  top: -14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f2c29b;
}

.signal {
  position: absolute;
  right: 30%;
  top: 10%;
  display: grid;
  gap: 5px;
  padding: 7px;
  background: #15191b;
  border-radius: 8px;
}

.signal span {
  width: 16px;
  height: 16px;
  display: block;
  border-radius: 50%;
  background: #394144;
}

.signal span:nth-child(1) { background: #7a1f1f; }
.signal span:nth-child(2) { background: #67581d; }
.signal .on { background: #27ae60; box-shadow: 0 0 18px #27ae60; }

.hud {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  color: #fff;
}

.hud div {
  min-width: 0;
  padding: 13px 14px;
  background: rgb(16 24 32 / 74%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
}

.label,
.label-dark {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.label { color: rgb(255 255 255 / 72%); }
.label-dark { color: var(--muted); }
.hud strong { display: block; margin-top: 3px; font-size: 1.05rem; }

.play-panel,
.panel {
  min-height: 100vh;
  padding: clamp(22px, 4vw, 52px);
  background: var(--panel);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.topbar,
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.95;
}

.icon-button,
.mode-tab,
.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: #dfe7e8;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  width: 44px;
  font-size: 1.35rem;
  font-weight: 900;
}

.mode-tabs,
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-tab.active {
  background: var(--ink);
  color: #fff;
}

.session-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.session-strip span,
.scenario-meta span {
  padding: 7px 10px;
  border-radius: 999px;
  background: #dfe7e8;
  color: #314044;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.timer {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9dedf;
}

#timer-fill {
  width: 100%;
  height: 100%;
  transform-origin: left;
  transition: transform 0.3s ease;
  background: var(--accent);
}

.scenario-text {
  margin: 0;
  color: #1f2b2f;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.35;
}

.event {
  margin: 0;
  color: #324044;
  font-size: 1.05rem;
  line-height: 1.45;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer,
.next,
.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.answer {
  padding: 13px 15px;
  background: #fff;
  color: var(--ink);
  border: 2px solid transparent;
  text-align: left;
}

.answer:hover,
.answer:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.answer.correct {
  border-color: var(--good);
  background: #eaf7ef;
}

.answer.wrong {
  border-color: var(--bad);
  background: #fdecea;
}

.feedback {
  min-height: 84px;
  padding: 14px 16px;
  border-left: 5px solid #9aa8ac;
  background: #fff;
  line-height: 1.45;
}

.feedback.good { border-color: var(--good); }
.feedback.bad { border-color: var(--bad); }

.next,
.primary-button {
  padding: 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--accent);
  color: #fff;
}

.next:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  flex: 1;
  padding: 0 16px;
}

.dashboard div {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
}

.dashboard strong {
  display: block;
  margin-top: 4px;
}

.summary {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(16 24 32 / 70%);
}

.summary[hidden] { display: none; }

.summary-panel {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .drive-view {
    min-height: 42vh;
  }

  .play-panel,
  .panel {
    min-height: auto;
    justify-content: flex-start;
  }

  .hud,
  .dashboard {
    grid-template-columns: 1fr 1fr;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
  }
}
