:root {
  --bg: #f4f1eb;
  --panel: #fffdf8;
  --ink: #202326;
  --muted: #697074;
  --line: #d8d2c7;
  --shadow: 0 18px 44px rgba(31, 35, 38, 0.16);
  --accent: #256d72;
  --accent-2: #b64c3f;
  --green: #477f5b;
  --blue: #316a9c;
  --gold: #b88624;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter,
    "Segoe UI",
    Arial,
    sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100%;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(46, 48, 50, 0.12);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 1px 0 0;
  font-size: 22px;
  font-weight: 720;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}

.topbarMetric {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.hidden {
  display: none !important;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fffaf1;
  cursor: pointer;
}

.icon-button:hover {
  border-color: #b9b0a2;
  background: #fff4df;
}

.cityMenu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 360px));
  justify-content: center;
  gap: 22px;
  min-height: 100vh;
  padding: 112px 24px 36px;
  align-content: start;
}

.cityCard {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(170px, 1fr) auto;
  gap: 16px;
  min-height: 420px;
  padding: 18px;
  border: 1px solid rgba(210, 198, 179, 0.9);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 253, 248, 0.96), rgba(246, 239, 226, 0.98) 44%, rgba(235, 241, 237, 0.96)),
    #fffdf8;
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(38, 42, 43, 0.14);
  cursor: pointer;
  isolation: isolate;
}

.cityCard::before {
  position: absolute;
  z-index: -1;
  inset: -45%;
  content: "";
  background:
    conic-gradient(
      from 0deg,
      rgba(255, 255, 255, 0.2),
      rgba(75, 145, 150, 0.26),
      rgba(213, 160, 64, 0.22),
      rgba(182, 76, 63, 0.18),
      rgba(255, 255, 255, 0.2)
    );
  animation: shimmerSpin 9s linear infinite;
  opacity: 0.8;
}

.cityCard::after {
  position: absolute;
  inset: 1px;
  z-index: -1;
  border-radius: 7px;
  content: "";
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.62), transparent 26%),
    linear-gradient(145deg, rgba(255, 253, 248, 0.98), rgba(246, 239, 226, 0.98) 46%, rgba(235, 241, 237, 0.98));
}

@keyframes shimmerSpin {
  to {
    transform: rotate(1turn);
  }
}

.cityCard:hover {
  transform: translateY(-1px);
  box-shadow: 0 30px 70px rgba(22, 29, 30, 0.3);
}

.cityCardTop {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.cityName {
  margin: 0;
  font-size: 31px;
  font-weight: 760;
  line-height: 1.08;
}

.cityRating {
  text-align: right;
  white-space: nowrap;
}

.cityRating strong {
  display: block;
  font-size: 38px;
  font-weight: 760;
  line-height: 1;
}

.cityRating span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.crestSlot {
  display: grid;
  place-items: center;
  align-self: center;
  justify-self: center;
  width: min(68%, 190px);
  aspect-ratio: 4 / 5;
  border: 1px solid rgba(191, 178, 157, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(37, 109, 114, 0.08), transparent 35%),
    rgba(255, 250, 241, 0.86);
}

.crestSlot img {
  display: block;
  max-width: 78%;
  max-height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(42, 46, 48, 0.14));
}

.cityFacts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.cityFacts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(86, 80, 71, 0.12);
}

.cityFacts dt {
  color: var(--muted);
  font-size: 13px;
}

.cityFacts dd {
  margin: 0;
  font-size: 14px;
  font-weight: 720;
}

.mapShell {
  position: fixed;
  inset: 72px 0 0;
  overflow: hidden;
  background: #e7e0d3;
}

#mapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#mapCanvas.dragging {
  cursor: grabbing;
}

.mapControls {
  position: absolute;
  z-index: 5;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(320px, calc(100vw - 32px));
}

.controlGroup {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(65, 66, 66, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 12px 30px rgba(31, 35, 38, 0.1);
}

.controlGroup.compact {
  width: max-content;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #ded6c9;
  border-radius: 8px;
  background: #fffaf1;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.infoPanel {
  position: absolute;
  z-index: 6;
  top: 16px;
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 112px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(65, 66, 66, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.panelTitle {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}

.panelTitle h2 {
  margin: 0;
  font-size: 20px;
}

.metricGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.metric {
  padding: 10px;
  border: 1px solid #e2dbcf;
  border-radius: 8px;
  background: #fffaf1;
}

.metric strong {
  display: block;
  font-size: 22px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.barList {
  display: grid;
  gap: 8px;
}

.barRow {
  display: grid;
  grid-template-columns: 116px 1fr 44px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.helpText,
.indicatorGroup h3,
.indicator {
  cursor: help;
}

.barTrack {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2dbcf;
}

.barFill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.indicatorList {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.indicatorGroup h3 {
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 760;
}

.indicator {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 58px;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ece4d8;
  color: var(--muted);
  font-size: 13px;
}

.indicator em {
  color: #8a8175;
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.indicator strong {
  color: var(--ink);
  text-align: right;
}

.legend {
  position: absolute;
  z-index: 5;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 7px;
  width: min(280px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid rgba(65, 66, 66, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--muted);
  font-size: 12px;
}

.symbolLegend {
  position: absolute;
  z-index: 5;
  left: 16px;
  bottom: 16px;
  width: min(280px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid rgba(65, 66, 66, 0.16);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--muted);
  font-size: 12px;
}

.legendTitle {
  color: var(--ink);
  font-weight: 720;
}

.legendGradient {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #a83d4b, #d97842, #dfbd54, #76ad70, #2d7b78);
}

.legendScale {
  display: flex;
  justify-content: space-between;
}

.legendSymbols {
  display: grid;
  gap: 6px;
}

.legendSymbols span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border: 1px solid #fff;
  border-radius: 50%;
}

.dot.bus {
  background: #316a9c;
}

.dot.tram {
  border-radius: 2px;
  background: #b64c3f;
}

.dot.crash {
  background: #b64c3f;
}

.dot.crash.small {
  width: 7px;
  height: 7px;
  margin-right: -4px;
}

.dot.crash.big {
  width: 14px;
  height: 14px;
}

.accidentPopup {
  position: absolute;
  z-index: 8;
  display: grid;
  gap: 3px;
  min-width: 190px;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid rgba(80, 52, 47, 0.2);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 14px 34px rgba(31, 35, 38, 0.2);
  color: var(--ink);
  font-size: 12px;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
}

.accidentPopup::after {
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  content: "";
  border-right: 1px solid rgba(80, 52, 47, 0.2);
  border-bottom: 1px solid rgba(80, 52, 47, 0.2);
  background: rgba(255, 253, 248, 0.98);
  transform: translateX(-50%) rotate(45deg);
}

.accidentPopup strong {
  font-size: 13px;
}

.accidentPopup small {
  color: var(--muted);
}

@media (max-width: 860px) {
  .topbar {
    min-height: 66px;
    padding: 10px 12px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbarMetric {
    display: none;
  }

  .cityMenu {
    padding: 90px 14px 20px;
    grid-template-columns: minmax(0, 1fr);
  }

  .cityCard {
    min-height: 480px;
  }

  .cityName {
    font-size: 23px;
  }

  .cityRating strong {
    font-size: 30px;
  }

  .mapShell {
    top: 66px;
  }

  .infoPanel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 42vh;
  }

  .legend,
  .symbolLegend {
    display: none;
  }
}
