:root {
  --bg: #0f1c2e;
  --panel: rgba(12, 18, 28, 0.92);
  --text: #f1f1f1;
  --muted: #9aa6b5;
  --orange: #f08a24;
  --green: #3fbf4f;
  --red: #e0533d;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
#map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; }
[hidden] { display: none !important; }

button {
  font: inherit; font-size: 14px; color: var(--text); cursor: pointer;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px; padding: 6px 12px;
}
button:hover { background: rgba(255, 255, 255, 0.16); }
button.primary { background: var(--orange); border-color: var(--orange); color: #1b1006; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.primary.active { background: #fff; border-color: #fff; }
button.success { background: var(--green); border-color: var(--green); color: #06180a; font-weight: 600; }
button.danger { color: #ffb4a8; border-color: rgba(224, 83, 61, 0.5); }
input, textarea {
  font: inherit; font-size: 14px; color: var(--text); width: 100%;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px; padding: 8px 10px;
}
input:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
textarea { resize: vertical; min-height: 80px; }
kbd { background: rgba(255,255,255,.15); border-radius: 3px; padding: 1px 5px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #ff8f7d; font-size: 13px; min-height: 1em; }

/* Top bar */
#topbar {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center;
  background: var(--panel); border-radius: 10px; padding: 8px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); max-width: calc(100vw - 20px);
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.counter { font-size: 14px; white-space: nowrap; }
.counter span { font-weight: 700; color: var(--green); }
.counter #count-total { color: var(--text); }
.counter .bar { height: 4px; background: rgba(255,255,255,.12); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.counter .bar div { height: 100%; width: 0; background: var(--green); transition: width .3s; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toggle { font-size: 13px; display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; }
.toggle input { width: auto; }
#whoami { color: var(--muted); font-size: 13px; }

#add-hint {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--panel); padding: 10px 16px; border-radius: 8px; font-size: 14px;
}
.adding .leaflet-container { cursor: crosshair; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 10, 18, 0.55); backdrop-filter: blur(3px); padding: 16px;
}
.panel {
  position: relative; background: var(--panel); border-radius: 12px; padding: 24px;
  width: 340px; max-width: 100%; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); max-height: calc(100vh - 32px); overflow: auto;
}
.panel.wide { width: 560px; }
.panel h1, .panel h2, .panel h3, .panel p { margin: 0; }
.panel h1 { font-size: 22px; }
.close { position: absolute; top: 10px; right: 10px; border: none; background: none; font-size: 22px; padding: 2px 8px; }
#invites { display: flex; flex-direction: column; gap: 6px; }
.invite { display: flex; gap: 6px; }
.invite input { font-family: monospace; font-size: 12px; }
#users { width: 100%; border-collapse: collapse; font-size: 14px; }
#users td { padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,.08); }
#users td:last-child { text-align: right; }
.badge { font-size: 11px; background: var(--orange); color: #1b1006; border-radius: 4px; padding: 1px 5px; margin-left: 6px; }

/* Road names, styled after the in-game map */
.road-label span {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font: 12px Arial, "Helvetica Neue", Helvetica, sans-serif; color: #2b2b2b;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.85), 0 0 1px rgba(255, 255, 255, 0.85);
}

/* Blips */
/* Leaflet positions the .blip element with an inline transform, so effects go on the inner svg. */
.blip { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }
.blip svg { display: block; transform-origin: 15px 17px; transition: transform .1s; }
.blip:hover svg { transform: scale(1.2); }
.blip.new svg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }

/* Popups */
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content-wrapper { border-radius: 10px; }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; min-width: 230px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.pop h4 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.pop .status { font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 6px; background: var(--green); color: #06180a; }
.pop .note { white-space: pre-wrap; word-wrap: break-word; margin: 0 0 8px; max-height: 220px; overflow: auto; }
.pop .note:empty::before { content: "No note"; color: var(--muted); font-style: italic; }
.pop .meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.pop .row { display: flex; gap: 6px; flex-wrap: wrap; }
.pop .row button { flex: 1; }
.pop button.wide { width: 100%; padding: 8px 12px; margin-bottom: 6px; }
.pop textarea { margin-bottom: 4px; }
.pop .chars { font-size: 11px; color: var(--muted); text-align: right; margin-bottom: 8px; }
.pop .warn { font-size: 12px; color: #ffd27d; margin-bottom: 8px; }

.leaflet-control-zoom a { background: var(--panel) !important; color: var(--text) !important; border-color: rgba(255,255,255,.1) !important; }
.leaflet-control-attribution { background: rgba(12,18,28,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

@media (max-width: 700px) {
  #topbar { top: 6px; gap: 8px; padding: 6px 10px; }
  .brand { display: none; }
  #whoami { display: none; }
}
