:root {
  --bg: #0f1220;
  --panel: #151a2f;
  --muted: #8aa0b4;
  --text: #e6eef6;
  --accent: #3fa4ff;
  --danger: #ff5470;
  --topbar-h: 56px; /* dynamic on mobile via JS */
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

#map {
  position: absolute;
  top: var(--topbar-h, 56px);
  bottom: 0;
  left: 0;
  right: 0;
}

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(10,12,22,0.95), rgba(10,12,22,0.8));
  border-bottom: 1px solid #1f2744;
  z-index: 1000;
}

#topbar .controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hamburger button hidden on desktop */
#topbar #menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border: 1px solid #2c3559;
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  font-size: 18px;
}

#topbar label {
  color: var(--muted);
}

#topbar select,
#topbar input,
#topbar button {
  height: 32px;
  border: 1px solid #2c3559;
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 0 10px;
}

#topbar input {
  min-width: 320px;
}

#topbar input.invalid {
  outline: 2px solid var(--danger);
  animation: pulse 0.6s ease;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,84,112,0.7); }
  100% { box-shadow: 0 0 0 10px rgba(255,84,112,0); }
}

#topbar button#reset-btn {
  cursor: pointer;
  border-color: #3a446b;
}

#topbar .stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

#help {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: min(480px, 52vw);
  background: rgba(10,12,22,0.7);
  border: 1px solid #1f2744;
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 800;
  pointer-events: none;
}

#help h1 {
  font-size: 16px;
  margin: 0 0 6px;
}

#help p, #help ul {
  margin: 4px 0;
  color: var(--muted);
}

#help .small {
  font-size: 12px;
}

.leaflet-container {
  background: #0a0d18;
}

.leaflet-control-attribution {
  background: rgba(10,12,22,0.6) !important;
  color: #b9c6d4 !important;
}

/* Subtle always-on labels for revealed cities */
.leaflet-tooltip.city-label {
  background: transparent;
  border: none;
  box-shadow: none;
  color: #1b2a41; /* darker, higher-contrast */
  font-size: 12px;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(255,255,255,0.55);
  pointer-events: none;
}

/* Responsive tweaks */
@media (max-width: 900px) {
  #topbar {
    height: auto; /* allow wrap */
    padding: 8px 10px;
    align-items: stretch;
  }
  #topbar .controls {
    flex-wrap: wrap;
    row-gap: 8px;
    column-gap: 8px;
    width: 100%;
  }
  /* Keep only hamburger and text box visible */
  #topbar #difficulty,
  #topbar #reset-btn { display: none; }
  /* Reduce clutter: hide Cities Revealed on mobile */
  #topbar #stat-dots { display: none; }
  /* Slightly larger stats for visibility */
  #topbar .stats { font-size: 14px; gap: 10px; margin-top: 4px; }
  /* show hamburger on mobile */
  #topbar #menu-btn {
    display: inline-flex;
  }
  /* Hide settings group by default on mobile */
  #topbar .settings {
    display: none;
    width: 100%;
  }
  /* When menu is open, show settings as a block row */
  .menu-open #topbar .settings {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
  }
  #topbar .stats {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
    margin-top: 6px;
  }
  #topbar input {
    min-width: 0;
    flex: 1 1 220px; /* grows to fill row */
  }
  #topbar select {
    flex: 1 1 140px;
  }
  #topbar button {
    flex: 0 0 auto;
  }
  /* Hide labels to save space; titles still provide context */
  #topbar label { display: none; }
  /* But when the settings menu is open, show labels for clarity */
  .menu-open #topbar label { display: inline-block; }
  /* Always hide Difficulty label on mobile (even when menu open) */
  #topbar label[for="difficulty"],
  .menu-open #topbar label[for="difficulty"] {
    display: none !important;
  }
}

@media (max-width: 600px) {
  #topbar select,
  #topbar input,
  #topbar button {
    height: 38px; /* bigger tap targets */
  }
  /* Reduce overlay clutter on small screens */
  #help {
    display: none;
  }
}
