* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: black;
}

.globe {
  width: 100vw;
  height: 100vh;
}

.globe canvas {
  display: block;
}

.logo {
  position: absolute;
  z-index: 2;
  top: 16px;
  left: 16px;
  width: 300px;
  padding: 0 16px;
  line-height: 0;
  user-select: none;
}

.logo img {
  width: 100%;
  height: auto;
}

.panel {
  position: absolute;
  z-index: 2;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  top: 80px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 300px;
  padding: 12px 16px;
  color: white;
  font-family: system-ui, sans-serif;
  background: rgba(20, 20, 20, 0.8);
  border-radius: 8px;
}

.panel--terrain {
  top: auto;
  bottom: 16px;
  width: 720px;
}

.panel__row {
  display: flex;
  align-items: flex-end;
  gap: 24px;
}

.panel__row .panel__layer {
  flex: 1;
}

.panel__layer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel__layer:not(:has(input:checked)) .legend {
  display: none;
}

.panel__options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel__option {
  position: relative;
  display: flex;
}

.panel__option input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.panel__option label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px 0 16px;
  overflow: hidden;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.panel__option label:hover {
  background: rgba(255, 255, 255, 0.07);
}

.panel__option input:checked + label {
  background: color-mix(in srgb, var(--layer-colour) 24%, transparent);
}

.panel__option input:checked + label:hover {
  background:
    linear-gradient(rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.07)),
    color-mix(in srgb, var(--layer-colour) 24%, transparent);
}

.panel__option input:checked + label::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--layer-colour);
}

.panel__option input:focus-visible + label {
  outline: 2px solid white;
  outline-offset: -2px;
}

.panel__swatch {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--layer-colour);
  opacity: 0.35;
}

.panel__option input:checked + label .panel__swatch {
  opacity: 1;
}

.panel__error {
  max-width: 280px;
  margin: 0;
  color: #ff8a80;
}

.panel__search {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  max-width: 300px;
}

.panel__button {
  padding: 6px 10px;
  color: white;
  font: inherit;
  background: #2f6f3e;
  border: 1px solid #41ab5d;
  border-radius: 4px;
  cursor: pointer;
}

.panel__status:empty {
  display: none;
}

.panel__status {
  margin: 0;
  font-size: 13px;
}

.results {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 260px;
  max-height: calc(100vh - 32px);
  padding: 12px;
  overflow-y: auto;
  color: white;
  font-family: system-ui, sans-serif;
  background: rgba(20, 20, 20, 0.8);
  border-radius: 8px;
}

.results[hidden] {
  display: none;
}

.results__cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  color: white;
  font: inherit;
  font-size: 13px;
  text-align: left;
  background: color-mix(in srgb, var(--rank-colour) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--rank-colour) 45%, #555);
  border-radius: 6px;
  cursor: pointer;
}

.result-card__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  color: black;
  font-size: 15px;
  font-weight: bold;
  background: white;
  border-radius: 50%;
}

.result-card:hover {
  border-color: #41ab5d;
}

.result-card__rank {
  font-size: 18px;
  font-weight: bold;
}

.result-card__place {
  font-weight: bold;
}

.result-card__score {
  color: #aaa;
}

.panel__divider {
  height: 4px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 0 4px 40px;
  user-select: none;
}

.legend:empty {
  display: none;
}

.legend__swatch {
  width: 14px;
  height: 10px;
  border: 1px solid #666;
}

.legend__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.legend__label {
  margin-left: 6px;
  color: #bbb;
  font-size: 11px;
}

.route-labels {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.route-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 2px 6px;
  color: white;
  font-family: system-ui, sans-serif;
  font-size: 12px;
  white-space: nowrap;
  background: rgba(20, 20, 20, 0.8);
  border-left: 3px solid white;
  border-radius: 3px;
}

.panel__clear {
  width: 100%;
  margin-top: 32px;
  padding: 6px 10px;
  color: #ddd;
  font: inherit;
  background: none;
  border: 1px solid #555;
  border-radius: 4px;
  cursor: pointer;
}
