:root {
  --bg: #0f1419;
  --panel: #1a2332;
  --accent: #3d9ee5;
  --accent-hover: #5eb0ef;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --error: #ff6b6b;
  --live: #ff4757;
  --marker: #ffa502;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.panel {
  max-width: 420px;
  margin: 8vh auto;
  padding: 2rem;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

.pin-hint {
  margin: -0.75rem 0 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  background: rgba(255, 165, 2, 0.12);
  border: 1px solid rgba(255, 165, 2, 0.35);
  color: #eccc68;
  font-size: 0.85rem;
}

.muted-inline {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: normal;
}

.login-optional.hidden {
  display: none;
}

.profile-modal-content {
  width: 75vw;
  max-width: 75vw;
  max-height: 75vh;
  overflow-y: auto;
  padding: 0;
  border-radius: 16px;
  border: 1px solid rgba(61, 158, 229, 0.22);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  scrollbar-gutter: stable;
}

.profile-modal-content h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.profile-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 1.35rem 1.75rem 1.1rem;
  background: linear-gradient(180deg, rgba(61, 158, 229, 0.1) 0%, var(--panel) 100%);
  border-bottom: 1px solid rgba(42, 56, 72, 0.9);
}

.profile-modal-close {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  padding: 0;
  line-height: 1;
  border-radius: 10px;
  font-size: 1.1rem;
  border: 1px solid transparent;
  background: rgba(42, 56, 72, 0.55);
  color: var(--muted);
}

.profile-modal-close:hover {
  background: rgba(255, 107, 107, 0.14);
  border-color: rgba(255, 107, 107, 0.28);
  color: #ff9a9a;
}

.profile-summary {
  margin: 0;
  padding: 1.6rem 1.75rem 1.75rem;
  background: linear-gradient(
    155deg,
    rgba(61, 158, 229, 0.14) 0%,
    rgba(61, 158, 229, 0.04) 45%,
    transparent 100%
  );
  border-bottom: 1px solid rgba(42, 56, 72, 0.85);
}

.profile-hero {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.profile-avatar-wrap {
  flex-shrink: 0;
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(145deg, #5eb0ef, #3d9ee5 45%, #2563a8);
  box-shadow: 0 10px 28px rgba(61, 158, 229, 0.28);
}

.profile-hero-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding-top: 0.35rem;
}

.profile-identity {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.profile-nickname {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

.profile-room-line {
  margin: 0;
  font-size: 0.9rem;
}

.profile-steam-line {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.profile-modal-content h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.profile-modal-content h3::before {
  content: "";
  width: 4px;
  height: 1.05em;
  border-radius: 3px;
  background: linear-gradient(180deg, #5eb0ef, #3d9ee5);
  flex-shrink: 0;
}

.profile-section {
  margin: 0;
  padding: 1.4rem 1.75rem;
  border-top: none;
  border-bottom: 1px solid rgba(42, 56, 72, 0.7);
}

.profile-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0 1.75rem;
  margin: 0.15rem 0 0;
  border-bottom: 1px solid rgba(42, 56, 72, 0.85);
}

.profile-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.65rem 0.85rem 0.75rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.profile-tab:hover {
  color: var(--text);
}

.profile-tab.is-active {
  color: var(--text);
  border-bottom-color: #3d9ee5;
}

.profile-tab-panels {
  min-height: 0;
}

.profile-tab-panel[hidden] {
  display: none !important;
}

.profile-tab-panel.is-active {
  display: block;
}

.profile-section-maps {
  border-bottom: none;
}

.profile-memberships-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.7rem;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}

.profile-membership-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.45);
}

.profile-membership-row.is-current {
  border-color: rgba(61, 158, 229, 0.45);
  background: rgba(61, 158, 229, 0.1);
}

.profile-membership-main {
  flex: 1;
  min-width: 0;
}

.profile-membership-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.profile-membership-meta {
  margin-top: 0.15rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.profile-membership-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: #9eb6cc;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 158, 229, 0.35);
}

.profile-membership-go {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.profile-section:last-of-type {
  border-bottom: none;
  padding-bottom: 1.6rem;
}

.profile-section > .muted-inline:first-of-type {
  margin: -0.35rem 0 1rem;
  line-height: 1.45;
}

.profile-modal-content label {
  margin-bottom: 0.9rem;
}

.profile-modal-content input {
  border-color: #334155;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-modal-content input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 158, 229, 0.16);
}

.profile-modal-footer {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid #2a3848;
  position: sticky;
  bottom: 0;
  background: var(--panel);
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

button, .btn-link {
  display: inline-block;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}

button:hover, .btn-link:hover { background: var(--accent-hover); }
button.secondary { background: #2a3848; }
button.secondary:hover { background: #3a4858; }

#login-form button { width: 100%; margin-top: 0.5rem; }

.error { color: var(--error); margin-top: 1rem; }
.download-link {
  display: block;
  margin-top: 1.5rem;
  text-align: center;
  color: var(--accent);
}

#map-view { display: flex; flex-direction: column; height: 100vh; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid #2a3848;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.user-info span { color: var(--muted); margin-left: 0.75rem; }
.toolbar-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.toolbar-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.25rem;
  padding-left: 0.5rem;
  border-left: 1px solid #2a3848;
}

.profile-avatar-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid #3d9ee5;
  border-radius: 50%;
  background: #1a2332;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
}

.profile-avatar-btn:hover {
  border-color: #5eb3f5;
  box-shadow: 0 0 0 2px rgba(61, 158, 229, 0.25);
}

.profile-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.profile-avatar-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--panel);
  background: #1a2332;
  flex-shrink: 0;
  display: block;
}

.profile-avatar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.65rem;
  align-items: center;
}

.profile-avatar-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.82rem;
}

.profile-avatar-upload-btn {
  display: inline-block;
  cursor: pointer;
  margin: 0;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(61, 158, 229, 0.35);
  background: rgba(61, 158, 229, 0.12);
  color: #b8dff7;
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.profile-avatar-upload-btn:hover {
  background: rgba(61, 158, 229, 0.22);
  border-color: rgba(61, 158, 229, 0.55);
}

@media (max-width: 540px) {
  .profile-hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-hero-main {
    align-items: center;
    padding-top: 0;
  }

  .profile-avatar-controls {
    justify-content: center;
  }
}

.map-wrapper {
  display: flex;
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#map {
  flex: 1;
  height: 100%;
  min-width: 0;
  background: #1a2332;
}

#map.leaflet-container,
.leaflet-container#map {
  cursor: default;
}

#map.leaflet-container.map-cursor-crosshair:not(.leaflet-dragging) {
  cursor: crosshair;
}

#map.leaflet-container.leaflet-dragging,
#map.leaflet-container.leaflet-dragging .leaflet-pane {
  cursor: grabbing !important;
}

.map-context-menu {
  position: fixed;
  z-index: 2500;
  min-width: 240px;
  max-width: 300px;
  padding: 0.35rem 0;
  background: rgba(26, 35, 50, 0.98);
  border: 1px solid #2a3848;
  border-radius: 10px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
}

.map-context-section + .map-context-section {
  border-top: 1px solid #2a3848;
  margin-top: 0.15rem;
  padding-top: 0.15rem;
}

.map-context-heading {
  padding: 0.4rem 0.85rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.map-context-coords {
  padding: 0.15rem 0.85rem 0.45rem;
  font-size: 0.95rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text);
}

.map-context-action {
  display: block;
  width: calc(100% - 1rem);
  margin: 0 0.5rem 0.45rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: rgba(42, 56, 72, 0.55);
  color: var(--text);
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}

.map-context-action:hover {
  border-color: var(--accent);
  background: rgba(61, 158, 229, 0.15);
}

.map-context-draw-tools {
  margin: 0;
  padding: 0 0.5rem 0.55rem;
  border: none;
  border-radius: 0;
  background: transparent;
}

#legend {
  flex-shrink: 0;
  width: 280px;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  background: rgba(26, 35, 50, 0.97);
  border-left: 1px solid #2a3848;
  font-size: 0.85rem;
  z-index: 100;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.legend-mouse-coords {
  position: sticky;
  bottom: -1rem;
  margin: 0.75rem -1rem -1rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid #2a3848;
  background: rgba(20, 28, 40, 0.98);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.legend-mouse-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.legend-mouse-value {
  color: var(--text);
  font-size: 0.70rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-all;
}

#legend.collapsed {
  width: 0;
  padding: 0;
  border-left: none;
  overflow: hidden;
}

.legend-toggle-btn {
  position: absolute;
  top: 15px;
  right: 280px;
  width: 32px;
  height: 38px;
  border-radius: 6px 0 0 6px;
  background: rgba(26, 35, 50, 0.97);
  border: 1px solid #2a3848;
  border-right: none;
  color: var(--text);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1001;
  box-shadow: -2px 2px 8px rgba(0, 0, 0, 0.35);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s;
}

.legend-toggle-btn:hover {
  background: var(--accent);
}

#legend.collapsed + .legend-toggle-btn {
  right: 0;
}

.filter-list {
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #2a3848;
  padding-bottom: 0.5rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.filter-row input {
  width: auto;
  margin: 0;
}

.scum-filter-search {
  width: 100%;
  margin: 0.4rem 0 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #2a3848;
  background: #121820;
  color: #e8eef6;
  font-size: 0.82rem;
}

.scum-filter-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 52vh;
  overflow: auto;
  padding-right: 0.15rem;
}

.scum-filter-section {
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: #151c24;
}

.scum-filter-section.hidden,
.scum-filter-item.hidden {
  display: none !important;
}

.scum-filter-section-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
}

.scum-filter-section-check {
  display: flex;
  align-items: center;
  margin: 0;
}

.scum-filter-section-check input {
  width: auto;
  margin: 0;
}

.scum-filter-section-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: transparent;
  border: 0;
  color: #e8eef6;
  font-size: 0.84rem;
  padding: 0.2rem 0.15rem;
  cursor: pointer;
  text-align: left;
}

.scum-filter-chevron {
  color: #8b9bb0;
  transition: transform 0.15s ease;
}

.scum-filter-section.open .scum-filter-chevron {
  transform: rotate(180deg);
}

.scum-filter-section-body {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.45rem 0.45rem 1.55rem;
}

.scum-filter-section.open .scum-filter-section-body {
  display: flex;
}

.scum-filter-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
}

.scum-filter-item input {
  width: auto;
  margin: 0;
}

.scum-filter-pin {
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--pin, #888);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  font-size: 10px;
  line-height: 1;
}

.scum-filter-pin em {
  font-style: normal;
  transform: rotate(45deg);
  display: inline-block;
}

.scum-filter-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scum-filter-count {
  color: #6f8096;
  font-size: 0.72rem;
}

.scum-map-pin-wrap {
  background: transparent !important;
  border: none !important;
}

.scum-map-pin {
  width: 26px;
  height: 26px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--pin, #c44);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 0 0 1.5px rgba(255, 255, 255, 0.35);
}

.scum-map-pin span {
  transform: rotate(45deg);
  font-size: 12px;
  line-height: 1;
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.5));
}

.scum-loc-gallery {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
  max-width: 280px;
}

.scum-loc-gallery .marker-popup-img {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
}

.scum-sector-canvas {
  pointer-events: none !important;
}

.death-map-pin-wrap {
  background: transparent !important;
  border: none !important;
}

.death-map-pin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(20, 10, 10, 0.85);
  border: 1.5px solid rgba(255, 80, 80, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}

.map-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  color: #3a2d49;
  white-space: nowrap;
  text-align: center;
  pointer-events: none;
  text-shadow:
    2px 0 0 #fff, -2px 0 0 #fff, 0 2px 0 #fff, 0 -2px 0 #fff,
    1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
}

.map-label span {
  display: block;
  line-height: 1.1;
}

.map-label.type-capital {
  font-size: 18px;
  font-weight: 900;
  color: #000;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.map-label.type-city {
  font-size: 15px;
  font-weight: 800;
  color: #222;
  text-transform: uppercase;
}

.map-label.type-village {
  font-size: 14px;
  font-weight: 700;
  color: #333;
}

.map-label.type-marine {
  font-size: 12px;
  font-style: italic;
  color: #01579b;
}

.map-label.type-hill {
  font-size: 12px;
  font-style: italic;
  color: #5d4037;
}

.map-label.type-camp {
  font-weight: 700;
  color: #8b0000;
}

.map-label.type-ruin {
  color: #5d4037;
  font-style: italic;
}

#radiation-legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#radiation-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.rad-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}

#legend h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
#legend h3 + h3 { margin-top: 0.75rem; }

.layer-switch {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.layer-btn {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: #2a3848;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.layer-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.focus-me-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: bold;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.focus-me-btn:hover {
  background: #2ecc71;
}

.focus-me-btn:active {
  transform: scale(0.98);
}

.coord-lookup-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  background: rgba(15, 20, 30, 0.92);
  border: 1px solid #2a3848;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  pointer-events: all;
}

.coord-lookup-bar input {
  width: 168px;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  font-size: 0.85rem;
  border-radius: 6px;
}

.coord-lookup-bar button {
  flex-shrink: 0;
  padding: 0.35rem 0.55rem;
  min-width: 2rem;
}

.coord-lookup-pin {
  background: transparent;
  border: none;
}

.coord-lookup-pin-inner {
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.75));
}

#map .leaflet-top.leaflet-left .leaflet-control-zoom {
  margin-top: 65px;
}

.leaflet-control-attribution {
  font-size: 0.7rem;
  background: rgba(26, 35, 50, 0.85) !important;
  color: var(--muted) !important;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

#legend ul { list-style: none; padding: 0; margin: 0 0 0.75rem; }
#legend li { margin-bottom: 0.35rem; }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot.live { background: var(--live); }
.dot.marker { background: var(--marker); }
.dot.poi { background: #3498db; }

.poi-map-pin {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.poi-pin {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.poi-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.55);
  line-height: 1;
}

.poi-glyph-map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  flex-shrink: 0;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.6);
}

.poi-glyph-map--emoji {
  font-size: 17px;
  font-weight: 400;
}

.poi-title {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
  font-style: italic;
  font-weight: 600;
  color: #fff;
  text-shadow:
    1px 0 0 #000, -1px 0 0 #000, 0 1px 0 #000, 0 -1px 0 #000,
    1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.poi-desc {
  margin: 0.35rem 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.poi-desc-image {
  display: block;
  box-sizing: border-box;
  width: auto;
  max-width: 100%;
  max-height: 160px;
  height: auto;
  object-fit: contain;
  margin: 0.4rem 0;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  cursor: zoom-in;
}

.poi-coords {
  color: var(--muted);
  font-size: 0.85rem;
}

.marker-popup-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.35rem;
}

.poi-trader-link {
  display: inline-block;
  color: #4fc3f7;
  font-size: 0.9rem;
  text-decoration: none;
}

.poi-trader-link:hover {
  text-decoration: underline;
}

.poi-marker {
  width: 22px;
  height: 22px;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: #3498db;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 12px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
}

.admin-link {
  display: block;
  margin-top: 0.75rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

#players-list { border-top: 1px solid #2a3848; padding-top: 0.5rem; }
.player-row { padding: 0.25rem 0; color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 1rem;
}

.modal-content {
  background: var(--panel);
  padding: 1.5rem;
  border-radius: 12px;
  max-width: 480px;
  width: 90%;
}

.modal-content.profile-modal-content {
  width: 75vw;
  max-width: 75vw;
  max-height: 75vh;
  padding: 0;
  border-radius: 16px;
}

.modal-content code {
  display: block;
  word-break: break-all;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  margin: 1rem 0;
  font-size: 0.8rem;
}

.leaflet-popup-content {
  color: #222;
  max-width: min(62vw, 260px);
  overflow: hidden;
  overflow-wrap: anywhere;
}

.leaflet-popup-content img {
  max-width: 100% !important;
  height: auto;
  box-sizing: border-box;
}

.marker-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.marker-popup-actions > button {
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1.2;
}

.marker-delete, .marker-route, .death-delete {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.marker-delete, .death-delete {
  background: #c0392b;
  color: #fff;
}

.marker-delete:hover, .death-delete:hover {
  background: #e74c3c;
}

.marker-route {
  background: var(--accent);
  color: #fff;
}

.marker-route:hover {
  background: var(--accent-hover);
}

@media (max-width: 768px) {
  #legend {
    width: 220px;
  }
  .legend-toggle-btn {
    top: 10px;
    right: 220px;
  }
  #legend.collapsed + .legend-toggle-btn {
    right: 0;
  }
}

/* ============================================================
   Navigator
   ============================================================ */

.nav-btn.active {
  background: #00c853;
  border-color: #00c853;
  color: #000;
}

.map-wrapper {
  position: relative;
}

.nav-panel {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}

.nav-panel-inner {
  background: rgba(15, 20, 30, 0.92);
  border: 1px solid #3d9ee5;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  pointer-events: all;
  min-width: 240px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(61, 158, 229, 0.2);
  backdrop-filter: blur(8px);
}

.nav-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: #00e5ff;
}

.nav-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
  line-height: 1;
}

.nav-close:hover { color: var(--text); }

.nav-status {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  min-height: 1.2em;
}

.nav-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

button.secondary.small {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

/* Roads filter row */
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}

.filter-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Sidebar Lists for Players and Markers */
.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
  background: rgba(15, 20, 25, 0.5);
  border: 1px solid #2a3848;
  border-radius: 8px;
  padding: 0.45rem;
  max-height: 220px;
  overflow-y: auto;
}

.sidebar-card {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.45rem 0.55rem;
  background: rgba(26, 35, 50, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-card:hover {
  background: rgba(61, 158, 229, 0.12);
  border-color: rgba(61, 158, 229, 0.35);
}

.sidebar-card-top {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 0;
}

.sidebar-card-main {
  flex: 1;
  min-width: 0;
}

.sidebar-card-title {
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.25;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sidebar-card-meta {
  margin-top: 0.12rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.sidebar-card-coords {
  font-size: 0.68rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #9eb6cc;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-all;
  padding-left: calc(22px + 0.45rem);
}

.sidebar-card-action {
  flex-shrink: 0;
  margin-left: auto;
  width: 26px;
  height: 26px;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: rgba(15, 20, 25, 0.7);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  padding: 0;
}

.sidebar-card-action:hover {
  border-color: var(--accent);
  background: rgba(61, 158, 229, 0.18);
}

.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.sidebar-section-head .filter-row {
  color: var(--muted);
  font-size: 0.78rem;
}

.draw-tools {
  margin-bottom: 1rem;
  padding: 0.55rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.5);
}

.draw-tool-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.draw-tool-row:last-child {
  margin-bottom: 0;
}

.draw-tool-row button {
  flex: 1;
}

.draw-tool-row button.active {
  border-color: var(--accent);
  background: rgba(61, 158, 229, 0.18);
  color: #fff;
}

#geo-edit-save-btn,
#geo-edit-cancel-btn {
  border-color: #3d9ee5;
}

.draw-hint {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.draw-tool-settings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.draw-tool-settings label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.draw-tool-settings input[type="number"] {
  width: 96px;
  padding: 0.22rem 0.35rem;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.draw-tool-settings input[type="color"] {
  width: 42px;
  height: 26px;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: transparent;
  padding: 0;
}

.draw-tool-settings select {
  min-width: 118px;
  padding: 0.22rem 0.35rem;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.sidebar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  background: rgba(26, 35, 50, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-row:hover {
  background: rgba(61, 158, 229, 0.12);
  border-color: rgba(61, 158, 229, 0.3);
}

.sidebar-row-left {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.sidebar-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.sidebar-info {
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-avatar-wrap {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--user-color, #3d9ee5);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a2332;
}

.sidebar-avatar,
.user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.live-player-pin {
  display: flex;
  align-items: center;
  white-space: nowrap;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.8));
}

.live-player-avatar-wrap {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  overflow: visible;
  flex-shrink: 0;
  background: #1a2332;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.65);
}

.live-player-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.live-travel-badge {
  position: absolute;
  right: -8px;
  bottom: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(12, 18, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.45);
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  pointer-events: none;
}

.live-travel-line {
  margin-top: 2px;
  font-size: 0.85rem;
  color: #445;
}

.live-player-name {
  margin-left: 5px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-family: sans-serif;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.list-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.78rem;
  text-align: center;
  padding: 0.5rem;
}

.delete-btn-small {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
  line-height: 1;
}

.delete-btn-small:hover {
  color: var(--error);
  background: rgba(255, 107, 107, 0.15);
}

/* Legend Tab System */
.legend-tabs {
  display: flex;
  border-bottom: 1px solid #2a3848;
  margin-bottom: 0.75rem;
  margin-top: -0.25rem; /* pull up slightly */
}

.legend-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}

.legend-tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.legend-tab-btn.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.app-tab-intro {
  margin: 0 0 0.85rem;
  line-height: 1.45;
  font-size: 0.84rem;
}

.app-help-card {
  padding: 0.85rem;
  margin-bottom: 0.7rem;
  border-radius: 10px;
  background: rgba(15, 20, 25, 0.55);
  border: 1px solid #2a3848;
}

.app-help-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--text);
}

.app-help-card p {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.app-help-card .btn-link,
.app-help-card button {
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}

.app-help-steps {
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  border-top: 1px solid #2a3848;
}

.app-help-steps h3 {
  margin: 0 0 0.45rem;
  font-size: 0.9rem;
}

.app-help-steps ol {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

.app-help-steps li + li {
  margin-top: 0.35rem;
}

.app-help-steps strong {
  color: var(--text);
  font-weight: 600;
}

.login-app-hint {
  margin: 0.65rem 0 0;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
}

.modal-content.app-modal-content {
  width: min(92vw, 640px);
  max-width: min(92vw, 640px);
  max-height: 85vh;
  padding: 0;
  overflow-y: auto;
  border-radius: 16px;
  border: 1px solid rgba(61, 158, 229, 0.22);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.app-modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

/* ============================================================
   Marker Edit Modal
   ============================================================ */

#marker-edit-modal .modal-content {
  max-width: 520px;
  width: 94%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

#marker-edit-modal h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.marker-edit-field {
  margin-bottom: 1rem;
}

.marker-category-hint {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.marker-category-hint.hidden {
  display: none;
}

.marker-edit-field label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.marker-edit-field input,
.marker-edit-field textarea,
.marker-edit-field select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

.marker-edit-field input:focus,
.marker-edit-field textarea:focus,
.marker-edit-field select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Icon type selector */
.icon-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.icon-picker-search {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}

.icon-picker-search:focus {
  outline: none;
  border-color: var(--accent);
}

.icon-picker-empty {
  grid-column: 1 / -1;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.marker-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.35rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.marker-icon-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0.55rem 0.25rem;
  border: 2px solid #2a3848;
  border-radius: 10px;
  background: rgba(42, 56, 72, 0.4);
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s;
  line-height: 1.2;
  text-align: center;
}

.marker-icon-btn .icon-emoji {
  font-size: 1.4rem;
  line-height: 1;
  font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Segoe UI", sans-serif;
}

.marker-icon-btn:hover {
  border-color: var(--accent);
  background: rgba(61, 158, 229, 0.12);
  transform: translateY(-1px);
}

.marker-icon-btn.selected {
  border-color: var(--accent);
  background: rgba(61, 158, 229, 0.2);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Image upload */
.marker-img-drop {
  border: 2px dashed #2a3848;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.marker-img-drop:hover,
.marker-img-drop.dragover {
  border-color: var(--accent);
  background: rgba(61, 158, 229, 0.06);
}

.marker-img-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.marker-img-hint {
  color: var(--muted);
  font-size: 0.82rem;
  pointer-events: none;
}

.marker-img-preview {
  display: none;
  margin-top: 0.75rem;
  position: relative;
}

.marker-img-preview img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: block;
  margin: 0 auto;
}

.marker-img-clear {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.marker-img-clear:hover { background: var(--error); }

/* Modal actions row */
.marker-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  justify-content: flex-end;
}

.marker-edit-actions button {
  padding: 0.5rem 1.2rem;
  font-size: 0.9rem;
}

/* ============================================================
   POI / Server marker edit modal
   ============================================================ */

#poi-edit-modal .poi-edit-modal-content {
  width: min(94vw, 760px);
  max-width: 760px;
  max-height: min(90vh, 820px);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
}

#poi-edit-modal .profile-modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #2a3848;
  flex-shrink: 0;
}

#poi-edit-modal .profile-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

#poi-edit-modal .poi-edit-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem 0.75rem;
}

#poi-edit-modal .poi-edit-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem 1rem;
  align-items: end;
  margin-bottom: 0.25rem;
}

#poi-edit-modal .poi-edit-coords {
  display: grid;
  grid-template-columns: auto minmax(88px, 110px) auto minmax(88px, 110px);
  gap: 0.35rem 0.5rem;
  align-items: center;
}

#poi-edit-modal .poi-edit-coords label {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

#poi-edit-modal .poi-edit-coords input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}

#poi-edit-modal .poi-edit-body .marker-edit-field {
  margin-bottom: 0.85rem;
}

#poi-edit-modal .poi-edit-body .marker-edit-field:last-child {
  margin-bottom: 0;
}

#poi-edit-modal .icon-picker-wrap {
  margin-top: 0.35rem;
}

#poi-edit-modal .icon-picker-search {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

#poi-edit-modal .icon-picker-search:focus {
  outline: none;
  border-color: var(--accent);
}

#poi-edit-modal .icon-picker-empty {
  grid-column: 1 / -1;
  padding: 0.65rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

#poi-edit-modal .icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.4rem;
  max-height: 168px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.45rem;
  border: 1px solid #2a3848;
  border-radius: 10px;
  background: rgba(15, 24, 38, 0.55);
}

#poi-edit-modal .icon-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  min-width: 0;
}

#poi-edit-modal .icon-option.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

#poi-edit-modal .icon-option-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
  font-family: "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Segoe UI", sans-serif;
}

#poi-edit-modal .icon-option-glyph--emoji {
  font-size: 15px;
  font-weight: 400;
  color: inherit;
}

#poi-edit-modal .icon-option-label {
  font-size: 0.72rem;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#poi-edit-modal .poi-edit-file-field input[type="file"] {
  width: 100%;
  font-size: 0.85rem;
}

#poi-edit-modal .poi-edit-footer {
  flex-shrink: 0;
  margin: 0;
  padding: 0.85rem 1.25rem 1rem;
  border-top: 1px solid #2a3848;
  background: rgba(15, 24, 38, 0.35);
}

@media (max-width: 640px) {
  #poi-edit-modal .poi-edit-top-grid {
    grid-template-columns: 1fr;
  }

  #poi-edit-modal .poi-edit-coords {
    grid-template-columns: auto 1fr auto 1fr;
  }

  #poi-edit-modal .icon-picker {
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    max-height: 140px;
  }
}

/* In-popup image thumbnail */
.marker-popup-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}

.marker-popup-avatar-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--user-color, #3d9ee5);
  overflow: hidden;
  background: #e8edf4;
}

.marker-popup-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.marker-popup-head-text {
  min-width: 0;
  line-height: 1.25;
}

.marker-popup-head-text b {
  display: block;
  font-size: 0.95rem;
}

.marker-popup-author {
  display: block;
  color: #555;
  font-size: 0.78rem;
  margin-top: 1px;
}

.marker-popup-img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  max-height: 160px;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.15);
  margin: 0.4rem 0;
  cursor: zoom-in;
}

.traders-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.traders-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.traders-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.traders-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  background: var(--panel);
  border: 1px solid #2a3848;
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
}

.traders-controls label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.traders-controls label:has(#traders-search-input) {
  flex: 1 1 220px;
}

.traders-controls input[type="number"] {
  width: 6.5rem;
}

.traders-controls #traders-reset-btn {
  align-self: flex-end;
}

.traders-meta {
  color: var(--muted);
  font-size: 0.9rem;
  padding-bottom: 0.45rem;
  margin-left: auto;
}

.traders-results {
  background: var(--panel);
  border: 1px solid #2a3848;
  border-radius: 10px;
  overflow: auto;
  max-height: calc(100vh - 220px);
}

.traders-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.traders-table th,
.traders-table td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid #2a3848;
  font-size: 0.87rem;
}

.traders-table thead th {
  position: sticky;
  top: 0;
  background: #1d2a3a;
  z-index: 2;
}

@media (max-width: 860px) {
  .traders-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .traders-controls label:has(#traders-search-input) {
    flex: initial;
  }

  .traders-meta {
    margin-left: 0;
  }
}

#marker-image-modal {
  z-index: 2600;
  background: rgba(0, 0, 0, 0.8);
  padding: 1rem;
  box-sizing: border-box;
}

.image-modal-content {
  position: relative;
  width: min(92vw, 1100px);
  max-width: min(92vw, 1100px);
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  padding: 0.75rem;
  background: rgba(12, 16, 22, 0.96);
  border: 1px solid #2a3848;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

#marker-image-full {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 4rem);
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
}

.image-modal-close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  min-width: 32px;
  padding: 0.2rem 0.5rem;
}

/* Popup edit button */
.marker-edit-btn,
.poi-edit-btn {
  background: #27ae60;
  color: #fff;
}

.marker-edit-btn:hover,
.poi-edit-btn:hover {
  background: #2ecc71;
}

.marker-geo-edit-btn {
  background: #8e44ad;
  color: #fff;
}

.marker-geo-edit-btn:hover {
  background: #9b59b6;
}

.poi-delete-btn {
  background: #c0392b;
  color: #fff;
}

.poi-delete-btn:hover {
  background: #e74c3c;
}

.marker-geo-field {
  padding: 0.7rem;
  border: 1px solid #2a3848;
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.35);
}

.marker-color-grid {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.marker-color-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.marker-color-grid input[type="color"] {
  width: 42px;
  height: 28px;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: transparent;
  padding: 0;
}

.marker-color-grid select {
  min-width: 116px;
  padding: 0.22rem 0.35rem;
  border: 1px solid #2a3848;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
