html,
body {
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  color: #000000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#map {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
}

.leaflet-bottom {
  display: none !important;
}

.leaflet-top.leaflet-right {
  top: 12px;
  right: 12px;
}

.leaflet-control-zoom a {
  color: #000;
}

/* Data-loading overlay. Stays invisible (and non-blocking) unless loading
   genuinely takes a moment — see the show-delay in map.js — so a fast load
   never flashes it. */
#loadingOverlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#loadingOverlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.loading-box {
  width: 220px;
  text-align: center;
}

.loading-label {
  font-size: 13px;
  color: #333;
  margin-bottom: 10px;
}

.loading-track {
  width: 100%;
  height: 6px;
  background: #ddd;
  border-radius: 999px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: #a0a;
  transition: width 0.15s ease;
}

.loading-pct {
  margin-top: 8px;
  font-size: 12px;
  color: #666;
  font-variant-numeric: tabular-nums;
}

#title-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 10px 16px;
  box-sizing: border-box;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0));
  pointer-events: none;
}

#title-bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Leader-line label overlay (country names, towns, water names). These live
   inside a Leaflet pane (see map.js) so panning/zooming repositions them the
   same way Leaflet repositions its own markers — no manual per-frame
   tracking needed. Children are positioned with absolute left/top in that
   pane's own coordinate space, so the pane itself stays zero-size with
   overflow visible rather than clipping at the viewport edge. */

#leaderSvg {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}

#leaderLabels {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
}

/* Hidden for the (brief) duration of a zoom transition — see map.js. No
   transition on this: an instant cut away and an instant reveal once the
   fresh layout is ready, rather than trying to track the animation. */
.leader-hidden {
  opacity: 0;
}

.leader-label {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
  font-weight: 500;
  line-height: 1;
  text-shadow:
    -1px -1px 2px rgba(255, 255, 255, 0.9),
    1px -1px 2px rgba(255, 255, 255, 0.9),
    -1px 1px 2px rgba(255, 255, 255, 0.9),
    1px 1px 2px rgba(255, 255, 255, 0.9),
    0 0 4px rgba(255, 255, 255, 0.7);
}

.leader-label-flag {
  line-height: 1;
}

.leader-label-name {
  line-height: 1;
  margin-top: 1px;
}

/* Settings toggle button */

#configToggle {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 15;
  background: rgba(20, 20, 20, 0.85);
  color: #eee;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

#configToggle:hover {
  background: rgba(40, 40, 40, 0.9);
}

/* Slide-open config panel */

#configPanel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 92vw;
  height: 100vh;
  box-sizing: border-box;
  background: rgba(18, 18, 18, 0.96);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

#configPanel.open {
  transform: translateX(0);
}

.config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

.config-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

#configClose {
  background: transparent;
  color: #eee;
  border: none;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 6px;
}

#configClose:hover {
  color: #fff;
}

.config-body {
  overflow-y: auto;
  padding: 4px 16px 20px;
  flex: 1;
}

.config-section {
  padding: 14px 0;
  border-bottom: 1px solid #2a2a2a;
}

.config-section:last-child {
  border-bottom: none;
}

.config-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #aaa;
}

.config-section .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}

/* Explicit ON/OFF toggle switch. Plain <button>, never a native checkbox —
   browsers only ever restore form-control VALUES on reload (checkboxes
   included, Firefox notably ignores autocomplete=off for them), and a
   button has no such restorable value, so there is nothing for the browser
   to desync from the actual setting after a reload. */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2a2a2a;
  border: 1px solid #555;
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #999;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.toggle:hover {
  border-color: #888;
}

.toggle:focus-visible {
  outline: 2px solid #e0e;
  outline-offset: 2px;
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #777;
  flex-shrink: 0;
  transition: background .15s ease;
}

.toggle[aria-checked="true"] {
  background: rgba(170, 0, 170, 0.28);
  border-color: #a0a;
  color: #fff;
}

.toggle[aria-checked="true"] .toggle-thumb {
  background: #e0e;
}

.config-section .sub-row {
  margin: 8px 0;
}

.config-section .sub-row label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #ccc;
  margin-bottom: 4px;
}

.config-section .sub-row .val {
  color: #fff;
  font-weight: 600;
}

.config-section input[type="range"] {
  width: 100%;
  accent-color: #a0a;
}

.config-section select {
  width: 100%;
  background: #2a2a2a;
  color: #eee;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
}

.config-section.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.config-section.actions button {
  flex: 1 1 auto;
  background: #3a3a3a;
  color: #eee;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.config-section.actions button:hover {
  background: #4a4a4a;
}

#resetBtn {
  flex-basis: 100% !important;
}

@media print {

  html,
  body {
    background: #fff !important;
    overflow: visible;
  }

  #map {
    position: static;
    width: 100%;
    height: 100vh;
  }

  .no-print,
  #title-bar,
  #configPanel,
  .leaflet-control-container {
    display: none !important;
  }
}
