:root {
  --ink: #04070b;
  --ink-2: #070b10;
  --paper: #e7e3d7;
  --muted: #8f9aa2;
  --faint: #56636d;
  --yellow: #ead79b;
  --yellow-hot: #f5e5b6;
  --line: rgba(230, 219, 184, 0.16);
  --panel: rgba(5, 9, 13, 0.68);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "MiSans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", ui-sans-serif, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: default;
  touch-action: none;
}

#map.is-arming,
#map.is-panning {
  cursor: grabbing;
}

#map.is-arming-tilt,
#map.is-tilting {
  cursor: ns-resize;
}

#map:focus-visible {
  outline: 1px solid rgba(234, 215, 155, 0.5);
  outline-offset: -4px;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 52% 44%, transparent 38%, rgba(1, 3, 6, 0.42) 100%),
    linear-gradient(to bottom, rgba(2, 5, 8, 0.28), transparent 18%, transparent 78%, rgba(2, 4, 7, 0.34));
  z-index: 2;
}

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

.road-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 1px 4px 2px;
  border: 1px solid rgba(234, 217, 160, 0.09);
  border-radius: 2px;
  background: rgba(3, 7, 10, 0.36);
  color: #bab5a6;
  font-size: 10px;
  line-height: 1.1;
  letter-spacing: 0.035em;
  white-space: nowrap;
  text-shadow:
    0 1px 1px rgba(0, 0, 0, 0.95),
    0 0 4px rgba(0, 0, 0, 0.8);
  transform: translate3d(-999px, -999px, 0);
  opacity: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.road-label.is-major {
  color: #d9c99b;
  border-color: rgba(234, 215, 155, 0.13);
  background: rgba(4, 8, 11, 0.44);
}

.road-label.is-secondary {
  color: #9aa5ab;
  border-color: rgba(180, 195, 203, 0.07);
  background: rgba(3, 7, 10, 0.3);
}

.road-label.is-edge {
  color: #d3c7a0;
  border-color: rgba(234, 215, 155, 0.18);
  background: rgba(6, 10, 13, 0.52);
  letter-spacing: 0.08em;
}

#metro-labels {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.metro-station-label {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 4px 2px 3px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 2px;
  background: rgba(4, 8, 12, 0.82);
  color: #ece9df;
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.035em;
  white-space: nowrap;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  transform: translate3d(-999px, -999px, 0);
  opacity: 0;
  will-change: transform, opacity;
}

.metro-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border-radius: 2px;
  background: #d71920;
  color: #fff;
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.metro-name {
  padding: 0 2px 0 1px;
  font-weight: 500;
}

.metro-badges {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.metro-badge {
  display: inline-block;
  min-width: 12px;
  height: 13px;
  padding: 0 3px;
  border-radius: 2px;
  background: var(--metro-colour, #8e9ba5);
  color: var(--metro-ink, #081014);
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
}

.metro-exit-label {
  position: absolute;
  left: 0;
  top: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 2px;
  background: var(--metro-colour, #aeb9c0);
  color: var(--metro-ink, #081014);
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.38);
  transform: translate3d(-999px, -999px, 0);
  opacity: 0;
  will-change: transform, opacity;
}

.metro-exit-label.is-empty {
  min-width: 12px;
  width: 12px;
  height: 12px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.34);
  color: transparent;
  background: #4b555b;
  line-height: 12px;
}

header.brand {
  position: fixed;
  top: 28px;
  left: 30px;
  z-index: 5;
  pointer-events: none;
  user-select: none;
}

.brand-kicker {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 8px;
  color: #c7b984;
  font-family: "SFMono-Regular", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.brand-kicker::before {
  content: "";
  width: 22px;
  height: 1px;
  background: #a79765;
  opacity: 0.7;
}

.brand h1 {
  margin: 0;
  color: #e6e1d4;
  font-size: clamp(23px, 3vw, 35px);
  font-weight: 350;
  line-height: 1;
  letter-spacing: 0.08em;
}

.brand h1 span {
  color: #a79c7d;
  font-weight: 300;
}

.brand-sub {
  margin: 9px 0 0;
  color: #7f8b93;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.rule {
  width: 42px;
  height: 1px;
  margin-top: 14px;
  background: linear-gradient(90deg, rgba(234, 215, 155, 0.68), transparent);
}

aside.legend {
  position: fixed;
  top: 28px;
  right: 30px;
  z-index: 5;
  width: 192px;
  padding: 13px 14px 12px;
  border: 1px solid rgba(221, 211, 181, 0.12);
  background: var(--panel);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  user-select: none;
}

.legend-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #8e989d;
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.legend-title::after {
  content: "OSM / 1:1";
  color: #5d696f;
  letter-spacing: 0.12em;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 19px;
  color: #aeb5b6;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.swatch {
  width: 18px;
  height: 3px;
  flex: 0 0 18px;
  border-radius: 1px;
  background: #ddd;
  box-shadow: 0 0 6px color-mix(in srgb, currentColor 30%, transparent);
}

.swatch.ground-major {
  background: #dfc98c;
}

.swatch.elevated {
  height: 2px;
  background: #f4e3ad;
  box-shadow: 0 0 8px rgba(244, 227, 173, 0.52);
}

.swatch.minor {
  background: #8e9ba5;
}

.swatch.metro {
  height: 2px;
  background: linear-gradient(90deg, #d9017a 0 38%, #ff6900 38% 63%, #009fdf 63%);
}

.swatch.station {
  width: 8px;
  height: 8px;
  flex-basis: 8px;
  margin-left: 5px;
  margin-right: 5px;
  border-radius: 2px;
  background: #d71920;
  box-shadow: 0 0 6px rgba(215, 25, 32, 0.45);
}

.swatch.water {
  height: 5px;
  background: #0a202b;
  border-top: 1px solid #173443;
}

.swatch.building {
  width: 8px;
  height: 8px;
  flex-basis: 8px;
  margin-left: 5px;
  margin-right: 5px;
  background: #929c9e;
  border-radius: 1px;
}

.legend-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(220, 210, 178, 0.09);
  color: #58656c;
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.06em;
}

.legend-meta strong {
  color: #8e958f;
  font-weight: 500;
}

.legend-meta-secondary {
  margin-top: 4px;
  padding-top: 0;
  border-top: 0;
}

.legend-meta-secondary strong {
  color: #b9ab86;
}

nav.view-controls {
  position: fixed;
  right: 30px;
  bottom: 31px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(221, 211, 181, 0.12);
  background: var(--panel);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.view-controls button {
  appearance: none;
  min-width: 45px;
  padding: 7px 9px 6px;
  border: 1px solid transparent;
  border-radius: 1px;
  background: transparent;
  color: #9aa4a8;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.view-controls button:hover,
.view-controls button:focus-visible {
  color: #e6ddc1;
  border-color: rgba(234, 215, 155, 0.22);
  background: rgba(234, 215, 155, 0.05);
  outline: none;
}

.view-controls button.is-active {
  color: #e8d8a6;
  border-color: rgba(234, 215, 155, 0.28);
}

.view-controls .divider {
  width: 1px;
  height: 16px;
  margin: 0 3px;
  background: rgba(221, 211, 181, 0.12);
}

.control-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 4px;
  color: #8c969b;
  font-size: 9px;
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: none;
}

.control-toggle input {
  appearance: none;
  position: relative;
  width: 23px;
  height: 12px;
  margin: 0;
  border: 1px solid rgba(157, 168, 174, 0.32);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.control-toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #75838a;
  transition: transform 160ms ease, background 160ms ease;
}

.control-toggle input:checked {
  border-color: rgba(234, 215, 155, 0.5);
  background: rgba(234, 215, 155, 0.1);
}

.control-toggle input:checked::after {
  transform: translateX(11px);
  background: #e6d29a;
}

.control-toggle input:focus-visible {
  outline: 1px solid rgba(234, 215, 155, 0.6);
  outline-offset: 2px;
}

#scalebar {
  position: fixed;
  left: 30px;
  bottom: 32px;
  z-index: 5;
  width: 138px;
  color: #899398;
  user-select: none;
  pointer-events: none;
}

.scale-line {
  position: relative;
  height: 6px;
  margin-bottom: 5px;
  border-bottom: 1px solid #a7a083;
}

.scale-line::before,
.scale-line::after {
  content: "";
  position: absolute;
  bottom: -1px;
  width: 1px;
  height: 5px;
  background: #a7a083;
}

.scale-line::before {
  left: 0;
}

.scale-line::after {
  right: 0;
}

#scale-label {
  display: flex;
  justify-content: space-between;
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

#scale-label b {
  color: #b9b29a;
  font-weight: 500;
}

#scale-label em {
  color: #8f8a78;
  font-style: normal;
  letter-spacing: 0.02em;
}

#view-angle {
  color: #a6a08c;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 4;
  transform: translateX(-50%);
  color: rgba(148, 158, 162, 0.62);
  font-size: 9px;
  letter-spacing: 0.16em;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.attrib {
  position: fixed;
  right: 30px;
  bottom: 10px;
  z-index: 5;
  color: rgba(115, 126, 130, 0.55);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.attrib:hover {
  color: rgba(190, 180, 150, 0.85);
}

#loader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #04070b;
  transition: opacity 700ms ease, visibility 700ms ease;
}

#loader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-mark {
  position: relative;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(234, 215, 155, 0.22);
  transform: rotate(45deg);
}

.loader-mark::before,
.loader-mark::after {
  content: "";
  position: absolute;
  background: rgba(234, 215, 155, 0.7);
}

.loader-mark::before {
  top: 50%;
  left: 13px;
  right: 13px;
  height: 1px;
}

.loader-mark::after {
  top: 13px;
  bottom: 13px;
  left: 50%;
  width: 1px;
}

.loader-mark span {
  position: absolute;
  inset: 17px;
  border: 1px solid rgba(234, 215, 155, 0.44);
  animation: breathe 2.4s ease-in-out infinite;
}

#loader p {
  margin: 0;
  color: #a6a08d;
  font-size: 10px;
  letter-spacing: 0.22em;
}

.loader-track {
  width: 176px;
  height: 1px;
  overflow: hidden;
  background: rgba(234, 215, 155, 0.13);
}

.loader-track i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #8d805b, #ead79b);
  transition: width 320ms ease;
}

.loader-note {
  min-height: 12px;
  color: #536067;
  font-family: "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
}

.fatal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 30px;
  background: #04070b;
  color: #c8c2b2;
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
}

.fatal.is-visible {
  display: grid;
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.03);
  }
}

@media (max-width: 760px) {
  header.brand {
    top: 18px;
    left: 18px;
  }

  .brand h1 {
    font-size: 24px;
  }

  .brand-sub {
    font-size: 9px;
  }

  aside.legend {
    display: none;
  }

  .hint {
    display: none;
  }

  nav.view-controls {
    right: 17px;
    bottom: 20px;
  }

  #scalebar {
    left: 18px;
    bottom: 21px;
    width: 104px;
  }

  .attrib {
    left: 18px;
    right: auto;
    bottom: 6px;
    font-size: 7px;
  }
}

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