:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1d242d;
  --line: #2a323d;
  --text: #e8edf3;
  --muted: #8b97a6;
  --accent: #5aa9ff;
  --gutter: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; background: var(--bg); }

.panel { position: fixed; z-index: 500; top: 12px; left: 12px; bottom: 12px; width: 340px;
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px var(--gutter) 8px; }
.panel-head h1 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.toggle { display: none; background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 4px 10px; font: inherit; }
.tabs { display: flex; gap: 4px; padding: 0 12px 8px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 4px;
  border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.tab-body { flex: 1; overflow-y: auto; padding: 8px var(--gutter) 12px; }
.tab-body[hidden] { display: none; }
.updated { padding: 8px var(--gutter); color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.panel.collapsed .tabs, .panel.collapsed .tab-body, .panel.collapsed .updated { display: none; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; flex: none; }
.row { display: flex; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.row:last-child { border-bottom: 0; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; }
.rank { width: 18px; color: var(--muted); text-align: right; }
.stat { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.stat b { color: var(--text); font-weight: 600; }
.lb-head { display: flex; gap: 8px; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; padding: 4px 0; }
.lb-head span:first-child { flex: 1; padding-left: 26px; }
.lb-head span { width: 64px; text-align: right; }
.lb-head span:first-child { width: auto; text-align: left; }

.city { padding: 10px 0; border-bottom: 1px solid var(--line); }
.city:last-child { border-bottom: 0; }
.city-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; cursor: pointer; }
.city-name { font-weight: 600; }
.boss { color: var(--muted); font-size: 12px; display: flex; align-items: center; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--panel-2); }
.bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; color: var(--muted); font-size: 12px; }

.ev { padding: 9px 0; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev-text b { font-weight: 600; }
.ev-time { color: var(--muted); font-size: 12px; margin-top: 2px; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

.hexcard { position: fixed; z-index: 600; right: 12px; top: 12px; width: 260px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px var(--gutter); box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.hexcard[hidden] { display: none; }
.hexcard h3 { margin: 0 0 2px; font-size: 15px; }
.hexcard .sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.hexcard .close { position: absolute; top: 8px; right: 10px; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border: 1px dashed #ffd166; color: #ffd166; border-radius: 10px; margin-left: 6px; }

.gate { position: fixed; z-index: 1000; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.86); padding: var(--gutter); }
.gate[hidden] { display: none; }
.gate-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.gate-card h2 { margin: 0; }
.gate-card p { margin: 0; color: var(--muted); }
.gate-card input { font: inherit; font-size: 18px; letter-spacing: 3px; text-transform: uppercase; text-align: center;
  padding: 12px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; }
.gate-card button { font: inherit; font-weight: 600; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #07121f; cursor: pointer; }
.gate-card .gate-error { color: #ff7b72; }

.leaflet-container { background: var(--bg); font: inherit; }
.leaflet-control-attribution { background: rgba(14,17,22,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

@media (max-width: 700px) {
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 46vh; border-radius: 14px 14px 0 0;
    border-left: 0; border-right: 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  .panel.collapsed { height: auto; }
  .toggle { display: inline-block; }
  .hexcard { top: 12px; left: 12px; right: 12px; width: auto; }
  .leaflet-control-zoom { display: none; }
}

/* OSM tiles are light; invert them for the dark theme. */
.osm-dark { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
.boss .dot { margin-left: 6px; }
