:root {
  --bg: #0a0c0e;
  --panel: rgba(16, 18, 21, .93);
  --panel-solid: #121417;
  --line: rgba(255, 255, 255, .09);
  --line-soft: rgba(255, 255, 255, .05);
  --text: #d9dde2;
  --text-dim: #8a929c;
  --accent: #d81f26;
  --accent-soft: rgba(216, 31, 38, .18);
  --gold: #e8b23a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .65);
  --veh-size: 62px;
  --veh-icon: 50px;
  --vend-size: 58px;
  --vend-icon: 40px;
  --trader-size: 46px;
  --trader-icon: 42px;
  --claim-size: 24px;
  --claim-icon: 16px;
  --player-dot: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage {
  position: absolute;
  inset: 0;
  cursor: grab;
  overflow: hidden;
}

#stage.dragging { cursor: grabbing; }

#map { position: absolute; inset: 0; width: 100%; height: 100%; }

#lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

#markers { position: absolute; inset: 0; pointer-events: none; --s: 1; }

/* ---------- brand ---------- */

#brand {
  position: absolute;
  top: 12px;
  left: 16px;
  z-index: 20;
  pointer-events: none;
}

#brand img {
  display: block;
  width: 230px;
  max-width: 48vw;
  height: auto;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, .9));
}

/* ---------- layer panel ---------- */

#panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 216px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.panel-head {
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  border-bottom: 1px solid var(--line);
}

.layer-list { margin: 0; padding: 4px; list-style: none; }

.layer-list label,
.panel-foot .mini {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  cursor: pointer;
  user-select: none;
  border-radius: 2px;
}

.layer-list label:hover,
.panel-foot .mini:hover { background: rgba(255, 255, 255, .05); }

.layer-list input,
.panel-foot input { position: absolute; opacity: 0; pointer-events: none; }

.box {
  flex: none;
  width: 15px;
  height: 15px;
  border: 1px solid #5a626c;
  background: #0d0f12;
  position: relative;
}

input:checked + .box {
  border-color: var(--accent);
  background: var(--accent);
}

input:checked + .box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.ico {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.ico img { width: 22px; height: 22px; object-fit: contain; }

.ico-player {
  width: 12px;
  height: 12px;
  margin: 0 5px;
  border-radius: 50%;
  background: #46c1ff;
  box-shadow: 0 0 0 2px rgba(70, 193, 255, .25), 0 0 8px rgba(70, 193, 255, .8);
}

.txt { flex: 1; }

.num {
  flex: none;
  min-width: 24px;
  padding: 1px 6px;
  text-align: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  background: rgba(255, 255, 255, .06);
  border-radius: 2px;
}

.panel-foot {
  padding: 4px;
  border-top: 1px solid var(--line-soft);
}

.panel-foot .mini { font-size: 12px; color: var(--text-dim); }

/* ---------- zoom ---------- */

#zoom {
  position: absolute;
  right: 14px;
  bottom: 46px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

#zoom button {
  width: 34px;
  height: 32px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

#zoom button:last-child { border-bottom: 0; font-size: 13px; }
#zoom button:hover { background: var(--accent); color: #fff; }

/* ---------- foot bar ---------- */

#footbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--text-dim);
  background: linear-gradient(180deg, transparent, rgba(6, 7, 9, .9));
  pointer-events: none;
}

#footbar .sep { width: 1px; height: 10px; background: var(--line); }
#status.error { color: #ff6b6b; }
#cursor { font-variant-numeric: tabular-nums; }

/* ---------- markers ---------- */

.mk {
  position: absolute;
  left: 0;
  top: 0;
  width: 150px;
  margin-left: -75px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  cursor: pointer;
  will-change: transform;
}

.mk > * { pointer-events: auto; }
.mk.hide { display: none; }

.mk-claim { z-index: 1; }
.mk-vend { z-index: 2; }
.mk-veh { z-index: 3; }
.mk-trader { z-index: 4; }
.mk-player { z-index: 5; }
.mk-cluster { z-index: 6; }
.mk.leg { z-index: 7; }
.mk.sel { z-index: 8; }

.mk .lbl {
  margin-top: 2px;
  max-width: 140px;
  padding: 1px 5px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #eef1f4;
  background: rgba(8, 10, 12, .78);
  border: 1px solid var(--line);
  border-radius: 2px;
}

#markers.nolabels .lbl { display: none; }
#markers.nolabels .mk:hover .lbl { display: block; }

.mk img {
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .95));
}

.mk-player .dot {
  width: calc(var(--player-dot) * var(--s));
  height: calc(var(--player-dot) * var(--s));
  min-width: 9px;
  min-height: 9px;
  border-radius: 50%;
  background: #46c1ff;
  border: 2px solid #08121a;
  box-shadow: 0 0 0 1px rgba(70, 193, 255, .8), 0 0 12px rgba(70, 193, 255, .9);
}

.mk-player .lbl { color: #9ddcff; border-color: rgba(70, 193, 255, .35); }

.badge {
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 12, 15, .85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .8);
}

.mk-veh .badge {
  width: calc(var(--veh-size) * var(--s));
  height: calc(var(--veh-size) * var(--s));
  border: max(2px, calc(3px * var(--s))) solid rgba(255, 176, 60, .9);
}

.mk-veh .badge img {
  width: calc(var(--veh-icon) * var(--s));
  height: calc(var(--veh-icon) * var(--s));
  object-fit: contain;
}
.mk-veh .lbl { color: #ffd08a; border-color: rgba(255, 176, 60, .3); }

.mk-vend .badge {
  width: calc(var(--vend-size) * var(--s));
  height: calc(var(--vend-size) * var(--s));
  border: max(2px, calc(3px * var(--s))) solid rgba(90, 210, 125, .95);
}

.mk-vend .badge img {
  width: calc(var(--vend-icon) * var(--s));
  height: calc(var(--vend-icon) * var(--s));
  object-fit: contain;
}
.mk-vend .lbl { color: #a7e0b0; border-color: rgba(90, 200, 120, .3); }

.mk-claim .badge {
  width: calc(var(--claim-size) * var(--s));
  height: calc(var(--claim-size) * var(--s));
  min-width: 13px;
  min-height: 13px;
  border: 2px solid rgba(255, 72, 78, .8);
}

.mk-claim .badge img {
  width: calc(var(--claim-icon) * var(--s));
  height: calc(var(--claim-icon) * var(--s));
  object-fit: contain;
}

.mk-claim .lbl { color: #ff9c9c; border-color: rgba(216, 31, 38, .4); }

.mk-veh .lbl,
.mk-vend .lbl,
.mk-claim .lbl { display: none; }

.mk-veh:hover .lbl,
.mk-vend:hover .lbl,
.mk-claim:hover .lbl,
.mk-veh.sel .lbl,
.mk-vend.sel .lbl,
.mk-claim.sel .lbl { display: block; }

.mk-trader .badge {
  width: calc(var(--trader-size) * var(--s));
  height: calc(var(--trader-size) * var(--s));
  border-radius: 4px;
  border: 2px solid rgba(216, 31, 38, .9);
  background: rgba(10, 12, 14, .9);
  overflow: hidden;
}

.mk-trader .badge img {
  width: calc(var(--trader-icon) * var(--s));
  height: calc(var(--trader-icon) * var(--s));
  object-fit: cover;
}
.mk-trader .lbl { color: #ff9c9c; border-color: rgba(216, 31, 38, .45); }

.mk.sel .badge,
.mk.sel .dot { outline: 2px solid #fff; outline-offset: 2px; }

.mk.leg .badge,
.mk.leg .dot { box-shadow: 0 0 0 1px rgba(255, 255, 255, .4), 0 2px 8px rgba(0, 0, 0, .85); }

/* ---------- clusters ---------- */

.mk-cluster .badge {
  position: relative;
  border: 2px solid rgba(255, 255, 255, .3);
  background: rgba(12, 14, 17, .92);
}

.mk-cluster .badge img { object-fit: contain; }

.mk-cluster .cdot {
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background: #46c1ff;
  box-shadow: 0 0 10px rgba(70, 193, 255, .9);
}

.mk-cluster .cnt {
  position: absolute;
  right: -4px;
  top: -4px;
  display: grid;
  place-items: center;
  min-width: max(15px, calc(19px * var(--s)));
  height: max(15px, calc(19px * var(--s)));
  padding: 0 4px;
  border-radius: 10px;
  font-size: max(9px, calc(11px * var(--s)));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #0a0c0e;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .8);
}

.mk-cluster .lbl { color: #cfd5db; }

.mk-cluster.cl-vehicles .badge { border-color: rgba(255, 176, 60, .9); }
.mk-cluster.cl-vehicles .cnt { background: #ffb03c; }
.mk-cluster.cl-vending .badge { border-color: rgba(90, 210, 125, .95); }
.mk-cluster.cl-vending .cnt { background: #5ad27d; }
.mk-cluster.cl-claims .badge { border-color: rgba(255, 72, 78, .85); }
.mk-cluster.cl-claims .cnt { background: #ff484e; color: #fff; }
.mk-cluster.cl-players .badge { border-color: rgba(70, 193, 255, .9); }
.mk-cluster.cl-players .cnt { background: #46c1ff; }
.mk-cluster.cl-traders .badge { border-color: rgba(216, 31, 38, .9); }
.mk-cluster.cl-traders .cnt { background: #ff484e; color: #fff; }

/* ---------- popup ---------- */

#popup[hidden] { display: none; }

#popup {
  position: absolute;
  z-index: 30;
  width: 268px;
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  box-shadow: var(--shadow);
  font-size: 12px;
}

.pop-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 30px 9px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.pop-head img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex: none;
}

.pop-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.25;
}

.pop-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.pop-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, .05);
  color: #cfd5db;
  font-size: 16px;
  cursor: pointer;
}

.pop-close:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.pop-rows { padding: 6px 10px; }

.pop-rows .r {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
}

.pop-rows .k { color: var(--text-dim); }
.pop-rows .v { color: #e7eaee; text-align: right; font-variant-numeric: tabular-nums; }

.pop-foot {
  margin-top: auto;
  padding: 8px 10px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .03);
}

.owner {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

a.nick {
  color: #64b5ff;
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
}

a.nick:hover { color: #9ed2ff; text-decoration: underline; }

span.nick { color: #e7eaee; font-weight: 600; font-size: 12px; }

/* shop list */

.shop {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-bottom: 1px solid var(--line-soft);
}

.shop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.shop-row:last-child { border-bottom: 0; }
.shop-row:hover { background: rgba(255, 255, 255, .04); }

.shop-ico {
  flex: none;
  width: 30px;
  height: 30px;
}

.shop-ico img { width: 30px; height: 30px; object-fit: contain; }

.shop-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #dfe3e8;
}

.shop-q {
  font-size: 10px;
  color: var(--gold);
  border: 1px solid rgba(232, 178, 58, .4);
  border-radius: 2px;
  padding: 0 3px;
  margin-left: 4px;
}

.shop-cnt {
  flex: none;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.shop-price {
  flex: none;
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 56px;
  justify-content: flex-end;
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.shop-price img { width: 13px; height: 13px; }

.shop-empty {
  padding: 14px 10px;
  text-align: center;
  color: var(--text-dim);
}

/* stack picker */

.pick-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-bottom: 1px solid var(--line-soft);
}

.pick-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: rgba(255, 255, 255, .05); }

.pick-ico {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.pick-ico img { width: 24px; height: 24px; object-fit: contain; }

.pick-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #46c1ff;
  box-shadow: 0 0 8px rgba(70, 193, 255, .8);
}

.pick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #dfe3e8;
}

.pick-pos {
  flex: none;
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 720px) {
  #brand img { width: 150px; }
  #panel { width: 186px; }
  #popup { width: 240px; }
}
