:root {
  --ink: #070b0d;
  --paper: #e9e6dc;
  --muted: #8e9690;
  --line: rgba(225, 230, 219, 0.17);
  --air: #ff8a3d;
  --sea: #69e4ff;
  --rail: #c9ff68;
  --migration: #ff5c9a;
  --messages: #a999ff;
  --finance: #ffd15c;
  --panel: rgba(10, 15, 17, 0.84);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  color-scheme: dark;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 38%, rgba(44, 61, 61, 0.18), transparent 42%),
    var(--ink);
  color: var(--paper);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 12px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 640px;
  overflow: hidden;
  isolation: isolate;
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: 0.12;
  pointer-events: none;
  mix-blend-mode: overlay;
  background:
    repeating-radial-gradient(circle at 17% 23%, rgba(255, 255, 255, 0.16) 0 0.45px, transparent 0.6px 3px),
    repeating-radial-gradient(circle at 71% 64%, rgba(255, 255, 255, 0.08) 0 0.35px, transparent 0.55px 4px);
  background-size: 7px 9px, 11px 13px;
}

.topbar {
  position: absolute;
  z-index: 12;
  top: 0;
  left: 0;
  right: 0;
  height: 66px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 11, 13, 0.95), rgba(7, 11, 13, 0.62));
  backdrop-filter: blur(16px);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  color: var(--paper);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.wordmark-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: 20px;
  height: 20px;
  transform: rotate(-18deg);
}

.wordmark-mark i {
  display: block;
  width: 3px;
  height: 14px;
  border-radius: 99px;
  background: var(--paper);
}

.wordmark-mark i:nth-child(2) {
  height: 20px;
  background: var(--air);
}

.wordmark-mark i:nth-child(3) {
  height: 9px;
}

.topbar-center,
.top-actions {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #a9b0aa;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.live-pulse,
.route-live i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bffa71;
  box-shadow: 0 0 13px #bffa71;
  animation: live 1.7s ease-in-out infinite;
}

.divider {
  color: #555e5a;
}

.top-actions {
  justify-self: end;
  gap: 20px;
}

.plain-button {
  padding: 7px 0;
  border: 0;
  background: none;
  color: #c5cac5;
  cursor: pointer;
  letter-spacing: 0.13em;
}

.plain-button:hover,
.plain-button:focus-visible {
  color: #fff;
}

.branding-link {
  padding-left: 20px;
  border-left: 1px solid var(--line);
  color: #c5cac5;
  text-decoration: none;
  letter-spacing: 0.13em;
  transition: color 160ms ease;
}

.branding-link:hover,
.branding-link:focus-visible {
  color: var(--paper);
}

.sound-icon {
  display: inline-flex;
  align-items: end;
  gap: 2px;
  height: 9px;
  margin-right: 6px;
}

.sound-icon i {
  width: 1px;
  height: 4px;
  background: currentColor;
}

.sound-icon i:nth-child(2) {
  height: 8px;
}

.sound-icon i:nth-child(3) {
  height: 6px;
}

.intro {
  position: absolute;
  z-index: 8;
  top: 98px;
  left: 28px;
  width: min(365px, 28vw);
  pointer-events: none;
}

.eyebrow,
.panel-label {
  margin: 0 0 17px;
  color: #99a19b;
  font-size: 9px;
  letter-spacing: 0.22em;
}

.eyebrow span {
  margin-right: 12px;
  color: var(--air);
}

.intro h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(52px, 5.8vw, 96px);
  font-weight: 900;
  line-height: 0.87;
  letter-spacing: -0.055em;
}

.intro h1 em {
  color: transparent;
  font-style: normal;
  -webkit-text-stroke: 1px rgba(233, 230, 220, 0.76);
}

.dek {
  max-width: 310px;
  margin: 24px 0 17px;
  color: #a9afa9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.48;
}

.intro-meta {
  display: flex;
  gap: 17px;
  color: #6f7872;
  font-size: 8px;
  letter-spacing: 0.15em;
}

.map-stage {
  position: absolute;
  z-index: 2;
  top: 66px;
  left: 0;
  right: 0;
  bottom: 132px;
  overflow: hidden;
  cursor: crosshair;
}

.map-stage.dragging {
  cursor: grabbing;
}

.map-wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(7, 11, 13, 0.92) 0%, rgba(7, 11, 13, 0.2) 28%, transparent 48%),
    linear-gradient(0deg, rgba(7, 11, 13, 0.48), transparent 22%);
}

#world-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.map-label {
  position: absolute;
  color: rgba(207, 215, 207, 0.35);
  font-size: 8px;
  letter-spacing: 0.12em;
  pointer-events: none;
}

.map-label-north { top: 16px; left: 50%; }
.map-label-south { bottom: 17px; left: 50%; }
.map-label-west { left: 7px; top: 54%; }
.map-label-east { right: 7px; top: 54%; }

.map-tools {
  position: absolute;
  z-index: 7;
  right: 28px;
  top: 25px;
  display: grid;
  border: 1px solid var(--line);
  background: rgba(7, 11, 13, 0.66);
  backdrop-filter: blur(10px);
}

.map-tools button {
  width: 34px;
  height: 31px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: #b8beb9;
  cursor: pointer;
  font-size: 16px;
}

.map-tools button:last-child {
  border-bottom: 0;
  font-size: 14px;
}

.map-tools button:hover,
.map-tools button:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.coordinates {
  position: absolute;
  right: 28px;
  bottom: 22px;
  display: flex;
  gap: 15px;
  color: #66716b;
  font-size: 8px;
  letter-spacing: 0.14em;
}

.route-card {
  --current: var(--air);
  position: absolute;
  z-index: 8;
  right: 80px;
  top: 124px;
  width: 238px;
  padding: 15px 16px 13px;
  border: 1px solid rgba(230, 235, 224, 0.2);
  background: rgba(9, 14, 16, 0.84);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34), inset 2px 0 0 var(--current);
  backdrop-filter: blur(16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.route-card.is-changing {
  opacity: 0.25;
  transform: translateY(3px);
}

.route-card-head,
.route-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #768079;
  font-size: 7px;
  letter-spacing: 0.16em;
}

.route-live {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #b5bdb6;
}

.route-live i {
  width: 4px;
  height: 4px;
  background: var(--current);
  box-shadow: 0 0 8px var(--current);
}

.route-type {
  margin: 20px 0 5px;
  color: var(--current);
  font-size: 8px;
  letter-spacing: 0.18em;
}

.route-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 400;
  line-height: 1.1;
}

.route-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 18px 0 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.route-stat strong {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.route-stat span {
  color: #7c867f;
  font-size: 7px;
  letter-spacing: 0.12em;
}

.route-note {
  margin: 11px 0 13px;
  color: #a8afa9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12.5px;
  line-height: 1.55;
}

.map-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  color: #727c76;
  font-size: 8px;
  letter-spacing: 0.13em;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.map-hint span {
  color: var(--paper);
  font-size: 14px;
}

.system-panel {
  position: absolute;
  z-index: 10;
  left: 28px;
  top: min(54vh, 500px);
  width: 225px;
}

.system-list {
  margin-top: 27px;
  border-top: 1px solid var(--line);
}

.system-button {
  display: grid;
  grid-template-columns: 25px 10px 1fr auto;
  align-items: center;
  width: 100%;
  height: 34px;
  padding: 0 4px 0 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: #79827c;
  cursor: pointer;
  text-align: left;
}

.system-button[data-system="featured"],
.system-button[data-system="all"] {
  grid-template-columns: 35px 1fr auto;
}

.system-button[data-system="featured"] .system-number {
  color: var(--finance);
  text-shadow: 0 0 10px rgba(255, 209, 92, 0.7);
}

.system-button:hover,
.system-button:focus-visible,
.system-button.active {
  color: var(--paper);
}

.system-button.active {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent);
}

.system-number,
.system-count {
  font-size: 7px;
  letter-spacing: 0.14em;
}

.system-name {
  font-size: 9px;
  letter-spacing: 0.16em;
}

.system-dot,
.drawer-legend i {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.dot-air { color: var(--air); background: var(--air); }
.dot-sea { color: var(--sea); background: var(--sea); }
.dot-rail { color: var(--rail); background: var(--rail); }
.dot-migration { color: var(--migration); background: var(--migration); }
.dot-messages { color: var(--messages); background: var(--messages); }
.dot-finance { color: var(--finance); background: var(--finance); }

.system-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 10px;
  margin-top: 14px;
}

.system-summary p {
  margin: 0;
  color: #69736c;
  font-size: 7px;
  letter-spacing: 0.15em;
}

.system-summary strong {
  grid-row: span 2;
  font-size: 14px;
  font-weight: 400;
}

.density-bar {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
}

.density-bar i {
  height: 3px;
  background: #313a36;
}

.density-bar i:nth-child(-n + 6) {
  background: #9ba59e;
}

.time-panel {
  position: absolute;
  z-index: 12;
  left: 0;
  right: 0;
  bottom: 32px;
  height: 100px;
  display: grid;
  grid-template-columns: 66px 1fr 180px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: rgba(7, 11, 13, 0.91);
  backdrop-filter: blur(18px);
}

.play-button {
  width: 38px;
  height: 38px;
  margin: auto;
  padding: 0;
  border: 1px solid rgba(235, 239, 230, 0.32);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.play-button:hover,
.play-button:focus-visible {
  border-color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
}

.time-main {
  padding: 0 28px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.time-head,
.time-ticks {
  display: flex;
  justify-content: space-between;
  color: #707a74;
  font-size: 7px;
  letter-spacing: 0.15em;
}

.time-head strong {
  color: var(--paper);
  font-weight: 500;
}

#time-slider {
  display: block;
  width: 100%;
  height: 18px;
  margin: 7px 0 1px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

#time-slider::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(90deg, var(--air) 0 var(--progress, 61%), rgba(233, 230, 220, 0.2) var(--progress, 61%));
}

#time-slider::-webkit-slider-thumb {
  width: 9px;
  height: 9px;
  margin-top: -4px;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--paper), 0 0 14px rgba(255, 138, 61, 0.7);
}

#time-slider::-moz-range-track {
  height: 1px;
  background: rgba(233, 230, 220, 0.2);
}

#time-slider::-moz-range-progress {
  height: 1px;
  background: var(--air);
}

#time-slider::-moz-range-thumb {
  width: 7px;
  height: 7px;
  border: 1px solid var(--paper);
  border-radius: 50%;
  background: var(--paper);
}

.flow-total {
  display: grid;
  justify-content: center;
  gap: 2px;
  text-align: right;
}

.flow-total span {
  color: #707a74;
  font-size: 7px;
  letter-spacing: 0.15em;
}

.flow-total strong {
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.footer {
  position: absolute;
  z-index: 12;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-top: 1px solid var(--line);
  background: #070b0d;
  color: #515b55;
  font-size: 7px;
  letter-spacing: 0.15em;
}

.drawer-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  background: rgba(1, 4, 5, 0.72);
  backdrop-filter: blur(10px);
}

.drawer-backdrop[hidden] {
  display: none;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(620px, 94vw);
  height: 100%;
  overflow-y: auto;
  padding: 24px 42px 40px;
  border-left: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 10%, rgba(255, 138, 61, 0.12), transparent 35%),
    #0b1012;
  animation: drawer-in 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer-top {
  display: flex;
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  color: #777f79;
  font-size: 8px;
  letter-spacing: 0.16em;
}

.drawer-top button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--paper);
  cursor: pointer;
  letter-spacing: inherit;
}

.drawer-kicker {
  margin: 45px 0 18px;
  color: var(--air);
  font-size: 8px;
  letter-spacing: 0.18em;
}

.drawer h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 400;
  line-height: 0.97;
  letter-spacing: -0.045em;
}

.drawer-lead {
  max-width: 500px;
  margin: 28px 0 36px;
  color: #a7aea8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.55;
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.drawer-grid section {
  min-height: 150px;
  padding: 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.drawer-grid span {
  color: var(--air);
  font-size: 8px;
  letter-spacing: 0.16em;
}

.drawer-grid p {
  color: #87908a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  line-height: 1.5;
}

.drawer-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 30px 0;
}

.drawer-sources {
  margin: 30px 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.drawer-sources > span {
  color: var(--air);
  font-size: 8px;
  letter-spacing: 0.17em;
}

.drawer-sources div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 22px;
  margin-top: 15px;
}

.drawer-sources a {
  color: #8b948e;
  font-size: 8px;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-decoration: none;
}

.drawer-sources a:hover,
.drawer-sources a:focus-visible {
  color: var(--paper);
}

.drawer-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #8b948e;
  font-size: 8px;
  letter-spacing: 0.14em;
}

.drawer-foot {
  color: #59625c;
  font-size: 8px;
  letter-spacing: 0.12em;
}

@keyframes live {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 920px) {
  body {
    overflow-y: auto;
  }

  .app {
    min-height: 820px;
  }

  .topbar-center {
    display: none;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .intro {
    width: 44vw;
  }

  .route-card {
    right: 25px;
    top: auto;
    bottom: 54px;
  }

  .system-panel {
    top: 425px;
  }
}

@media (max-width: 640px) {
  .app {
    height: 100svh;
    min-height: 700px;
  }

  .topbar {
    height: 56px;
    padding: 0 16px;
  }

  .top-actions .plain-button:first-child {
    display: none;
  }

  .branding-link {
    display: none;
  }

  .intro {
    top: 76px;
    left: 16px;
    width: calc(100% - 32px);
  }

  .intro h1 {
    font-size: clamp(48px, 16vw, 72px);
    line-height: 0.86;
  }

  .dek {
    max-width: 270px;
    margin-top: 18px;
  }

  .map-stage {
    top: 56px;
    bottom: 142px;
  }

  .map-wash {
    background: linear-gradient(180deg, rgba(7, 11, 13, 0.72) 0, transparent 48%);
  }

  .system-panel {
    top: auto;
    left: 16px;
    right: 16px;
    bottom: 150px;
    width: auto;
  }

  .panel-label,
  .system-summary,
  .system-number,
  .system-count {
    display: none;
  }

  .system-list {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    margin-top: 0;
    padding-top: 10px;
    border-top: 0;
    scrollbar-width: none;
  }

  .system-button,
  .system-button[data-system="featured"],
  .system-button[data-system="all"] {
    flex: 0 0 auto;
    display: flex;
    gap: 7px;
    width: auto;
    height: 29px;
    padding: 0 10px;
    border: 1px solid var(--line);
    background: rgba(7, 11, 13, 0.76);
  }

  .system-button.active {
    border-color: rgba(233, 230, 220, 0.5);
  }

  .route-card {
    top: auto;
    right: 16px;
    bottom: 66px;
    width: 205px;
    padding: 12px;
  }

  .route-card-head,
  .route-note,
  .route-card-foot {
    display: none;
  }

  .route-type {
    margin-top: 0;
  }

  .route-card h2 {
    font-size: 18px;
  }

  .route-stat {
    margin-top: 10px;
    padding: 8px 0 0;
    border-bottom: 0;
  }

  .route-stat strong {
    font-size: 18px;
  }

  .map-tools {
    top: 18px;
    right: 16px;
  }

  .coordinates,
  .map-hint,
  .map-label {
    display: none;
  }

  .time-panel {
    bottom: 27px;
    height: 115px;
    grid-template-columns: 48px 1fr;
  }

  .time-main {
    padding: 0 14px;
    border-right: 0;
  }

  .flow-total {
    display: none;
  }

  .footer {
    height: 27px;
    padding: 0 16px;
  }

  .footer span:nth-child(2),
  .footer span:nth-child(3) {
    display: none;
  }

  .drawer {
    padding: 20px 20px 36px;
  }

  .drawer-grid {
    grid-template-columns: 1fr;
  }

  .drawer-sources div {
    grid-template-columns: 1fr;
  }
}

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