:root {
  --bg: #16150f;
  --panel: #23211a;
  --panel2: #2e2b22;
  --line: #3d392d;
  --text: #e8e2cf;
  --muted: #9c957f;
  --accent: #c8a03c;        /* выцветшее золото */
  --danger: #c4553b;
  --rad: #9bc53d;           /* радиационный зелёный */
  --common: #b9b4a3;
  --uncommon: #7fbf5a;
  --rare: #4e9be0;
  --epic: #b06ad8;
  --legendary: #e39b2d;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button:disabled { opacity: .4; }
button.primary { background: var(--accent); color: #1b1608; border: none; font-weight: 700; width: 100%; padding: 14px; }
input { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; width: 100%; margin-top: 6px; }
h1 { font-size: 22px; margin: 0 0 16px; letter-spacing: .5px; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.4em; }

.screen { position: fixed; inset: 0; display: none; padding: 20px; overflow-y: auto; }
.screen.active { display: block; }
.screen.center.active { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; }
.logo { font-size: 64px; color: var(--rad); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.field { display: block; margin-bottom: 18px; color: var(--muted); }
.toggle { display: flex; gap: 8px; margin-top: 6px; }
.toggle button { flex: 1; }
.toggle button.on, .mode button.on { background: var(--accent); color: #1b1608; border-color: var(--accent); }
.avatars { display: flex; gap: 12px; margin-top: 8px; }
.avatars img { width: 96px; height: 96px; border-radius: 18px; border: 3px solid transparent; cursor: pointer; }
.avatars img.on { border-color: var(--accent); }

.stat-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stat-row .name { flex: 1; }
.stat-row .desc { display: block; font-size: 12px; color: var(--muted); }
.stat-row .val { width: 28px; text-align: center; font-weight: 700; font-size: 18px; }
.stat-row button { width: 40px; padding: 8px 0; }
.row-buttons { display: flex; gap: 10px; margin-top: 16px; }
.row-buttons button { flex: 1; }

.news { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--danger);
  border-radius: 12px; padding: 22px; max-width: 420px; width: 100%; text-align: left; min-height: 170px; }
.news-label { color: var(--danger); font-size: 12px; letter-spacing: 2px; font-weight: 700; }
.news-year { font-size: 34px; font-weight: 800; margin: 8px 0; }
.news-text { font-size: 17px; }
.dots { display: flex; gap: 6px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--accent); }
#screen-prologue .primary, #screen-shelter .primary { max-width: 420px; }

.shelter-icon { font-size: 56px; }
.radio { font-style: italic; max-width: 420px; }
.kit { background: var(--panel); border-radius: 12px; padding: 14px 18px; text-align: left; min-width: 260px; }
.kit ul { margin: 8px 0 0; padding-left: 18px; }

/* --- карта --- */
#screen-map { padding: 0; }
#map { position: absolute; inset: 0; }
/* постапокалиптическая подложка: выцветшая, тёплая, темнее */
#map canvas { filter: sepia(.55) saturate(.7) brightness(.72) contrast(1.15); }
.hud { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 10px; align-items: center;
  background: rgba(22,21,15,.88); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.hud-avatar { width: 44px; height: 44px; border-radius: 10px; }
.hud-main { flex: 1; min-width: 0; }
.hud-district { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xpbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 4px 0; }
.xpbar div { height: 100%; width: 0; background: var(--rad); transition: width .4s; }
.xpbar.gold div { background: var(--accent); }

.mode { position: absolute; top: 84px; left: 10px; display: flex; gap: 6px; }
.mode button { padding: 6px 10px; font-size: 13px; background: rgba(22,21,15,.88); }
.speeds { position: absolute; top: 120px; left: 10px; display: flex; gap: 6px; align-items: center; }
.speeds[hidden] { display: none; }
.speeds button { padding: 4px 8px; font-size: 12px; background: rgba(22,21,15,.88); }
.speeds button.on { background: var(--rare); border-color: var(--rare); color: #fff; }
.player-marker.walk { border-color: var(--rad); box-shadow: 0 0 0 6px rgba(155,197,61,.3); }
.hint { position: absolute; top: 124px; left: 10px; right: 10px; font-size: 12px; color: var(--muted);
  background: rgba(22,21,15,.8); border-radius: 8px; padding: 6px 10px; display: none; }
.hint.show { display: block; }
.speeds:not([hidden]) ~ .hint { top: 156px; }

.dwell { position: absolute; left: 10px; right: 66px; bottom: 92px; background: rgba(22,21,15,.92);
  border: 1px solid var(--accent); border-radius: 12px; padding: 10px 12px; }
.dwell-title { font-weight: 700; }

.toasts { position: absolute; left: 10px; right: 66px; bottom: 170px; z-index: 7; display: flex; flex-direction: column-reverse; gap: 6px; pointer-events: none; }
.toast { background: rgba(22,21,15,.94); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  animation: in .25s ease-out; font-size: 14px; }
.toast.good { border-color: var(--rad); }
.toast.warn { border-color: var(--danger); }
.toast.gold { border-color: var(--accent); }
@keyframes in { from { transform: translateY(10px); opacity: 0; } }

/* кнопки справа над меню */
.fabs { position: absolute; right: 10px; bottom: 92px; display: flex; flex-direction: column; gap: 8px; }
.fabs button { width: 46px; height: 46px; padding: 0; border-radius: 50%; font-size: 20px;
  background: rgba(35,33,26,.95); }
.fabs #btn-home { border-color: var(--rare); box-shadow: 0 0 0 3px rgba(78,155,224,.3); }
.badge { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px;
  position: absolute; top: 4px; right: 8px; }

/* нижнее меню: База · Персонаж · КАРТА · Клан · Магазин */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; height: 74px; z-index: 6; display: flex; align-items: flex-end;
  background: linear-gradient(#2a271e, #1b1a13); border-top: 2px solid #4a4433;
  padding: 0 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 14px rgba(0,0,0,.5); }
.tabbar button { position: relative; flex: 1; background: none; border: none; border-radius: 0; padding: 6px 0 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); }
.tabbar .ico { font-size: 24px; line-height: 1; filter: grayscale(.3); }
.tabbar button.on { color: var(--accent); }
.tabbar button.on .ico { filter: none; }
.tabbar button.center { flex: 1.2; }
.tabbar button.center .ico { width: 64px; height: 64px; margin-top: -30px; border-radius: 50%; font-size: 30px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #e8c25a, #a07a22); border: 3px solid #1b1a13;
  box-shadow: 0 0 0 2px #6b5a2a, 0 4px 12px rgba(0,0,0,.6); }
.tabbar button.center:not(.on) .ico { background: radial-gradient(circle at 35% 30%, #8a7a50, #4d4430); }
.tabbar button.soon { opacity: .38; }
.tabbar button.soon .ico { filter: grayscale(1); }
.soon-tag { position: absolute; top: 2px; right: 50%; transform: translateX(26px); font-size: 9px;
  background: #4a4433; color: var(--text); border-radius: 6px; padding: 0 4px; }

/* вкладки поверх карты */
.page { position: absolute; top: 0; left: 0; right: 0; bottom: 74px; z-index: 5; background: var(--bg);
  overflow-y: auto; padding: 18px 16px 24px; }
.page[hidden] { display: none; }
.page h2.section { font-size: 16px; margin: 20px 0 6px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.base-card { border-color: var(--accent); }
.base-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
button.wide { width: 100%; margin-top: 10px; }
button.danger { color: var(--danger); border-color: var(--danger); background: none; }
.center-text { text-align: center; margin: 6px 0 0; }
.rules { color: var(--muted); font-size: 13px; padding-left: 18px; margin-top: 18px; }
.rules li { margin-bottom: 4px; }
.base-marker { display: flex; flex-direction: column; align-items: center; font-size: 26px; line-height: 1;
  filter: drop-shadow(0 1px 2px #000); }
.base-marker span { font-size: 11px; font-weight: 700; color: var(--accent); background: rgba(22,21,15,.85);
  border-radius: 6px; padding: 1px 5px; margin-top: 2px; white-space: nowrap; max-width: 140px;
  overflow: hidden; text-overflow: ellipsis; }

/* персонаж: кукла + слоты */
.char-head { margin-bottom: 6px; }
.doll-wrap { display: flex; gap: 10px; align-items: center; }
.doll { flex: 1.1; max-width: 220px; aspect-ratio: 170 / 260;
  background: radial-gradient(ellipse at 50% 70%, rgba(200,160,60,.16), transparent 65%); }
.doll svg { width: 100%; height: 100%; overflow: visible; }
.doll .breath { animation: breathe 3.4s ease-in-out infinite; transform-origin: 82px 245px; transform-box: view-box; }
.doll .head { animation: look 7s ease-in-out infinite; transform-origin: 80px 58px; transform-box: view-box; }
.doll .weapon, .doll .arm-r { animation: sway 3.4s ease-in-out infinite; transform-origin: 114px 74px; transform-box: view-box; }
.doll .eye { animation: blink 5s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes breathe { 50% { transform: translateY(-1.5px) scaleY(1.012); } }
@keyframes look { 0%, 40%, 100% { transform: rotate(0); } 50%, 60% { transform: rotate(-4deg); } 70%, 80% { transform: rotate(3deg); } }
@keyframes sway { 50% { transform: rotate(-3deg); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.slots { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; flex-direction: column; align-items: flex-start; text-align: left; padding: 7px 10px;
  border-style: dashed; font-size: 13px; }
.slot.full { border-style: solid; background: var(--panel); }
.stat-val { display: flex; gap: 8px; align-items: center; }
.stat-val button { padding: 2px 10px; }
.bag-right { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.bag-right button, #slot-list button { padding: 5px 10px; font-size: 13px; }
#slot-list button.pick { background: var(--accent); color: #1b1608; border-color: var(--accent); }

.player-marker { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--accent);
  background: #222 center/cover; box-shadow: 0 0 0 6px rgba(200,160,60,.25); }
.player-marker.virtual { border-color: var(--rare); box-shadow: 0 0 0 6px rgba(78,155,224,.25); }

.sheet { position: fixed; left: 0; right: 0; bottom: 74px; max-height: 75vh; background: var(--panel);
  border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 14px 16px 24px; overflow-y: auto; z-index: 10; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.close { padding: 4px 10px; }
.list .item { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.item .meta { font-size: 12px; color: var(--muted); }
.grade-common { color: var(--common); } .grade-uncommon { color: var(--uncommon); }
.grade-rare { color: var(--rare); } .grade-epic { color: var(--epic); } .grade-legendary { color: var(--legendary); }
.profile-top { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.big-avatar { width: 72px; height: 72px; border-radius: 14px; }
.profile-nick { font-size: 18px; font-weight: 700; }
.maplibregl-ctrl-attrib { font-size: 10px; opacity: .7; }

/* всплывающее окно */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; max-width: 420px; width: 100%; }
.modal-box h2 { margin-bottom: 10px; }
.modal-text ul { margin: 0; padding-left: 18px; }
.modal-text li { margin-bottom: 6px; }
.modal-dont { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-top: 12px; }
.modal-dont input { width: auto; margin: 0; }
.modal .row-buttons button.primary { width: auto; flex: 1; }
.target-marker { font-size: 26px; line-height: 1; filter: drop-shadow(0 1px 2px #000); }

/* игроки рядом */
.player-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.player-row img { width: 36px; height: 36px; border-radius: 8px; }
.player-row .who { flex: 1; }

/* здоровье */
.hpbar { position: relative; height: 12px; background: #3a1d17; border-radius: 6px; overflow: hidden; margin-top: 3px; }
.hpbar div { height: 100%; width: 100%; background: linear-gradient(#d9604a, #a83a26); transition: width .35s; }
.hpbar span { position: absolute; inset: 0; font-size: 9px; line-height: 12px; text-align: center; color: #fff;
  text-shadow: 0 1px 1px #000; }
.hpbar.mob div { background: linear-gradient(#9a8f6c, #6b6247); }
.char-combat { margin: 8px 0 0; }

/* моб на карте */
.mob-marker { display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.mob-marker .mob-ico { width: 42px; height: 42px; border-radius: 50%; font-size: 26px; display: flex;
  align-items: center; justify-content: center; background: rgba(22,21,15,.9); border: 2px solid var(--danger);
  box-shadow: 0 0 0 5px rgba(196,85,59,.25); animation: mobpulse 1.6s ease-in-out infinite; }
.mob-marker.rank-elite .mob-ico { border-color: var(--epic); box-shadow: 0 0 0 5px rgba(176,106,216,.3); }
.mob-marker.rank-boss .mob-ico { border-color: var(--legendary); box-shadow: 0 0 0 6px rgba(227,155,45,.35);
  width: 52px; height: 52px; font-size: 32px; }
.mob-marker.weak { opacity: .55; }
.mob-marker span { font-size: 11px; font-weight: 700; color: var(--text); background: rgba(22,21,15,.85);
  border-radius: 6px; padding: 1px 5px; margin-top: 3px; white-space: nowrap; }
@keyframes mobpulse { 50% { transform: scale(1.08); } }

/* бой */
.fight { position: fixed; inset: 0; z-index: 15; background: rgba(10,9,6,.92); display: flex;
  align-items: center; justify-content: center; padding: 14px; }
.fight[hidden] { display: none; }
.fight-box { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--danger);
  border-radius: 16px; padding: 14px; }
.fight.rank-elite .fight-box { border-color: var(--epic); }
.fight.rank-boss .fight-box { border-color: var(--legendary); }
.fight-ambush { color: var(--danger); font-weight: 800; text-align: center; letter-spacing: 1px; margin-bottom: 8px;
  animation: pulse 1s infinite; }
.fight-mob { display: flex; gap: 12px; align-items: center; }
.fight-emoji { font-size: 56px; line-height: 1; animation: mobpulse 1.8s ease-in-out infinite; }
.fight-mob-info { flex: 1; }
.fight-name { font-size: 19px; font-weight: 800; }
.fight-log { height: 112px; overflow: hidden; margin: 10px 0; padding: 8px 10px; background: var(--bg);
  border-radius: 10px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.fight-log div { color: var(--muted); }
.fight-log div:first-child { color: var(--text); }
.fight-log .hit:first-child { color: var(--rad); }
.fight-log .hurt:first-child { color: var(--danger); }
.fight-me { margin-bottom: 10px; }
.zone-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.zone-label { width: 78px; font-size: 13px; color: var(--muted); }
.zone-row button { flex: 1; padding: 9px 4px; font-size: 13px; }
.zone-row button.on { background: var(--accent); color: #1b1608; border-color: var(--accent); font-weight: 700; }
.zone-row:nth-child(2) button.on { background: var(--rare); border-color: var(--rare); color: #fff; }
#fight-result { text-align: center; }
.fight-result-title { font-size: 24px; font-weight: 800; margin: 6px 0; }
