:root {
  color-scheme: dark;
  --bg: #05000c;
  --bg-2: #090919;
  --panel: rgba(9, 9, 25, 0.9);
  --panel-strong: rgba(12, 8, 32, 0.96);
  --ink: #e5f7ff;
  --muted: #a6bdd5;
  --cyan: #00ffff;
  --magenta: #ff007f;
  --violet: #8c6bff;
  --lime: #e4ff7b;
  --gold: #ffd700;
  --rail: rgba(0, 255, 255, 0.28);
  --line-dark: #00ffff;
  --accent: #00ffff;
  --shadow: 0 0 18px rgba(0, 255, 255, 0.22), 0 0 30px rgba(255, 0, 127, 0.16);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(0, 255, 255, 0.075) 1px, transparent 1px),
    linear-gradient(rgba(255, 0, 127, 0.06) 1px, transparent 1px),
    linear-gradient(135deg, #05000c 0%, #090919 58%, #120824 100%);
  background-size: 32px 32px, 32px 32px, auto;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: 30;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.045) 0,
    rgba(255, 255, 255, 0.045) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  opacity: 0.12;
}

body::after {
  z-index: 0;
  background: radial-gradient(ellipse at center, rgba(5, 0, 12, 0) 42%, rgba(5, 0, 12, 0.52) 76%, rgba(5, 0, 12, 0.88) 100%);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 100vh;
}

.map-stage {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 100vh;
}

.topbar,
.filterbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--rail);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.16), inset 0 -1px 0 rgba(255, 0, 127, 0.18);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  color: #c7b8ff;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(140, 107, 255, 1), 0 0 24px rgba(0, 255, 255, 0.44);
}

.topbar p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.18);
}

.credit-line {
  margin-top: 5px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  text-shadow: 0 0 9px rgba(0, 255, 255, 0.72);
}

.toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 7px;
  justify-content: flex-end;
}

.toolbar button,
.search input,
.select select {
  border: 1px solid rgba(0, 255, 255, 0.72);
  border-radius: 4px;
  color: var(--ink);
  background: rgba(5, 0, 12, 0.86);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.25), inset 0 0 12px rgba(0, 255, 255, 0.06);
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--cyan);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.9);
}

.toolbar button:hover,
.search input:hover,
.select select:hover,
.toolbar button:focus-visible,
.search input:focus,
.select select:focus {
  border-color: var(--magenta);
  outline: 0;
  box-shadow: 0 0 14px rgba(255, 0, 127, 0.42), 0 0 24px rgba(0, 255, 255, 0.18), inset 0 0 12px rgba(255, 0, 127, 0.08);
}

.toolbar button:active {
  transform: translate(1px, 1px);
  box-shadow: 0 0 8px rgba(255, 0, 127, 0.35), inset 0 0 18px rgba(0, 255, 255, 0.1);
}

.toolbar #resetView {
  min-width: 62px;
  color: var(--lime);
  text-shadow: 0 0 8px rgba(228, 255, 123, 0.75);
}

.toolbar #helpToggle {
  min-width: 58px;
  color: #f5fbff;
}

.toolbar #helpToggle.is-active {
  color: #05000c;
  background: var(--magenta);
  border-color: var(--magenta);
  box-shadow: 0 0 16px rgba(255, 0, 127, 0.66);
  text-shadow: none;
}

.filterbar {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom-color: rgba(255, 0, 127, 0.28);
}

.search,
.select {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.search span,
.select span {
  color: #c5e9ff;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.55);
}

.search {
  flex: 1 1 280px;
}

.select {
  flex: 0 0 150px;
}

.search input,
.select select {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  text-transform: none;
}

.search input::placeholder {
  color: rgba(197, 233, 255, 0.55);
}

.map-viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

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

#tubeMap {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 520px;
  background:
    linear-gradient(90deg, rgba(0, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(rgba(255, 0, 127, 0.045) 1px, transparent 1px),
    rgba(5, 0, 12, 0.22);
  background-size: 32px 32px;
}

.map-background {
  fill: transparent;
}

.route {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.2;
}

.route.is-muted {
  opacity: 0.018;
}

.route.is-hidden-by-legend,
.line-track.is-hidden-by-legend,
.station.is-hidden-by-legend {
  display: none;
}

.route.is-highlight {
  opacity: 1;
  stroke-width: 8;
}

.route.is-soft {
  opacity: 0.045;
  stroke-width: 2.2;
}

.route.is-soft.is-muted {
  opacity: 0.006;
}

.route.is-hover-route {
  opacity: 0.82;
  stroke-width: 5;
}

.line-track {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 7;
  opacity: 0.95;
}

.station {
  cursor: pointer;
}

.station-hit {
  fill: transparent;
  stroke: transparent;
  stroke-width: 22;
}

.station-dot {
  fill: #05000c;
  stroke: var(--cyan);
  stroke-width: 2.6;
}

.station.is-hub .station-dot {
  fill: var(--cyan);
  stroke: #f5f5ff;
  stroke-width: 3;
}

.station.is-selected .station-dot,
.station.is-hover-related .station-dot,
.station:hover .station-dot {
  fill: var(--magenta);
  stroke: var(--lime);
  stroke-width: 4.8;
}

.station.is-muted {
  opacity: 0.14;
}

.station-label {
  fill: var(--ink);
  paint-order: stroke;
  stroke: rgba(5, 0, 12, 0.94);
  stroke-width: 5;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.75);
}

.station[class*="designation-sub-level"] .station-dot {
  stroke-dasharray: 2 2;
}

.station.designation-anomalous-level .station-dot,
.station.designation-secret-level .station-dot,
.station.designation-glitched-level .station-dot {
  fill: rgba(228, 255, 123, 0.22);
  stroke: var(--lime);
}

.station.is-muted .station-label {
  opacity: 0;
}

.cluster-label {
  fill: rgba(197, 233, 255, 0.82);
  paint-order: stroke;
  stroke: rgba(5, 0, 12, 0.9);
  stroke-width: 4;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
  pointer-events: none;
  text-transform: uppercase;
}

.designation-legend {
  position: fixed;
  left: 16px;
  bottom: 76px;
  z-index: 34;
  width: min(360px, calc(100% - 32px));
  max-height: min(180px, calc(100% - 32px));
  overflow: auto;
  padding: 10px;
  color: var(--ink);
  background: rgba(5, 0, 12, 0.86);
  border: 1px solid rgba(0, 255, 255, 0.38);
  border-radius: 6px;
  box-shadow: 0 0 16px rgba(0, 255, 255, 0.14), 0 0 18px rgba(255, 0, 127, 0.12);
  cursor: auto;
  touch-action: auto;
}

.designation-legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.designation-legend-title {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.72);
}

.designation-legend-count {
  margin-left: 8px;
  color: var(--muted);
  letter-spacing: 0;
}

.designation-legend.is-filtering .designation-legend-count {
  color: var(--lime);
  text-shadow: 0 0 8px rgba(228, 255, 123, 0.5);
}

.designation-legend-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.designation-legend button {
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--lime);
  border-radius: 4px;
  color: #05000c;
  background: var(--lime);
  box-shadow: 0 0 10px rgba(228, 255, 123, 0.28);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.designation-legend-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px 10px;
}

.designation-choice {
  display: grid;
  grid-template-columns: 14px 34px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 6px;
  padding: 2px 3px;
  border-radius: 3px;
  color: rgba(229, 247, 255, 0.88);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.designation-choice:hover,
.designation-choice:focus-within {
  background: rgba(0, 255, 255, 0.08);
}

.designation-choice input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--lime);
}

.designation-swatch {
  display: block;
  height: 0;
  border-top: 4px solid var(--line-color);
  border-radius: 999px;
  box-shadow: 0 0 8px color-mix(in srgb, var(--line-color) 58%, transparent);
}

.designation-name {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details-panel {
  position: relative;
  z-index: 2;
  min-width: 0;
  max-height: 100vh;
  overflow: auto;
  background: var(--panel-strong);
  border-left: 1px solid rgba(255, 0, 127, 0.7);
  box-shadow: -10px 0 28px rgba(255, 0, 127, 0.12), -2px 0 12px rgba(0, 255, 255, 0.12);
}

.details-empty,
.details-content {
  padding: 22px;
}

.details-empty h2,
.details-content h2 {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.9);
}

.details-empty p,
.details-content p {
  color: var(--muted);
  line-height: 1.5;
  text-shadow: 0 0 7px rgba(0, 255, 255, 0.12);
}

.badge-row,
.link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(0, 255, 255, 0.72);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--ink);
  background: rgba(5, 0, 12, 0.7);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 900;
}

.badge-strong {
  color: #05000c;
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(0, 255, 255, 0.62);
}

.node-tooltip,
.ui-help-tooltip {
  color: #f5fbff;
  background: rgba(5, 0, 12, 0.98);
  border: 1px solid rgba(255, 0, 127, 0.65);
  border-radius: 6px;
  box-shadow: 0 0 16px rgba(0, 255, 255, 0.28), 0 0 24px rgba(255, 0, 127, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.45);
}

.node-tooltip {
  position: absolute;
  z-index: 40;
  max-width: min(300px, calc(100% - 24px));
  padding: 10px 12px;
  transition: opacity 160ms ease, transform 160ms ease;
}

.ui-help-tooltip {
  position: fixed;
  z-index: 40;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 10px;
  transition: opacity 140ms ease, transform 140ms ease;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.node-tooltip.is-visible,
.ui-help-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.node-tooltip strong,
.node-tooltip span {
  display: block;
}

.node-tooltip strong {
  color: var(--lime);
  font-size: 13px;
  line-height: 1.2;
  text-shadow: 0 0 8px rgba(228, 255, 123, 0.62);
}

.node-tooltip span {
  margin-top: 4px;
  color: rgba(197, 233, 255, 0.78);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid rgba(0, 255, 255, 0.7);
  border-radius: 4px;
  margin: 0 0 16px;
  background: var(--bg);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.stat {
  border: 1px solid rgba(255, 0, 127, 0.62);
  border-radius: 4px;
  padding: 10px;
  background: rgba(5, 0, 12, 0.68);
  box-shadow: 0 0 12px rgba(255, 0, 127, 0.16);
}

.stat strong {
  display: block;
  color: var(--lime);
  font-size: 24px;
  text-shadow: 0 0 8px rgba(228, 255, 123, 0.7);
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.section-title {
  margin: 20px 0 8px;
  color: var(--magenta);
  font-size: 14px;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(255, 0, 127, 0.74);
  text-transform: uppercase;
}

.node-link {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  text-decoration-color: rgba(0, 255, 255, 0.65);
  text-decoration-thickness: 2px;
  text-shadow: 0 0 7px rgba(0, 255, 255, 0.42);
}

.wiki-link {
  display: inline-flex;
  margin-top: 18px;
  color: #05000c;
  background: var(--lime);
  border: 1px solid var(--lime);
  border-radius: 4px;
  padding: 10px 12px;
  box-shadow: 0 0 14px rgba(228, 255, 123, 0.42);
  font-weight: 900;
  text-decoration: none;
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  color: var(--ink);
  background: rgba(5, 0, 12, 0.68);
  backdrop-filter: blur(3px);
}

.help-overlay.is-visible {
  display: flex;
}

.help-panel {
  position: relative;
  width: min(620px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 22px 24px 24px;
  background: rgba(9, 9, 25, 0.94);
  border: 1px solid rgba(255, 0, 127, 0.68);
  border-radius: 10px;
  box-shadow: 0 0 22px rgba(0, 255, 255, 0.28), 0 0 34px rgba(255, 0, 127, 0.18);
  text-align: left;
}

.help-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 255, 255, 0.72);
  border-radius: 4px;
  color: var(--cyan);
  background: rgba(5, 0, 12, 0.82);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.22);
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.help-panel h2 {
  margin: 0 42px 6px 0;
  color: var(--violet);
  font-size: 28px;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 10px rgba(140, 107, 255, 0.95), 0 0 20px rgba(0, 255, 255, 0.32);
}

.help-credit {
  margin: 0 0 14px;
  color: var(--cyan);
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.help-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.help-legend {
  display: grid;
  gap: 9px;
  margin: 16px 0;
}

.help-legend div {
  padding: 9px 10px;
  border: 1px solid rgba(0, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(5, 0, 12, 0.58);
}

.help-legend strong {
  color: var(--lime);
  text-shadow: 0 0 8px rgba(228, 255, 123, 0.55);
}

.help-cta {
  color: var(--magenta);
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(255, 0, 127, 0.7);
}

.donate-container {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  padding: 8px 10px;
  color: var(--ink);
  background: rgba(9, 9, 25, 0.84);
  border: 1px solid rgba(255, 0, 127, 0.58);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 255, 255, 0.18), 0 0 22px rgba(255, 0, 127, 0.14);
}

.donate-copy {
  appearance: none;
  padding: 0;
  border: 0;
  color: var(--cyan);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.6);
  white-space: nowrap;
}

.donate-copy:hover,
.donate-copy:focus-visible {
  color: var(--lime);
  outline: 0;
  text-shadow: 0 0 10px rgba(228, 255, 123, 0.7);
}

.paypal-button-host {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.donate-fallback {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid var(--lime);
  border-radius: 4px;
  color: #05000c;
  background: var(--lime);
  box-shadow: 0 0 12px rgba(228, 255, 123, 0.36);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.donate-fallback[hidden] {
  display: none;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(70vh, 1fr) auto;
  }

  .details-panel {
    max-height: none;
    border-left: 0;
    border-top: 1px solid rgba(255, 0, 127, 0.7);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .filterbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .search {
    grid-column: 1 / -1;
  }

  .search,
  .select {
    min-width: 0;
    width: auto;
    flex: none;
  }

  .search input,
  .select select {
    min-height: 34px;
  }

  #tubeMap {
    min-height: 460px;
  }

  .designation-legend {
    left: 10px;
    bottom: 10px;
    width: min(360px, calc(100% - 20px));
    max-height: 155px;
  }

  .designation-legend-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .donate-container {
    position: static;
    justify-content: center;
    transform: none;
    max-width: none;
    border-width: 1px 0 0;
    border-radius: 0;
  }
}

@media (max-width: 430px) {
  .donate-container {
    flex-wrap: wrap;
  }

  .donate-copy {
    width: 100%;
    text-align: center;
    white-space: normal;
  }

  .designation-legend-list {
    grid-template-columns: 1fr;
  }
}
