:root {
  --bg: #15181c;
  --panel: #1d2126;
  --line: #2c323a;
  --text: #e4e6e9;
  --muted: #8b939d;
  --accent: #e0b451;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { display: flex; }

#panel { width: 280px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; z-index: 2; }
#panel h1 { font-size: 18px; margin: 0; letter-spacing: .02em; }
#panel h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
#map-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
#map-select { width: 100%; margin-top: 8px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
#map-select[hidden] { display: none; }
.link-btn { background: none; border: none; padding: 0; margin-top: 6px; color: #ff8a8a; font: inherit; font-size: 12px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn[hidden] { display: none; }

.search { position: relative; }
#search { width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; }
#search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#results { list-style: none; margin: 4px 0 0; padding: 0; }
#results li { padding: 6px 8px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#results li:hover, #results li.active { background: var(--line); }
#results li small { color: var(--muted); }

/* ---- filters: collapsible categories, options inside ---- */
#panel h2.h2-row { display: flex; align-items: baseline; justify-content: space-between; }
#panel h2.h2-row .link-btn { margin: 0; color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 500; }
#filters { margin: 0 0 8px; }
.fcat { border-top: 1px solid var(--line); }
.fcat:last-child { border-bottom: 1px solid var(--line); }
.fcat-head { display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.fcat-arrow { background: none; border: none; color: var(--muted); width: 16px; padding: 0; font-size: 11px; cursor: pointer;
  transition: transform .15s; flex: none; }
.fcat.open .fcat-arrow { transform: rotate(90deg); }
.fcat-name { flex: 1; font-weight: 600; cursor: pointer; user-select: none; }
.fopts { list-style: none; margin: 0 0 6px; padding: 0 0 0 22px; display: none; }
.fcat.open .fopts { display: block; }
.fopts li { display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.fopts li.off .fname { color: var(--muted); }
.fopts label, .toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; min-width: 0; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fopts .only { visibility: hidden; background: none; border: none; color: var(--accent); font: inherit; font-size: 11px; padding: 0 2px; cursor: pointer; }
.fopts li:hover .only, .fopts .only:focus-visible { visibility: visible; }
.fglyph { width: 14px; text-align: center; font-size: 12px; line-height: 1; flex: none; }
.swatch.area { border-radius: 2px; background: none; border: 1.5px dashed #fff; box-shadow: none; }
.swatch.area.outside { border-color: var(--muted); }
.area-label { color: rgba(255,255,255,.9); font-weight: 600; font-style: italic; font-size: 14px; letter-spacing: .15em; text-transform: uppercase;
  text-shadow: 0 0 3px #000, 0 0 8px #000; white-space: nowrap; transform: translate(-50%, 4px); pointer-events: none; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
input[type=checkbox] { accent-color: var(--accent); margin: 0; }

.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tools button, .leaflet-popup-content button { background: var(--line); color: var(--text); border: 1px solid #3a414b;
  border-radius: 5px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.tools button:hover, .leaflet-popup-content button:hover { border-color: var(--accent); }
.leaflet-popup-content button.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
.leaflet-popup-content .popup-actions a { color: var(--accent); font-size: 12px; }
.tools button.on { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

#map { flex: 1; background: #24465f; }
.leaflet-container { font: inherit; }
.leaflet-image-layer { image-rendering: auto; }

#coords { position: fixed; right: 12px; bottom: 12px; z-index: 1000; background: rgba(21,24,28,.88);
  border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; font: 12px ui-monospace, Consolas, monospace; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 2000; font-size: 16px; color: var(--muted); }
#loading.hidden { display: none; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2001; background: var(--accent);
  color: #1a1a1a; padding: 8px 14px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; font-weight: 500; }
#toast.show { opacity: 1; }

.town-label { color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  text-shadow: 0 0 3px #000, 0 0 6px #000; white-space: nowrap; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer; }
.leaflet-tooltip.poi-label { background: none; border: none; box-shadow: none; color: #fff; font-weight: 600; font-size: 12px;
  text-shadow: 0 0 3px #000, 0 0 5px #000; padding: 0 4px; }
.leaflet-tooltip.poi-label::before { display: none; }
.zoom-low .leaflet-tooltip.poi-label.minor { display: none; }
.grid-label { color: rgba(255,255,255,.75); font: 600 11px ui-monospace, Consolas, monospace; text-shadow: 0 0 3px #000; white-space: nowrap; }
.pin { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: var(--accent); transform: rotate(-45deg);
  box-shadow: 0 0 0 2px #1a1a1a; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-popup-content { margin: 12px 14px; }
.popup-title { font-weight: 600; font-size: 14px; }
.popup-type { color: var(--muted); font-size: 12px; }
.popup-coords { font: 12px ui-monospace, Consolas, monospace; margin: 6px 0 8px; }
.popup-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.leaflet-tooltip.measure { background: var(--accent); color: #1a1a1a; border: none; font-weight: 600; }

/* ---- admin / players ---- */
.badge { background: var(--line); color: var(--accent); border-radius: 3px; padding: 1px 5px; font-size: 10px; margin-left: 4px; }
#login-form { display: flex; flex-wrap: wrap; gap: 6px; }
#login-form[hidden] { display: none; }
#login-form input, #player-filter, #server-select { flex: 1; min-width: 0; padding: 7px 9px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; }
#login-form button { background: var(--accent); color: #1a1a1a; border: none; border-radius: 6px; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.hint.error { color: #ff8a8a; margin: 0; flex-basis: 100%; }
.hint.error:empty { display: none; }
#admin-panel { display: flex; flex-direction: column; gap: 8px; }
#admin-panel[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
#server-select { width: 100%; }
a.button { background: var(--accent); color: #1a1a1a; border-radius: 5px; padding: 6px 10px; font-size: 13px; font-weight: 600; text-decoration: none; }
a.button.disabled { background: var(--line); color: var(--muted); pointer-events: none; font-weight: 400; }
#join-hint:empty { display: none; }
#join-hint { margin: 0; }
#player-layers { list-style: none; margin: 0; padding: 0; }
#player-layers li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
#player-layers label { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
#player-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
#player-list li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; cursor: pointer; }
#player-list li:hover { background: var(--line); }
#player-list li.offline { opacity: .6; }
#player-list .pl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player-list small { color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.online { background: #3ddc84; } .dot.offline { background: #7d8590; }

.pm { display: flex; align-items: center; gap: 4px; transform: translate(-14px, -14px); white-space: nowrap; }
.pm .av { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #3ddc84; background: #2c323a center/cover;
  display: grid; place-items: center; color: #fff; font: 700 11px system-ui; box-shadow: 0 1px 4px rgba(0,0,0,.6); flex: none; }
.pm.offline .av { border-color: #7d8590; filter: grayscale(1); opacity: .85; }
.pm .nm { color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 0 3px #000, 0 0 5px #000; }
.pm.offline .nm { color: #c7ccd1; font-weight: 500; }
.zoom-low .pm.offline .nm { display: none; }

/* ---- teleport requests ---- */
.tp-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.tp-row select { flex: 1; min-width: 0; max-width: 190px; padding: 5px 6px; border-radius: 5px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 12px; }
.tp-box { margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.tp-box .tp-id { font: 11px ui-monospace, Consolas, monospace; color: var(--muted); word-break: break-all; margin: 2px 0 6px; }
#tp-log { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; }
#tp-log[hidden] { display: none; }
#tp-log .modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(1000px, 100%); max-height: 85vh; display: flex; flex-direction: column; }
#tp-log header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#tp-log header h2 { margin: 0; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--text); }
#tp-log-body { overflow: auto; padding: 0 16px 12px; }
#tp-log table { width: 100%; border-collapse: collapse; font-size: 13px; }
#tp-log th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 8px 6px; position: sticky; top: 0; background: var(--panel); }
#tp-log td { padding: 8px; border-top: 1px solid var(--line); vertical-align: top; }
#tp-log td.mono, #tp-log .ev { font: 12px ui-monospace, Consolas, monospace; }
#tp-log .ev { color: var(--muted); white-space: nowrap; }
#tp-log .ev b { color: var(--text); font-weight: 600; }
#tp-log .ev.bad b { color: #ff8a8a; }
.status { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--line); }
.status.pending { background: #4a3d16; color: #ffd166; } .status.used { background: #173d2a; color: #3ddc84; }
.status.expired, .status.cancelled { color: var(--muted); }

@media (max-width: 700px) {
  body { flex-direction: column-reverse; }
  #panel { width: 100%; max-height: 40vh; border-right: none; border-top: 1px solid var(--line); }
}

/* moving players from the map */
.tp-row.picked select { border-color: #e0b451; }
.tp-box.bad .popup-type { color: #ff8a80; }
.leaflet-container.picking { cursor: crosshair; }
#move-hint { position: fixed; top: 12px; left: calc(50% + 150px); transform: translateX(-50%); z-index: 1000; padding: 6px 12px;
  border-radius: 6px; background: rgba(20, 22, 26, .92); border: 1px solid var(--line); color: #fff; font-size: 13px; pointer-events: none; }

/* creatures (map entities) */
.dot.entity { background: #e0b451; }
.em { display: flex; align-items: center; gap: 3px; transform: translate(-11px, -11px); white-space: nowrap; }
.em .ei { font-size: 20px; line-height: 22px; filter: drop-shadow(0 0 2px #000); }
.em .nm { color: #ffe9b0; font-size: 11px; font-weight: 600; text-shadow: 0 0 3px #000, 0 0 5px #000; }
.em.dead .ei { filter: grayscale(1) drop-shadow(0 0 2px #000); opacity: .6; transform: rotate(90deg); }
.em.dead .nm { color: #9aa0a6; text-decoration: line-through; }
.zoom-low .em .nm { display: none; }
button.danger { background: #8b2c2c; border-color: #a33; color: #fff; }
button.danger:disabled { opacity: .45; }
.fopts li.fempty { color: var(--muted); font-size: 12px; font-style: italic; }
.fcat-all:disabled { opacity: .4; }

/* ---- markers players place ---- */
.mk { width: 26px; height: 26px; border-radius: 50%; background: #1d2126; border: 2.5px solid var(--c); display: grid; place-items: center;
  transform: translate(-13px, -13px); box-shadow: 0 1px 4px rgba(0,0,0,.6); cursor: pointer; font-size: 14px; line-height: 1; }
.mk.shared { border-style: dashed; }
.mk-label { position: absolute; left: 16px; top: -8px; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap;
  text-shadow: 0 0 3px #000, 0 0 5px #000; pointer-events: none; }
.zoom-low .mk-label { display: none; }
.leaflet-tooltip.mk-tip { background: rgba(21,24,28,.85); border: none; color: #fff; font-weight: 600; font-size: 12px; box-shadow: none; }
.leaflet-tooltip.mk-tip::before { display: none; }
.mk-note { margin: 6px 0 2px; white-space: pre-wrap; color: var(--text); font-size: 13px; }
.mk-form { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
.mk-form input, .mk-form select, .mk-form textarea, .inline-form input { background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 7px; font: inherit; font-size: 13px; }
.mk-colors { display: flex; gap: 6px; }
.leaflet-popup-content button.mk-color { width: 22px; height: 22px; padding: 0; border-radius: 50%; background: var(--c); border: 2px solid transparent; }
.leaflet-popup-content button.mk-color.on { border-color: #fff; box-shadow: 0 0 0 2px #000; }
.place-tools { margin-bottom: 6px; }
/* ---- you and your tribe on the map ---- */
.pm.me .av { border-color: var(--accent); }
.pm.mate .av { border-color: #4cc9f0; }
.pm.me.offline .av, .pm.mate.offline .av { filter: grayscale(.7); }
.dot.me { background: var(--accent); } .dot.mate { background: #4cc9f0; }
/* ---- account / tribe panel ---- */
#account[hidden] { display: none; }
#account h3 { font-size: 13px; margin: 12px 0 4px; }
.acct-row { display: flex; align-items: center; gap: 8px; }
.acct-row .av { width: 32px; height: 32px; border-radius: 50%; background: #2c323a center/cover; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.acct-name { flex: 1; display: flex; flex-direction: column; font-weight: 600; line-height: 1.2; }
.acct-name small { color: var(--muted); font-weight: 400; }
.acct-row .link-btn, .tribe .link-btn { margin: 0 0 0 6px; color: var(--accent); }
.tribe .link-btn.danger-link { color: #ff8a8a; margin: 6px 0 0; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form button, #acct-import button { background: var(--line); color: var(--text); border: 1px solid #3a414b; border-radius: 5px; padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer; }
#acct-import button { margin-top: 10px; width: 100%; }
.tribe-code { font-size: 12px; color: var(--muted); }
.tribe-code code { color: var(--text); font-size: 13px; letter-spacing: .1em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
#tribe-list { list-style: none; margin: 8px 0 0; padding: 0; }
#tribe-list li { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
#tribe-list li.go { cursor: pointer; } #tribe-list li.go:hover .mname { text-decoration: underline; }
#tribe-list .mname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#tribe-list small { color: var(--muted); font-size: 11px; }
#tribe-list .kick { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 0 2px; }
#tribe-list .kick:hover { color: #ff8a8a; }
