:root {
  --bg: #1d1f1a;
  --panel: #262922;
  --panel2: #30342b;
  --line: #454a3e;
  --text: #e6e4d8;
  --dim: #a7a594;
  --accent: #c9a44a;
  --bad: #e0574a;
  --good: #7cb46b;
  --su: #b3261e;
  --de: #3d6595;
}
* { 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", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.on, button.primary { background: var(--accent); color: #1a1a14; border-color: var(--accent); }
button.danger { border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
textarea { width: 100%; resize: vertical; }
input[type=number] { width: 72px; }
label { color: var(--dim); }
a { color: var(--accent); }

#top { height: 40px; display: flex; align-items: center; gap: 18px; padding: 0 12px;
  background: #121410; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
#role { font-weight: 700; letter-spacing: .5px; }
#clock { font: 600 18px ui-monospace, Menlo, Consolas, monospace; color: var(--accent); }
#cursor { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--dim); }
.grow { flex: 1; }

main { position: absolute; top: 40px; bottom: 0; left: 0; right: 0; display: flex; }
#mapwrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #2b2e27; }
#side { width: 440px; max-width: 48vw; display: flex; flex-direction: column; background: var(--panel);
  border-left: 1px solid var(--line); }
#tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
#tabs button { border: 0; border-radius: 0; background: transparent; padding: 8px 10px; color: var(--dim); }
#tabs button.on { color: var(--accent); box-shadow: inset 0 -2px var(--accent); background: transparent; }
#panel { flex: 1; overflow-y: auto; padding: 10px; }
#dock { border-top: 1px solid var(--line); padding: 8px 10px; background: var(--panel2); }
#dock:empty { display: none; }

#hint[hidden] { display: none; }
#hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: #121410ee; border: 1px solid var(--accent); padding: 6px 10px; border-radius: 6px;
  display: flex; gap: 8px; align-items: center; }

#toast { position: fixed; bottom: 16px; left: 16px; z-index: 3000; padding: 8px 12px; border-radius: 6px;
  background: #121410; border: 1px solid var(--good); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 60vw; }
#toast.show { opacity: 1; }
#toast.bad { border-color: var(--bad); }

#modal { position: fixed; inset: 0; z-index: 2500; background: #000a; display: flex; align-items: center; justify-content: center; }
#modal[hidden] { display: none; }
.modal-box { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 16px; max-width: 92vw; max-height: 92vh; overflow: auto; }
.modal-x { position: absolute; top: 6px; right: 6px; }
.modal-box img, .modal-box canvas { max-width: 86vw; max-height: 78vh; display: block; }

h3 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
h3:first-child { margin-top: 0; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.col { display: flex; flex-direction: column; gap: 4px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.box { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin: 6px 0; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff;
  font-size: 11px; text-align: center; margin-left: 4px; }
.side-su { color: #e46d63; }
.side-de { color: #7fa6d6; }
.warn { color: var(--bad); }

/* списки */
.list { display: flex; flex-direction: column; gap: 4px; }
.item { padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); }
.item.click { cursor: pointer; }
.item.click:hover { border-color: var(--accent); }
.item.sel { border-color: var(--accent); }
.item.dead { opacity: .45; }
.item .t { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--dim); margin-right: 6px; }
.chip { display: inline-block; font-size: 12px; padding: 0 6px; border: 1px solid var(--line); border-radius: 10px; margin: 2px 2px 0 0; }

/* сообщения */
.msg { padding: 6px 8px; border-radius: 6px; margin: 4px 0; background: var(--panel2); border-left: 3px solid var(--line); }
.msg.out { border-left-color: var(--accent); }
.msg.in { border-left-color: var(--good); }
.msg.sys { border-left-color: #888; font-style: italic; }
.msg img { max-width: 100%; margin-top: 4px; cursor: zoom-in; border: 1px solid var(--line); }
.msg .who { font-weight: 600; }

/* оповещения */
.alert { padding: 6px 8px; border-radius: 6px; margin: 4px 0; background: var(--panel2); border-left: 3px solid var(--line); }
.alert.k-spot { border-left-color: #e0b84a; }
.alert.k-sound { border-left-color: #8a7fd6; }
.alert.k-combat, .alert.k-death { border-left-color: var(--bad); }
.alert.k-runner { border-left-color: #4fb0a6; }
.alert.k-order { border-left-color: var(--accent); }
.alert.k-mine, .alert.k-morale { border-left-color: #f08a24; }
.alert .drafts { margin-top: 4px; display: flex; flex-direction: column; gap: 2px; }
.alert .drafts button { text-align: left; font-size: 12px; padding: 2px 6px; }
.alert .x { float: right; padding: 0 6px; }

/* карта */
.pixelated { image-rendering: pixelated; }
.sqlabel { color: #000; font: 600 11px ui-monospace, Menlo, monospace; opacity: .55; pointer-events: none; text-shadow: 0 0 2px #fff; }
.unit { position: relative; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff;
  border: 2px solid #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px #000a; }
.unit b { font-size: 11px; }
.unit span { position: absolute; top: 26px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11px;
  font-weight: 600; color: #000; text-shadow: 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; }
.unit i { position: absolute; right: -8px; top: -8px; font-style: normal; font-size: 12px; background: #fff; color: #000;
  border-radius: 50%; width: 15px; height: 15px; display: flex; align-items: center; justify-content: center; }
.unit.sel { outline: 3px solid var(--accent); outline-offset: 2px; }
.unit.ghost { background: transparent; border: 2px dashed var(--c); color: var(--c); box-shadow: none; }
.unit.ghost b { color: var(--c); }
.unit.dead { background: #777; }
.unit.st-question i { background: #f0a020; }
.unit.st-lost { background: #555; border-color: var(--bad); }
.unit.st-lost i { background: var(--bad); color: #fff; }
.pin { position: relative; width: 0; height: 0; }
.pin > i { position: absolute; left: -4px; top: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 1.5px #fff, 0 0 2px 1.5px #0006; }
.pin.pin-kt > i { left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 0; transform: rotate(45deg); }
.pin-lbl { position: absolute; top: 6px; left: 0; transform: translateX(-50%); white-space: nowrap; }
.msym { display: flex; flex-direction: column; align-items: center; }
.msym b { border: 2px solid var(--c); color: var(--c); background: #fffd; font-size: 10px; padding: 0 3px; border-radius: 2px; white-space: nowrap; }
.msym.conf-prob b { border-style: dashed; }
.msym.conf-maybe b { border-style: dotted; }
.msym span { font-size: 10px; color: var(--c); background: #fffc; padding: 0 2px; white-space: nowrap; }
.msym em { font-size: 9px; font-style: normal; color: #333; background: #fffa; padding: 0 2px; }
.mtext { font-weight: 700; white-space: nowrap; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.mlabel { background: #fffd; border: 0; box-shadow: none; font-size: 11px; padding: 0 3px; }
.mine-ic { font-size: 14px; text-shadow: 0 0 2px #fff; }
.landmark { white-space: nowrap; font: 700 11px system-ui; color: #4a2b00; background: #ffe9a8e6; border: 1px solid #8a6200;
  padding: 0 4px; border-radius: 3px; }
.landmark.kt { background: #fff; border-color: #000; color: #000; }
.leaflet-container { cursor: crosshair; }
.leaflet-tooltip.ruler { font: 600 12px ui-monospace, Menlo, monospace; }

/* легенда карты */
.legend { background: #121410; color: #e6e4d8; border: 1px solid var(--line); border-radius: 6px; font: 12px/1.45 system-ui, sans-serif; max-width: 320px; box-shadow: 0 2px 8px #0008; }
.legend .lg-body > div { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.legend .lg-toggle { color: #e6e4d8; font: 600 12px system-ui, sans-serif; }
.legend .lg-toggle { border: 0; background: transparent; padding: 5px 9px; }
.legend .lg-body { padding: 4px 10px 8px; display: flex; flex-direction: column; gap: 3px; max-height: 60vh; overflow-y: auto; }
.legend .lg-body[hidden] { display: none; }
.legend b { color: var(--accent); margin-top: 4px; }
.legend .dim { color: var(--dim); margin-top: 4px; }
.lg-unit { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--su); color: #fff; font: 700 10px system-ui; margin-right: 6px; vertical-align: middle; border: 2px solid #fff; }
.lg-unit.ghost { background: transparent; border: 2px dashed #e46d63; color: #e46d63; }
.lg-unit.solid:empty::after { content: 'П'; }
.lg-unit.ghost:empty::after { content: 'П'; }
.lg-circle { display: inline-block; width: 20px; height: 20px; border-radius: 50%; border: 1px solid #e46d63; background: #e46d6322; margin-right: 6px; vertical-align: middle; }
.lg-line { display: inline-block; width: 22px; margin-right: 6px; vertical-align: middle; border-top: 2px dashed #e46d63; }
.lg-arrow { display: inline-block; width: 22px; margin-right: 6px; color: #e46d63; font-weight: 700; }
.cmp-label { font: 700 10px ui-monospace, Menlo, monospace; color: #111; text-align: center; text-shadow: 0 0 3px #fff, 0 0 3px #fff; pointer-events: none; }
.cmp-toggle { width: 34px; height: 34px; font-size: 18px; padding: 0; background: #fff; border: 2px solid #0003; border-radius: 4px; cursor: pointer; opacity: .55; }
.cmp-toggle.on { opacity: 1; border-color: var(--accent); background: #fff6dc; }
