:root {
  --bg: #12141a; /* same as the server-side fog colour */
  --panel: rgba(24, 26, 32, 0.92);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e6e6e6;
  --muted: #9aa0a8;
  --accent: #e0b35a;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
  cursor: grab;
}
#map.leaflet-drag-target, #map:active { cursor: grabbing; }

.leaflet-container { font-family: var(--font); }
.leaflet-tile { image-rendering: auto; }

/* Zoom buttons styled dark */
.leaflet-bar { border: 1px solid var(--panel-border) !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-bottom-color: var(--panel-border) !important;
}
.leaflet-bar a:hover { background: #2a2d35 !important; }
.leaflet-bar a.leaflet-disabled { color: #555 !important; }
.leaflet-control-scale-line {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--muted) !important;
}

/* Top status pill */
.status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 7px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  max-width: calc(100vw - 120px);
  pointer-events: none;
}
.status #world-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.status .clock { color: var(--muted); font-variant-numeric: tabular-nums; }
.status .clock:empty { display: none; }
.render { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.render.hidden { display: none; }
.render .bar { width: 90px; height: 5px; background: rgba(255,255,255,0.12); border-radius: 3px; overflow: hidden; }
.render .bar div { height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }

/* Player panel */
.panel {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  width: 260px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px 6px;
}
.tabs { display: flex; gap: 4px; }
.panel-title { margin: 0; padding: 10px 14px 4px; font-size: 14px; font-weight: 600; }
.tab {
  border: none;
  background: none;
  color: var(--muted);
  font: 600 13px var(--font);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: rgba(255,255,255,0.08); }
.tab-page { display: none; flex-direction: column; min-height: 0; }
.tab-page.active { display: flex; }
.panel ul { list-style: none; margin: 0; padding: 0 6px; overflow-y: auto; }
.panel li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.panel li:hover { background: rgba(255,255,255,0.06); }
.panel li.following { background: rgba(224, 179, 90, 0.16); }
.panel li.hidden-pos { cursor: default; opacity: 0.6; }
.panel li .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 0 2px rgba(0,0,0,0.5); }
.panel li.hidden-pos .dot { background: transparent; border: 2px dashed var(--muted); }
.panel li .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel li .sub { grid-column: 2 / span 2; color: var(--muted); font-size: 12px; margin-top: -2px; }
.panel li .follow { color: var(--accent); font-size: 12px; }
.panel li .skull { color: #e06060; font-size: 12px; }
.panel li.history { grid-template-columns: 1fr auto; }
.panel li.history .stats { grid-column: 1 / span 2; color: var(--muted); font-size: 12px; }
.panel li.history .online-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd27a; }
.panel li.history .sessions { grid-column: 1 / span 2; margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; }
.panel li.history .sessions li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 3px 0; cursor: default; color: var(--muted); }
.panel li.history .sessions li:hover { background: none; }
.panel li.history .sessions .dur { color: var(--text); font-variant-numeric: tabular-nums; }
.panel #no-history { margin: 0; padding: 4px 14px 12px; }
.panel #no-history.hidden { display: none; }
.panel footer { padding: 8px 14px 10px; font-size: 11px; line-height: 1.4; border-top: 1px solid var(--panel-border); }
.panel #no-players { margin: 0; padding: 4px 14px 12px; }
.panel #no-players.hidden { display: none; }
.muted { color: var(--muted); font-size: 12px; }

.panel-toggle {
  display: none;
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font: 600 14px var(--font);
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Coordinates readout */
.coords {
  position: absolute;
  left: 10px;
  bottom: 30px;
  z-index: 1000;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  pointer-events: none;
}
.coords:empty { display: none; }

/* Player markers */
.player-marker { background: none !important; border: none !important; }
.leaflet-marker-icon.player-marker { transition: transform 1s linear; }
.leaflet-zoom-anim .leaflet-marker-icon.player-marker { transition: none; }
.pm {
  position: relative;
  width: 0;
  height: 0;
}
.pm .pm-arrow {
  position: absolute;
  left: -14px;
  top: -14px;
  width: 28px;
  height: 28px;
  transform: rotate(var(--yaw, 0deg));
  transition: transform 0.6s ease;
}
.pm .pm-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--c, #fff);
  filter: drop-shadow(0 0 1px #000);
}
.pm .pm-dot {
  position: absolute;
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c, #fff);
  border: 2px solid #111;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 2px 6px rgba(0,0,0,0.6);
}
.pm .pm-label {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(10, 12, 16, 0.85);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 1px 1px #000;
  pointer-events: none;
}
.pm.no-heading .pm-arrow { display: none; }
.pm.following .pm-dot { box-shadow: 0 0 0 3px var(--accent), 0 2px 6px rgba(0,0,0,0.6); }

@media (max-width: 720px) {
  /* The status pill spans the top on phones; keep the zoom buttons below it. */
  .leaflet-top .leaflet-control { margin-top: 62px; }
  .panel-toggle { display: block; }
  .panel { display: none; top: 62px; right: 10px; left: 10px; width: auto; max-height: 45%; }
  .panel.open { display: flex; }
  .status { max-width: calc(100vw - 130px); left: 10px; transform: none; }
  .render .bar { width: 50px; }
  .coords { bottom: 26px; }
}
