:root {
  --bg: #f4f1ea; --bg2: #ebe6da; --bg3: #e0d9c9; --panel: #fbf9f4; --line: #b9b2a0; --line2: #8f8872;
  --ink: #1e2430; --dim: #5a6170; --teal: #0e7c7b; --teal2: #0a5f5e; --tealbg: #d8ecea; --amber: #b86e00; --amberbg: #fbe9c8;
  --red: #b3261e; --redbg: #f8d9d6; --green: #2e7d32; --hp: #c0392b; --ton: #2f80c9; --xp: #b86e00;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #d9d4c7; overflow: hidden; }
body { font: 14px/1.35 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#game { position: relative; width: 1000px; height: 600px; background: var(--bg); transform-origin: center center; box-shadow: 0 6px 30px rgba(30, 36, 48, .35); overflow: hidden; flex: none; }
button { font: inherit; color: var(--ink); }
.btn { background: var(--panel); border: 1.5px solid var(--line2); padding: 5px 12px; cursor: pointer; clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px); min-height: 30px; font-weight: 600; }
.btn:hover:not(:disabled) { background: var(--tealbg); border-color: var(--teal); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal2); }
.btn.primary:hover:not(:disabled) { background: var(--teal2); }
.btn.warn { background: var(--amberbg); border-color: var(--amber); }
.btn.on { background: var(--tealbg); border-color: var(--teal); box-shadow: inset 0 0 0 1.5px var(--teal); }
.btn.small { padding: 2px 8px; min-height: 24px; font-size: 13px; }

/* сцена */
#scene { position: absolute; left: 0; top: 0; width: 810px; height: 540px; }
#scene canvas { position: absolute; left: 0; top: 0; }
#goal { position: absolute; left: 0; top: 0; width: 810px; min-height: 27px; padding: 4px 10px 4px 14px; background: rgba(251, 249, 244, .95); border-bottom: 1.5px solid var(--line); border-left: 6px solid var(--amber); font-size: 14px; font-weight: 600; z-index: 5; }
#goal b { color: var(--amber); }
#scenebtns { position: absolute; left: 8px; right: 8px; top: calc(var(--gh, 27px) + 7px); display: flex; gap: 8px; z-index: 5; pointer-events: none; }
#scenebtns .btn { pointer-events: auto; box-shadow: 0 2px 6px rgba(30, 36, 48, .25); }
#scenebtns .btn:not(.primary):not(.warn) { background: rgba(251, 249, 244, .97); }
#scenebtns .sp { flex: 1; }
.minehint { position: absolute; left: 10px; top: calc(var(--gh, 27px) + 47px); font-size: 12.5px; color: var(--ink); background: rgba(251, 249, 244, .9); padding: 2px 8px; border-left: 4px solid var(--teal); z-index: 4; white-space: nowrap; }
#banner.note { background: rgba(251, 249, 244, .96); border-color: var(--teal); font-weight: 400; white-space: normal; width: 560px; text-align: center; }
#banner { position: absolute; left: 50%; top: calc(var(--gh, 27px) + 50px); transform: translateX(-50%); background: var(--amberbg); border: 1.5px solid var(--amber); padding: 6px 14px; font-weight: 700; z-index: 6; white-space: normal; width: max-content; max-width: 700px; text-align: center; line-height: 1.3; }
.label { position: absolute; transform: translate(-50%, -100%); background: rgba(251, 249, 244, .95); border: 1.5px solid var(--line2); padding: 1px 8px; font-weight: 700; font-size: 13px; white-space: nowrap; pointer-events: none; z-index: 3; }
.label.foe { border-color: var(--red); color: var(--red); }
.label.hot { border-color: var(--teal); background: var(--tealbg); }
#npc { position: absolute; left: 10px; top: 250px; width: 66px; height: 66px; border: 2.5px solid var(--line2); background: var(--panel); cursor: pointer; z-index: 4; }
#npc.news { border-color: var(--amber); animation: blink 1s infinite; }
#npc canvas { position: static; display: block; }
@keyframes blink { 50% { box-shadow: 0 0 0 5px rgba(184, 110, 0, .55); } }

/* правая колонка */
#right { position: absolute; left: 810px; top: 0; width: 190px; height: 540px; background: var(--bg2); border-left: 2px solid var(--line2); display: flex; flex-direction: column; }
#mm { padding: 5px 7px 6px; border-bottom: 1.5px solid var(--line); }
#mm .title { font-weight: 700; font-size: 13px; line-height: 1.15; margin-bottom: 4px; }
#mm .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
#mm .cell { height: 30px; border: 1.5px solid var(--line2); position: relative; cursor: pointer; background: #cfe8cf; }
#mm .cell.danger { background: #f1c9c4; }
#mm .cell.none { background: #c9c5ba; cursor: default; border-style: dashed; }
#mm .cell.cur { box-shadow: inset 0 0 0 2.5px var(--ink); cursor: default; }
#mm .cell.goal::after { content: "★"; position: absolute; right: 2px; top: -3px; color: var(--amber); font-size: 15px; text-shadow: 0 0 2px #fff; }
#mm .cell:hover:not(.none):not(.cur) { outline: 2.5px solid var(--teal); z-index: 2; }
#mm .dot { position: absolute; width: 7px; height: 7px; border-radius: 50%; border: 1px solid #fff; }
#mm .b { position: absolute; left: 2px; bottom: 1px; font-size: 10px; font-weight: 700; color: var(--teal2); }
#mm .hint { font-size: 11px; line-height: 1.2; color: var(--dim); height: 27px; margin-top: 3px; overflow: hidden; }
#binfo { display: none; padding: 4px 8px; border-bottom: 1.5px solid var(--line); font-weight: 700; font-size: 15px; justify-content: space-between; background: var(--panel); }
#binfo.on { display: flex; }
#binfo .t.low { color: var(--red); }
#hp { padding: 6px 8px; flex: 1; display: flex; flex-direction: column; gap: 5px; min-height: 0; }
#hp .name { font-weight: 700; display: flex; justify-content: space-between; }
#hp .row { display: flex; gap: 7px; align-items: flex-start; }
#hp canvas.portrait { width: 56px; height: 56px; border: 1.5px solid var(--line2); flex: none; }
.bar { height: 13px; background: #d6d0c0; border: 1px solid var(--line2); position: relative; margin-bottom: 3px; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; }
.bar > span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 12px; font-weight: 700; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.bar.hp > i { background: var(--hp); } .bar.ton > i { background: var(--ton); } .bar.xp > i { background: var(--xp); }
#body { display: flex; gap: 6px; align-items: center; }
#body svg { flex: none; }
#body .z { font-size: 12px; color: var(--dim); line-height: 1.5; }
#stances { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
#stances .btn { padding: 2px 0; font-size: 11px; min-height: 34px; min-width: 0; overflow: hidden; white-space: nowrap; letter-spacing: -.02em; display: flex; flex-direction: column; align-items: center; justify-content: center; clip-path: none; }
#stances svg { width: 18px; height: 18px; }
#turnbtns { display: none; flex-direction: column; gap: 4px; margin-top: auto; }
#turnbtns.on { display: flex; }
#turnbtns .btn { width: 100%; }
#peace { margin-top: auto; font-size: 12px; color: var(--dim); }

/* низ */
#bottom { position: absolute; left: 0; top: 540px; width: 1000px; height: 60px; background: var(--bg3); border-top: 2px solid var(--line2); display: flex; align-items: center; padding: 0 8px; gap: 5px; }
.slot { width: 48px; height: 48px; border: 1.5px solid var(--line2); background: var(--panel); position: relative; flex: none; }
.slot.over { outline: 3px solid var(--teal); background: var(--tealbg); }
.slot .key { position: absolute; left: 2px; top: 0; font-size: 10px; color: var(--dim); font-weight: 700; }
.it { width: 100%; height: 100%; position: relative; cursor: grab; }
.it svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.it .n { position: absolute; right: 2px; bottom: 0; font-size: 12px; font-weight: 800; color: var(--ink); text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff; pointer-events: none; }
#bottom .sp { flex: 1; }
#bottom .btn { display: flex; align-items: center; gap: 6px; }
#bottom .btn svg { width: 20px; height: 20px; }
#bottom .btn.news { border-color: var(--amber); background: var(--amberbg); animation: blink 1s infinite; }
#dragghost { position: fixed; width: 48px; height: 48px; pointer-events: none; z-index: 1000; opacity: .9; }
#dragghost svg { width: 100%; height: 100%; }

/* окна */
.win { position: absolute; background: var(--panel); border: 2px solid var(--line2); box-shadow: 0 5px 18px rgba(30, 36, 48, .3); z-index: 20; display: flex; flex-direction: column; clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px); }
.win > .hd { background: var(--bg3); border-bottom: 1.5px solid var(--line2); padding: 5px 10px 5px 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.win > .hd .x { margin-left: auto; cursor: pointer; width: 24px; height: 24px; border: 1.5px solid var(--line2); background: var(--panel); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.win > .hd .x:hover { background: var(--redbg); border-color: var(--red); }
.win > .bd { padding: 10px; flex: 1; min-height: 0; overflow: auto; }
.win .ft { padding: 8px 10px 12px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1.5px solid var(--line); }
#veil { position: absolute; left: 0; top: 0; width: 810px; height: 540px; background: rgba(244, 241, 234, .55); z-index: 15; }
.cols { display: flex; gap: 10px; height: 100%; }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tabs.h { flex-direction: row; margin-bottom: 8px; flex-wrap: wrap; }
.sub { font-size: 12px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; margin: 2px 0 5px; }
.kv { display: flex; justify-content: space-between; padding: 1px 0; border-bottom: 1px dotted var(--line); }
.kv b { font-weight: 700; }
.bad { color: var(--red); font-weight: 700; }
.good { color: var(--green); font-weight: 700; }
.dim { color: var(--dim); }
.grid6 { display: grid; grid-template-columns: repeat(6, 48px); gap: 3px; align-content: start; }
.packpanel { background: var(--bg2); border: 1.5px solid var(--line); padding: 6px; }
.packpanel.over { outline: 3px solid var(--teal); }
.doll { position: relative; width: 240px; height: 380px; background: linear-gradient(#f0ece2, #e2dccd); border: 1.5px solid var(--line); flex: none; }
.doll.over { outline: 3px solid var(--teal); }
.doll canvas { position: absolute; left: 44px; top: 8px; }
.doll .slot { position: absolute; }
.doll .slot .cap { position: absolute; left: 0; right: 0; bottom: -15px; text-align: center; font-size: 10px; color: var(--dim); white-space: nowrap; }
.doll .slot.empty { background: repeating-linear-gradient(45deg, #efeae0, #efeae0 5px, #e6e0d2 5px, #e6e0d2 10px); }
.perk { border: 1.5px solid var(--line); padding: 5px 8px; margin-bottom: 5px; background: var(--bg); }
.perk.take { cursor: pointer; border-color: var(--teal); }
.perk.take:hover { background: var(--tealbg); }
.perk b { display: block; }
#tip { position: fixed; z-index: 900; background: var(--panel); border: 1.5px solid var(--ink); padding: 7px 10px; max-width: 280px; font-size: 13px; pointer-events: none; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); }
#tip h4 { margin: 0 0 3px; font-size: 14px; }
#tip .kv { border: 0; gap: 12px; }
#toasts { position: absolute; left: 0; width: 810px; bottom: 70px; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 60; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 7px 16px; font-weight: 600; max-width: 640px; text-align: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }
.toast.bad { background: var(--red); } .toast.good { background: var(--teal2); }
#hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--gh, 27px) + 7px); width: 640px; background: var(--panel); border: 1.5px solid var(--amber); border-left: 7px solid var(--amber); padding: 8px 12px; z-index: 40; display: flex; gap: 12px; align-items: center; box-shadow: 0 3px 12px rgba(0, 0, 0, .22); }
#hint div { flex: 1; }
/* магазин */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card { border: 1.5px solid var(--line); background: var(--bg); padding: 7px; display: flex; flex-direction: column; gap: 3px; }
.card .top { display: flex; gap: 8px; }
.card .ic { width: 48px; height: 48px; flex: none; border: 1px solid var(--line); background: var(--panel); }
.card .ic svg { width: 100%; height: 100%; }
.card h5 { margin: 0; font-size: 13px; }
.card .st { font-size: 12px; color: var(--dim); }
.card .buy { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 4px; }
.qty { display: flex; align-items: center; gap: 6px; justify-content: center; margin: 10px 0; }
.qty input { width: 64px; font: inherit; font-size: 18px; text-align: center; padding: 3px; border: 1.5px solid var(--line2); background: #fff; }
table.t { border-collapse: collapse; width: 100%; }
table.t td, table.t th { padding: 2px 6px; border-bottom: 1px dotted var(--line); text-align: left; font-size: 13px; }
table.t td:last-child, table.t th:last-child { text-align: right; }
/* диалог */
.dlg { display: flex; gap: 12px; }
.dlg canvas { border: 1.5px solid var(--line2); flex: none; }
.dlg .opts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.dlg .opts .btn { text-align: left; }
/* карта мира */
.wmap { display: grid; grid-template-columns: 22px repeat(10, 56px); gap: 2px; font-size: 10px; }
.wmap .c { height: 30px; border: 1px solid var(--line2); position: relative; background: #cfe8cf; display: flex; align-items: center; justify-content: center; font-weight: 700; text-align: center; line-height: 1; }
.wmap .c.danger { background: #f1c9c4; } .wmap .c.none { background: #c9c5ba; } .wmap .c.fog { background: #e9e5da; color: transparent; }
.wmap .c.cur { box-shadow: inset 0 0 0 2.5px var(--ink); } .wmap .c.goal { outline: 2.5px solid var(--amber); z-index: 1; }
.wmap .ax { display: flex; align-items: center; justify-content: center; color: var(--dim); font-weight: 700; }
/* полигон */
.rooms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.room { border: 1.5px solid var(--line2); background: var(--bg2); padding: 6px; height: 62px; font-size: 12px; position: relative; }
.room b { font-size: 18px; color: var(--line2); position: absolute; right: 6px; top: 2px; }
.room.busy { background: var(--amberbg); }
/* бой */
#blog { position: absolute; left: 4px; bottom: 4px; width: 318px; height: 122px; background: rgba(251, 249, 244, .95); border: 1.5px solid var(--line2); z-index: 8; display: flex; flex-direction: column; font-size: 12px; }
#blog .hd { background: var(--bg3); padding: 2px 6px; font-weight: 700; display: flex; gap: 6px; align-items: center; white-space: nowrap; }
#blog .hd .sp { flex: 1; }
#blog .ls { flex: 1; overflow-y: auto; padding: 2px 6px; }
#blog .ls div.plan { color: var(--teal2); font-weight: 600; }
#blog .ls div.h { font-weight: 700; margin-top: 2px; }
#bweap { position: absolute; right: 4px; bottom: 4px; width: 480px; height: 122px; background: rgba(251, 249, 244, .95); border: 1.5px solid var(--line2); z-index: 8; padding: 5px 7px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
#bweap .r { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
#bweap .ic { width: 40px; height: 40px; border: 1px solid var(--line); flex: none; background: var(--panel); }
#bweap .ic svg { width: 100%; height: 100%; }
#bweap b.nm { font-size: 13px; }
#bcursor { position: fixed; z-index: 800; background: var(--ink); color: #fff; padding: 3px 8px; font-size: 12px; font-weight: 600; pointer-events: none; white-space: nowrap; }
#bcursor.bad { background: var(--red); }
#bcursor.warn { background: var(--amber); white-space: normal; max-width: 330px; }
/* меню */
#menu { position: absolute; inset: 0; background: linear-gradient(160deg, #f4f1ea, #d8ecea); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
#menu h1 { font-size: 50px; line-height: 1.1; margin: 0; letter-spacing: .12em; color: var(--teal2); }
#menu p { margin: 0 0 6px; color: var(--dim); font-size: 15px; }
#menu .btn { min-width: 300px; font-size: 15px; padding: 6px 18px; }
#menu .btn.small { min-width: 0; font-size: 14px; }
#menu .saves { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.create { display: flex; gap: 12px; height: 100%; }
.create .info { width: 210px; }
.create .holo { width: 230px; background: linear-gradient(#d8ecea, #bfe0dd); border: 1.5px solid var(--teal); position: relative; flex: none; }
.create .opts { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.create input { font: inherit; font-size: 16px; padding: 5px 8px; border: 1.5px solid var(--line2); background: #fff; width: 100%; user-select: text; -webkit-user-select: text; }
.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.looks canvas { width: 100%; border: 2px solid var(--line); cursor: pointer; background: var(--bg); display: block; }
.looks canvas.on { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal); }
progress { width: 100%; height: 14px; accent-color: var(--teal); }

/* корзина в рюкзаке: сюда перетаскивают вещь, чтобы выбросить */
.bin { margin-top: 6px; padding: 5px 8px; border: 1.5px dashed #b9b29c; border-radius: 4px; font-size: 12px; color: #5a6170; text-align: center; }
.bin.over { border-color: #b3261e; background: #f6d9d5; color: #b3261e; }

/* панель оружия в бою: всё должно помещаться в свою рамку */
#bweap { overflow: hidden; }
#bweap .r > div { min-width: 0; }
#bweap .r > div > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bweap .btn.small { padding-left: 7px; padding-right: 7px; }
#bweap > .dim, #bweap > .bad { font-size: 11px; line-height: 1.2 !important; }

/* вне боя: состояние магазинов и кнопка «Зарядить оружие» */
#peace .guns { color: var(--ink); margin-bottom: 3px; line-height: 1.3; }
#peace .btn.small { width: 100%; margin-bottom: 6px; }

/* полоска прочности под надетой вещью */
.it .dur { position: absolute; left: 3px; right: 3px; bottom: 2px; height: 3px; background: rgba(30, 36, 48, .18); border-radius: 2px; overflow: hidden; }
.it .dur i { display: block; height: 100%; }

/* глушь: дальние опасные клетки темнее обычных опасных */
#mm .cell.danger.wild { background: #e2a39b; }
.wmap .c.danger.wild { background: #e2a39b; }

/* отсчёт перехода через опасную клетку: кольцо на клетке героя, соседние клетки приглушены */
#mm .ring { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; display: flex; align-items: center; justify-content: center; }
#mm .ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
#mm .ring circle { fill: none; stroke-width: 3; }
#mm .ring .bg { stroke: rgba(30, 36, 48, .18); fill: rgba(251, 249, 244, .9); }
#mm .ring .fg { stroke: var(--amber); stroke-linecap: round; stroke-dasharray: 59.7; animation: ringrun linear forwards; }
#mm .ring b { position: relative; font-size: 11px; line-height: 1; color: var(--ink); }
@keyframes ringrun { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 59.7; } }
#mm.hold .cell:not(.cur):not(.none) { opacity: .55; cursor: not-allowed; }
#mm.hold .cell:hover:not(.none):not(.cur) { outline-color: var(--line2); }

/* подпись достопримечательности: спокойнее, чем у зданий */
.label.lm { background: rgba(251, 249, 244, .85); border-color: var(--line2); color: var(--dim); font-weight: 600; font-size: 11px; pointer-events: none; }

/* вход, регистрация, выбор бойца */
#menu .who { font-weight: 700; color: var(--teal2); }
#menu .err { color: var(--red); font-weight: 600; min-height: 18px; max-width: 320px; text-align: center; }
#menu p.ok { color: var(--green); font-weight: 600; margin: 0; }
#menu .auth { display: flex; flex-direction: column; gap: 8px; align-items: stretch; width: 300px; background: var(--panel); border: 1.5px solid var(--line); padding: 14px 16px; }
#menu .auth .tabs { display: flex; flex-direction: row; gap: 6px; margin-bottom: 4px; }
#menu .auth .tabs .btn { flex: 1; }
#menu .auth .btn { min-width: 0; }
#menu .field { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--dim); }
#menu .field input { font: inherit; font-size: 15px; color: var(--ink); padding: 6px 8px; border: 1.5px solid var(--line2); background: #fff; user-select: text; -webkit-user-select: text; }
#menu .field input:focus { outline: none; border-color: var(--teal); }
#menu .auth .note { margin: 0; font-size: 12px; line-height: 1.3; }
#menu .langs { display: flex; gap: 6px; margin-top: 6px; }
#menu .langs .btn { min-width: 0; font-size: 13px; }
#menu .link { background: none; border: none; padding: 0; color: var(--teal2); text-decoration: underline; cursor: pointer; font-size: 13px; text-align: left; }
#menu .link:hover { color: var(--teal); }
#menu .auth .note.ok, #menu p.note.ok { color: var(--green); font-weight: 600; }
#menu .auth .note:empty { display: none; }
