:root {
  --sea: #b4aeac;
  --ink: #f4ede0;
  --ink-2: #c9bfae;
  --ink-3: #9d937f;
  --panel: rgba(30, 27, 23, 0.93);
  --panel-line: rgba(255, 244, 220, 0.12);
  --accent: #f0c46a;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--sea); color: var(--ink); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; }

/* expansion colours: keep in step with EXPANSIONS in js/catalog.js (checked by a test) */
[data-exp="original"] { --c: #2563eb; }
[data-exp="zilart"] { --c: #d97706; }
[data-exp="cop"] { --c: #7c3aed; }
[data-exp="toau"] { --c: #dc2626; }
[data-exp="wotg"] { --c: #db2777; }
[data-exp="abyssea"] { --c: #0d9488; }
[data-exp="soa"] { --c: #16a34a; }
[data-exp="rov"] { --c: #0891b2; }
[data-exp="tvr"] { --c: #475569; }

/* ---------- the map ---------- */
#map {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  outline: none;
  --fill: 0.38;
  user-select: none;
  -webkit-user-select: none;
}
#map.dragging { cursor: grabbing; }

.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tiles, .shapes, .markers { position: absolute; left: 0; top: 0; }
.tiles img { position: absolute; display: block; max-width: none; image-rendering: auto; pointer-events: none; }
.backdrop img { filter: saturate(0.95); }
.shapes { overflow: visible; pointer-events: none; }

.zone {
  fill: var(--c);
  fill-opacity: var(--fill);
  stroke: var(--c);
  stroke-width: 2;
  stroke-opacity: 0.9;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: visiblePainted;
  cursor: pointer;
  transition: fill-opacity 0.15s, stroke-width 0.15s;
}
.zone:hover { fill-opacity: calc(var(--fill) + 0.2); stroke-width: 3; }
.zone.sel { fill-opacity: calc(var(--fill) + 0.25); stroke: #fff; stroke-width: 3.5; }
.zone.old { fill-opacity: calc(var(--fill) * 0.25); stroke-opacity: 0.25; }
.zone.off, #map.hide-shapes .zone { display: none; }

.marker {
  position: absolute;
  width: 12px;
  height: 12px;
  padding: 0;
  margin: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--c);
  transform: translate(-50%, -50%) scale(var(--inv));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}
.marker::after { content: ""; position: absolute; inset: -9px; } /* bigger touch target */
.marker.k-city { width: 16px; height: 16px; border-radius: 4px; border-width: 2.5px; }
.marker.k-other { border-radius: 2px; width: 10px; height: 10px; transform: translate(-50%, -50%) scale(var(--inv)) rotate(45deg); }
.marker.near { opacity: 0.88; border-style: dashed; }
.marker:hover, .marker:focus-visible { outline: 2px solid #111; z-index: 2; }
.marker.sel { outline: 3px solid #fff; box-shadow: 0 0 0 6px rgba(0, 0, 0, 0.35); z-index: 3; }
.marker.old { opacity: 0.25; }
.marker.off,
#map.hide-city .k-city,
#map.hide-dungeon .k-dungeon,
#map.hide-other .k-other { display: none; }
/* zoomed far out, only cities show; the rest appear as you zoom in */
#map[data-zoom="far"] .marker:not(.k-city):not(.sel) { display: none; }

/* ---------- panels ---------- */
.panel, .info, .zoombar, .minimap, .tip, .results {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.panel {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 316px;
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px 16px; }
.brand h1 { font-size: 17px; letter-spacing: 0.01em; font-weight: 700; }
.ver { color: var(--ink-3); font-size: 12px; }
.brand .icon-btn { margin-left: auto; }
.panel-body { overflow-y: auto; padding: 0 16px 14px; overscroll-behavior: contain; }
.panel.collapsed .panel-body { display: none; }
.panel section { padding: 12px 0; border-top: 1px solid var(--panel-line); }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 600; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.label-row label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); font-weight: 600; }
.label-row output { font-weight: 600; color: var(--accent); text-align: right; }
.timeline .label-row { flex-direction: column; align-items: flex-start; gap: 2px; }
.timeline .label-row output { text-align: left; font-size: 15px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.search { position: relative; padding: 0 12px 12px 16px; }
.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ink);
  font: inherit;
}
.search input::placeholder { color: var(--ink-3); }
.results {
  position: absolute;
  left: 16px;
  right: 12px;
  top: 40px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: rgba(22, 20, 17, 0.97);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 5;
}
.results li { display: grid; grid-template-columns: 12px 1fr; column-gap: 8px; align-items: center; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.results li .meta { grid-column: 2; color: var(--ink-3); font-size: 12px; }
.results li[aria-selected="true"], .results li:hover { background: rgba(255, 255, 255, 0.1); }
.results li.none { display: block; color: var(--ink-3); cursor: default; }

.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); flex: none; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
.tl-ends { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 11px; margin: -2px 2px 6px; }
.check { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; color: var(--ink); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.slider { display: block; margin-top: 8px; color: var(--ink-2); font-size: 13px; }

.exps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chip {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 7px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  text-align: left;
  opacity: 0.5;
  transition: opacity 0.12s, background 0.12s, border-color 0.12s;
}
.chip .sw { grid-row: 1 / 3; width: 12px; height: 26px; border-radius: 4px; }
.chip .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .yr { grid-column: 2; color: var(--ink-3); font-size: 11px; }
.chip .ct { grid-row: 1 / 3; grid-column: 3; color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { opacity: 1; border-color: color-mix(in srgb, var(--c) 70%, transparent); background: color-mix(in srgb, var(--c) 18%, transparent); }
.chip.is-new { box-shadow: 0 0 0 2px var(--accent); }
.chip:hover { opacity: 1; }
.quick { font-size: 13px; color: var(--ink-3); }

.list-box { border-top: 1px solid var(--panel-line); padding-top: 10px; }
.list-box summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.count { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.list h3 { display: flex; align-items: center; gap: 7px; font-size: 13px; margin: 12px 0 4px; }
.list ul { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0 2px 19px; }
.list .link-btn { color: var(--ink); }
.list .link-btn:hover { color: var(--accent); }
.list .kind { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.empty { color: var(--ink-3); }
.credit { color: var(--ink-3); font-size: 11.5px; margin: 14px 0 0; border-top: 1px solid var(--panel-line); padding-top: 10px; }

/* ---------- info card ---------- */
.info {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 320px;
  max-height: calc(100% - 180px);
  overflow-y: auto;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 11;
}
.info .close { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; }
.info h2 { font-size: 19px; padding-right: 36px; line-height: 1.25; }
.badge { display: inline-flex; align-items: center; gap: 7px; margin: 8px 0 4px; padding: 3px 10px 3px 6px; border-radius: 999px; background: color-mix(in srgb, var(--c) 28%, transparent); border: 1px solid color-mix(in srgb, var(--c) 70%, transparent); font-weight: 600; font-size: 13px; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; }
.info dt { color: var(--ink-3); }
.info dd { margin: 0; }
.info h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-2); margin: 14px 0 6px; }
.info .note { color: var(--ink-2); font-size: 13px; }
.kids { display: flex; flex-direction: column; gap: 4px; }
.goto { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); }
.btn { padding: 7px 14px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); background: color-mix(in srgb, var(--accent) 20%, transparent); cursor: pointer; font-weight: 600; }
.btn:hover { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.actions { margin: 14px 0 0; }

/* ---------- zoom, minimap, tooltip ---------- */
.zoombar { position: fixed; right: 12px; bottom: 150px; display: flex; flex-direction: column; gap: 6px; z-index: 9; }
.zoombar .icon-btn { width: 40px; height: 40px; background: var(--panel); box-shadow: var(--shadow); }
.minimap {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 300px;
  height: 125px;
  border-radius: 10px;
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
  background: var(--sea);
  cursor: crosshair;
  touch-action: none;
  z-index: 9;
}
.tip {
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(22, 20, 17, 0.94);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 20;
  max-width: 260px;
}
.tip b { font-size: 14px; }
.tip-exp { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.tip-exp::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.tip-kind { font-size: 12px; color: var(--ink-3); }
.noscript { position: fixed; inset: auto 0 0; margin: 0; padding: 12px; background: #400; color: #fff; text-align: center; z-index: 50; }
[hidden] { display: none !important; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .panel { top: 8px; left: 8px; right: 8px; width: auto; max-height: 72%; }
  .brand { padding: 8px 8px 6px 12px; }
  .search { padding: 0 8px 8px 12px; }
  .panel-body { padding: 0 12px 12px; }
  .info { top: auto; bottom: 8px; left: 8px; right: 8px; width: auto; max-height: 48%; }
  .minimap { display: none; }
  .zoombar { bottom: 16px; right: 8px; }
  .zoombar .icon-btn { width: 44px; height: 44px; }
  .info:not([hidden]) ~ .zoombar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .zone, .chip { transition: none; }
}

/* ---------- 1.1.0: language switch, logos, area maps ---------- */
.lang { display: inline-flex; flex: none; border: 1px solid var(--panel-line); border-radius: 9px; overflow: hidden; }
.search { display: flex; gap: 6px; align-items: center; }
.search input { flex: 1; min-width: 0; }
.lang button { border: 0; background: transparent; height: 34px; padding: 0 9px; font-size: 12px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.lang button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 28%, transparent); color: var(--ink); font-weight: 700; }
.brand h1 { white-space: nowrap; }

.chip { grid-template-columns: 10px 1fr auto; grid-template-rows: auto auto; row-gap: 5px; padding: 7px 8px 6px; }
.chip .nm { grid-column: 1 / 4; grid-row: 1; display: flex; align-items: center; min-height: 24px; }
.chip .sw { grid-row: 2; grid-column: 1; width: 10px; height: 10px; border-radius: 3px; }
.chip .yr { grid-row: 2; grid-column: 2; }
.chip .ct { grid-row: 2; grid-column: 3; }
.chip-logo { display: block; width: 100%; height: auto; max-height: 30px; object-fit: contain; object-position: left center; border-radius: 3px; }
.logo-text.chip-logo { height: auto; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex-wrap: wrap; padding: 4px 12px 4px 8px; border-radius: 12px; }
.badge-logo { height: 34px; max-width: 170px; object-fit: contain; border-radius: 3px; }
.logo-text.badge-logo { height: auto; }
.alt-name { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }

.floors { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; }
.floor { min-width: 30px; padding: 3px 7px; border-radius: 7px; border: 1px solid var(--panel-line); background: rgba(255, 255, 255, .05); cursor: pointer; font-size: 12px; }
.floor[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); font-weight: 700; }
.mini-map { display: block; width: 100%; padding: 0; border: 1px solid var(--panel-line); border-radius: 10px; overflow: hidden; background: #2a2418; cursor: zoom-in; }
.mini-map img { display: block; width: 100%; height: auto; }
.mini-map:hover { border-color: var(--accent); }
.has-map { color: var(--accent); }

.lightbox { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: rgba(10, 9, 7, .9); backdrop-filter: blur(4px); }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; }
.lb-bar h2 { font-size: 18px; margin-right: auto; }
.lb-floor { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lb-stage { flex: 1; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: grab; }
.lb-stage:active { cursor: grabbing; }
.lb-stage img { max-width: min(96vw, 1024px); max-height: calc(100vh - 110px); transform-origin: center; user-select: none; border-radius: 6px; box-shadow: var(--shadow); }
body.lb-open .tip { display: none; }
@media (max-width: 720px) {
  .brand h1 { font-size: 15px; }
  .ver { display: none; }
}
.lb-credit { margin: 0; padding: 6px 14px 10px; color: var(--ink-3); font-size: 11.5px; text-align: center; }
