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

:root {
  --bg: #07111f;
  --bg-deep: #030914;
  --surface: #0d2238;
  --surface-strong: #123b5d;
  --surface-soft: #101827;
  --line: rgba(148, 190, 235, 0.18);
  --line-strong: rgba(64, 150, 255, 0.42);
  --text: #f8fbff;
  --muted: #aac0d8;
  --dim: #748aa4;
  --blue: #2d7ff9;
  --blue-strong: #1f6dff;
  --blue-soft: rgba(45, 127, 249, 0.18);
  --purple: #8B5CF6;
  --severe: #ff4248;
  --moderate: #f97316;
  --light: #38bdf8;
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    linear-gradient(145deg, rgba(45, 127, 249, 0.16), transparent 28%),
    linear-gradient(215deg, rgba(139, 92, 246, 0.14), transparent 32%),
    linear-gradient(180deg, var(--bg), var(--bg-deep));
  line-height: 1.5;
  overflow-x: hidden;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 20;
  transform: translateY(-140%);
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
}

.skip-link:focus {
  transform: none;
}

.game-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  padding: 12px 18px;
  background: rgba(7, 17, 31, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.game-nav__brand,
.game-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 12px;
  font-weight: 800;
}

.game-nav__brand {
  gap: 10px;
  color: #fff;
  letter-spacing: -0.01em;
}

.game-nav__brand img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: cover;
}

.game-nav__link {
  justify-content: center;
  padding: 0 14px;
  color: #d9e8ff;
  background: rgba(45, 127, 249, 0.12);
  border: 1px solid rgba(45, 127, 249, 0.28);
  font-size: 0.88rem;
}

.game-nav__link:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.secondary-link:focus-visible,
.incident-card:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.72);
  outline-offset: 3px;
}

.game-shell {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 16px 42px;
}

.screen {
  min-height: calc(100svh - 132px);
}

.screen.is-hidden {
  display: none !important;
}

.screen--start,
.screen--end {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}

.start-visual {
  width: min(86vw, 340px);
  border-radius: 22px;
  overflow: hidden;
  background: #0d1320;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 0 1px rgba(45, 127, 249, 0.16),
    0 26px 60px rgba(0, 0, 0, 0.42),
    0 0 42px rgba(139, 92, 246, 0.28);
}

.logo-motion,
.logo-poster {
  width: 100%;
}

.logo-poster {
  display: none;
}

.start-copy h1,
.screen--end h2 {
  margin: 0;
  font-size: clamp(2.25rem, 9vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 900;
}

.start-copy p,
.end-result,
.end-score {
  width: min(100%, 560px);
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 1rem;
}

.primary-action,
.secondary-action,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 14px;
  padding: 0 22px;
  border: 0;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.primary-action {
  min-width: 180px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-strong));
  box-shadow: 0 18px 36px rgba(45, 127, 249, 0.32);
}

.primary-action:active,
.secondary-action:active,
.incident-card:active {
  transform: scale(0.99);
}

.screen--play {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hud p {
  margin: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(13, 34, 56, 0.78);
  border: 1px solid var(--line);
  color: #d7e9ff;
  font-size: 0.88rem;
  font-weight: 800;
}

.hud p:first-child {
  grid-column: 1 / -1;
  color: #fff;
  background: linear-gradient(135deg, rgba(45, 127, 249, 0.28), rgba(139, 92, 246, 0.18));
  border-color: rgba(45, 127, 249, 0.34);
}

.road-scene {
  margin: 0;
}

.route-stage {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 250px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(180deg, #0e2740, #071526);
  background-size: 42px 42px, 42px 42px, auto;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 22px 48px rgba(0, 0, 0, 0.25);
}

.route-stage::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 12%, rgba(248, 251, 255, 0.18), transparent 16%),
    radial-gradient(circle at 28% 52%, rgba(255, 66, 72, 0.13), transparent 18%),
    radial-gradient(circle at 71% 46%, rgba(139, 92, 246, 0.18), transparent 22%);
  pointer-events: none;
}

.route-map {
  position: absolute;
  inset: 10px 12px 8px;
  width: calc(100% - 24px);
  height: calc(100% - 18px);
  overflow: visible;
}

.route-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.motion-path {
  fill: none;
  stroke: none;
  opacity: 0;
  pointer-events: none;
}

.route-stage.debug-paths .motion-path {
  opacity: 1;
  stroke: #f8fbff;
  stroke-width: 1.4;
}

.route-stage.debug-paths #idlePath {
  stroke: #38bdf8;
}

.route-stage.debug-paths #wrongPath {
  stroke: #ff4248;
}

.route-stage.debug-paths #correctPath {
  stroke: #8B5CF6;
}

.route-road {
  fill: none;
  stroke: rgba(121, 150, 182, 0.22);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 22;
}

.route-road--bad {
  stroke: rgba(255, 66, 72, 0.12);
}

.route-road--detour {
  stroke: rgba(139, 92, 246, 0.15);
}

.route-line--shared {
  stroke: rgba(118, 171, 226, 0.64);
  stroke-width: 6;
  stroke-dasharray: 12 11;
  filter: drop-shadow(0 0 9px rgba(45, 127, 249, 0.38));
}

.route-line--bad {
  stroke: rgba(255, 66, 72, 0.86);
  stroke-width: 8;
  filter: drop-shadow(0 0 10px rgba(255, 66, 72, 0.45));
  stroke-dasharray: 20 7;
  animation: bad-route-crawl 2.4s linear infinite;
}

.route-line--detour {
  stroke: var(--purple);
  stroke-width: 8;
  stroke-dasharray: 3 14;
  filter: drop-shadow(0 0 13px rgba(139, 92, 246, 0.7));
  animation: detour-dash 1.35s linear infinite;
}

.fork-node circle {
  transform-box: view-box;
  transform-origin: 160px 146px;
}

.fork-node circle:first-child {
  fill: #38bdf8;
  filter: drop-shadow(0 0 10px rgba(45, 127, 249, 0.9));
}

.fork-node circle:last-child {
  fill: rgba(45, 127, 249, 0.1);
  stroke: rgba(56, 189, 248, 0.62);
  stroke-width: 2.5;
  animation: fork-pulse 1.8s ease-in-out infinite;
}

.traffic-stack {
  fill: rgba(255, 66, 72, 0.26);
  stroke: rgba(255, 66, 72, 0.9);
  stroke-width: 2;
  filter: drop-shadow(0 0 8px rgba(255, 66, 72, 0.45));
  animation: traffic-pulse 1.8s ease-in-out infinite;
}

.roadblock {
  fill: none;
  stroke: var(--severe);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 12px rgba(255, 66, 72, 0.65));
  transform-box: view-box;
  transform-origin: 128px 40px;
  animation: warning-pulse 1.4s ease-in-out infinite;
}

.roadblock circle {
  fill: rgba(255, 66, 72, 0.16);
  stroke-width: 2.6;
}

.roadblock rect {
  fill: rgba(255, 66, 72, 0.22);
}

.destination-bulb {
  fill: none;
  stroke: #f8fbff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.78));
  transform-box: view-box;
  transform-origin: 202px 54px;
  animation: bulb-breathe 1.8s ease-in-out infinite;
}

.bulb-glow {
  fill: rgba(56, 189, 248, 0.17);
  stroke: none;
}

.bulb-rays {
  opacity: 0.9;
}

.impact-burst {
  opacity: 0;
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 14px rgba(255, 66, 72, 0.95));
  transform-box: view-box;
  transform-origin: 128px 40px;
}

.debug-points {
  opacity: 0;
  pointer-events: none;
}

.route-stage.debug-paths .debug-points {
  opacity: 1;
}

.debug-point {
  fill: #f8fbff;
  stroke: #06111f;
  stroke-width: 1.4;
}

.debug-point--idle-start,
.debug-point--idle-end {
  fill: #38bdf8;
}

.debug-point--correct-start,
.debug-point--correct-end {
  fill: var(--purple);
}

.debug-point--wrong-start,
.debug-point--wrong-end {
  fill: var(--severe);
}

.car-anchor-debug {
  opacity: 0;
  pointer-events: none;
  fill: rgba(248, 251, 255, 0.95);
  stroke: #06111f;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.route-stage.debug-paths .car-anchor-debug {
  opacity: 1;
}

.path-debug-controls {
  display: none;
}

.route-stage.debug-paths .path-debug-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.path-debug-controls button {
  min-height: 30px;
  border: 1px solid rgba(248, 251, 255, 0.35);
  border-radius: 8px;
  padding: 0 8px;
  color: #f8fbff;
  background: rgba(3, 9, 20, 0.82);
  font-size: 0.68rem;
  font-weight: 800;
}

.map-car {
  color: var(--blue);
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 7px 8px rgba(0, 0, 0, 0.44));
}

.map-car__sprite {
  transform-box: fill-box;
  transform-origin: center;
}

.map-car__shadow {
  fill: rgba(0, 0, 0, 0.24);
}

.map-car__body {
  fill: currentColor;
}

.map-car__glass {
  fill: rgba(248, 251, 255, 0.88);
}

.map-car__hood,
.map-car__lights {
  fill: none;
  stroke: rgba(248, 251, 255, 0.85);
  stroke-width: 2;
  stroke-linecap: round;
}

.map-car__wheel {
  fill: #06111f;
}

.route-stage.is-correct .map-car {
  color: #38bdf8;
  filter: drop-shadow(0 0 16px rgba(56, 189, 248, 0.8));
}

.route-stage.is-wrong .map-car {
  color: var(--severe);
}

.route-stage.is-correct .route-line--detour {
  stroke-width: 10;
  filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.95));
}

.route-stage.is-arrived .destination-bulb {
  animation: bulb-win 0.95s ease-in-out forwards;
}

.route-stage.is-wrong .route-line--bad {
  stroke-width: 10;
  animation: danger-flash 0.28s linear 4;
}

.route-stage.is-impact .impact-burst {
  animation: impact-pop 0.62s ease-out both;
}

.route-stage.is-impact .map-car__sprite {
  animation: car-impact-shake 0.28s ease-in-out 2;
}

.round-copy {
  text-align: center;
}

.round-copy h2 {
  margin: 0;
  font-size: clamp(1.35rem, 7vw, 2.15rem);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.round-copy p {
  margin: 8px auto 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 0.95rem;
}

.route-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.incident-card {
  --severity: var(--blue);
  --severity-bg: rgba(45, 127, 249, 0.16);
  --severity-shadow: rgba(45, 127, 249, 0.34);
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  width: 100%;
  min-height: 150px;
  padding: 17px 15px 17px 20px;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  background: linear-gradient(135deg, rgba(18, 59, 93, 0.96), rgba(13, 34, 56, 0.98));
  border: 1px solid rgba(64, 150, 255, 0.2);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.025);
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, background 180ms ease;
}

.incident-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 1px rgba(45, 127, 249, 0.16), 0 16px 36px rgba(0, 0, 0, 0.2);
}

.incident-card:disabled {
  cursor: default;
}

.incident-card__strip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 7px;
  background: var(--severity);
  box-shadow: 0 0 24px var(--severity-shadow);
}

.incident-card__icon {
  width: 58px;
  height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: var(--severity);
  box-shadow: 0 0 26px var(--severity-shadow);
}

.incident-card__icon svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.incident-card__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.incident-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.incident-card__title {
  color: #fff;
  font-size: 1.1rem;
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.severity-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--severity);
  background: rgba(255, 255, 255, 0.11);
  font-size: 0.78rem;
  font-weight: 900;
}

.incident-card__description,
.incident-card__location,
.incident-card__footer {
  font-size: 0.88rem;
}

.incident-card__description {
  color: var(--muted);
  line-height: 1.32;
}

.incident-card__location {
  display: flex;
  gap: 7px;
  color: #bfd2e8;
  line-height: 1.26;
}

.pin-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.incident-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
  color: #dceaff;
  font-weight: 800;
}

.incident-card__footer strong {
  color: #fff;
  font-weight: 900;
}

.severity-severe {
  --severity: var(--severe);
  --severity-bg: rgba(255, 66, 72, 0.16);
  --severity-shadow: rgba(255, 66, 72, 0.42);
  border-color: rgba(255, 66, 72, 0.3);
}

.severity-moderate {
  --severity: var(--moderate);
  --severity-bg: rgba(249, 115, 22, 0.16);
  --severity-shadow: rgba(249, 115, 22, 0.42);
  border-color: rgba(249, 115, 22, 0.3);
}

.severity-light {
  --severity: var(--blue);
  --severity-bg: rgba(45, 127, 249, 0.17);
  --severity-shadow: rgba(45, 127, 249, 0.38);
}

.incident-card.is-selected {
  border-color: var(--blue);
  box-shadow:
    0 0 0 2px rgba(45, 127, 249, 0.45),
    0 22px 46px rgba(0, 0, 0, 0.26);
}

.incident-card.is-correct {
  border-color: rgba(56, 189, 248, 0.72);
  background: linear-gradient(135deg, rgba(18, 59, 93, 0.98), rgba(14, 47, 76, 0.98));
}

.incident-card.is-wrong {
  border-color: rgba(255, 66, 72, 0.78);
  box-shadow:
    0 0 0 2px rgba(255, 66, 72, 0.28),
    0 18px 38px rgba(0, 0, 0, 0.28);
}

.feedback {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(45, 127, 249, 0.16), rgba(139, 92, 246, 0.13));
  border: 1px solid rgba(45, 127, 249, 0.34);
}

.feedback.is-hidden {
  display: none;
}

.feedback p {
  margin: 0;
  color: #f3f8ff;
  font-weight: 800;
  line-height: 1.35;
}

.secondary-action {
  color: #07111f;
  background: #f8fbff;
}

.screen--end {
  max-width: 620px;
  margin: 0 auto;
}

.end-orbit {
  width: 108px;
  height: 108px;
  color: #f8fbff;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(45, 127, 249, 0.28), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(255,255,255,0.12);
  padding: 12px;
  box-shadow: 0 0 34px rgba(45, 127, 249, 0.3);
}

.end-orbit svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.end-orbit svg path:nth-child(2) {
  fill: rgba(248, 251, 255, 0.16);
}

.end-result {
  color: #dceaff;
  font-size: 1.1rem;
}

.end-result strong {
  color: var(--light);
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 360px);
}

.secondary-link {
  color: #d9e8ff;
  background: rgba(45, 127, 249, 0.12);
  border: 1px solid rgba(45, 127, 249, 0.32);
}

@keyframes detour-dash {
  to { stroke-dashoffset: -34; }
}

@keyframes bad-route-crawl {
  to { stroke-dashoffset: 27; }
}

@keyframes fork-pulse {
  0%, 100% { opacity: 0.68; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1.04); }
}

@keyframes warning-pulse {
  0%, 100% { opacity: 0.75; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes traffic-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes bulb-breathe {
  0%, 100% {
    opacity: 0.82;
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.65));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 22px rgba(248, 251, 255, 0.92));
  }
}

@keyframes bulb-win {
  0% { transform: scale(1); opacity: 1; }
  35% { transform: scale(1.18); opacity: 1; }
  70% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1.1); opacity: 1; }
}

@keyframes danger-flash {
  0%, 100% { stroke: rgba(255, 66, 72, 0.86); }
  50% { stroke: #fff; }
}

@keyframes impact-pop {
  0% { opacity: 0; transform: scale(0.45); }
  38% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.4); }
}

@keyframes car-impact-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.4px, 0.7px); }
  50% { transform: translate(1.2px, -0.6px); }
  75% { transform: translate(-0.7px, -0.4px); }
}

@media (min-width: 720px) {
  .game-shell {
    padding: 34px 24px 58px;
  }

  .screen--play {
    gap: 22px;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
  }

  .hud p:first-child {
    grid-column: auto;
  }

  .route-stage {
    height: 272px;
  }

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

  .incident-card {
    min-height: 198px;
    align-content: start;
  }

  .feedback {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .end-actions {
    flex-direction: row;
    justify-content: center;
    width: auto;
  }
}

@media (max-width: 380px) {
  .game-nav {
    padding-left: 12px;
    padding-right: 12px;
  }

  .game-nav__link {
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .game-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .incident-card {
    grid-template-columns: 50px 1fr;
    gap: 12px;
    padding-right: 12px;
  }

  .incident-card__icon {
    width: 50px;
    height: 50px;
  }

  .incident-card__icon svg {
    width: 30px;
    height: 30px;
  }

  .severity-pill {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .logo-motion {
    display: none;
  }

  .logo-poster {
    display: block;
  }

  .route-stage.is-impact .impact-burst {
    opacity: 1;
    transform: scale(1);
  }
}
