:root {
  color-scheme: dark;
  --ink: #fff9ee;
  --muted: #c8caed;
  --faint: #969fce;
  --panel: rgba(29, 31, 80, 0.96);
  --panel-solid: #24275f;
  --line: rgba(143, 181, 255, 0.28);
  --mint: #ffd23f;
  --mint-strong: #ffad2f;
  --mint-dim: rgba(255, 210, 63, 0.16);
  --cyan: #56c9ff;
  --amber: #ffc53d;
  --danger: #ff5368;
  --shadow: 0 18px 55px rgba(4, 7, 34, 0.52), 0 4px 0 rgba(5, 9, 43, 0.4), inset 0 1px rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", "Avenir Next", Verdana, system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0b0d2a;
}

body {
  color: var(--ink);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible,
summary:focus-visible,
.timeline:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: #18204d;
  background: var(--mint);
  border-radius: 8px;
  font-weight: 750;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  isolation: isolate;
  background:
    radial-gradient(circle at 72% 30%, rgba(93, 101, 255, 0.22), transparent 40%),
    linear-gradient(145deg, #11164a, #260f43);
}

#map-canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#map-canvas:active {
  cursor: grabbing;
}

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

.topbar {
  position: absolute;
  z-index: 10;
  top: calc(14px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  width: min(760px, calc(100% - 28px - var(--safe-left) - var(--safe-right)));
  display: grid;
  grid-template-columns: minmax(250px, 1.4fr) minmax(90px, 0.55fr) minmax(90px, 0.55fr) minmax(125px, 0.75fr);
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: linear-gradient(120deg, rgba(31, 39, 101, 0.98), rgba(76, 34, 103, 0.97));
  border: 1px solid rgba(143, 190, 255, 0.36);
  border-radius: 15px;
  box-shadow: 0 16px 50px rgba(4, 7, 34, 0.55), 0 4px 0 rgba(12, 15, 58, 0.52), inset 0 1px rgba(255, 255, 255, 0.11);
  backdrop-filter: blur(22px) saturate(125%);
  -webkit-backdrop-filter: blur(22px) saturate(125%);
}

.episode-card {
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  height: 48px;
  gap: 8px;
  padding: 6px 10px 11px 7px;
  overflow: visible;
  background: linear-gradient(105deg, rgba(255, 83, 104, 0.18), rgba(87, 106, 255, 0.14));
  border: 1px solid rgba(255, 210, 63, 0.28);
  border-radius: 11px;
}

.episode-copy {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
}

.playback-toggle {
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  color: #21194c;
  background: var(--mint);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.69rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0 14px rgba(255, 210, 63, 0.25);
}

.playback-toggle:hover {
  background: #ffe279;
  transform: translateY(-1px);
}

.eyebrow {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 760;
  letter-spacing: 0.115em;
  line-height: 1.2;
  text-transform: uppercase;
}

#episode-time {
  color: var(--mint);
  font-size: 1.16rem;
  font-weight: 710;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 0 18px rgba(255, 190, 49, 0.3), 0 1px 0 rgba(63, 28, 91, 0.5);
}

.tick-text {
  justify-self: end;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: ew-resize;
}

.timeline::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(90deg, #ff5368, #ffd23f, #56c9ff);
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.72);
  border-radius: 99px;
}

.timeline::-moz-range-track {
  height: 3px;
  background: linear-gradient(90deg, #ff5368, #ffd23f, #56c9ff);
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.72);
  border-radius: 99px;
}

.timeline::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  background: #fff9df;
  border: 2px solid var(--mint-strong);
  border-radius: 50%;
  box-shadow: 0 2px 9px rgba(11, 9, 48, 0.75);
}

.timeline::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #fff9df;
  border: 2px solid var(--mint-strong);
  border-radius: 50%;
  box-shadow: 0 2px 9px rgba(11, 9, 48, 0.75);
}

.topbar > .status-pill,
.topbar > .vehicle-count,
.topbar > .fleet-distance {
  min-width: 0;
  height: 48px;
  padding: 4px 11px;
  background: rgba(14, 18, 63, 0.34);
  border: 1px solid rgba(143, 181, 255, 0.18);
  border-radius: 11px;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f8f4ff;
  font-size: 0.73rem;
  font-weight: 680;
}

.status-pill i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 197, 61, 0.14), 0 0 13px rgba(255, 197, 61, 0.5);
}

.status-pill.is-live i {
  background: #43df7f;
  box-shadow: 0 0 0 4px rgba(67, 223, 127, 0.14), 0 0 13px rgba(67, 223, 127, 0.58);
}

.status-pill.is-replay i {
  background: var(--cyan);
  box-shadow: 0 0 0 4px rgba(86, 201, 255, 0.14), 0 0 13px rgba(86, 201, 255, 0.58);
}

.status-pill.is-offline i {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 83, 104, 0.14), 0 0 13px rgba(255, 83, 104, 0.5);
}

.status-pill.is-connecting i {
  animation: status-pulse 1.1s ease-in-out infinite;
}

@keyframes status-pulse {
  50% { opacity: 0.38; transform: scale(0.72); }
}

.vehicle-count,
.fleet-distance {
  display: grid;
  align-content: center;
  gap: 1px;
}

.vehicle-count .eyebrow,
.fleet-distance .eyebrow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-count strong,
.fleet-distance strong {
  overflow: hidden;
  color: #fff8ed;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  font-weight: 690;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-count > small,
.fleet-distance > small {
  overflow: hidden;
  color: var(--faint);
  font-size: 0.61rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fleet-distance strong small {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 680;
  letter-spacing: 0;
}

.landmark-panel {
  position: absolute;
  z-index: 8;
  top: calc(110px + var(--safe-top));
  left: calc(14px + var(--safe-left));
  width: 178px;
  padding: 10px;
}

.panel-heading {
  display: grid;
  gap: 3px;
  padding: 4px 6px 9px;
}

.panel-heading > span:last-child {
  overflow: hidden;
  color: #f1efff;
  font-size: 0.71rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.landmark-list {
  display: grid;
  gap: 4px;
}

.landmark-list button {
  min-width: 0;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  color: #eef0ff;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 660;
  text-align: left;
  transition: color 130ms ease, background 130ms ease, border-color 130ms ease;
}

.landmark-list button:hover:not(:disabled) {
  color: #ffffff;
  background: rgba(86, 201, 255, 0.16);
  border-color: rgba(111, 213, 255, 0.38);
}

.landmark-list button:active:not(:disabled) {
  background: rgba(255, 210, 63, 0.2);
}

.landmark-list i {
  position: relative;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  border: 1.5px solid #79a7ff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg) scale(0.74);
}

.landmark-list i::after {
  content: "";
  position: absolute;
  top: 3.5px;
  left: 3.5px;
  width: 5px;
  height: 5px;
  background: var(--mint);
  border-radius: 50%;
}

.landmark-list span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-tools {
  position: absolute;
  z-index: 8;
  right: calc(14px + var(--safe-right));
  top: calc(110px + var(--safe-top));
  display: grid;
  padding: 5px;
}

.map-tools button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #eef0ff;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  transition: color 130ms ease, background 130ms ease;
}

.map-tools button:last-child {
  border-bottom: 0;
}

.map-tools button:hover {
  color: var(--mint);
  background: var(--mint-dim);
  border-radius: 7px;
}

.map-tools svg {
  width: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-hint {
  position: absolute;
  z-index: 6;
  left: calc(14px + var(--safe-left));
  bottom: calc(14px + var(--safe-bottom));
  max-width: calc(100% - 370px);
  padding: 8px 11px;
  color: #b9bee5;
  font-size: 0.64rem;
  pointer-events: none;
}

.map-hint kbd {
  color: #fff4c4;
  font: inherit;
  font-weight: 700;
}

.about-panel {
  position: absolute;
  z-index: 7;
  right: calc(14px + var(--safe-right));
  bottom: calc(34px + var(--safe-bottom));
  width: min(350px, calc(100% - 28px - var(--safe-left) - var(--safe-right)));
  overflow: hidden;
}

.about-panel:not([open]) {
  width: auto;
}

.about-panel summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.about-panel summary::-webkit-details-marker {
  display: none;
}

.about-panel summary:focus-visible {
  outline-offset: -3px;
}

.about-panel summary strong {
  color: #fff8ed;
  font-size: 0.72rem;
}

.about-panel summary::after {
  content: "+";
  margin-left: auto;
  color: var(--mint);
  font-size: 1rem;
  line-height: 1;
}

.about-panel[open] summary::after {
  content: "−";
}

.about-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.about-panel p {
  margin: 0;
  padding: 11px 13px 13px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.5;
}

.touch-hint {
  display: none;
}

.vehicle-hud {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  min-width: 290px;
  height: 58px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 7px 8px 7px 14px;
  transform: translateX(-50%);
}

.vehicle-hud > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.vehicle-hud > div strong {
  overflow: hidden;
  color: #fff8ee;
  font-size: 0.73rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#selected-speed {
  color: var(--mint);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 730;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

#selected-speed small {
  color: var(--muted);
  font-size: 0.55rem;
  letter-spacing: 0;
}

.vehicle-hud button {
  height: 40px;
  padding: 0 12px;
  color: #dce1ff;
  background: rgba(112, 145, 255, 0.12);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.66rem;
  font-weight: 700;
}

.vehicle-hud button:hover {
  color: var(--mint);
  border-color: rgba(255, 210, 63, 0.58);
}

.loading-screen {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  background:
    radial-gradient(circle at center, rgba(255, 83, 104, 0.28), transparent 34%),
    linear-gradient(145deg, #161b57, #37134f);
  transition: opacity 420ms ease, visibility 420ms ease;
}

body[data-ready="true"] .loading-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.loading-screen strong {
  margin-top: 10px;
  font-size: 0.9rem;
  font-weight: 720;
  letter-spacing: 0.01em;
}

.loading-screen span {
  color: var(--muted);
  font-size: 0.7rem;
}

.loading-mark {
  width: 54px;
  height: 54px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid rgba(255, 210, 63, 0.5);
  border-radius: 50%;
  box-shadow: 0 0 32px rgba(255, 210, 63, 0.25), inset 0 0 18px rgba(86, 201, 255, 0.13);
}

.loading-mark::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid transparent;
  border-top-color: var(--mint);
  border-radius: 50%;
  animation: spin 1.1s linear infinite;
}

.loading-mark i {
  width: 5px;
  height: 5px;
  background: var(--mint);
  border-radius: 50%;
  animation: loading-dot 900ms ease-in-out infinite alternate;
}

.loading-mark i:nth-child(2) { animation-delay: 150ms; }
.loading-mark i:nth-child(3) { animation-delay: 300ms; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes loading-dot { to { opacity: 0.25; transform: scale(0.7); } }

.fatal-error {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 12, 48, 0.97);
}

.fatal-error > div {
  max-width: 420px;
  display: grid;
  justify-items: center;
  text-align: center;
}

.error-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: #fff0f3;
  background: rgba(255, 83, 104, 0.2);
  border: 1px solid rgba(255, 112, 132, 0.55);
  border-radius: 50%;
  font-size: 1.35rem;
  font-weight: 800;
}

.fatal-error h1 {
  margin: 20px 0 7px;
  font-size: 1.25rem;
}

.fatal-error p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.fatal-error button {
  margin-top: 22px;
  min-height: 44px;
  padding: 0 19px;
  color: #202557;
  background: var(--mint);
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 750;
}

.toast-region {
  position: fixed;
  z-index: 90;
  right: calc(18px + var(--safe-right));
  bottom: calc(48px + var(--safe-bottom));
  width: min(340px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  color: #fff9ef;
  background: rgba(38, 38, 99, 0.98);
  border: 1px solid rgba(143, 181, 255, 0.36);
  border-left: 3px solid var(--mint);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  line-height: 1.4;
  animation: toast-in 220ms ease both;
}

.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--amber); }
.toast.is-leaving { animation: toast-out 180ms ease both; }

@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

.noscript {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: #fff9ee;
  background: #171743;
  text-align: center;
}

@media (max-width: 820px) {
  .topbar {
    right: calc(14px + var(--safe-right));
    width: auto;
    grid-template-columns: minmax(205px, 1.3fr) minmax(76px, 0.5fr) minmax(72px, 0.52fr) minmax(110px, 0.72fr);
  }

  .episode-card {
    padding-right: 10px;
    padding-left: 10px;
  }

  .episode-copy {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
  }

  .landmark-panel {
    top: calc(96px + var(--safe-top));
    right: calc(14px + var(--safe-right));
    width: auto;
    padding: 5px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .landmark-panel::-webkit-scrollbar {
    display: none;
  }

  .panel-heading {
    display: none;
  }

  .landmark-list {
    display: flex;
    gap: 3px;
  }

  .landmark-list button {
    height: 38px;
    padding: 0 10px;
    flex: 0 0 auto;
  }

  .map-tools {
    top: calc(149px + var(--safe-top));
  }

  .map-hint {
    max-width: none;
  }

  .about-panel {
    bottom: calc(58px + var(--safe-bottom));
  }
}

@media (max-width: 620px) {
  .topbar {
    grid-template-columns: minmax(175px, 1.15fr) 28px minmax(68px, 0.52fr) minmax(105px, 0.7fr);
  }

  .topbar > .status-pill {
    justify-content: center;
    padding-right: 0;
    padding-left: 0;
  }

  .status-pill span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

@media (pointer: coarse), (max-width: 720px) {
  .desktop-hint {
    display: none;
  }

  .touch-hint {
    display: inline;
  }

  .vehicle-hud {
    top: calc(154px + var(--safe-top));
    bottom: auto;
    min-width: 0;
    width: auto;
    height: 42px;
    gap: 10px;
    padding: 4px 5px 4px 10px;
  }

  #selected-speed {
    font-size: 1rem;
  }

  .vehicle-hud button {
    height: 32px;
  }

  .map-tools {
    display: none;
  }

  .map-hint {
    bottom: calc(25px + var(--safe-bottom));
  }
}

@media (max-width: 560px) {
  .topbar {
    top: calc(8px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    grid-template-columns: minmax(130px, 1.15fr) 22px minmax(52px, 0.58fr) minmax(84px, 0.82fr);
    gap: 4px;
    padding: 4px;
    border-radius: 13px;
  }

  .episode-card {
    height: 46px;
    gap: 5px;
    padding: 5px 6px 9px 4px;
  }

  .episode-copy {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 6px;
  }

  .tick-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #episode-time {
    font-size: 1.04rem;
  }

  .playback-toggle {
    width: 25px;
    height: 25px;
    font-size: 0.61rem;
  }

  .topbar > .status-pill,
  .topbar > .vehicle-count,
  .topbar > .fleet-distance {
    height: 46px;
  }

  .topbar > .vehicle-count,
  .topbar > .fleet-distance {
    padding: 4px 6px;
  }

  .vehicle-count .eyebrow,
  .fleet-distance .eyebrow {
    font-size: 0.56rem;
    letter-spacing: 0.08em;
  }

  .vehicle-count strong,
  .fleet-distance strong {
    font-size: 0.69rem;
  }

  .vehicle-count > small,
  .fleet-distance > small {
    font-size: 0.55rem;
  }

  .landmark-panel {
    top: calc(79px + var(--safe-top));
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    border-radius: 11px;
  }

  .landmark-list button {
    height: 36px;
    padding: 0 8px;
    font-size: 0.64rem;
  }

  .landmark-list i {
    display: none;
  }

  .map-hint {
    left: calc(8px + var(--safe-left));
    padding: 7px 9px;
  }

  .vehicle-hud {
    top: calc(126px + var(--safe-top));
    max-width: calc(100% - 18px - var(--safe-left) - var(--safe-right));
  }
}

@media (max-width: 390px) {
  .landmark-list button {
    padding: 0 7px;
  }

}

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

@media (forced-colors: active) {
  .glass-panel,
  .topbar {
    border: 1px solid CanvasText;
  }
}
