:root {
  --ink: #3a2614;
  --ink-soft: #6b5238;
  --parchment: #f7eed6;
  --parchment-2: #efe2c0;
  --edge: #8a6a3e;
  --roll: #3f6fb5;
  --roll-dark: #24497f;
  --accent: #2f7fd6;
  --panel-w: 380px;
  --font: "Fredoka", "Segoe UI", system-ui, sans-serif;
  --font-title: "Alegreya SC", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #4aa6dc;
  font-family: var(--font);
  color: var(--ink);
}

#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  cursor: grab;
  touch-action: none;
}
#map.dragging { cursor: grabbing; }
#map.pointing { cursor: pointer; }

.card {
  background: var(--parchment);
  border: 2px solid var(--edge);
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(58, 38, 20, .35), 0 8px 24px rgba(0, 0, 0, .18);
}

/* ---------- HUD (top left) ---------- */
#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 240px;
  z-index: 5;
}

.title-scroll {
  display: flex;
  align-items: stretch;
  filter: drop-shadow(0 3px 0 rgba(58, 38, 20, .35));
}
.title-scroll .roll {
  width: 14px;
  background: linear-gradient(90deg, var(--roll-dark), var(--roll) 45%, var(--roll-dark));
  border: 2px solid var(--ink);
  border-radius: 7px;
  margin: -4px 0;
}
.title-body {
  flex: 1;
  background: var(--parchment);
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  padding: 8px 10px 6px;
  text-align: center;
}
.title-main {
  font-family: var(--font-title);
  font-size: 24px;
  line-height: 1;
  border-bottom: 2px solid var(--ink-soft);
  padding-bottom: 4px;
}
.title-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 4px;
}

.controls {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.controls .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
}
.controls input[type=number] {
  width: 64px;
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  border: 2px solid var(--edge);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
  padding: 2px 4px;
}
.controls input[type=range] { width: 100%; accent-color: var(--accent); }
.controls input[type=search] {
  font: inherit;
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fffaf0;
  color: var(--ink);
}
.search-row {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--edge);
  border-radius: 8px;
  background: #fffaf0;
  overflow: hidden;
}
.search-row:focus-within { border-color: var(--ink); }
.controls .search-row input[type=search] {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: none;
}
.picker-btn {
  flex: none;
  width: 38px;
  border: 0;
  border-left: 2px solid var(--edge);
  background: #fff1c9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.picker-btn img { max-width: 30px; max-height: 26px; object-fit: contain; }
.picker-btn:hover { background: #ffe39a; }
.picker-btn.on { background: #d6f7f2; box-shadow: inset 0 0 0 2px #2aa89a; }
.search-hint {
  margin-top: -4px;
  border-radius: 6px;
  background: #d6f7f2;
  border: 1px solid #6fd3c6;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  flex-direction: column;
}
.search-hint[hidden], .hint-row[hidden] { display: none; }
.hint-row { display: flex; align-items: baseline; gap: 6px; padding: 3px 4px 3px 8px; }
.hint-row + .hint-row { border-top: 1px solid #6fd3c6; }
.hint-tag { flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #1d7d72; }
.hint-text { flex: 1; min-width: 0; }
.hint-row button { flex: none; border: 0; background: transparent; font-size: 16px; line-height: 1; cursor: pointer; color: var(--ink-soft); }
.hint-row button:hover { color: var(--ink); }

/* "Selected" chips at the top of the picker. */
.picked-chips { max-height: 72px; overflow-y: auto; }
.picked-chips button { display: inline-flex; align-items: center; gap: 4px; border-color: #2aa89a; background: #e3f9f5; padding: 1px 6px 1px 4px; }
.picked-chips button img { height: 18px; max-width: 24px; object-fit: contain; }
.picked-chips button b { font-size: 14px; line-height: 1; color: var(--ink-soft); margin-left: 2px; }
.picked-chips button:hover b { color: var(--ink); }

/* ---------- Monster picker dialog ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(20, 30, 50, .28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.dialog-backdrop[hidden] { display: none; }
.dialog {
  width: min(760px, 100%);
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}
/* Only the card grid shrinks (and scrolls) when the dialog hits its max height; every other
   row keeps its natural height, or the browser squashes the chip rows to slivers. */
.dialog > * { flex-shrink: 0; }
.dialog > .mob-grid { flex: 1 1 auto; min-height: 0; }
.dialog header { display: flex; align-items: center; justify-content: space-between; }
.dialog h2 { margin: 0; font-family: var(--font-title); font-size: 20px; }
.dialog .close { font-size: 26px; line-height: 1; border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.dialog .close:hover { color: var(--ink); }
#mobFilter {
  font: inherit;
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fffaf0;
  color: var(--ink);
}
.map-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; }
.map-chips[hidden] { display: none; }
.map-chips .chip-label { font-weight: 700; color: var(--ink-soft); }
.map-chips button {
  font: inherit; font-weight: 600;
  border: 1.5px solid var(--edge); border-radius: 999px;
  background: #fff6dc; color: var(--ink);
  padding: 2px 10px; cursor: pointer;
}
.map-chips button:hover { border-color: var(--ink); }
.mob-grid {
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  padding: 2px 4px 4px 2px;
}
.mob-card {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px 7px;
  border: 2px solid var(--edge);
  border-radius: 10px;
  background: #fffaf0;
  cursor: pointer;
  position: relative;
}
.mob-card:hover { border-color: var(--ink); }
/* NPC and item cards: a small icon instead of a sprite, so more fit. */
.mob-grid.tab-npcs, .mob-grid.tab-items { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.mob-card .sprite.small { height: 32px; align-items: center; }
.mob-card .sprite.small img { max-height: 32px; }
.mob-card .sprite.small .npc-chip { width: 16px; height: 16px; }
.mob-card.npc-card .mob-name, .mob-card.item-card .mob-name { color: var(--ink); text-shadow: none; } /* the outline is for difficulty colours */
.npc-card .mob-lv, .item-card .mob-lv { text-align: center; }

/* Monsters / NPCs / Items tabs. A tab with nothing matching the filter is greyed out. */
.picker-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--edge); }
.picker-tabs button {
  font: inherit; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; margin-bottom: -2px;
  border: 2px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0;
  background: transparent; color: var(--ink-soft); cursor: pointer;
}
.picker-tabs button:hover { color: var(--ink); }
.picker-tabs button.on { background: #fffaf0; border-color: var(--edge); color: var(--ink); }
.picker-tabs button.empty { opacity: .45; }
.picker-tabs .n { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--parchment-2); }
.picker-tabs .picks { font-size: 11px; font-weight: 700; color: #1d7d72; }
.mob-card.sel { border-color: #2aa89a; background: #e3f9f5; box-shadow: 0 0 0 2px #7fe3d6; }
.mob-card.sel::after {
  content: "✓"; position: absolute; top: 4px; right: 6px;
  font-weight: 700; color: #1f8a7e;
}
.mob-card .sprite { height: 72px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.mob-card .sprite img { max-height: 72px; max-width: 100%; object-fit: contain; image-rendering: auto; }
.mob-card .mob-name {
  font-weight: 700; font-size: 13px; line-height: 1.15; text-align: center;
  text-shadow: -1px -1px 0 #2b1a0e, 1px -1px 0 #2b1a0e, -1px 1px 0 #2b1a0e, 1px 1px 0 #2b1a0e,
    0 -1px 0 #2b1a0e, 0 1px 0 #2b1a0e, -1px 0 0 #2b1a0e, 1px 0 0 #2b1a0e;
}
.mob-card .mob-lv { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.mob-empty { grid-column: 1 / -1; text-align: center; color: var(--ink-soft); padding: 20px 0; }
.dialog footer { display: flex; align-items: center; gap: 8px; }
.dialog footer span { flex: 1; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.label-mode { display: flex; flex-direction: column; gap: 2px; }
.label-mode > label { font-weight: 600; }
.label-mode .ticks { display: flex; justify-content: space-between; font-size: 12px; }
.label-mode .ticks > span { cursor: pointer; padding: 0 2px; opacity: .6; }
.label-mode .ticks > span.on { font-weight: 700; opacity: 1; color: var(--ink); }
.check input { accent-color: var(--accent); }

.btn {
  font: inherit;
  font-weight: 600;
  border: 2px solid var(--ink);
  background: #ffd86b;
  color: var(--ink);
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
}
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; border-color: var(--edge); }
.btn.on { background: #ffb347; border-color: var(--ink); }

/* ---------- Legend (bottom left) ---------- */
#legend {
  position: fixed;
  left: 16px;
  bottom: 16px;
  padding: 10px 12px;
  font-size: 13px;
  z-index: 5;
  width: 240px;
}
#legend h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
#legend .lg-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
#legend .lg-row .range { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
#legend .shapes { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--edge); }
#legend .shapes span { display: inline-flex; align-items: center; gap: 4px; }
#legend .note { margin-top: 8px; font-size: 11px; color: var(--ink-soft); }

.chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  flex: none;
}

/* ---------- Zoom controls ---------- */
#zoomCtl {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 5;
  transition: right .25s ease;
}
#zoomCtl button {
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
#zoomCtl button + button { border-top: 1px solid var(--edge); }
#zoomCtl button:hover { background: var(--parchment-2); }
body.panel-open #zoomCtl { right: calc(var(--panel-w) + 16px); }

/* ---------- Side panel ---------- */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: var(--panel-w);
  max-width: 100vw;
  background: var(--parchment);
  border-left: 3px solid var(--edge);
  box-shadow: -8px 0 30px rgba(0, 0, 0, .25);
  transform: translateX(105%);
  transition: transform .25s ease;
  z-index: 10;
  overflow-y: auto;
  padding: 20px 20px 32px;
}
body.panel-open #panel { transform: none; }

#panel .close {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 26px;
  line-height: 1;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
#panel .close:hover { color: var(--ink); }

.p-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: #fff6dc;
}
.badge.town { background: #bfe3ff; }
.badge.hidden { background: #fff; border-style: dashed; }
.badge.dungeon { background: #e6dcf5; }
.badge.boss { background: #ffc8c0; }
.badge.underground { background: #3a3348; color: #e8e0ff; border-color: #241f30; }

#panel h2 {
  font-family: var(--font-title);
  font-size: 26px;
  line-height: 1.1;
  margin: 0 30px 4px 0;
}
.p-sub { color: var(--ink-soft); font-size: 14px; }

.p-level {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  font-weight: 600;
}
.p-level .big { font-size: 20px; font-weight: 700; }
.p-level .verdict { margin-left: auto; font-size: 13px; text-align: right; }

#panel section { margin-top: 18px; }
#panel h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-soft);
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid var(--parchment-2);
}

.mob-list { list-style: none; margin: 0; padding: 0; }
.mob-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px dashed var(--parchment-2);
}
.mob-list .lv { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.mob-list .why { font-size: 12px; color: var(--ink-soft); width: 92px; text-align: right; }
.mob-list .stats { font-size: 12px; color: var(--ink-soft); }
/* Found by search: the teal of the world map's rings and the search hint. */
.mob-list li.found { background: #d6f7f2; box-shadow: inset 3px 0 0 #2aa89a; padding-left: 9px; border-radius: 4px; }
.mob-list .sel-drops { display: block; font-size: 12px; font-weight: 600; color: #1d7d72; }
.mob-list .sel-drops[hidden] { display: none; }
.mob-list a, .p-sub a { color: inherit; text-decoration-color: var(--edge); }
.badge.verified { background: #d6f2c9; border-color: #2f6a27; color: #1f4a1a; }
.badge.draft { background: transparent; border-style: dashed; color: var(--ink-soft); border-color: var(--ink-soft); }
.boss-tag { font-size: 11px; font-weight: 700; color: #b3261e; margin-left: 4px; }

.links { display: flex; flex-direction: column; gap: 6px; }
.link-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  background: #fffaf0;
  border: 1.5px solid var(--edge);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--ink);
}
.link-btn:hover { background: #fff1c9; }
.link-btn .lv { margin-left: auto; font-size: 12px; color: var(--ink-soft); }
.link-btn .via { font-size: 11px; color: var(--ink-soft); }

.p-notes { font-size: 14px; line-height: 1.45; background: #fffaf0; border-left: 3px solid var(--edge); padding: 8px 10px; border-radius: 4px; }
.p-back {
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 12px;
  padding: 5px 12px 5px 8px;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: #fff6dc;
  color: var(--ink);
  cursor: pointer;
}
.p-back:hover { background: #fff1c9; border-color: var(--ink); }
.chip.building-chip { background: #f3ead2; border-radius: 3px; }
.p-meta { margin-top: 18px; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); font-size: 14px; }

/* ---------- Tooltip ---------- */
#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 20;
  background: rgba(40, 26, 12, .92);
  color: #fff8e6;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.35;
  display: none;
  max-width: 260px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
#tooltip b { font-weight: 600; }
#tooltip .tt-lv { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
#tooltip .chip { width: 10px; height: 10px; border-width: 1.5px; border-color: #fff8e6; }
/* Selected search entries on the hovered map; same light blue as the search hint. */
#tooltip .tt-hits {
  margin: 6px -4px -1px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #d6f7f2;
  border: 1px solid #6fd3c6;
  color: var(--ink);
  font-size: 12px;
}
#tooltip { max-width: 340px; }
#tooltip .tt-hit { font-weight: 600; display: flex; align-items: center; gap: 6px; }
#tooltip .tt-hit .tt-name { flex: 1; min-width: 0; }
/* A small monster sprite, about the text's height, so it doesn't dominate the tooltip. */
#tooltip .tt-mob { flex: none; width: 20px; height: 18px; object-fit: contain; }
#tooltip .tt-hit .rk-stars { margin-left: 8px; }
#tooltip .tt-hit .rk-stars { flex: none; font-size: 12px; }
#tooltip .tt-hits ul { margin: 0 0 2px; padding-left: 42px; } /* bullets line up under the name, past the sprite */
#tooltip .tt-kind { font-size: 10px; font-weight: 700; color: #1d7d72; }

/* Common drops, shown on hovering a monster card (picker) or monster row (panel). */
#dropTip {
  position: fixed;
  pointer-events: none;
  z-index: 60; /* above the picker dialog */
  background: rgba(40, 26, 12, .94);
  color: #fff8e6;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.3;
  width: 240px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
#dropTip .dt-head { font-weight: 600; }
#dropTip .dt-sub { font-size: 11px; opacity: .75; margin-bottom: 6px; }
#dropTip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
#dropTip li { display: flex; align-items: center; gap: 6px; }
#dropTip li img, #dropTip li .dt-noicon { width: 22px; height: 22px; object-fit: contain; flex: none; }
#dropTip li .dt-name { flex: 1; min-width: 0; }
#dropTip li .dt-name small { display: block; font-size: 10.5px; opacity: .65; }
#dropTip li .dt-rate { font-size: 11px; opacity: .8; font-variant-numeric: tabular-nums; }
#dropTip .dt-none { opacity: .75; font-style: italic; }

/* ---------- Edit bar ---------- */
#editBar {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  font-size: 13px;
  z-index: 6;
  background: #fff3c4;
}
body.editing #editBar { display: flex; }
#coords { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 110px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff8e6;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 720px) {
  :root { --panel-w: 100vw; }
  #hud { width: 200px; }
  #legend { display: none; }
  #editBar { flex-wrap: wrap; width: calc(100vw - 32px); }
}

/* ---------- Minimap (side panel) ---------- */
.minimap {
  position: relative;
  border: 1.5px solid var(--edge);
  border-radius: 8px;
  background: #2b2a33;
}
.minimap img { display: block; width: 100%; height: 100%; border-radius: 6.5px; }
.mm-portal {
  position: absolute;
  width: 16px;
  height: 16px;
  padding: 0;
  transform: translate(-50%, -75%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #d9f3ff, #3aa0ff 55%, #1d5fb3);
  box-shadow: 0 0 0 1.5px rgba(20, 30, 60, .55), 0 0 8px rgba(80, 180, 255, .8);
  cursor: pointer;
  transition: transform .12s;
}
.mm-portal.to-building { background: radial-gradient(circle at 40% 35%, #fff4d6, #f2b33d 55%, #b9741a); box-shadow: 0 0 0 1.5px rgba(60, 35, 10, .55), 0 0 8px rgba(255, 190, 80, .8); }
.mm-portal.off { background: radial-gradient(circle at 40% 35%, #eee, #9a9aa6 55%, #5c5c68); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .45); }
.mm-portal:hover, .mm-portal:focus-visible, .mm-portal.lit, .mm-portal.picked, .mm-portal.npc-hl, .mm-portal.npc-found { transform: translate(-50%, -75%) scale(1.3); z-index: 1; outline: none; }
/* NPC dots: small and quiet until hovered, clicked in the list (hl) or found by search. */
.mm-npc {
  position: absolute;
  width: 9px;
  height: 9px;
  transform: translate(-50%, -100%);
  border: 1.5px solid #3a2614;
  border-radius: 50%;
  background: #ffe27a;
  cursor: pointer;
  transition: width .12s, height .12s, box-shadow .12s;
}
.mm-npc:hover, .mm-npc.hl { width: 15px; height: 15px; z-index: 2; box-shadow: 0 0 0 2px #fff, 0 0 10px 2px rgba(255, 220, 90, .95); }
.mm-npc.found { width: 13px; height: 13px; z-index: 1; background: #7fe3d6; box-shadow: 0 0 0 2px #2aa89a, 0 0 10px 3px rgba(120, 230, 215, .9); }
.mm-portal.npc-found { box-shadow: 0 0 0 3px #7fe3d6, 0 0 12px 3px rgba(120, 230, 215, .9); }
/* Name above a pin or dot while it's hovered, focused or highlighted. */
.mm-portal::after, .mm-npc::after {
  content: attr(data-name);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(30, 22, 12, .92);
  color: #fff;
  font: 600 12px/1.2 var(--font);
  pointer-events: none;
  display: none; /* not just invisible: a hidden label would still widen the panel */
}
.mm-portal.edge-l::after, .mm-npc.edge-l::after { left: -6px; transform: none; }
.mm-portal.edge-r::after, .mm-npc.edge-r::after { left: auto; right: -6px; transform: none; }
.mm-portal:hover::after, .mm-portal:focus-visible::after, .mm-portal.lit::after, .mm-portal.picked::after, .mm-portal.npc-hl::after, .mm-portal.npc-found::after,
.mm-npc:hover::after, .mm-npc.hl::after, .mm-npc.found::after { display: block; }

/* NPC list rows */
.chip.npc-chip { background: #ffe27a; }
.npc-row.hl { background: #fff1c9; border-color: var(--ink); }
/* The clicked row in any list (NPCs, buildings, connected maps). */
.link-btn.picked { background: #fff1c9; border-color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
/* Pins into the clicked building/connected-map row keep a glow and their label. */
.mm-portal.picked { box-shadow: 0 0 0 3px #fff, 0 0 12px 3px rgba(80, 170, 255, .95); }
/* Found by search: the same teal as monster rows and the world map's rings. */
.npc-row.found { background: #d6f7f2; border-color: #2aa89a; }
.npc-row.found .npc-chip { background: #7fe3d6; box-shadow: 0 0 0 2px rgba(42, 168, 154, .5); }

/* ---------- Map rankings (the picker's subdialog) ---------- */
.btn.small { font-size: 12px; padding: 3px 8px; }
.btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.dialog.ranking > #pickedChips, .dialog.ranking > #mobFilter, .dialog.ranking > #mapChips,
.dialog.ranking > #pickerTabs, .dialog.ranking > #mobGrid, .dialog.ranking > footer { display: none; }
.dialog:not(.ranking) > .rank-only { display: none; }
.dialog > .rank-cards { flex: 1 1 auto; min-height: 0; }
.rank-head { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.rank-cards { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px 4px 4px 2px; }
.rank-card {
  --rk-row: 30px;
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
  padding: 10px;
  border: 2px solid var(--edge);
  border-radius: 10px;
  background: #fffaf0;
}
.rank-card.has-items { grid-template-columns: 120px minmax(0, 150px) 1fr; }
.rank-mob { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rank-mob .sprite { height: 72px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.rank-mob .sprite img { max-height: 72px; max-width: 100%; object-fit: contain; }
.rank-mob .mob-name {
  font-weight: 700; font-size: 13px; line-height: 1.15; text-align: center;
  text-shadow: -1px -1px 0 #2b1a0e, 1px -1px 0 #2b1a0e, -1px 1px 0 #2b1a0e, 1px 1px 0 #2b1a0e,
    0 -1px 0 #2b1a0e, 0 1px 0 #2b1a0e, -1px 0 0 #2b1a0e, 1px 0 0 #2b1a0e;
}
.rank-mob .mob-lv { font-size: 11px; color: var(--ink-soft); font-weight: 600; text-align: center; }
.rk-reset { font: inherit; font-size: 11px; font-weight: 600; border: 0; background: transparent; color: var(--accent); cursor: pointer; text-decoration: underline; }
.rank-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; }
.rank-items li { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; background: #d6f7f2; border: 1px solid #6fd3c6; }
.rank-items img { height: 22px; max-width: 26px; object-fit: contain; }
/* The map list is a fixed 10 rows tall and scrolls inside the card. */
.rank-list {
  list-style: none; margin: 0; padding: 0 2px 0 0;
  height: calc(10 * var(--rk-row));
  overflow-y: auto;
  border: 1px solid var(--parchment-2); border-radius: 8px; background: #fff;
}
.rank-tier {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 8px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  background: var(--parchment-2); color: var(--ink);
}
.rank-tier[data-tier="best"] { background: #cdeec9; }
.rank-tier[data-tier="okay"] { background: #f6e7b4; }
.rank-tier[data-tier="meh"] { background: #e6ddd0; }
.rk-stars { display: inline-flex; gap: 1px; font-size: 14px; line-height: 1; letter-spacing: 0; }
.rk-stars span { color: transparent; -webkit-text-stroke: 1px #9a8466; }
.label-mode .ticks .rk-stars { display: flex; font-size: 11px; justify-content: inherit; }
#rankTicks > span { display: flex; flex-direction: column; align-items: center; }
#rankTicks > span:first-child { align-items: flex-start; }
#rankTicks > span:last-child { align-items: flex-end; }
.rk-stars span.on { color: #f2b01e; -webkit-text-stroke: 1px #a8740a; }
.rank-tier .n { font-size: 11px; padding: 0 6px; border-radius: 999px; background: rgba(255,255,255,.7); }
.rank-empty { height: var(--rk-row); display: flex; align-items: center; padding: 0 10px; font-size: 12px; font-style: italic; color: var(--ink-soft); }
.rank-row {
  height: var(--rk-row);
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px 0 10px;
  font-size: 13px; font-weight: 600;
  border-top: 1px solid #f1e8d4;
  background: #fff;
}
.rank-row.dragging { background: #e3f9f5; box-shadow: 0 2px 8px rgba(0,0,0,.18); position: relative; z-index: 2; }
.rk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-in { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.rk-stat { flex: none; font-size: 11px; color: var(--ink-soft); }
.rk-find {
  flex: none; font: inherit; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--edge); border-radius: 999px; background: #fff6dc; color: var(--ink);
  padding: 0 10px; cursor: pointer;
}
.rk-find:hover { border-color: var(--ink); }
.rk-drag { flex: none; width: 22px; text-align: center; font-size: 18px; color: var(--ink-soft); cursor: grab; touch-action: none; user-select: none; }
.drag-active, .drag-active * { cursor: grabbing !important; user-select: none; }
@media (max-width: 600px) {
  .rank-card, .rank-card.has-items { grid-template-columns: 1fr; }
  .rk-stat { display: none; }
}

/* "Find in map" from the rankings: the HUD swaps its search and map toggles for this bar. */
.rank-focus-bar { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.rank-focus-bar[hidden] { display: none; }
.rank-focus-bar .btn.small { align-self: center; }
body.rank-focus #hud .search-row, body.rank-focus #searchHint, body.rank-focus #hud .check, body.rank-focus #editToggle { display: none; }
.rk-unranked { font-style: italic; }
.rank-list.rank-none { height: auto; min-height: 90px; display: flex; align-items: center; justify-content: center; padding: 16px; text-align: center; font-size: 13px; font-style: italic; color: var(--ink-soft); }
