/* ═══════════════════════════════════════════════════
   LGRO World Map — Integrated Dark Fantasy Theme
   Three-column layout: sidebar | map | legend
   ═══════════════════════════════════════════════════ */

/* ── Page-level overrides ── */
body[data-page="worldmap"] .scroll-progress { display: none; }
body[data-page="worldmap"] {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Slim footer */
body[data-page="worldmap"] .site-footer {
  background: var(--void);
  border-top: 1px solid var(--gold-05);
  flex-shrink: 0;
  padding: 4px 0;
}
body[data-page="worldmap"] .site-footer .footer-bottom { padding: 0; }
body[data-page="worldmap"] .site-footer .footer-copy { font-size: 0.62rem; margin: 0; opacity: 0.5; }

/* ── Main container ── */
.worldmap-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding-top: 64px; /* Push below fixed header */
}

/* ── Toolbar ── */
.wm-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  background: linear-gradient(180deg, var(--deep) 0%, var(--void) 100%);
  border-bottom: 1px solid var(--gold-08);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.wm-toolbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 5%;
  right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-20), var(--gold-35), var(--gold-20), transparent);
}

.wm-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.wm-status {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 88px;
  font-size: 0.78rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--text);
}

#wm-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
  flex-shrink: 0;
}
#wm-status-dot.online { background: var(--online); box-shadow: 0 0 6px var(--online), 0 0 12px var(--online-glow); animation: wm-glow-dot 2s ease-in-out infinite; }
@keyframes wm-glow-dot {
  0%, 100% { box-shadow: 0 0 6px var(--online), 0 0 12px var(--online-glow); }
  50% { box-shadow: 0 0 8px var(--online), 0 0 18px var(--online-glow); }
}
#wm-status-dot.offline { background: var(--error); }
#wm-status-dot.loading { background: #fbbf24; animation: wm-pulse-dot 1s infinite; }

@keyframes wm-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.wm-counts {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  border: 1px solid var(--gold-06);
  border-radius: 12px;
  padding: 2px 10px;
  background: rgba(16, 14, 30, 0.4);
}

.wm-count-label { color: var(--text-dim); }
.wm-count-val { font-weight: bold; color: var(--gold); }
.wm-count-val.online { color: var(--online); }
.wm-count-sep { color: var(--text-muted); }

.wm-toolbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

#search-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-width: 160px;
}

#search-input {
  width: 100%;
  padding: 7px 14px 7px 32px;
  background: var(--void);
  border: 1px solid var(--gold-08);
  border-radius: 4px;
  color: var(--gold-pale);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 1;
  transition: color 0.3s;
}
#search-input:focus ~ .search-icon,
#search-wrap:focus-within .search-icon { color: var(--gold-dim); }

#search-input::placeholder { color: var(--text-muted); }
#search-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 1px 0 0 var(--gold-dim), 0 0 0 1px var(--gold-10), inset 0 1px 3px rgba(0,0,0,0.3);
}

#search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 400px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--gold-08);
  border-top: none;
  border-radius: 0 0 4px 4px;
  z-index: 300;
  box-shadow: 0 12px 32px rgba(0,0,0,0.7);
}

.wm-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

/* Tool buttons in toolbar */
.wm-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--deep);
  border: 1px solid var(--gold-08);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
  padding: 0;
}

.wm-tool-btn svg {
  width: 18px;
  height: 18px;
}

.wm-tool-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.wm-tool-btn.active {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: var(--gold-06);
  box-shadow: 0 0 8px var(--gold-08);
}

/* ── Viewport: map fills entire area, panels overlay ── */
.wm-viewport {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #132030;
}

/* ── Side panels — floating overlays ── */
.wm-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: rgba(12, 10, 24, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  z-index: 20;
  box-shadow: inset 0 0 0 1px var(--gold-05);
}

.wm-panel-left {
  left: 0;
  width: 260px;
  border-right: 1px solid var(--gold-10);
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--gold-05);
}

.wm-panel-right {
  right: 0;
  width: 290px;
  border-left: 1px solid var(--gold-10);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--gold-05);
}

.wm-panel-left.wm-panel-hidden {
  transform: translateX(-100%);
  opacity: 0;
  pointer-events: none;
}

.wm-panel-right.wm-panel-hidden {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

.wm-panel-header {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gold-15);
  background: linear-gradient(180deg, var(--gold-06) 0%, transparent 100%);
  flex-shrink: 0;
  white-space: nowrap;
}

.wm-panel-title {
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--gold);
  letter-spacing: 0.8px;
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.wm-panel-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.2s;
}
.wm-panel-close:hover { color: var(--error); }

.wm-panel-body {
  overflow-y: auto;
  padding: 8px 10px;
  flex: 1;
  min-height: 0;
}

/* ── Map container — fills entire viewport ── */
.worldmap-page .map-wrap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: #132030;
}

/* Inner wrapper — absolute fills container, flex-centers the image */
.map-inner {
  position: absolute;
  top: 6px; left: 0; right: 0; bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.map-inner img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* Canvas and hit-layer: positioned by JS to match the image exactly */
.map-inner canvas {
  position: absolute;
  pointer-events: none;
}

#hit-layer {
  position: absolute;
  cursor: crosshair;
  z-index: 10;
}

#hit-layer.mag-active { cursor: none; }

/* ── Magnifier lens ── */
#magnifier {
  position: absolute;
  width: 160px; height: 160px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.5), 0 0 0 4px var(--gold-20), 0 4px 16px rgba(0,0,0,0.6), inset 0 0 8px rgba(0,0,0,0.3);
  pointer-events: none;
  display: none;
  z-index: 50;
  overflow: hidden;
  background: var(--void);
}
#mag-canvas { width: 160px; height: 160px; border-radius: 50%; }
#mag-crosshair {
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  border: 1px solid var(--gold-50);
  border-radius: 50%;
  pointer-events: none;
}

/* ── Tooltip ── */
#tooltip {
  display: none;
  position: absolute;
  background: rgba(8, 5, 16, 0.96);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--gold-pale);
  pointer-events: none;
  z-index: 60;
  max-width: 400px;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
}
#tooltip .tt-map { font-family: 'Cinzel', serif; color: var(--gold); font-size: 0.88rem; margin-bottom: 4px; letter-spacing: 0.3px; }
#tooltip .tt-char { color: var(--text); }
#tooltip .tt-char.offline { color: var(--text-dim); }
#tooltip .tt-char .lvl { color: #8b9dc3; font-size: 0.78rem; }
#tooltip .tt-char .job { color: #6e9a5e; font-size: 0.78rem; }
#tooltip .tt-char .status-on { color: var(--online); font-size: 0.72rem; }
#tooltip .tt-char .status-off { color: var(--text-dim); font-size: 0.72rem; font-style: italic; }

/* ── Search result items ── */
.search-group { padding: 4px 0; border-bottom: 1px solid var(--gold-05); }
.search-group:last-child { border-bottom: none; }
.search-group-label { padding: 4px 12px 2px; font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; font-family: 'Cinzel', serif; }
.search-item { padding: 6px 12px; cursor: pointer; font-size: 0.8rem; color: var(--text); transition: background 0.15s; }
.search-item:hover { background: var(--gold-04); }
.search-item .si-map { color: var(--text-dim); font-size: 0.72rem; margin-left: 6px; }
.search-item .si-badge { display: inline-block; padding: 1px 5px; border-radius: 2px; font-size: 0.6rem; margin-right: 4px; vertical-align: middle; letter-spacing: 0.5px; font-weight: bold; }
.si-badge.map-badge { background: #1a2838; color: #6898b8; }
.si-badge.city-badge { background: #2a2410; color: var(--gold); }
.si-badge.npc-badge { background: #1a2818; color: #6e9a5e; }
.si-badge.mob-badge { background: #2a1818; color: #c87070; }
.si-badge.mvp-badge { background: #3a2410; color: var(--ember); }
.si-badge.player-badge { background: #102838; color: #58b8d8; }

/* ── Sidebar content ── */
.sidebar-section { margin-bottom: 6px; }
.worldmap-page .sidebar-section h2 {
  font-family: 'Cinzel', serif;
  font-size: 0.76rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 3px;
  transition: background 0.2s;
}
.worldmap-page .sidebar-section h2:hover { background: rgba(255,255,255,0.03); }
.worldmap-page .sidebar-section h2.online-header { color: var(--online); }
.worldmap-page .sidebar-section h2.offline-header { color: var(--text-dim); }

.sidebar-arrow {
  display: inline-block;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-dim);
  transition: transform 0.25s ease;
}
.sidebar-arrow.collapsed { transform: rotate(-90deg); }
.section-arrow { margin-left: 4px; vertical-align: middle; }

.player-list-wrap { display: flex; flex-direction: column; gap: 3px; }

.player-tag {
  background: rgba(16, 14, 30, 0.6);
  border: 1px solid var(--gold-08);
  border-radius: 3px;
  padding: 4px 7px;
  font-size: 0.82rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-tag:hover { border-color: var(--gold-dim); color: var(--gold); background: var(--gold-03); }
.player-tag.offline { color: var(--text-dim); border-color: var(--gold-05); }
.player-tag.offline:hover { border-color: var(--text-dim); color: var(--text); background: rgba(255,255,255,0.02); }
.player-tag .tag-lvl { color: #8b9dc3; font-size: 0.78rem; }
.player-tag.offline .tag-lvl { color: var(--text-muted); }

#unmapped-info { margin-top: 8px; padding: 0 6px; font-size: 0.82rem; color: var(--text-dim); font-style: italic; }

/* ── Legend content ── */
.legend-ornament { color: var(--gold-30); font-size: 0.64rem; }

.legend-section { margin-top: 0; padding-top: 0; }
.legend-section h3 {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--gold-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ls-icon { font-size: 0.68rem; color: var(--gold-30); }

.legend-divider { display: flex; align-items: center; padding: 5px 0; }
.legend-divider span { display: block; width: 100%; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-15), var(--gold-25), var(--gold-15), transparent); }

.legend-row { display: flex; align-items: center; gap: 5px; padding: 1px 0; font-size: 0.78rem; }
.legend-key { color: var(--text); white-space: nowrap; flex-shrink: 0; }
.legend-val { color: var(--text-dim); font-size: 0.72rem; }

.legend-swatch { display: inline-block; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.legend-swatch.on-swatch { background: var(--online); box-shadow: 0 0 4px var(--online); }
.legend-swatch.off-swatch { background: var(--text-muted); border: 1px solid var(--text-dim); }

.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; }
.legend-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.legend-badge-row { display: flex; align-items: center; gap: 3px; }
.legend-badge-row .dl-cat { font-size: 0.66rem; padding: 1px 4px; flex-shrink: 0; }
.legend-desc { font-size: 0.7rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Detail panel overlay ── */
#detail-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 3, 8, 0.88);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wm-fadeIn 0.2s;
  backdrop-filter: blur(2px);
}
#detail-overlay.hidden { display: none; }

@keyframes wm-fadeIn { from { opacity: 0; } to { opacity: 1; } }

#detail-panel {
  background: var(--panel);
  border: 1px solid var(--gold-08);
  border-radius: 6px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8), 0 0 0 1px rgba(0,0,0,0.3);
  position: relative;
}

#detail-close {
  position: absolute;
  top: 10px; right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}
#detail-close:hover { color: var(--error); background: rgba(192, 96, 96, 0.15); }

#detail-header {
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--gold-05);
  background: linear-gradient(180deg, var(--gold-02) 0%, transparent 100%);
  position: relative;
}
#detail-header h2 { font-family: 'Cinzel', serif; color: var(--gold); font-size: 1.1rem; font-weight: 400; letter-spacing: 0.5px; margin-right: 40px; }
#detail-level { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; }
.detail-level-badge { display: inline-block; padding: 2px 10px; border: 1px solid rgba(139, 157, 195, 0.3); border-radius: 12px; color: #8b9dc3; font-size: 0.72rem; font-family: 'Cormorant Garamond', Georgia, serif; background: rgba(139, 157, 195, 0.06); white-space: nowrap; }
.detail-map-key { font-family: 'Courier New', Consolas, monospace; font-size: 0.7rem; font-weight: normal; color: var(--text-muted); letter-spacing: 0; }
#detail-connected { margin-top: 4px; font-size: 0.75rem; }
#detail-connected.hidden { display: none; }
.conn-label { color: var(--text-dim); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.5px; }
.conn-link { color: var(--gold-dim); text-decoration: none; transition: color 0.2s; cursor: pointer; }
.conn-link:hover { color: var(--gold); text-decoration: underline; }
.conn-link::before { content: '⟡ '; font-size: 0.6rem; opacity: 0.6; }

/* Floor tabs */
#detail-floors { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 24px; border-bottom: 1px solid var(--gold-05); }
#detail-floors.hidden { display: none; }
.floor-tab { padding: 4px 12px; border: 1px solid var(--gold-08); border-radius: 3px; font-size: 0.75rem; font-family: 'Cormorant Garamond', Georgia, serif; color: var(--text-dim); background: transparent; cursor: pointer; transition: all 0.2s; }
.floor-tab:hover { border-color: var(--text-muted); color: var(--text); }
.floor-tab.active { border-color: var(--gold-dim); color: var(--gold); background: var(--gold-06); }

/* Detail body */
#detail-body { display: flex; gap: 0; min-height: 300px; }
#detail-left { width: 280px; min-width: 280px; border-right: 1px solid var(--gold-05); padding: 16px; }
#detail-preview { position: relative; width: 100%; aspect-ratio: 1; background: var(--void); border: 1px solid var(--gold-05); border-radius: 4px; overflow: hidden; margin-bottom: 12px; box-shadow: inset 0 0 20px rgba(0,0,0,0.3); }
#detail-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
#detail-preview::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 50%, rgba(8,5,16,0.35) 100%); pointer-events: none; }

.preview-dot { position: absolute; width: 10px; height: 10px; margin-left: -5px; margin-top: -5px; background: #ff3030; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 6px rgba(255, 48, 48, 0.8), 0 0 12px rgba(255, 48, 48, 0.4); z-index: 5; pointer-events: none; }
.preview-dot.hidden { display: none; }
.preview-dot.blink { animation: wm-dotBlink 1.5s ease-in-out infinite; }
@keyframes wm-dotBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

#detail-chars h3, #detail-npcs h3, #detail-mobs h3 { font-family: 'Cinzel', serif; font-size: 0.78rem; font-weight: 400; color: var(--gold); margin-bottom: 8px; letter-spacing: 0.5px; }
#detail-char-list { font-size: 0.78rem; max-height: 200px; overflow-y: auto; }
.dc-char { padding: 3px 0; display: flex; align-items: center; gap: 6px; }
.dc-char .dc-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dc-dot.on { background: var(--online); box-shadow: 0 0 4px var(--online); }
.dc-dot.off { background: var(--text-muted); }
.dc-char .dc-name { color: var(--text); }
.dc-char.off-char .dc-name { color: var(--text-dim); }
.dc-char .dc-info { color: var(--text-dim); font-size: 0.72rem; }
#detail-right { flex: 1; padding: 16px; overflow-y: auto; max-height: calc(85vh - 60px); min-height: 0; }
#detail-npcs, #detail-mobs { overflow: hidden; }
#detail-mobs { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gold-05); }

/* Filter pills */
.worldmap-page .filter-pills { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.worldmap-page .filter-pill { padding: 3px 10px; border: 1px solid var(--gold-08); border-radius: 12px; font-size: 0.7rem; font-family: 'Cormorant Garamond', Georgia, serif; color: var(--text-dim); background: transparent; cursor: pointer; transition: all 0.2s; }
.worldmap-page .filter-pill:hover { border-color: var(--text-muted); color: var(--text); }
.worldmap-page .filter-pill.active { border-color: var(--gold-dim); color: var(--gold); background: var(--gold-06); }

/* NPC/Mob lists */
.worldmap-page .detail-list { max-height: 260px; overflow-y: auto; }
.dl-item { padding: 6px 4px; font-size: 0.78rem; border-bottom: 1px solid rgba(8, 5, 16, 0.6); display: flex; align-items: baseline; gap: 6px; border-radius: 3px; }
.dl-item:last-child { border-bottom: none; }
.dl-clickable { cursor: pointer; transition: background 0.15s, border-color 0.15s; border-left: 2px solid transparent; }
.dl-clickable:hover { background: var(--gold-03); border-left-color: var(--gold-20); }
.dl-clickable.dl-selected { background: #1e1428; border-left: 2px solid #ff3030; padding-left: 4px; }
.dl-cat { display: inline-block; padding: 1px 5px; border-radius: 2px; font-size: 0.62rem; text-transform: uppercase; flex-shrink: 0; letter-spacing: 0.3px; }
.dl-cat.cat-service { background: #142420; color: #5e9a7e; }
.dl-cat.cat-shop { background: #24240e; color: #9a985e; }
.dl-cat.cat-guide { background: #141a24; color: #5e7a9a; }
.dl-cat.cat-quest { background: #241424; color: #9a5e9a; }
.dl-cat.cat-event { background: #241e0e; color: #c89830; }
.dl-cat.cat-warp { background: #141428; color: #4858a0; }
.dl-cat.cat-other { background: #181818; color: #787878; }
.dl-cat.cat-normal { background: #181818; color: #787878; }
.dl-cat.cat-boss { background: #2a1818; color: #c87070; }
.dl-cat.cat-mvp { background: #3a2010; color: var(--ember); font-weight: bold; }
.dl-name { color: var(--text); }
.dl-coord { color: var(--text-muted); font-size: 0.68rem; }
.dl-random { font-style: italic; color: var(--text-dim); }
.dl-count { color: var(--text-dim); font-size: 0.72rem; }
.dl-level { color: #8b9dc3; font-size: 0.68rem; }
.dl-empty { color: var(--text-muted); font-style: italic; font-size: 0.78rem; padding: 8px 0; }

/* ── Themed scrollbars ── */
.wm-panel-body, #detail-panel, .detail-list, #detail-char-list, #search-results, #detail-right {
  scrollbar-width: thin;
  scrollbar-color: var(--gold-10) var(--void);
}
.wm-panel-body::-webkit-scrollbar, #detail-panel::-webkit-scrollbar, .detail-list::-webkit-scrollbar, #detail-char-list::-webkit-scrollbar, #search-results::-webkit-scrollbar, #detail-right::-webkit-scrollbar { width: 5px; }
.wm-panel-body::-webkit-scrollbar-track, #detail-panel::-webkit-scrollbar-track, .detail-list::-webkit-scrollbar-track, #detail-char-list::-webkit-scrollbar-track, #search-results::-webkit-scrollbar-track, #detail-right::-webkit-scrollbar-track { background: var(--void); }
.wm-panel-body::-webkit-scrollbar-thumb, #detail-panel::-webkit-scrollbar-thumb, .detail-list::-webkit-scrollbar-thumb, #detail-char-list::-webkit-scrollbar-thumb, #search-results::-webkit-scrollbar-thumb, #detail-right::-webkit-scrollbar-thumb { background: var(--gold-10); border-radius: 3px; }

/* ── Powered-by badge ── */
body[data-page="worldmap"] .footer-bottom { position: relative; }
.powered-by-badge {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
  white-space: nowrap;
  border-left: 1px solid var(--gold-10);
  padding-left: 10px;
}
.powered-by-badge:hover { color: var(--gold-dim); }
.powered-by-badge strong { font-weight: 600; }

/* ── Ad slots ── */
.wm-ad-leaderboard {
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--void);
  border-bottom: 1px solid var(--gold-05);
  padding: 6px 0;
  flex-shrink: 0;
}
.wm-ad-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gold-05);
  display: flex;
  justify-content: center;
}
.wm-ad-placeholder {
  width: 728px;
  max-width: 100%;
  height: 90px;
  border: 1px dotted var(--gold-06);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.5;
  background: rgba(16, 14, 30, 0.3);
  letter-spacing: 1px;
}
.wm-ad-placeholder-rect {
  width: 300px;
  height: 250px;
}

/* ── Changelog modal ── */
#changelog-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(4, 3, 8, 0.88);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: wm-fadeIn 0.2s;
  backdrop-filter: blur(2px);
}
#changelog-overlay.hidden { display: none; }

#changelog-panel {
  background: var(--panel);
  border: 1px solid var(--gold-08);
  border-radius: 6px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8), 0 0 0 1px rgba(0,0,0,0.3);
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--gold-10) var(--void);
}
#changelog-panel::-webkit-scrollbar { width: 5px; }
#changelog-panel::-webkit-scrollbar-track { background: var(--void); }
#changelog-panel::-webkit-scrollbar-thumb { background: var(--gold-10); border-radius: 3px; }

#changelog-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  line-height: 1;
  transition: color 0.2s;
}
#changelog-close:hover { color: var(--error); }

#changelog-header {
  padding: 18px 24px 12px;
  border-bottom: 1px solid var(--gold-05);
  background: linear-gradient(180deg, var(--gold-02) 0%, transparent 100%);
}
#changelog-header h2 {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.5px;
  margin: 0;
}

#changelog-body { padding: 16px 24px; }

.cl-entry { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--gold-05); }
.cl-entry:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.cl-date {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.cl-title {
  font-family: 'Cinzel', serif;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--gold-pale);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.cl-body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.6;
}
.cl-body p { margin: 0 0 6px; }
.cl-body p:last-child { margin-bottom: 0; }
.cl-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  text-align: center;
  padding: 24px 0;
}

/* ── Map loader ── */
.map-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 15;
  transition: opacity 0.5s ease;
}
.map-loader.loaded { opacity: 0; pointer-events: none; }
.map-loader span {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.82rem;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.map-loader-ring {
  width: 36px;
  height: 36px;
  border: 2px solid var(--gold-10);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: wm-spin 0.8s linear infinite;
}
@keyframes wm-spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 900px) {
  .wm-toolbar { flex-wrap: wrap; gap: 6px; padding: 5px 10px; }
  .wm-toolbar-left { order: 2; }
  .wm-toolbar-center { order: 1; flex-basis: 100%; }
  .wm-toolbar-right { order: 3; margin-left: auto; }
  #search-wrap { max-width: none; }

  .wm-panel-left { width: 210px; }
  .wm-panel-right { width: 240px; }
}

@media (max-width: 700px) {
  #detail-body { flex-direction: column; }
  #detail-left { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--gold-05); }
  #detail-preview { width: 100%; height: auto; aspect-ratio: 1; }
  #detail-right { max-height: none; }

  .wm-panel-left, .wm-panel-right { width: 240px; }
}
