:root {
  color-scheme: dark;
  --bg: #071014;
  --ink: #eef9fb;
  --muted: rgba(238, 249, 251, 0.66);
  --glass: rgba(7, 16, 20, 0.68);
  --glass-strong: rgba(7, 16, 20, 0.82);
  --line-tram: #3fe6d0;
  --line-bus: #ffb13b;
  --line-ferry: #58a6ff;
  --line-rail: #d9e7ff;
  --line-s-bahn: #70d66b;
  --line-unknown: #d9e7ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.transit-shell,
.transit-map {
  position: fixed;
  inset: 0;
}

.transit-map {
  background:
    radial-gradient(circle at 50% 42%, rgba(63, 230, 208, 0.14), transparent 34%),
    linear-gradient(145deg, #071014 0%, #10151d 54%, #09141b 100%);
}

.map-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, transparent 0%, transparent 48%, rgba(3, 8, 12, 0.42) 100%),
    linear-gradient(180deg, rgba(3, 8, 12, 0.32), transparent 28%, transparent 66%, rgba(3, 8, 12, 0.56));
  z-index: 1;
}

.status,
.legend {
  position: fixed;
  z-index: 2;
  border: 1px solid rgba(238, 249, 251, 0.15);
  background: linear-gradient(135deg, var(--glass), rgba(13, 31, 39, 0.58));
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

.status {
  top: 20px;
  left: 20px;
  width: min(330px, calc(100vw - 40px));
  padding: 13px 15px 12px;
  border-radius: 8px;
}

.status__title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.status__pulse {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #56f2c8;
  box-shadow: 0 0 0 0 rgba(86, 242, 200, 0.54), 0 0 18px rgba(86, 242, 200, 0.78);
  animation: livePulse 1.8s ease-out infinite;
}

.status__pulse.is-stale {
  background: #ffb13b;
  box-shadow: 0 0 18px rgba(255, 177, 59, 0.5);
  animation-duration: 3.2s;
}

.status__meta {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.legend {
  right: 20px;
  bottom: 24px;
  display: grid;
  grid-template-columns: repeat(5, auto);
  gap: 10px 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(238, 249, 251, 0.72);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.legend__item span {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  box-shadow: 0 0 14px currentColor;
}

.legend__item[data-mode="tram"] span { background: var(--line-tram); color: var(--line-tram); }
.legend__item[data-mode="bus"] span { background: var(--line-bus); color: var(--line-bus); }
.legend__item[data-mode="ferry"] span { background: var(--line-ferry); color: var(--line-ferry); }
.legend__item[data-mode="rail"] span { background: var(--line-rail); color: var(--line-rail); }
.legend__item[data-mode="s-bahn"] span { background: var(--line-s-bahn); color: var(--line-s-bahn); }

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib a {
  color: rgba(238, 249, 251, 0.66);
}

.maplibregl-ctrl-attrib {
  background: var(--glass-strong) !important;
  border-top-left-radius: 6px;
}

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib a {
  color: rgba(238, 249, 251, 0.76) !important;
}

.maplibregl-ctrl-attrib-button {
  background-color: rgba(238, 249, 251, 0.84) !important;
  filter: invert(1);
}

.maplibregl-ctrl-bottom-left,
.maplibregl-ctrl-bottom-right {
  bottom: 72px !important;
}

.maplibregl-ctrl-bottom-left .maplibregl-ctrl,
.maplibregl-ctrl-bottom-right .maplibregl-ctrl {
  margin-bottom: 0;
}

.vehicle {
  --vehicle-color: var(--line-unknown);
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-style: preserve-3d;
  pointer-events: auto;
}

.vehicle__shadow {
  position: absolute;
  left: 6px;
  top: 20px;
  width: 24px;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  filter: blur(5px);
  transform: rotateX(68deg);
}

.vehicle__body {
  position: absolute;
  left: 6px;
  top: 5px;
  width: 22px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 5px 5px 7px 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.18) 22%, transparent 23%),
    linear-gradient(135deg, color-mix(in srgb, var(--vehicle-color) 86%, #ffffff 14%), var(--vehicle-color));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--vehicle-color) 70%, transparent),
    0 8px 18px color-mix(in srgb, var(--vehicle-color) 45%, transparent),
    inset 0 -6px 9px rgba(0, 0, 0, 0.22);
  transform: perspective(70px) rotateX(18deg);
}

.vehicle__body::before {
  content: "";
  position: absolute;
  left: 7px;
  top: -6px;
  width: 8px;
  height: 8px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  background: rgba(255, 255, 255, 0.9);
}

.vehicle__window {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 5px;
  height: 5px;
  border-radius: 2px;
  background: rgba(6, 19, 24, 0.58);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.vehicle--bus .vehicle__body {
  width: 26px;
  left: 4px;
  border-radius: 4px 7px 7px 4px;
}

.vehicle--ferry .vehicle__body {
  height: 15px;
  top: 8px;
  border-radius: 999px 999px 7px 7px;
}

.vehicle--rail .vehicle__body,
.vehicle--s-bahn .vehicle__body {
  height: 22px;
  top: 2px;
  border-radius: 9px 9px 5px 5px;
}

.vehicle--inferred {
  opacity: 0.76;
  filter: saturate(0.86);
}

.vehicle--inferred .vehicle__body {
  border-style: dashed;
}

.vehicle--stale {
  opacity: 0.48;
  filter: grayscale(0.28);
}

.vehicle--stale .vehicle__body {
  animation: staleDrift 2.8s ease-in-out infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(86, 242, 200, 0.52), 0 0 18px rgba(86, 242, 200, 0.78); }
  80% { box-shadow: 0 0 0 12px rgba(86, 242, 200, 0), 0 0 18px rgba(86, 242, 200, 0.78); }
  100% { box-shadow: 0 0 0 0 rgba(86, 242, 200, 0), 0 0 18px rgba(86, 242, 200, 0.78); }
}

@keyframes staleDrift {
  0%, 100% { transform: perspective(70px) rotateX(18deg) translateY(0); }
  50% { transform: perspective(70px) rotateX(18deg) translateY(-2px); }
}

@media (max-width: 700px) {
  .status {
    top: 12px;
    left: 12px;
    width: calc(100vw - 24px);
    padding: 12px 13px;
  }

  .legend {
    right: 12px;
    bottom: 18px;
    left: 12px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-items: center;
    padding: 10px 8px;
  }

  .maplibregl-ctrl-bottom-left,
  .maplibregl-ctrl-bottom-right {
    right: 8px;
    bottom: 82px !important;
    left: 8px;
  }

  .maplibregl-ctrl-bottom-left .maplibregl-ctrl,
  .maplibregl-ctrl-bottom-right .maplibregl-ctrl {
    max-width: calc(100vw - 16px);
    margin-right: 0;
  }

  .legend__item {
    flex-direction: column;
    gap: 5px;
    font-size: 10px;
  }

  .vehicle {
    width: 30px;
    height: 30px;
  }
}

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