html, body {
  margin: 0;
  height: 100%;
  background: transparent;
  font-family: system-ui, sans-serif;
  color: #e8e6e0;
  overflow: hidden;
}
#panel {
  position: absolute;
  inset: 0;
  background: rgba(20, 22, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
}
#map {
  position: absolute;
  inset: 0;
  background: #2b3326;
}
#toolbar, #status {
  position: absolute;
  z-index: 1000;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 10px;
  background: rgba(15, 16, 15, 0.8);
  border-radius: 6px;
  font-size: 13px;
}
/* Search and toolbar share the top bar and wrap onto more rows when narrow. */
#topbar {
  position: absolute; z-index: 1001; top: 10px; left: 10px; right: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#toolbar { position: static; flex-wrap: wrap; justify-content: flex-end; gap: 8px 10px; margin-left: auto; }
@media (max-width: 1000px) { #hint, #help { display: none; } }
#status { bottom: 10px; left: 10px; font-variant-numeric: tabular-nums; }
#coords { font-family: ui-monospace, Consolas, monospace; font-size: 15px; }
#hint { opacity: 0.6; font-size: 12px; }
#route { font-family: ui-monospace, Consolas, monospace; color: #ffd27a; }
#route:empty, #help:empty, #tier:empty, #elev:empty, #marker-pills:empty { display: none; }
#elev { font-variant-numeric: tabular-nums; opacity: 0.85; }
#tier { font-weight: 600; font-size: 12px; padding: 1px 6px; border-radius: 4px; color: #111; }
#help { opacity: 0.6; font-size: 12px; }
button {
  background: #2a2c2a; color: inherit; border: 1px solid #444; border-radius: 4px; padding: 2px 8px;
  font: inherit; font-size: 12px; cursor: pointer;
}
button:hover { background: #363936; }
select {
  background: #222; color: inherit; border: 1px solid #444; border-radius: 4px; padding: 2px 4px;
}
.leaflet-container { font-family: inherit; }

#search-box {
  position: relative;
  flex: 1 1 220px;
  max-width: 420px;
}
#search {
  box-sizing: border-box;
  width: 100%;
  padding: 8px 12px;
  background: rgba(15, 16, 15, 0.9);
  color: inherit;
  border: 1px solid #555;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  outline: none;
}
#search:focus { border-color: #ffd27a; }
#results {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px 0;
  background: rgba(15, 16, 15, 0.95);
  border: 1px solid #444;
  border-radius: 6px;
}
#results:empty { display: none; }
#results li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 14px;
}
#results li.active, #results li:hover { background: #3a3d38; }
#results .meta { opacity: 0.55; font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
#results .empty { opacity: 0.6; cursor: default; }

.town-label {
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 6px #000;
  transform: translate(-50%, calc(-100% - 6px)); /* sit above the point, clear of markers */
  pointer-events: none;
}
.town-label.r1 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.04em; }
.town-label.r2 { font-size: 14px; }
.town-label.r3 { font-size: 12px; }
.town-label.r4, .town-label.r5, .town-label.r6 { font-size: 11px; font-weight: 400; font-style: italic; opacity: 0.85; }
.leaflet-marker-icon.town-icon { width: auto !important; height: auto !important; background: none; border: none; }

.search-hit { background: none; border: none; }
.search-hit div {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 50%;
  border: 3px solid #ffd27a;
  box-shadow: 0 0 12px #ffd27a;
  animation: pulse 1.2s ease-out 3;
}
@keyframes pulse {
  from { transform: scale(0.4); opacity: 1; }
  to { transform: scale(1.6); opacity: 0.2; }
}

/* Filter each 256px tile, not the layer: a filter on the (hugely scaled) layer
   container can't be rasterized in time while zooming and flashes blank. */
.sat-layer .leaflet-tile, img.sat-overview {
  filter: brightness(var(--sat-brightness, 1.7)) contrast(1.08) saturate(1.15);
}
.topo-layer .leaflet-tile, img.topo-overview {
  filter: brightness(var(--topo-brightness, 1));
}
/* Peek: view only, so hide the controls. */
body.peek #toolbar, body.peek #search-box, body.peek #layers-panel, body.peek #routes-panel, body.peek #settings-panel, body.peek #squad-panel, body.peek #challenges-panel, body.peek #welcome, body.peek .leaflet-control-zoom { display: none; }
/* Move / resize handles for the window. */
.grip { touch-action: none; user-select: none; }
#move { cursor: move; font-size: 15px; opacity: 0.7; padding: 0 2px; }
#move:hover, #resize:hover { opacity: 1; }
#resize {
  position: absolute; right: 0; bottom: 0; z-index: 1001; width: 18px; height: 18px; cursor: nwse-resize; opacity: 0.6;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.5) 50%, rgba(255,255,255,0.5) 58%, transparent 58%, transparent 70%, rgba(255,255,255,0.5) 70%, rgba(255,255,255,0.5) 78%, transparent 78%);
}
body.peek #resize { display: none; }
#toolbar label { display: flex; align-items: center; gap: 4px; opacity: 0.85; }
#brightness { width: 90px; accent-color: #ffd27a; }
.leaflet-control-zoom a {
  background: rgba(15, 16, 15, 0.85) !important;
  color: #e8e6e0 !important;
  border-color: #444 !important;
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  font-size: 20px !important;
}
.leaflet-control-zoom a:hover { background: #363936 !important; }

#layers-panel, #routes-panel, #settings-panel, #squad-panel, #challenges-panel {
  position: absolute;
  z-index: 1001;
  top: var(--toolbar-bottom, 52px);
  right: 10px;
  max-height: calc(100% - var(--toolbar-bottom, 52px) - 60px);
  overflow-y: auto;
  min-width: 230px;
  padding: 8px 12px 10px;
  background: rgba(15, 16, 15, 0.92);
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 13px;
}
#layers-panel[hidden], #routes-panel[hidden], #settings-panel[hidden], #squad-panel[hidden], #challenges-panel[hidden] { display: none; }
#layers-panel h3, #routes-panel h3, #settings-panel h3, #squad-panel h3 {
  margin: 10px 0 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}
#layers-panel h3:first-child, #routes-panel h3:first-child, #settings-panel h3:first-child, #squad-panel h3:first-child { margin-top: 2px; }
#layers-panel label { display: flex; align-items: center; gap: 8px; padding: 2px 0; cursor: pointer; }
#layers-panel .count, #routes-panel .count { margin-left: auto; opacity: 0.5; font-variant-numeric: tabular-nums; font-size: 12px; }
#layers-panel .swatch { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.6); flex: none; }
#layers-panel .icon { width: 16px; height: 16px; flex: none; }
#layers-panel .actions { display: flex; gap: 6px; margin-top: 4px; }
#layers-panel .empty, #routes-panel .empty { opacity: 0.6; }
#layers-panel input { accent-color: #ffd27a; margin: 0; }

.badge-icon { background: none; border: none; }
.map-icon { display: block; }
.leaflet-tooltip.loot-tip {
  background: rgba(15, 16, 15, 0.95);
  color: #e8e6e0;
  border: 1px solid #555;
  box-shadow: none;
  font-size: 12px;
}
.leaflet-tooltip.loot-tip::before { display: none; }
.loot-tip b { font-size: 13px; }
.loot-tip .cats { opacity: 0.7; }
#layers-panel .legend { display: flex; gap: 10px; padding: 2px 0 2px 24px; font-size: 12px; opacity: 0.85; }
#layers-panel .legend span { display: flex; align-items: center; gap: 4px; }

[hidden] { display: none !important; }

.leaflet-tooltip.route-label {
  background: rgba(20, 22, 20, 0.85); color: #ffd27a; border: 1px solid #ffd27a; border-radius: 4px;
  font: 600 12px ui-monospace, Consolas, monospace; padding: 1px 6px; box-shadow: none;
}
.leaflet-tooltip.route-label::before { display: none; }

/* Loot routes */
#routes-panel { min-width: 280px; }
.route-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 4px 6px; margin: 1px 0;
  background: none; border: 1px solid transparent; border-radius: 4px; text-align: left; font-size: 13px;
}
.route-row:hover { background: #2a2c2a; }
.route-row.active { background: #33352f; border-color: #ffd27a; }
.route-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,0.6); }
.route-line { animation: route-march 1.2s linear infinite; }
@keyframes route-march { from { stroke-dashoffset: 22; } to { stroke-dashoffset: 0; } }
.route-arrow { background: none; border: none; }
.route-arrow span {
  display: block; width: 14px; height: 14px; line-height: 14px; text-align: center; font-size: 12px;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
.route-stop-icon { background: none; border: none; }
.route-stop {
  display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin: 2px;
  border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 0 2px rgba(0,0,0,0.35);
  color: #111; font: 700 12px system-ui, sans-serif;
}
#route-card {
  position: absolute; z-index: 1001; left: 50%; bottom: 10px; transform: translateX(-50%);
  max-width: min(520px, calc(100% - 40px)); padding: 8px 12px; border-radius: 6px;
  background: rgba(15, 16, 15, 0.9); border: 1px solid #444; font-size: 13px;
}
#route-card[hidden] { display: none; }
.route-card-head { display: flex; align-items: center; gap: 8px; }
.route-card-title { opacity: 0.85; margin-top: 2px; }
.route-card-stats { opacity: 0.7; font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.route-goal { margin-left: auto; font-size: 11px; padding: 1px 6px; }
.route-goal + .route-overlays { margin-left: 0; }
.route-overlays { margin-left: auto; font-size: 11px; padding: 1px 6px; }
.route-close { padding: 0 6px; font-size: 15px; line-height: 18px; }
.route-card-tiers { margin-top: 3px; font-size: 12px; }
.tier-pill { display: inline-block; padding: 0 5px; border-radius: 3px; color: #111; font-weight: 600; }
.route-hint { font-size: 12px; margin-bottom: 4px; }

/* Marker chips in the status bar */
#marker-pills { display: flex; gap: 6px; }
.marker-pill { display: inline-flex; border: 1px solid #444; border-radius: 4px; overflow: hidden; }
.marker-pill button { border: none; border-radius: 0; padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; }
.pill-go { display: inline-flex; align-items: center; gap: 5px; }
.pill-x { border-left: 1px solid #444 !important; opacity: 0.7; }
.pill-x:hover { opacity: 1; }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid #fff; }

/* Settings */
#settings-panel { min-width: 300px; }
.settings-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.settings-row > span:first-child { flex: 1; opacity: 0.85; }
.settings-version { margin-top: 10px; font-size: 11px; opacity: 0.5; }
#server-state.bad { color: #ff8a65; }
#server-state.ok { color: #9ccc65; }

/* Status notice (backend problems, map not available) */
#notice {
  position: absolute; z-index: 1002; left: 50%; top: calc(var(--toolbar-bottom, 52px) + 4px); transform: translateX(-50%);
  max-width: min(560px, calc(100% - 40px)); padding: 6px 12px; border-radius: 6px; font-size: 13px;
  background: rgba(60, 30, 20, 0.92); border: 1px solid #ff8a65; color: #ffd8c8; text-align: center;
}
#notice[hidden] { display: none; }
#notice.info { background: rgba(20, 30, 40, 0.92); border-color: #6aa9ff; color: #d6e6ff; }

/* Welcome guide */
#welcome {
  position: absolute; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}
#welcome[hidden] { display: none; }
.welcome-card {
  width: min(560px, calc(100% - 40px)); max-height: calc(100% - 40px); overflow-y: auto; padding: 18px 22px;
  background: #1a1c1a; border: 1px solid #555; border-radius: 10px; font-size: 14px; line-height: 1.45;
}
.welcome-card h2 { margin: 0 0 10px; font-size: 19px; }
.welcome-card ul { margin: 6px 0 12px; padding-left: 20px; }
.welcome-card kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid #666; border-bottom-width: 2px;
  border-radius: 4px; background: #2a2c2a; font: 600 12px ui-monospace, Consolas, monospace; text-align: center;
}
.welcome-warn { padding: 8px 10px; margin: 8px 0; border-radius: 6px; background: rgba(255, 138, 101, 0.12); border: 1px solid #ff8a65; }
.welcome-card .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.welcome-card .primary { background: #ffd27a; color: #111; border-color: #ffd27a; font-weight: 600; padding: 4px 14px; }

#pin-toggle.active { background: #ffd27a; color: #111; border-color: #ffd27a; }

/* Squad */
#squad-panel { min-width: 300px; }
#squad-panel .empty { opacity: 0.6; font-size: 12px; }
.squad-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.squad-row input[type=text] { flex: 1; min-width: 0; background: #222; color: inherit; border: 1px solid #444; border-radius: 4px; padding: 3px 6px; font: inherit; }
.squad-colors { display: flex; gap: 5px; }
.squad-color { width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.squad-color.active { border-color: #fff; }
.squad-code { font: 600 15px ui-monospace, Consolas, monospace; letter-spacing: 0.05em; }
.squad-status { font-size: 12px; opacity: 0.75; }
.squad-status.bad { color: #ff8a65; opacity: 1; }
.squad-member { display: flex; align-items: center; gap: 8px; width: 100%; padding: 3px 6px; background: none; border: 1px solid transparent; text-align: left; }
.squad-member:hover { background: #2a2c2a; }
.squad-member .where { margin-left: auto; opacity: 0.55; font-size: 12px; }
.squad-dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid #fff; flex: none; }
.squad-label {
  background: rgba(15, 16, 15, 0.85); color: #fff; border: none; box-shadow: none;
  font: 600 11px system-ui, sans-serif; padding: 1px 5px; border-radius: 3px;
}
.squad-label::before { display: none; }
.squad-label.stale { opacity: 0.6; font-weight: 400; }
#squad-toggle.live { border-color: #9ccc65; }

/* Challenges */
#challenges-panel { width: 340px; }
.challenge { padding: 8px 0 10px; border-bottom: 1px solid #333; }
.challenge:last-of-type { border-bottom: none; }
.challenge-head { display: flex; align-items: baseline; gap: 8px; }
.challenge-head .count { margin-left: auto; opacity: 0.55; font-size: 11px; white-space: nowrap; }
.challenge-kind { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 5px; border-radius: 3px; color: #111; }
.challenge.daily .challenge-kind { background: #ffb300; }
.challenge.weekly .challenge-kind { background: #b388ff; }
.challenge.quest .challenge-kind { background: #4dd0e1; }
.challenge-section { margin: 10px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.6; }
.challenge-text { opacity: 0.75; font-size: 12px; font-style: italic; line-height: 1.4; margin: 4px 0 6px; }
.challenge-step { display: flex; align-items: center; gap: 7px; padding: 2px 0; cursor: pointer; font-size: 13px; }
.challenge-step.done > span:not(.by) { opacity: 0.55; text-decoration: line-through; }
.challenge-step .where { opacity: 0.5; font: 11px ui-monospace, Consolas, monospace; text-decoration: none; }
.challenge-step .by { margin-left: auto; font-size: 11px; color: #9ccc65; white-space: nowrap; }
.challenge-bullet { width: 16px; text-align: center; flex: none; }
.challenge .actions { display: flex; gap: 6px; margin-top: 6px; }
.challenge-foot { margin-top: 6px; font-size: 11px; }
.challenge-done-banner { padding: 6px 8px; margin-bottom: 6px; border-radius: 5px; background: rgba(255, 179, 0, 0.15); border: 1px solid #ffb300; font-weight: 600; }
.challenge-icon { background: none; border: none; }
.challenge-pin {
  display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin: 2px;
  border-radius: 6px; background: var(--c); border: 2px solid #fff;
  box-shadow: 0 1px 0 2px rgba(0,0,0,0.35); color: #111; font: 700 11px system-ui, sans-serif;
}
.challenge-pin { line-height: 1; }
.challenge-pin.done { background: #555; color: #fff; }

/* 3D view */
#view3d { position: absolute; inset: 0; z-index: 900; background: #9fb7c9; }
#view3d[hidden] { display: none; }
#view3d canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#view3d canvas:active { cursor: grabbing; }
#view3d-height {
  position: absolute; right: 10px; bottom: 10px; z-index: 2; display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 6px; background: rgba(15, 16, 15, 0.8); font-size: 13px;
}
#view3d-height input { width: 100px; accent-color: #ffd27a; }
#view3d-toggle.active { background: #ffd27a; color: #111; border-color: #ffd27a; }
/* Panels and markers that only make sense on the 2D map. */
body.view3d #layers-panel, body.view3d #route-card, body.view3d .leaflet-control-zoom { display: none; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 116px); gap: 4px; margin: 2px 0 5px; }
.photo-grid img { width: 116px; height: 87px; object-fit: cover; border-radius: 3px; background: #222; }
.building-photo { display: block; width: 240px; height: 180px; object-fit: cover; border-radius: 4px; margin: 2px 0 5px; background: #222; }

.challenge-hint { display: block; margin-top: 2px; font-size: 11px; line-height: 1.35; opacity: 0.65; }
.challenge-bonus { font-size: 10px; padding: 0 5px; border-radius: 6px; background: rgba(255, 255, 255, 0.15); vertical-align: 1px; }
/* Your position and target: a dark halo around the white ring (app.js MARKER_STYLE). */
.pos-marker { cursor: grab; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 4px rgba(0, 0, 0, 0.6)); }

/* Map picker (mappicker.js): a grid of map cards over everything. */
#map-picker {
  position: absolute; inset: 0; z-index: 1200; overflow-y: auto;
  background: radial-gradient(circle at 50% 0%, #262a24, #121412 70%);
}
#map-picker[hidden] { display: none; }
.picker-inner { max-width: 1100px; margin: 0 auto; padding: 48px 24px 40px; }
#map-picker h1 { margin: 0; font-size: 34px; letter-spacing: 0.5px; }
.picker-sub { margin: 4px 0 28px; opacity: 0.7; font-size: 16px; }
#map-picker h2 { margin: 0 0 12px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; opacity: 0.6; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.picker-card {
  display: flex; flex-direction: column; gap: 2px; padding: 0 0 12px; overflow: hidden; text-align: left;
  background: #1c1f1b; border: 1px solid #3a3d38; border-radius: 12px; cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.picker-card:hover, .picker-card:focus-visible { transform: translateY(-3px); border-color: #ffd27a; }
.picker-card.current { border-color: #ffd27a; }
.picker-pic { display: block; aspect-ratio: 1; overflow: hidden; background: #2a2d28; margin-bottom: 8px; }
.picker-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker-name { padding: 0 14px; font-size: 18px; font-weight: 600; }
.picker-size { padding: 0 14px; font-size: 13px; opacity: 0.6; }
.picker-close { margin-top: 28px; padding: 8px 16px; font-size: 14px; }
@media (max-width: 700px) {
  .picker-inner { padding: 28px 16px 32px; }
  .picker-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .picker-name { font-size: 16px; padding: 0 10px; }
  .picker-size { padding: 0 10px; }
}

/* Your places (pins.js): emoji pin with its name under it. */
.place-pin { background: none; border: none; }
.place-emoji {
  display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; font-size: 18px;
  background: #1a1c1a; border: 2px solid #ffd27a; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); box-sizing: border-box;
}
.place-emoji > span { transform: rotate(45deg); line-height: 1; }
.place-label {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  padding: 1px 6px; border-radius: 4px; font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(15, 16, 15, 0.85);
}
#map.placing { cursor: crosshair; }
#place-add[aria-pressed="true"] { background: #ffd27a; color: #141614; }
.place-popup .leaflet-popup-content-wrapper, .place-popup .leaflet-popup-tip { background: #1a1c1a; color: #e8e6e0; border: 1px solid #555; }
.place-popup .leaflet-popup-content { margin: 10px 12px; }
.place-edit input { width: 100%; box-sizing: border-box; padding: 6px 8px; background: #222; color: inherit; border: 1px solid #555; border-radius: 4px; font: inherit; font-size: 14px; }
.place-icons { display: flex; gap: 4px; margin: 8px 0; }
.place-icons button { flex: 1; font-size: 18px; padding: 4px 0; }
.place-icons button.active { border-color: #ffd27a; background: #3a3d38; }
.place-actions { display: flex; align-items: center; gap: 6px; }
.place-actions .where { margin-right: auto; opacity: 0.6; font: 12px ui-monospace, Consolas, monospace; }
.place-delete { color: #ff8a65; }
