:root {
  --bg: #06110f;
  --bg-deep: #020807;
  --panel: rgba(8, 24, 22, 0.66);
  --panel-strong: rgba(7, 18, 17, 0.84);
  --text: #f1f7f5;
  --muted: #9fb4ae;
  --accent: #58f0dc;
  --accent-2: #1e9f91;
  --accent-soft: rgba(88, 240, 220, 0.18);
  --border: rgba(126, 248, 230, 0.18);
  --shadow: 0 16px 50px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button, input { font: inherit; }

button { cursor: pointer; }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.app-shell {
  min-height: 100dvh;
  width: 100%;
  position: relative;
}

.startup {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(48, 153, 136, 0.12), transparent 24%),
    linear-gradient(180deg, #04110f 0%, #020706 100%);
  overflow: hidden;
}

.startup-map {
  position: absolute;
  inset: -12%;
  opacity: 0.12;
  filter: blur(26px);
  transform: scale(1.09);
  background:
    radial-gradient(ellipse at 20% 65%, rgba(116, 79, 52, 0.38) 0 16%, transparent 17%),
    radial-gradient(ellipse at 75% 30%, rgba(49, 85, 66, 0.38) 0 21%, transparent 22%),
    linear-gradient(118deg, transparent 46%, rgba(88, 240, 220, 0.28) 47%, rgba(88, 240, 220, 0.13) 49%, transparent 51%);
  animation: mapAwaken 5.8s cubic-bezier(.22,.61,.36,1) forwards;
}

.light-morph {
  width: 86px;
  height: 104px;
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  transform: translateY(0);
  animation: morphTravel 5.8s cubic-bezier(.22,.61,.36,1) forwards;
}

.morph-aura,
.morph-shape {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 58px;
  margin-left: -23px;
  margin-top: -29px;
}

.morph-aura {
  background: rgba(88, 240, 220, 0.42);
  filter: blur(16px);
  opacity: .42;
  clip-path: polygon(
    42% 42%, 50% 38%, 58% 42%, 62% 50%,
    58% 58%, 50% 62%, 42% 58%, 38% 50%
  );
  animation:
    auraMorph 5.8s cubic-bezier(.22,.61,.36,1) forwards,
    auraBreathe 2.8s ease-in-out infinite;
}

.morph-shape {
  background: var(--accent);
  box-shadow:
    0 0 12px rgba(88,240,220,.92),
    0 0 28px rgba(88,240,220,.54),
    0 0 58px rgba(88,240,220,.2);
  clip-path: polygon(
    42% 42%, 50% 38%, 58% 42%, 62% 50%,
    58% 58%, 50% 62%, 42% 58%, 38% 50%
  );
  animation:
    shapeMorph 5.8s cubic-bezier(.22,.61,.36,1) forwards,
    shapeBreathe 2.8s ease-in-out infinite;
}

.startup-status {
  position: absolute;
  bottom: max(8vh, 42px);
  color: var(--muted);
  letter-spacing: 0.08em;
  font-size: 0.86rem;
  opacity: 0;
  animation: statusIn 1.1s ease 0.7s forwards;
}

.drive-screen, .map-stage { width: 100%; min-height: 100dvh; }

.drive-screen {
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 1.15s ease, transform 1.35s ease;
}

.drive-screen.ready {
  opacity: 1;
  transform: scale(1);
}

.map-stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(88, 88, 58, 0.38), transparent 25%),
    radial-gradient(circle at 78% 20%, rgba(29, 77, 65, 0.45), transparent 30%),
    linear-gradient(180deg, #17312d 0%, #0d221f 46%, #0a1715 100%);
  perspective: 1000px;
  transition: filter 0.45s ease, transform 0.45s ease;
}

.map-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,.18), transparent 28%, transparent 66%, rgba(0,0,0,.42)),
    radial-gradient(circle at center, transparent 35%, rgba(0,0,0,.2) 100%);
}

.terrain {
  position: absolute;
  border-radius: 48% 52% 55% 45%;
  opacity: 0.85;
  filter: blur(1px);
  transform: rotate(-9deg);
}

.terrain-a {
  width: 54vw;
  height: 42vh;
  left: -8vw;
  top: 20vh;
  background: linear-gradient(145deg, #5f5a39, #294238 62%, #1b2b27);
}

.terrain-b {
  width: 62vw;
  height: 44vh;
  right: -12vw;
  top: 9vh;
  background: linear-gradient(160deg, #436048, #1e433a 58%, #172c29);
}

.terrain-c {
  width: 70vw;
  height: 36vh;
  left: 16vw;
  bottom: -10vh;
  background: linear-gradient(160deg, #3e3929, #1d2f29);
}

.road {
  position: absolute;
  background: rgba(19, 27, 26, 0.94);
  border: 1px solid rgba(220, 234, 228, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.025);
  transform-origin: center;
}

.road-main {
  width: 17vw;
  min-width: 88px;
  height: 120vh;
  left: 50%;
  top: 5vh;
  transform: translateX(-50%) rotate(10deg);
  border-radius: 50%;
}

.road-side {
  width: 9vw;
  min-width: 50px;
  height: 80vh;
  border-radius: 50%;
}

.road-side-a { left: 23%; top: -8%; transform: rotate(-28deg); }
.road-side-b { right: 15%; top: 30%; transform: rotate(42deg); }

.route-glow {
  position: absolute;
  width: 4.2vw;
  min-width: 20px;
  height: 110vh;
  left: 50%;
  top: 10vh;
  transform: translateX(-50%) rotate(10deg);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(88,240,220,.14), var(--accent) 62%, rgba(88,240,220,.32));
  box-shadow:
    0 0 12px rgba(88,240,220,.65),
    0 0 30px rgba(88,240,220,.38);
  z-index: 2;
}

.glass {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.top-hud {
  position: absolute;
  z-index: 10;
  top: max(16px, env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  min-height: 62px;
  border-radius: 23px;
  padding: 8px;
  display: grid;
  grid-template-columns: 46px 1fr 48px;
  gap: 8px;
  align-items: center;
}

.icon-button, .mic-button, .recenter-button {
  border: 0;
  color: var(--text);
  background: rgba(255,255,255,.055);
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 17px;
  font-size: 1.2rem;
}

.search-wrap input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  padding: 13px 4px;
}

.search-wrap input::placeholder { color: #b4c5c0; }

.mic-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
}

.mic-button::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(88,240,220,.32);
  border-radius: 50%;
}

.mic-symbol {
  color: var(--accent);
  font-size: 0.75rem;
  filter: drop-shadow(0 0 8px var(--accent));
}

.mic-dot {
  position: absolute;
  inset: -3px;
  border: 1px solid transparent;
  border-radius: 50%;
}

.mic-button.listening .mic-dot {
  border-color: rgba(88,240,220,.5);
  animation: micPulse 1.2s ease infinite;
}

.maneuver-card {
  position: absolute;
  z-index: 8;
  left: 16px;
  top: calc(max(16px, env(safe-area-inset-top)) + 78px);
  border-radius: 21px;
  padding: 12px 16px 12px 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.maneuver-card strong, .maneuver-card span { display: block; }
.maneuver-card strong { font-size: 1.05rem; }
.maneuver-card span { color: var(--muted); font-size: .82rem; margin-top: 2px; }

.turn-icon {
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 1.55rem;
}

.vehicle-arrow {
  position: absolute;
  z-index: 7;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 52px;
  filter: drop-shadow(0 0 12px rgba(88,240,220,.58));
}

.vehicle-arrow span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  clip-path: polygon(50% 0, 88% 88%, 50% 72%, 12% 88%);
  border-radius: 8px;
}

.speed-card {
  position: absolute;
  z-index: 9;
  left: 16px;
  bottom: calc(116px + env(safe-area-inset-bottom));
  width: 86px;
  height: 86px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  align-content: center;
}

.speed-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.speed-unit { font-size: .7rem; color: var(--muted); margin-top: 5px; }

.limit-card {
  position: absolute;
  z-index: 9;
  left: 112px;
  bottom: calc(125px + env(safe-area-inset-bottom));
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: #f5f5f2;
  border: 6px solid #c84242;
  display: grid;
  place-items: center;
  color: #161616;
  font-weight: 800;
  font-size: 1.4rem;
  box-shadow: var(--shadow);
}

.view-controls {
  position: absolute;
  z-index: 9;
  right: 16px;
  top: calc(max(16px, env(safe-area-inset-top)) + 82px);
  padding: 5px;
  border-radius: 18px;
  display: flex;
  gap: 3px;
}

.view-controls button {
  border: 0;
  border-radius: 13px;
  padding: 9px 11px;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
}

.view-controls button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.recenter-button {
  position: absolute;
  z-index: 9;
  right: 16px;
  bottom: calc(121px + env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
  border-radius: 18px;
  font-size: 1.4rem;
}

.bottom-panel {
  position: absolute;
  z-index: 10;
  left: 16px;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  min-height: 86px;
  border-radius: 26px;
  padding: 13px 13px 13px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.bottom-panel strong { display: block; font-size: .95rem; margin-top: 3px; }
.eyebrow { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }

.start-button {
  border: 0;
  border-radius: 18px;
  padding: 14px 17px;
  font-weight: 700;
  color: #04110f;
  background: var(--accent);
  box-shadow: 0 10px 26px rgba(88,240,220,.22);
  white-space: nowrap;
}

.toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -8px);
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 11px 15px;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  backdrop-filter: blur(16px);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.map-stage.view-2d {
  transform: scale(1.035);
  filter: saturate(.88) contrast(1.05);
}

.map-stage.view-2d .terrain { opacity: .42; filter: blur(3px); }
.map-stage.view-2d .road-main,
.map-stage.view-2d .route-glow { transform: translateX(-50%) rotate(0deg); }

.map-stage.view-3d .terrain { transform: rotate(-9deg) translateY(-8px); }

@keyframes shapeBreathe {
  0%, 100% {
    filter: brightness(.94);
  }
  50% {
    filter: brightness(1.13);
  }
}

@keyframes auraBreathe {
  0%, 100% { opacity: .34; transform: scale(.92); }
  50% { opacity: .58; transform: scale(1.08); }
}

@keyframes shapeMorph {
  0%, 24% {
    clip-path: polygon(
      42% 42%, 50% 38%, 58% 42%, 62% 50%,
      58% 58%, 50% 62%, 42% 58%, 38% 50%
    );
    transform: scale(.28) rotate(0deg);
    border-radius: 50%;
    opacity: .92;
  }
  40% {
    clip-path: polygon(
      39% 37%, 50% 31%, 61% 37%, 67% 49%,
      61% 63%, 50% 70%, 39% 63%, 33% 49%
    );
    transform: scale(.42) rotate(2deg);
    border-radius: 42%;
    opacity: 1;
  }
  58% {
    clip-path: polygon(
      34% 30%, 50% 20%, 66% 30%, 72% 52%,
      63% 72%, 50% 82%, 37% 72%, 28% 52%
    );
    transform: scale(.66) rotate(4deg);
    border-radius: 28%;
    opacity: 1;
  }
  76% {
    clip-path: polygon(
      25% 35%, 50% 4%, 75% 35%, 88% 88%,
      59% 73%, 50% 84%, 41% 73%, 12% 88%
    );
    transform: scale(.88) rotate(6deg);
    border-radius: 13%;
    opacity: 1;
  }
  100% {
    clip-path: polygon(
      25% 35%, 50% 0%, 75% 35%, 88% 88%,
      59% 73%, 50% 84%, 41% 73%, 12% 88%
    );
    transform: scale(1) rotate(8deg);
    border-radius: 7%;
    opacity: 1;
  }
}

@keyframes auraMorph {
  0%, 24% {
    clip-path: polygon(
      42% 42%, 50% 38%, 58% 42%, 62% 50%,
      58% 58%, 50% 62%, 42% 58%, 38% 50%
    );
    transform: scale(.5);
  }
  58% {
    clip-path: polygon(
      34% 30%, 50% 20%, 66% 30%, 72% 52%,
      63% 72%, 50% 82%, 37% 72%, 28% 52%
    );
    transform: scale(.9);
  }
  100% {
    clip-path: polygon(
      25% 35%, 50% 0%, 75% 35%, 88% 88%,
      59% 73%, 50% 84%, 41% 73%, 12% 88%
    );
    transform: scale(1.18);
  }
}

@keyframes morphTravel {
  0%, 68% { transform: translateY(0); }
  100% { transform: translateY(7vh); }
}

@keyframes mapAwaken {
  0% { filter: blur(28px); transform: scale(1.1); opacity: .08; }
  45% { filter: blur(20px); transform: scale(1.07); opacity: .24; }
  72% { filter: blur(11px); transform: scale(1.035); opacity: .46; }
  100% { filter: blur(5px); transform: scale(1); opacity: .64; }
}

@keyframes statusIn {
  to { opacity: 1; }
}

@keyframes micPulse {
  0% { transform: scale(.8); opacity: .9; }
  100% { transform: scale(1.25); opacity: 0; }
}

@media (min-width: 760px) {
  .top-hud { left: 28px; right: 28px; max-width: 820px; margin: auto; }
  .bottom-panel { left: 28px; right: 28px; max-width: 820px; margin: auto; }
  .maneuver-card { left: 28px; }
  .view-controls, .recenter-button { right: 28px; }
  .speed-card { left: 28px; }
  .limit-card { left: 128px; }
}

@media (max-width: 420px) {
  .top-hud { grid-template-columns: 42px 1fr 44px; }
  .icon-button { width: 42px; height: 42px; }
  .mic-button { width: 44px; height: 44px; }
  .bottom-panel strong { max-width: 170px; }
  .start-button { padding-inline: 14px; }
  .view-controls button { padding-inline: 9px; }
}
