:root {
  --bg: #0b1622;
  --ocean-1: #0d1b2b;
  --ocean-2: #0a1420;
  --panel: rgba(12, 22, 34, 0.92);
  --panel-solid: #0f1c2b;
  --line: rgba(120, 170, 210, 0.10);
  --text: #e8f0f7;
  --muted: #8aa2b8;
  --accent: #35c9a5;
  --live: #35d07a;
  --offline: #d0555a;
  --statues: #ffcf4d;
  --dungeons: #b98cff;
  --arenas: #ff8a5b;
  --bosses: #ff5d7a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#map {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 30%, var(--ocean-1) 0%, var(--ocean-2) 70%, #070f18 100%);
}
.leaflet-container { background: transparent; outline: none; }
.leaflet-control-attribution { display: none; }
/* Keep the zoom control clear of the toggles + info handle, and theme it dark. */
.leaflet-bottom.leaflet-right { bottom: calc(104px + var(--safe-bottom)); right: 10px; }
.leaflet-control-zoom { border: 1px solid var(--line) !important; box-shadow: none !important; }
.leaflet-touch .leaflet-control-zoom a,
.leaflet-control-zoom a {
  background: var(--panel-solid); color: var(--text);
  border-bottom-color: var(--line);
}
.leaflet-touch .leaflet-control-zoom a:hover,
.leaflet-control-zoom a:hover { background: #16273a; color: var(--accent); }

/* ---- top bar ---- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(6,12,20,0.92) 0%, rgba(6,12,20,0.55) 70%, transparent 100%);
  pointer-events: none;
}
.brand { display: flex; flex-direction: column; gap: 3px; pointer-events: auto; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.2px; }
.instance-badge {
  align-self: flex-start;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #06131d;
  background: var(--live);
  padding: 2px 7px;
  border-radius: 999px;
}
.instance-badge.is-test { background: var(--statues); }
.live-stat {
  display: flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 15px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 7px 11px; border-radius: 999px;
  pointer-events: auto;
}
.live-stat .muted { color: var(--muted); font-weight: 500; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--offline); }
.dot.on { background: var(--live); box-shadow: 0 0 0 0 rgba(53,208,122,0.7); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(53,208,122,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(53,208,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,208,122,0); }
}

/* ---- POI category toggles ---- */
#poiToggles {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(58px + var(--safe-bottom));
  z-index: 500;
  display: flex;
  gap: 8px;
  padding: 0 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#poiToggles::-webkit-scrollbar { display: none; }
.toggle {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 999px;
  cursor: pointer; user-select: none;
  transition: opacity .15s, border-color .15s;
  opacity: 0.42;
}
.toggle.on { opacity: 1; border-color: currentColor; }
.toggle .swatch { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.toggle .n { color: var(--muted); font-weight: 500; }

/* ---- slide-up info sheet ---- */
#infoHandle {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 600;
  border: none;
  font: inherit; font-weight: 600; font-size: 13.5px;
  color: var(--text);
  background: var(--panel-solid);
  border-top: 1px solid var(--line);
  padding: 16px 14px calc(16px + var(--safe-bottom));
  cursor: pointer;
  text-align: center;
}
#infoHandle .chev { display: inline-block; color: var(--accent); transition: transform .25s; margin-right: 6px; }
#infoHandle.open .chev { transform: rotate(180deg); }

#infoSheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 590;
  background: var(--panel-solid);
  border-top: 1px solid var(--line);
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  max-height: 82vh; overflow-y: auto;
}
#infoSheet.open { transform: translateY(0); }
.sheet-inner { padding: 20px 18px calc(84px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.sheet-inner h1 { font-size: 20px; margin: 0 0 6px; }
.desc { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 18px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 0 0 20px; }
.stats > div { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.stats dt { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.stats dd { margin: 0; font-size: 16px; font-weight: 700; }
.join { background: rgba(53,201,165,0.08); border: 1px solid rgba(53,201,165,0.25); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.join h2 { margin: 0 0 8px; font-size: 15px; }
.join-line { font-size: 15px; font-weight: 700; margin: 0 0 6px; word-break: break-all; }
.join-note { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.5; }
.footnote { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin: 10px 0 0; }
.footnote a { color: var(--accent); }
.credit { opacity: 0.75; }

/* ---- player pins (vector divIcons) ---- */
.player-pin { position: relative; }
.player-pin .glow {
  width: 16px; height: 16px; border-radius: 50%;
  background: #6fd0ff;
  border: 2px solid #eaf7ff;
  box-shadow: 0 0 12px 2px rgba(111,208,255,0.8);
  animation: pins 2.2s infinite;
}
.player-pin.p-Xbox .glow { background: #7bd66a; box-shadow: 0 0 12px 2px rgba(123,214,106,0.8); }
.player-pin.p-PS5 .glow { background: #7aa0ff; box-shadow: 0 0 12px 2px rgba(122,160,255,0.8); }
@keyframes pins { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }
.player-pin .label {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--text);
  background: rgba(6,12,20,0.85); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 6px;
  pointer-events: none;
}
.player-pin .label .lvl { color: var(--accent); font-weight: 700; }

/* POI markers use Leaflet circleMarker (SVG) — styled via JS options. */

/* region rectangles (coarse mode) label */
.region-count {
  font-size: 14px; font-weight: 800; color: var(--text);
  text-shadow: 0 1px 3px #000;
}

/* transform-warning banner */
#warn {
  position: absolute; z-index: 550; left: 12px; right: 12px;
  top: calc(64px + var(--safe-top));
  background: rgba(208,85,90,0.14); border: 1px solid rgba(208,85,90,0.5);
  color: #ffd9db; font-size: 12px; padding: 8px 12px; border-radius: 10px;
  display: none;
}

@media (min-width: 720px) {
  .brand-name { font-size: 17px; }
  #poiToggles { justify-content: center; }
}
