/* ============================================================
   实时地图
   ============================================================ */

.map-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.map-head {
  margin-bottom: 0;
}

.map-count {
  min-width: 28px;
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

.map-chip {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.map-chip:hover {
  color: #fff;
  border-color: var(--brand-line);
}

.map-chip.warn {
  border-color: rgba(255, 196, 0, 0.4);
  color: #ffc400;
  background: rgba(255, 196, 0, 0.08);
}

.map-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #0d0816;
}

/* 顶部工具条：搜索 + 游戏过滤，压在瓦片上面 */
.map-toolbar {
  position: absolute;
  top: 12px;
  left: 48px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-search {
position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: rgba(8, 16, 24, 0.92);
  backdrop-filter: blur(10px);
  color: var(--muted);
  width: 232px;
  box-sizing: border-box;
}

.map-search svg {
  flex: 0 0 auto;
  opacity: 0.8;
}

.map-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 12px;
  outline: none;
}

.map-search-input::placeholder {
  color: var(--dim);
}

.map-search-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(8, 16, 24, 0.97);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.5);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.map-search-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: #e6f5ff;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.map-search-item:hover {
  background: rgba(0, 60, 91, 0.16);
}

.map-search-item em {
  margin-left: auto;
  font-style: normal;
  font-size: 10.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.map-search-empty {
  padding: 9px;
  font-size: 11.5px;
  color: var(--dim);
}

.map-filters {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: rgba(8, 16, 24, 0.92);
  backdrop-filter: blur(10px);
}

.map-filter {
  height: 26px;
  padding: 0 11px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.map-filter.on {
  background: linear-gradient(180deg, #0a5b83, #00344d);
  color: #fff;
}

.map-canvas {
  height: clamp(460px, calc(100vh - 230px), 860px);
  width: 100%;
  background: #0d0816;
}

/* Esri 的 World_Dark_Gray_Base 本身就是暗色瓦片，无需再反相；
   早期 OSM 亮色瓦片时期留下的滤镜已移除。 */
.leaflet-tile-pane {
  filter: none;
}

.map-canvas.tiles-down {
  background: repeating-linear-gradient(45deg, #140d1f, #140d1f 10px, #171024 10px, #171024 20px);
}

/* MapLibre 底图控件与面板主题对齐 */
.maplibregl-map {
  font-family: inherit;
}
.maplibregl-ctrl-group {
  background: rgba(8, 16, 24, 0.9);
  border: 1px solid rgba(90, 150, 190, 0.25);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.maplibregl-ctrl-group button {
  background: transparent;
}
.maplibregl-ctrl-group button + button {
  border-top-color: rgba(90, 150, 190, 0.2);
}
.maplibregl-ctrl-group button span {
  filter: invert(1) brightness(0.8);
}
.maplibregl-ctrl-attrib {
  background: rgba(5, 9, 13, 0.78) !important;
  border-radius: 6px;
  color: #93a8b8 !important;
  font-size: 10px !important;
}
.maplibregl-ctrl-attrib a {
  color: #6f8aa0 !important;
}

.map-city-label {
  padding: 1px 4px;
  color: #c8d5df;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.map-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  width: 288px;
  max-height: calc(100% - 24px);
  pointer-events: none;
}

.map-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 100%;
  overflow-y: auto;
  pointer-events: auto;
  padding-right: 2px;
}

.map-person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 20, 28, 0.92);
  backdrop-filter: blur(10px);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.map-person:hover {
  border-color: var(--brand-line);
  background: rgba(14, 28, 40, 0.95);
}

.map-person.nopos {
  opacity: 0.55;
  cursor: default;
}

.map-person-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1 1 auto;
}

.map-person-main strong {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-person-main span {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-person-job {
  color: var(--amber) !important;
}

.map-person-time {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.map-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(10, 20, 28, 0.94);
  backdrop-filter: blur(10px);
  color: var(--muted);
  text-align: center;
}

.map-empty svg {
  color: var(--amber);
  opacity: 0.9;
}

.map-empty strong {
  color: #fff;
  font-size: 13px;
}

.map-empty span {
  font-size: 11.5px;
  line-height: 1.5;
}

.map-empty .btn {
  margin-top: 4px;
}

/* -------------------------------------------------- 标记 */

.map-pin-wrap {
  background: transparent;
}

.map-pin {
  position: relative;
  width: 40px;
  height: 40px;
}

.map-pin-name {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 2px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(5, 11, 16, 0.82);
  color: #ecf7ff;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.map-pin.active .map-pin-dot {
  border-color: #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pin) 35%, transparent), 0 0 0 9px color-mix(in srgb, var(--pin) 18%, transparent);
}

.map-follow-tag {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
  background: linear-gradient(180deg, #0a5b83, #00344d);
  border-radius: 5px;
  padding: 1px 5px;
}

.map-person-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.map-person.following {
  border-color: var(--brand-line);
  background: rgba(18, 36, 51, 0.95);
}

.map-pin-dot {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--pin);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), 0 0 0 6px color-mix(in srgb, var(--pin) 22%, transparent);
}

.map-pin-arrow {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 0;
  height: 0;
  margin-left: -5px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--pin);
  transform-origin: 50% 24px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.map-tip {
  background: rgba(7, 13, 20, 0.95) !important;
  border: 1px solid var(--line-2) !important;
  color: #ecf7ff !important;
  font-size: 11.5px !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45) !important;
}

/* -------------------------------------------------- 校准弹窗 */

.calib {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calib-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.calib-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calib-label {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.calib-line {
  display: flex;
  gap: 8px;
}

.calib-line .input {
  flex: 1 1 auto;
}

.calib-note {
  font-size: 11.5px;
  color: var(--dim);
}

@media (max-width: 900px) {
  .map-toolbar {
    left: 10px;
    right: 10px;
    flex-wrap: wrap;
  }
  .map-search {
    width: 200px;
  }
  .map-overlay {
    position: static;
    width: auto;
    max-height: none;
    padding: 10px;
  }
  .map-people {
    flex-direction: row;
    overflow-x: auto;
  }
  .map-person {
    flex: 0 0 240px;
  }
}
