:root {
  color: #e0e0e0;
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  background: #111111;
  color-scheme: dark;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #111111;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1,
h2,
p,
ul {
  margin: 0;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  height: 100vh;
  grid-template-columns: minmax(17rem, 19rem) minmax(26rem, 1.35fr) minmax(16rem, 22rem);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.app-header,
.app-panel {
  min-width: 0;
}

.app-header {
  grid-column: 1 / -1;
  display: grid;
  position: relative;
  gap: 0.5rem;
  padding: clamp(1.5rem, 2vw, 2rem);
  border-bottom: 1px solid #2a2a2a;
}

.header-meta {
  position: absolute;
  top: clamp(1rem, 1.5vw, 1.5rem);
  right: clamp(1rem, 1.5vw, 1.5rem);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.github-link {
  color: #888;
  transition: color 0.15s;
}

.github-link:hover {
  color: #e0e0e0;
}

.github-link svg {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

.data-credits {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.data-credits li {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-credits a {
  color: #444;
  text-decoration: none;
  transition: color 0.15s;
}

.data-credits a:hover {
  color: #888;
}

.app-header h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.subtitle {
  max-width: 34rem;
  color: #666666;
  line-height: 1.5;
}

.app-panel {
  display: grid;
  align-content: start;
  gap: 1rem;
  min-height: 0;
  padding: clamp(1.15rem, 1.4vw, 1.5rem);
  overflow: hidden;
}

.controls-panel,
.map-panel {
  border-right: 1px solid #2a2a2a;
}

.controls-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.app-panel h2 {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #666666;
}

#preferences {
  display: grid;
  gap: 1.25rem;
  min-height: 0;
  align-content: start;
  overflow: auto;
}

.control {
  display: grid;
  gap: 0.45rem;
  padding-bottom: 0.15rem;
}

.control__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.control__label,
.control__value {
  font-size: 0.95rem;
}

.control__label {
  color: #e0e0e0;
}

.control__value {
  min-width: 11ch;
  text-align: right;
  color: #e0e0e0;
}

.control__description,
.control__scale {
  font-size: 0.72rem;
  line-height: 1.45;
  color: #666666;
}

.control__scale {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control input {
  --range-progress: 50%;
  height: 1rem;
  width: 100%;
  margin: 0;
  appearance: none;
  background: transparent;
}

.control input::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(to right, #4a9eff 0 var(--range-progress), #333333 var(--range-progress) 100%);
}

.control input::-webkit-slider-thumb {
  width: 0.45rem;
  height: 1rem;
  margin-top: -0.475rem;
  appearance: none;
  border: 0;
  border-radius: 0;
  background: #4a9eff;
}

.control input::-moz-range-track {
  height: 1px;
  border: 0;
  background: #333333;
}

.control input::-moz-range-progress {
  height: 1px;
  background: #4a9eff;
}

.control input::-moz-range-thumb {
  width: 0.45rem;
  height: 1rem;
  border: 0;
  border-radius: 0;
  background: #4a9eff;
}

.control input:focus-visible {
  outline: none;
}

.control input:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 1px #111111, 0 0 0 2px #4a9eff;
}

.control input:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 1px #111111, 0 0 0 2px #4a9eff;
}

.map-panel {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  min-height: 0;
  gap: 0.85rem;
}

.map-description {
  max-width: 40rem;
  color: #666666;
  line-height: 1.5;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  color: #666666;
}

.map-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.map-legend__item--low span {
  color: #355c7d;
}

.map-legend__item--mid span {
  color: #f8b65a;
}

.map-legend__item--high span {
  color: #ea5f89;
}

.results-panel {
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.results-panel h2 {
  width: min(100%, 18.5rem);
}

#score-results-list {
  display: grid;
  gap: 0.2rem;
  padding: 0;
  list-style: none;
  overflow: auto;
  justify-items: start;
  align-content: start;
}

.score-results__item,
.score-results__empty {
  display: grid;
  width: min(100%, 18.5rem);
  grid-template-columns: 5ch minmax(0, 1fr) 2ch;
  gap: 0.75rem;
  align-items: baseline;
  padding-block: 0.18rem;
}

.score-results__item {
  cursor: pointer;
}

.score-results__item:hover,
.score-results__item:focus-visible {
  color: #f2f2f2;
  background: #151515;
  outline: none;
}

.score-results__item:focus-visible {
  box-shadow: inset 0 0 0 1px #2f2f2f;
}

.score-results__score {
  color: #4a9eff;
  text-align: right;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.score-results__name {
  min-width: 0;
  color: #e0e0e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-results__flag {
  color: #e0e0e0;
  justify-self: end;
}

.score-results__empty {
  grid-template-columns: 1fr;
  color: #666666;
}

.score-results__more {
  width: min(100%, 18.5rem);
  padding-block: 0.1rem 0.45rem;
}

.score-results__more-button {
  border: 1px solid #2a2a2a;
  background: #141414;
  color: #b8b8b8;
  padding: 0.3rem 0.55rem;
  font: inherit;
  text-transform: lowercase;
  cursor: pointer;
}

.score-results__more-button:hover,
.score-results__more-button:focus-visible {
  background: #1b1b1b;
  color: #e0e0e0;
  outline: none;
  border-color: #3a3a3a;
}

#map {
  width: 100%;
  min-height: 0;
  height: 100%;
  aspect-ratio: 1.5;
  max-height: 100%;
  justify-self: stretch;
  overflow: hidden;
  background: #111111;
  border: 1px solid #2a2a2a;
}

#map .maplibregl-map {
  width: 100%;
  height: 100%;
}

#map .maplibregl-ctrl-group {
  border-radius: 0;
  border: 1px solid #2a2a2a;
  background: #1a1a1a;
  box-shadow: none;
}

#map .maplibregl-ctrl-group button {
  background: #1a1a1a;
}

#map .maplibregl-ctrl-group button span {
  filter: invert(1) contrast(0.75);
}

.map-probe-tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  padding: 0.5rem 0.75rem;
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.65;
  white-space: nowrap;
  color: #e0e0e0;
  max-width: min(24rem, calc(100vw - 2rem));
  box-shadow: 0 0 0 1px #111111;
}

.probe-tooltip__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 0.75rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  font-weight: 600;
  color: #c0c0c0;
}

.probe-tooltip__header-score {
  justify-self: start;
}

.probe-tooltip__header-city {
  display: inline-flex;
  justify-self: end;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.probe-tooltip__header-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.probe-tooltip__header-flag {
  flex: 0 0 auto;
}

.probe-tooltip__row {
  display: grid;
  grid-template-columns: 4ch 1fr 4ch;
  column-gap: 0.75rem;
}

.probe-tooltip__label {
  color: #8a8a8a;
  letter-spacing: 0.02em;
}

.probe-tooltip__value {
  color: #d6d6d6;
  justify-self: end;
}

.probe-tooltip__metric {
  color: #e0e0e0;
  justify-self: end;
  text-align: right;
}

.score-results__continent {
  width: min(100%, 18.5rem);
  padding-block: 0.55rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #555555;
  border-top: 1px solid #222222;
}

.score-results__continent:first-child {
  border-top: none;
  padding-top: 0;
}


@media (max-width: 72rem) {
  .app-shell {
    grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .controls-panel {
    border-bottom: 1px solid #2a2a2a;
  }

  .map-panel {
    grid-column: 2;
    grid-row: 2 / 4;
    border-right: 0;
  }

  .results-panel {
    grid-column: 1;
    grid-row: 3;
    border-right: 1px solid #2a2a2a;
    border-top: 0;
  }
}

@media (max-width: 48rem) {
  .app-shell {
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    overflow: visible;
  }

  .app-header,
  .controls-panel,
  .map-panel,
  .results-panel {
    border-right: 0;
    border-bottom: 1px solid #2a2a2a;
  }

  .results-panel {
    border-top: 0;
  }

  .app-header,
  .app-panel {
    padding: 1.25rem;
  }

  .app-panel,
  #preferences {
    overflow: visible;
  }

  .map-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .results-panel {
    grid-column: auto;
    grid-row: auto;
  }

  #map {
    min-height: 20rem;
    aspect-ratio: 1.1;
  }

  .score-results__item {
    grid-template-columns: 5ch minmax(0, 1fr);
  }

  .score-results__flag {
    grid-column: 2;
  }
}
