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

#map {
  height: 100%;
  width: 100%;
}

.status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  font: 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  max-width: 360px;
  display: none;
}

.value-overlay {
  position: absolute;
  top: 12px;
  /* place to the left of the controls container (container width ~160px + 8px gap + 12px right margin) */
  right: calc(12px + 160px + 12px);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 8px 10px;
  font: 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
}

.value-overlay .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

.controls-container {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 160px;
}

.data-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font: 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.contour-toggle {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
  font: 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.contour-toggle input {
  margin: 0;
}

#map-title {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 8px 12px;
  font: 14px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  text-align: center;
  white-space: nowrap;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  #map-title {
    top: 8px;
    left: 8px;
    right: 8px;
    transform: none;
    width: auto;
    font-size: 12px;
    padding: 6px 10px;
    white-space: normal;
  }

  .controls-container {
    top: 50px;
    left: 8px;
    right: 8px;
    width: auto;
    flex-direction: row;
  }

  .data-select {
    flex: 1;
    font-size: 14px;
    padding: 8px;
  }

  .contour-toggle {
    flex: 0 0 auto;
    font-size: 14px;
    padding: 8px;
  }

  .value-overlay {
    top: 95px;
    left: 8px;
    right: 8px;
    width: auto;
    justify-content: center;
    font-size: 13px;
  }

  .legend {
    padding: 8px;
    font-size: 11px;
    max-width: 160px;
  }

  .legend .title {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .legend .row {
    margin: 2px 0;
    gap: 6px;
  }

  .legend .swatch {
    width: 12px;
    height: 12px;
  }
}

#map-title a {
  color: #007bff;
  text-decoration: none;
  font-weight: normal;
}

#map-title a:hover {
  text-decoration: underline;
}
.legend {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 10px 12px;
  font: 12px/1.3 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}

.legend .title {
  font-weight: 600;
  margin-bottom: 8px;
}

.legend .row {
  display: flex;
  align-items: centre;
  gap: 8px;
  margin: 4px 0;
}

.legend .swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}

.legend .note {
  margin-top: 8px;
  opacity: 0.8;
}
.contour-label {
  background: none;
  border: none;
  box-shadow: none;
}

.contour-label-text {
  font: bold 10px/1 system-ui, -apple-system, sans-serif;
  color: #333;
  background: rgba(255, 255, 255, 0.7);
  padding: 1px 3px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 2px #fff;
}
/* Force browser to use nearest-neighbour scaling for raster overlay to show pixel grid
   instead of smooth interpolated colours when the overlay is scaled. */
.pixelated-overlay,
.pixelated-overlay img {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: -o-pixelated;
  -ms-interpolation-mode: nearest-neighbor; /* IE */
  image-rendering: -webkit-optimize-contrast;
}
