:root {
  --bg: #14181d;
  --panel: #1c2229;
  --panel2: #232b34;
  --border: #2e3945;
  --text: #d7e0e8;
  --dim: #8496a5;
  --accent: #4fc3f7;
  --spawn: #ffb300;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* z-index so the layers panel, which hangs out of the header, sits over the map */
header {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .6rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 30;
}
h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; }
.brandmark { width: 1.4em; height: 1.4em; color: var(--accent); vertical-align: -0.22em; }
.hdrField { display: inline-flex; align-items: center; gap: .4rem; color: var(--dim); font-size: .82rem; }
.fieldLabel { white-space: nowrap; }
#status { margin-left: auto; font-size: .85rem; }
#status.err { color: #ef5350; }

/* creature picker: our own dropdown, anchored to the input. A native <datalist>
   put its popup wherever it liked and restyled the field on selection. */
#spawnBox { position: relative; }
#spawnSearch { width: 15rem; max-width: 40vw; }
#spawnSearch:disabled { opacity: .5; }
#spawnClear { color: var(--dim); font-size: .8rem; padding: .35rem .5rem; }
#spawnClear:hover { color: var(--text); }
#spawnResults {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
  min-width: 100%; max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0,0,0,.55); padding: .25rem;
}
.spItem {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .3rem .5rem; border-radius: 4px; cursor: pointer; font-size: .85rem;
  color: var(--text); white-space: nowrap;
}
.spItem:hover, .spItem.active { background: var(--panel2); }
.spZones { color: var(--dim); font-size: .75rem; }
.spEmpty { padding: .4rem .5rem; color: var(--dim); font-size: .82rem; }

/* Markers is a headline feature, not a footnote in the map bar */
button.primary {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .42rem .8rem; font-size: .88rem; font-weight: 600;
  color: var(--text); background: var(--panel2); border-color: var(--accent);
}
button.primary:hover { background: rgba(79,195,247,.16); }
button.primary.on { background: rgba(79,195,247,.22); }
.pill {
  background: var(--accent); color: #07222e; border-radius: 999px;
  padding: 0 .4rem; font-size: .72rem; font-weight: 700; line-height: 1.35;
}

select, input, button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: .35rem .6rem; font-size: .9rem;
}
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
/* the global input rule styles boxes; checkboxes must opt out or they render as
   big empty boxes that swallow their label */
input[type="checkbox"] {
  appearance: auto; -webkit-appearance: auto; width: auto; padding: 0; margin: 0;
  border: 0; background: none; accent-color: var(--accent); vertical-align: middle; flex: none;
}
.chk { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--dim); white-space: nowrap; }
.dim { color: var(--dim); }
.hidden { display: none !important; }
.ico { width: 1.05em; height: 1.05em; vertical-align: -0.16em; flex: none; }

/* position: relative anchors the absolutely-placed layers panel */
main { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: .8rem; position: relative; }

#mapViewport {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  background: #0b0e11; border: 1px solid var(--border); border-radius: 6px;
  cursor: grab; user-select: none; -webkit-user-select: none;
}
#mapViewport.dragging { cursor: grabbing; }
#mapInner { position: absolute; transform-origin: 0 0; }
#mapInner > img { display: block; width: 100%; height: 100%; user-select: none; pointer-events: none; }
/* canvas overlays the whole viewport (NOT inside the transformed #mapInner) so
   markers render at device resolution and stay crisp at any zoom */
#mapCanvas { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
#tileLayer { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
#tileLayer img { position: absolute; user-select: none; pointer-events: none; }

/* on-screen zoom control (for when the scroll wheel is awkward) */
#zoomCtl {
  position: absolute; top: .6rem; left: .6rem; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  background: rgba(10,14,18,.85); border: 1px solid var(--border);
  border-radius: 6px; padding: .35rem .3rem;
}
#zoomCtl button {
  width: 1.7rem; height: 1.7rem; padding: 0; font-size: 1.1rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
#zoomSlider {
  writing-mode: vertical-lr; direction: rtl;      /* vertical, + at top */
  width: 1.2rem; height: 7rem; padding: 0; cursor: ns-resize;
}

/* which marker layers are currently shown (so those diamonds aren't a mystery) */
#activeMarkers {
  position: absolute; left: .6rem; bottom: .6rem; z-index: 3;
  background: rgba(10,14,18,.82); border: 1px solid var(--border); border-radius: 6px;
  padding: .3rem .5rem; font-size: .75rem; max-width: 12rem; max-height: 40%; overflow-y: auto;
}
#activeMarkers .amTitle {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  color: var(--dim); font-weight: 600; margin-bottom: .2rem;
}
#activeMarkers .amItem { display: flex; align-items: center; gap: .4rem; padding: .08rem 0; }
#activeMarkers .amSw { width: .6rem; height: .6rem; flex: none; transform: rotate(45deg); border: 1px solid rgba(0,0,0,.5); }
#activeMarkers .amClear { padding: 0 .3rem; font-size: .8rem; line-height: 1.3; color: var(--dim); }
#activeMarkers .amClear:hover { color: var(--text); }

/* spawn-zone readout: which regions, ranked by how likely the creature is there */
#spawnInfo {
  position: absolute; right: .6rem; top: .6rem; z-index: 3;
  background: rgba(10,14,18,.88); border: 1px solid var(--border); border-radius: 6px;
  padding: .45rem .6rem; font-size: .78rem; width: 15rem; max-height: 70%; overflow-y: auto;
}
.siTitle { font-weight: 600; margin-bottom: .35rem; }
.siRow { display: grid; grid-template-columns: 1fr 4.5rem; align-items: center; gap: .5rem; margin-bottom: .22rem; }
.siName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.siCave { color: var(--dim); font-size: .9em; }
.siTrack { height: .55rem; background: rgba(255,255,255,.06); border-radius: 3px; overflow: hidden; }
.siFill { display: block; height: 100%; background: var(--spawn); border-radius: 3px; }
.siFoot { margin-top: .4rem; font-size: .7rem; line-height: 1.3; }

#mapTooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(10,14,18,.92); border: 1px solid var(--border);
  padding: .3rem .5rem; border-radius: 4px; font-size: .8rem; white-space: pre;
}

#mapBar {
  display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
  padding: .35rem .2rem 0; color: var(--dim); font-size: .82rem;
}
#mapBar button, #mapBar select { padding: .1rem .5rem; font-size: .8rem; }
#mapCoords { min-width: 6rem; font-variant-numeric: tabular-nums; }
#mapReset { margin-left: auto; }

/* hangs directly off the Markers button, which is what opens it */
#layersWrap { position: relative; }
#layersPanel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  max-height: 70vh; overflow-y: auto; min-width: 17rem;
  background: rgba(10,14,18,.97); border: 1px solid var(--accent);
  border-radius: 6px; padding: .5rem .6rem; font-size: .82rem;
  box-shadow: 0 10px 34px rgba(0,0,0,.6);
}
#layersPanel label { display: flex; align-items: center; gap: .45rem; padding: .12rem 0; cursor: pointer; }
#layersPanel .sw { width: .7rem; height: .7rem; border-radius: 2px; flex: none; }
#layersPanel .cnt { color: var(--dim); margin-left: auto; }
.layersHead { display: flex; gap: .3rem; margin-bottom: .35rem; }
#layersFilter { flex: 1; min-width: 0; font-size: .8rem; }
.layerBulk { padding: .1rem .45rem; font-size: .78rem; color: var(--dim); }
.layerBulk:hover { color: var(--text); }
.layerHint { margin: .1rem 0 .35rem; font-size: .76rem; }

footer {
  padding: .5rem 1rem .7rem; color: var(--dim); font-size: .75rem; line-height: 1.5;
  border-top: 1px solid var(--border);
}
footer a { color: var(--accent); }
.prov { color: var(--text); }
/* if we ever ship Evolved data by mistake, this must be loud */
.prov.warn { color: #ffb74d; font-weight: 600; }

@media (max-width: 760px) {
  header { gap: .6rem; }
  #status { margin-left: 0; }
  #spawnInfo { position: static; width: auto; max-height: none; margin-top: .5rem; }
}
