:root {
  color-scheme: dark;
  --navy: #071a2e;
  --panel: rgba(9, 18, 29, 0.94);
  --panel-soft: rgba(14, 28, 43, 0.86);
  --line: rgba(211, 171, 66, 0.34);
  --gold: #d8ad43;
  --gold-soft: #f1d47d;
  --text: #f4f0e5;
  --muted: #a9b3bf;
  --ok: #51d28c;
  --danger: #ff786f;
}

* { box-sizing: border-box; }
html, body, #map { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: var(--navy); color: var(--text); font-family: Inter, "Segoe UI", sans-serif; }
#map { position: fixed; inset: 0; background: #06213c; }

/* Use Leaflet's standard tile, overlay, marker and popup panes. */
.map-actions { display:flex; gap:12px; align-items:center; margin-bottom:10px; }
.map-actions a { color:var(--gold-soft); }
.map-actions button { color:var(--text); background:transparent; border:1px solid var(--line); border-radius:4px; padding:7px; cursor:pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline:2px solid var(--gold); outline-offset:3px; }

.statusbar {
  position: fixed;
  z-index: 1000;
  top: 14px;
  left: 14px;
  right: 310px;
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 7px 16px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.38);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--gold-soft); font: 700 0.95rem/1 Georgia, serif; letter-spacing: 0.08em; }
.brand-mark { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold); font-size: 1.1rem; }
.status, .metric { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.82rem; }
.metric { padding-left: 16px; border-left: 1px solid rgba(255, 255, 255, 0.1); }
.metric strong { color: var(--text); font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(169, 179, 191, 0.14); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(81, 210, 140, 0.15); }

.layers {
  position: fixed;
  z-index: 1000;
  top: 14px;
  right: 14px;
  width: 280px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.38);
}
.layers h1 { margin: 0 0 10px; color: var(--gold-soft); font: 600 1rem/1.2 Georgia, serif; letter-spacing: 0.04em; }
.layers label { display: flex; align-items: center; min-height: 38px; gap: 10px; padding: 6px 8px; border-top: 1px solid rgba(255,255,255,.08); color: #dce2e8; font-size: .9rem; cursor: pointer; }
.layers input { accent-color: var(--gold); width: 16px; height: 16px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }
.swatch.outpost { background: #ee9f43; }
.swatch.personal { background: #7ab8ff; }
.swatch.admin { background: #ef5b57; }
.swatch.grid { border: 1px solid #e8e2c4; border-radius: 1px; background: transparent; }
.swatch.regions { border-radius: 2px; background: linear-gradient(180deg, #e44f47 0 44%, #e1b241 44% 56%, #4ca568 56%); }

.claim-label { color: #fff5c9; font: 700 12px/1.1 Georgia, serif; white-space: nowrap; text-shadow: 0 1px 3px #000, 0 0 5px #000; }
.claim-label .tier { margin-right: 5px; padding: 2px 4px; color: #16120a; background: var(--gold); border-radius: 2px; }
.outpost-marker { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid #19130b; border-radius: 50%; background: #ee9f43; color: #17100a; font-weight: 900; box-shadow: 0 2px 7px #000; }

.leaflet-control-zoom a { color: var(--gold-soft) !important; background: var(--panel) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(5, 13, 22, .78) !important; color: #aab3bd; }
.leaflet-control-attribution a { color: var(--gold-soft); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #111d29; color: var(--text); }
.leaflet-popup-content { line-height: 1.5; }

.error { position: fixed; z-index: 1100; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: min(620px, calc(100% - 32px)); padding: 12px 16px; border: 1px solid rgba(255,120,111,.6); border-radius: 6px; background: rgba(47, 12, 15, .94); color: #ffd4d1; }

@media (max-width: 820px) {
  .statusbar { right: 14px; gap: 10px; padding-right: 10px; flex-wrap: wrap; }
  .metric { padding-left: 10px; }
  .layers { top: auto; right: 10px; bottom: 20px; width: 245px; }
  .layers label { min-height: 34px; }
}

/* Compact, independently collapsible panels keep the map available on phones. */
.statusbar { right: 354px; }
.map-sidebar { position: fixed; z-index: 1000; top: 14px; right: 14px; width: 324px; max-height: calc(100dvh - 42px); overflow-y: auto; scrollbar-width: thin; }
.map-sidebar > details { position: static; width: auto; padding: 0; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: 0 10px 35px rgba(0,0,0,.38); }
.map-sidebar summary { padding: 14px; cursor: pointer; color: var(--gold-soft); font: 600 1rem/1.2 Georgia,serif; }
.map-sidebar summary:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }
.panel-hint { float: right; color: var(--muted); font: 400 .72rem/1.5 'Segoe UI',sans-serif; }
.panel-content { padding: 0 14px 14px; }
.statusbar { z-index: 1002; }
.statusbar .metric { padding-left: 12px; }
.game-clock, .restart-metric { gap: 4px; flex-direction: column; align-items: flex-start; }
.restart-metric > span { font-size: .7rem; }
.restart-metric b { color: var(--muted); font-weight: 500; }
.restart-metric strong, .game-clock strong { font-variant-numeric: tabular-nums; }
.brand { max-width: 100%; min-width: 0; }
#server-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.brand-mark { flex-shrink: 0; }
.weather-panel { margin-left: auto; }
.weather-panel > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-size: .76rem; font-weight: 600; }
.weather-panel > summary::-webkit-details-marker { display: none; }
.weather-date, .weather-current { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 8px; border: 1px solid rgba(255,255,255,.1); border-radius: 4px; background: #1b2330; }
.weather-date > span:first-child { color: #f19b38; }
.weather-chevron { color: var(--gold); }
.weather-panel[open] .weather-chevron { transform: rotate(180deg); }
.weather-popover { position: fixed; top: var(--statusbar-bottom, 80px); left: var(--weather-left, 14px); width: min(340px, calc(100vw - 20px)); max-height: calc(100dvh - var(--statusbar-bottom, 80px) - 16px); overflow-y: auto; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #0e141e; box-shadow: 0 12px 36px #0008; }
.weather-popover h2 { margin: 0; font-size: .86rem; }
.weather-state { margin: 8px 0 12px; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.weather-days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 4px; }
.weather-day { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 1px; border: 1px solid transparent; border-radius: 4px; }
.weather-day.is-tomorrow { background: rgba(216,173,67,.08); border-color: var(--line); }
.weather-day img { width: 28px; height: 28px; object-fit: contain; }
.weather-day strong { color: var(--muted); font-size: .74rem; }
.weather-kind { font-size: .76rem; }
.weather-season { color: #ee9f43; font-size: .68rem; }
.weather-note { color: var(--muted); font-size: .73rem; line-height: 1.5; margin: 10px 0 0; }
.players-metric strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.map-data-status { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .72rem; color: var(--muted); }
.map-data-status > div { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; }
.map-data-status > .status { justify-content: flex-start; font-size: .75rem; }
.map-data-status strong { font-weight: 500; text-align: right; }
@media (max-width: 820px) {
  .statusbar { right: 10px; left: 10px; top: 10px; gap: 9px; }
  .statusbar .brand { flex: 1; }
  .statusbar .metric { padding-left: 8px; }
  .statusbar .players-metric { flex-basis: 100%; border-left: 0; padding-left: 0; }
  .weather-panel { margin-left: 0; }
  .map-sidebar { top: var(--statusbar-bottom, 180px); right: 10px; width: min(324px, calc(100% - 20px)); max-height: calc(100dvh - var(--statusbar-bottom, 180px) - 30px); }
  .map-sidebar > details { margin-bottom: 6px; }
}
