/* Дача Онлайн — стиль интерфейса.
   Все окна (магазины, рюкзак, доска, кухня, справка…) собраны в одну рамку: шапка с заголовком,
   левая колонка с вкладками или оглавлением, тело с прокруткой. Цвета — переменные ниже. */
:root {
  --paper: #fcf6e6;        /* фон окон и панелей */
  --paper-2: #f4ead3;      /* колонка вкладок, шапки */
  --paper-3: #fffaf0;      /* карточки внутри окон */
  --ink: #3a2f22;
  --muted: #7a6a55;
  --line: #e3d5b5;         /* разделители */
  --brown: #8a6a43;        /* рамки панелей */
  --brown-2: #a4855a;      /* рамки кнопок */
  --accent: #d18a00;       /* выбранное */
  --accent-bg: #ffe9a8;
  --btn: #efe2c4;
  --btn-hover: #fff3d6;
  --green: #5c9a3a;
  --red: #b3402a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .28);
  --radius: 14px;
}

/* Выделение выключено на всём (Safari понимает только -webkit-user-select) — кроме полей ввода */
* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b4a26; }
body { font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); }
img { -webkit-user-drag: none; }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; }
button { font: inherit; cursor: pointer; color: inherit; }
.hidden { display: none !important; }
h2 { font-size: 20px; margin: 0; line-height: 1.2; }

#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
/* Объёмная графика (WebGL) рисуется под игровым холстом; тот в этом режиме прозрачен — на нём только накладки */
#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: none; pointer-events: none; }

.panel {
  background: rgba(252, 246, 230, 0.95);
  border: 2px solid var(--brown);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* Общие кнопки */
.hud-btns button, .btn {
  background: var(--btn); border: 1.5px solid var(--brown-2); border-radius: 8px; padding: 4px 10px; font-size: 14px;
  transition: background .12s, transform .08s;
}
.hud-btns button:hover, .btn:hover { background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.active { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }
.btn.primary { background: var(--green); border-color: #4d8a2f; color: #fff; font-weight: 600; }
.btn.primary:hover { background: #4d8a2f; }
.linkbtn { background: none; border: none; padding: 0; font-size: 11px; color: var(--brown); text-decoration: underline dotted; }
.linkbtn:hover { color: #5a4210; }
.linkbtn.on { color: #b07800; font-weight: 700; }
.muted { color: var(--muted); font-size: 12px; }
.miss { color: var(--red); }
.lock { font-size: 11px; color: #8a4a00; font-weight: 600; white-space: nowrap; }

/* ---------- HUD (слева сверху) ---------- */
/* Верхний левый угол: цвет, имя и показатели одной строкой — только значки и цифры; ресурсы — плашкой под ней */
#hud { position: fixed; top: 12px; left: 58px; padding: 7px 12px; }
/* «Домой» — своя плашка слева от строки с именем, только домик */
#hud-home { position: fixed; top: 12px; left: 12px; width: 40px; height: var(--hud-h, 38px); padding: 0; font-size: 19px; line-height: 1; color: inherit; transition: transform .12s; }
#hud-home:hover { transform: translateY(-1px); background: var(--btn-hover); }
/* Бонус новичка к ноше — плашка справа от панели параметров (left ставит ui.updateBonus) */
/* Временные бонусы (BUFFS): значок, под ним оставшееся время — все в одном стиле */
#hud-bonus { position: fixed; display: flex; gap: 6px; z-index: 5; }
#hud-bonus .buff { min-width: 56px; padding: 5px 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--accent-bg); border: 1px solid #e8c56a; border-radius: 10px; box-shadow: var(--shadow); color: #5a4210; cursor: help; }
#hud-bonus .buff .ic { font-size: 20px; line-height: 1; }
#hud-bonus .buff .t { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
#hud-bonus .buff .nm { font-size: 9px; line-height: 1; opacity: .8; white-space: nowrap; }
.cat-group { margin: 10px 0 2px; font-size: 12px; font-weight: 600; opacity: .7; text-transform: uppercase; letter-spacing: .03em; }
.hud-name { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; margin-right: 4px; }
#hud-res { position: fixed; top: 54px; left: 12px; padding: 4px 12px; display: flex; gap: 10px; font-size: 13px; white-space: nowrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(0,0,0,.3); display: inline-block; }
.hud-res { display: flex; gap: 10px; flex-wrap: wrap; }
.can-bar { position: relative; height: 18px; margin-top: 8px; background: #d9ccb0; border-radius: 9px; overflow: hidden; }
#load-text, #can-text, #fuel-text { position: relative; display: block; text-align: center; font-size: 12px; font-weight: 600; }
.hud-stats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; white-space: nowrap; }
.hud-stats b { font-weight: 700; color: #3f3120; }
.hud-stats small { font-size: 11px; color: var(--muted); }
/* Мало сил, голод или перегруз — краснеет и мигает только цифра, значок остаётся как есть */
.hud-stats .low b { color: #b3402a; animation: num-low 1s ease-in-out infinite alternate; }
.hud-stats .resting b { color: #2d7a3a; animation: num-rest .7s ease-in-out infinite alternate; }   /* быстрый отдых: цифра бодрости растёт и «дышит» зелёным */
.hud-stats .resting small { color: #2d7a3a; font-weight: 700; }
@keyframes num-rest { from { text-shadow: 0 0 0 rgba(92, 154, 58, 0); } to { text-shadow: 0 0 8px rgba(92, 154, 58, .9); transform: scale(1.08); } }
@keyframes num-low { to { color: #f07a60; } }
/* Молния бодрости — голубая (жёлтый эмодзи перекрашен фильтром) */
.ico-en { display: inline-block; filter: hue-rotate(165deg) saturate(1.4); }
/* Время года, погода и день недели — по центру сверху */
#hud-env { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); padding: 6px 14px; font-size: 13px; color: #5a4a35; white-space: nowrap; }
/* Меню — кнопки столбиком у левого края, по центру экрана по высоте, без общей подложки */
#menu { position: fixed; top: 92px; left: 12px; padding: 0; background: none; border: 0; box-shadow: none; }   /* под строкой ресурсов: 18 кнопок по 30 px влезают над чатом и при 800 px высоты */
#menu .hud-btns { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0; }
#menu .hud-btns button { position: relative; flex: none; display: flex; align-items: center; width: auto; min-width: 36px; height: 30px; padding: 0; font-size: 16px; box-shadow: 0 2px 6px rgba(0,0,0,.25); overflow: hidden; }
/* Красная точка: председатель заметит беспорядок или уже выписал предписание — подробности в 📋 */
#menu button.alert::after { content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: #d9534f; box-shadow: 0 0 0 1.5px var(--paper); }
#menu .mi { flex: none; width: 36px; text-align: center; }
/* Название раскрывается вправо при наведении */
#menu .ml { max-width: 0; opacity: 0; padding: 0; font-size: 13px; white-space: nowrap; overflow: hidden; transition: max-width .18s ease, opacity .12s ease, padding .18s ease; }
#menu button:hover .ml, #menu button:focus-visible .ml { max-width: 160px; opacity: 1; padding: 0 10px 0 2px; }
/* Развёрнутое меню (по умолчанию): подписи видны всегда; «Свернуть» оставляет значки, подписи — по наведению */
#menu.wide .ml { max-width: 160px; opacity: 1; padding: 0 10px 0 2px; }
#menu.wide .hud-btns { align-items: stretch; }
#btn-menu .mi { font-weight: 700; color: var(--muted, #7a6a55); }
@keyframes vit-low { to { background: #f0a89a; } }
.eat { display: flex; gap: 4px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.eat button { padding: 1px 6px; font-size: 12px; }

/* ---------- Правая колонка: миникарта, участок, задание, рейтинг ---------- */
#side { position: fixed; top: 12px; right: 12px; width: 236px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 300px); }
/* Миникарта — в правом нижнем углу; клик — карта мира. Где панель инструментов до неё дотягивается — выше неё */
#minibox { position: fixed; right: 12px; bottom: 12px; width: 216px; cursor: pointer; z-index: 5; transition: transform .12s, box-shadow .12s; }
#minibox:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
@media (max-width: 1300px) { #minibox { bottom: 92px; } }
.minimap-wrap { padding: 8px; display: flex; justify-content: center; }
#minimap { display: block; border-radius: 6px; }
#plotinfo, #questpanel, #toppanel { padding: 0 0 8px; overflow: hidden; }
#plotinfo > *:not(h3), #questpanel > *:not(h3), #toppanel > *:not(h3) { margin-left: 12px; margin-right: 12px; }
#plotinfo h3, #questpanel h3, #toppanel h3 {
  margin: 0 0 6px; padding: 7px 12px; font-size: 13px; background: var(--paper-2); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
}
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { background: #e6d6b0; border-radius: 10px; padding: 1px 8px; font-size: 12px; }
.quest-title { font-weight: 700; margin-bottom: 2px; }
.quest-reward { font-size: 12px; font-weight: 700; color: #5a4210; }
.quest-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: 5px; }
.quest-why { margin-top: 4px; }
/* Карточка задания справа: просторнее остальных панелей — крупный значок, заголовок, отступы между рядами */
#questpanel { padding-bottom: 14px; cursor: pointer; }
#questpanel:hover { background: var(--paper-3); }
#questpanel h3 { margin-bottom: 12px; padding: 9px 8px 9px 10px; font-size: 13px; letter-spacing: -.3px; align-items: center; }   /* 13 px и счётчик 12 px: «📜 Путь дачника 38 из 41» с двузначным номером обрезалось до «38…» */
#questpanel h3 .muted { font-size: 12px; }
#questpanel .quest-fold { margin-left: 2px; }
/* свёрнутая карточка задания: только заголовок со значком шага (ui.questMin) */
#questpanel h3 > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#questpanel.min { padding-bottom: 0; }
#questpanel.min h3 { margin-bottom: 0; border-bottom: 0; }
.quest-min { display: inline-flex; align-items: center; gap: 4px; font-size: 18px; }
.quest-min .muted { font-size: 12px; }
.quest-fold { flex: 0 0 auto; width: 24px; height: 24px; margin-left: 4px; border-radius: 6px; border: 1px solid var(--brown-2); background: var(--btn);
  font-size: 12px; line-height: 1; padding: 0; color: var(--muted); }
.quest-fold:hover { background: var(--btn-hover); color: var(--ink); }
.quest-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.quest-ic { font-size: 40px; line-height: 1; }
.quest-row .quest-title { margin: 0; font-size: 16px; line-height: 1.25; }
#questpanel .progress { height: 22px; margin: 12px 12px 0; }
#questpanel .progress span { line-height: 22px; font-size: 13px; }
#questpanel .quest-foot { margin-top: 12px; }
#questpanel .quest-reward { font-size: 16px; }
.quest-row .lock { font-weight: 500; }
.quest-row .quest-title { flex: 1; min-width: 0; }
.quest-nav { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--brown-2); background: var(--btn); font-size: 16px; line-height: 1; padding: 0; opacity: .8; }   /* указатель дороги к цели задания */
.quest-nav:hover { background: var(--btn-hover); opacity: 1; }
.quest-nav.on { background: var(--accent-bg); border-color: var(--accent); opacity: 1; box-shadow: 0 0 0 2px rgba(209, 138, 0, .25); }

/* Раздел «Путь дачника» на доске: слева главы с заданиями и наградой, справа карточка выбранного задания */
.qwrap { display: grid; grid-template-columns: 250px 1fr; gap: 14px; align-items: start; }
.qnav { display: flex; flex-direction: column; gap: 8px; }
.qchap { border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper-3); padding: 6px 6px 6px; }
.qchap.cur { border-color: var(--accent); }
.qchap.done { border-color: #a7cf8a; }
.qchap.next { opacity: .75; }
.qchap-h { display: flex; justify-content: space-between; align-items: baseline; width: 100%; padding: 4px 6px 6px; border: 0; background: none; text-align: left; font-weight: 700; font-size: 13px; }
.qchap.closed .qchap-h { padding-bottom: 4px; }
.qchap.done .qchap-h { color: #3f7d2c; }
/* Награда главы над карточкой задания: предметы плитками */
.qreward { margin-bottom: 10px; padding: 10px 12px; border: 1.5px solid var(--accent); border-radius: 12px; background: rgba(255, 233, 168, .45); }
.qreward.got { border-color: #7fae5a; background: #e3f1d4; }
.qreward-h { font-weight: 700; font-size: 13px; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; }
.qreward-items { display: flex; flex-wrap: wrap; gap: 6px; }
.rw-item { position: relative; display: flex; flex-direction: column; align-items: center; width: 84px; padding: 8px 4px 6px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper-3); text-align: center; }
.rw-ic { font-size: 30px; line-height: 1; }
.rw-n { position: absolute; top: 4px; right: 5px; font-size: 11px; font-weight: 700; color: #5a4a35; }
.rw-nm { font-size: 11px; line-height: 1.15; margin-top: 5px; color: #5a4a35; }
.qch-n { font-size: 11px; font-weight: 700; color: #5a4a35; }
.qstep { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; width: 100%; padding: 4px 6px; border: 1.5px solid transparent; border-radius: 7px; background: none; text-align: left; font-size: 12.5px; line-height: 1.2; }
.qstep:hover { background: var(--btn-hover); }
.qstep-ic { font-size: 16px; line-height: 1; text-align: center; }
.qstep.done { color: var(--muted); }
.qstep.done .qstep-m { color: #5c9a3a; font-weight: 700; }
.qstep.cur { font-weight: 600; }
.qstep.cur .qstep-m { color: var(--accent); }
.qstep.sel { background: var(--accent-bg); border-color: var(--accent); }
.quest-card { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; padding: 14px 16px; border: 1.5px solid var(--accent); border-radius: 12px; background: #fff8e3; }
.quest-card.done { border-color: #7fae5a; background: #e3f1d4; }
.quest-card.next { border-color: var(--line); background: var(--paper-3); }
.quest-big { font-size: 44px; line-height: 1; text-align: center; }
.quest-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 16px; }
.qtag { font-size: 12px; font-weight: 600; white-space: nowrap; }
.qtag.done { color: #3f7d2c; }
.qtag.cur { color: var(--accent); }
.qtag.lock { color: #8a4a00; }
.qtag.next { color: var(--muted); }
.quest-pay { display: flex; gap: 14px; margin: 6px 0 8px; font-size: 15px; font-weight: 700; color: #5a4210; }
.quest-body .progress { max-width: 260px; }
.quest-body .btn.on { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }
@media (max-width: 760px) {
  .qwrap { grid-template-columns: 1fr; }
  .qmain { order: -1; }
}

/* Свёрнутые правила раздела доски: одна строка, разворачивается по клику */
details.rules { margin: 4px 0 10px; font-size: 13px; color: #5a4a35; }
details.rules summary { cursor: pointer; color: var(--brown); font-size: 12px; text-decoration: underline dotted; list-style: none; width: max-content; }
details.rules summary::-webkit-details-marker { display: none; }
details.rules summary::before { content: 'ℹ️ '; }
details.rules[open] summary { margin-bottom: 4px; }
details.rules p { margin: 4px 0; }
.qstep { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 5px 8px; border-bottom: 1px dashed var(--line); font-size: 13px; }
.qstep-ic { font-size: 20px; line-height: 1; text-align: center; }
.qstep.done { color: var(--muted); }
.qstep.done .qstep-t { text-decoration: line-through; }
.qstep.done .qstep-m { color: #5c9a3a; font-weight: 700; }
.qstep.cur { background: var(--accent-bg); border-radius: 8px; border-bottom-color: transparent; font-weight: 600; }
.qstep.cur .qstep-m { color: var(--accent); }
.qstep.next { opacity: .7; }
.qstep.next .qstep-m { font-size: 11px; color: var(--muted); }
#questpanel .lock { white-space: normal; margin-top: 4px; }   /* «откроется на N-м уровне» — в узкой панели переносится */
#questpanel.flash { animation: quest-flash 1.2s ease-out; }
@keyframes quest-flash { 0% { background: #c8f0a8; transform: scale(1.04); } 100% { transform: none; } }
#toppanel { overflow-y: auto; }
.top-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.top-row.me { font-weight: 700; color: #7a4a00; }
.top-row small { display: block; color: #8a7a65; font-weight: 400; }

/* ---------- Панель инструментов ---------- */
#toolbar { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: flex-end; }
#hotbar { display: flex; gap: 5px; }
.tool {
  position: relative; width: 56px; height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  background: rgba(252, 246, 230, 0.94); border: 2px solid var(--brown); border-radius: 12px; box-shadow: 0 3px 10px rgba(0,0,0,.3); padding: 3px 2px 4px;
}
/* Ячейка в три ряда, как плитка рюкзака: полоса (номер слева, количество справа), картинка, название */
.tool .bi-top { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0 3px; box-sizing: border-box; min-height: 12px; font-size: 10px; line-height: 12px; }
.tool .ico { font-size: 21px; line-height: 1; }
.tool .lbl { font-size: 10px; line-height: 1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool .key { font-size: 10px; color: #8a7a65; }
.tool.active { background: var(--accent-bg); border-color: var(--accent); transform: translateY(-4px); }
.tool:hover { background: var(--btn-hover); }
/* Картинка предмета вместо эмодзи: размером с текущий шрифт, чтобы вставать на место значка где угодно */
img.iimg { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; pointer-events: none; }
/* Двойной значок семян: росток слева вверху, культура справа внизу крупнее — в ячейке панели, на плитке рюкзака, в магазине */
.ico2 { position: relative; display: inline-block; width: 1.35em; height: 1em; vertical-align: -0.12em; line-height: 1; }
.ico2 .a { position: absolute; left: 0; top: 0; font-size: .62em; }
.ico2 .b { position: absolute; right: 0; bottom: 0; font-size: .8em; }
/* Мелкий урожай: три маленьких значка горсткой в одной клетке */
.ico-small { position: relative; display: inline-block; width: 1.1em; height: 1em; vertical-align: -0.12em; line-height: 1; }
.ico-small span { position: absolute; font-size: .55em; }
.ico-small span:nth-child(1) { left: 0; top: 0; }
.ico-small span:nth-child(2) { right: 0; top: .1em; }
.ico-small span:nth-child(3) { left: .45em; bottom: 0; }
/* Панель быстрого доступа: ячейки с предметами, пустые — пунктиром; qty — сколько в рюкзаке, none — кончилось */
.tool.empty { opacity: .55; border-style: dashed; }
.tool.empty .ico { color: #8a7a65; }
.tool.none .ico, .tool.none .lbl { opacity: .4; }
.tool .qty { font-size: 10px; font-weight: 700; color: #5a4a35; }
.tool.drop { outline: 3px dashed var(--accent); outline-offset: -3px; }

#subbar { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); padding: 6px; display: flex; gap: 6px; max-width: calc(100vw - 24px); overflow-x: auto; }
.seed { padding: 6px 10px; border-radius: 8px; border: 1.5px solid transparent; background: var(--btn); text-align: center; min-width: 70px; flex: 0 0 auto; }
.seed.active { border-color: var(--accent); background: var(--accent-bg); }
.seed.empty { opacity: .5; }
.seed b { display: block; font-size: 20px; }
.seed.tool-chip { cursor: default; }

/* Полоска выбранной постройки над панелью инструментов */
#buildpanel { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); padding: 6px 10px; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; }
#buildpanel .bb-ico { font-size: 24px; }
#buildpanel .bb-name { font-weight: 700; }
#buildpanel .bb-hint { font-size: 12px; color: var(--muted); }
#buildpanel .btn { font-size: 13px; padding: 3px 8px; }

/* Панель топлива/заряда: видна, пока едете на технике с баком или батареей — шкала и кнопки заправки, как в окне 🚲.
   Над панелью инструмента (снасть в лодке, лопата на мотоблоке) поднимает её renderRideBar */
#ridepanel { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); padding: 6px 10px; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center; }
#ridepanel .fuel-bar { flex: 0 1 240px; margin: 0; }
#ridepanel .btn { font-size: 13px; padding: 3px 8px; }
#fuel-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#ffd96a, #e0a526); transition: width .2s; }
#ridepanel .fuel-bar.low #fuel-fill { background: linear-gradient(#f08a6c, #d04a2a); }
#ridepanel .fuel-bar.batt #fuel-fill { background: linear-gradient(#a4e08a, #57a83f); }   /* шкала заряда — зелёная */

/* ---------- Единая рамка окон ---------- */
#modal, #buildmenu { position: fixed; inset: 0; background: rgba(20, 30, 15, .45); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal-box, .bm-box {
  position: relative; display: flex; flex-direction: column; overflow: hidden; padding: 0;
  width: min(1040px, calc(100vw - 24px)); height: auto; min-height: min(440px, calc(100vh - 32px)); max-height: min(740px, calc(100vh - 32px));
  border-radius: var(--radius); box-shadow: var(--shadow); background: var(--paper);
  animation: modal-in .16s ease-out;
}
@keyframes modal-in { from { transform: translateY(10px) scale(.985); opacity: 0; } }
.mh {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; flex: 0 0 auto;
  background: linear-gradient(var(--paper-2), #ecdfc2); border-bottom: 1px solid #d9c9a4;
}
.mh-title { flex: 1; min-width: 0; }
.mh-title h2 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-close {
  position: static; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; font-size: 17px; line-height: 1;
  background: var(--btn); border: 1.5px solid var(--brown-2);
}
.modal-close:hover { background: var(--btn-hover); }
.mwrap { display: flex; flex: 1; min-height: 0; }
.mnav {
  flex: 0 0 200px; display: flex; flex-direction: column; gap: 2px; padding: 12px 8px; overflow-y: auto;
  background: var(--paper-2); border-right: 1px solid var(--line);
}
.mnav button, .mnav-toc button {
  display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 8px; border: 1.5px solid transparent;
  background: none; font-size: 14px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mnav button:hover { background: var(--btn-hover); }
.mnav button.active { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }
.mnav .tabs { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.mnav .tabs button { flex: none; }
.mnav-toc { display: flex; flex-direction: column; gap: 1px; }
.mnav-toc button { font-size: 13px; color: #5a4a35; padding: 6px 12px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mnav-toc button.active { background: rgba(255, 233, 168, .6); border-color: transparent; font-weight: 600; color: var(--ink); }
.mnav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 12px 4px; }
.mbody { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 20px 20px; scroll-behavior: smooth; }
.mbody > h2 { display: none; }   /* заголовок уже в шапке; если окно перерисовалось до раскладки — не дублировать */
.mbody h3 {
  margin: 18px 0 6px; padding-bottom: 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--brown); border-bottom: 1px solid var(--line); scroll-margin-top: 8px;
}
.mbody h3:first-child, .mbody > *:first-child > h3:first-child { margin-top: 2px; }
.mbody p { margin: 6px 0; }
.mbody kbd { background: var(--btn); border: 1px solid var(--brown-2); border-radius: 4px; padding: 0 5px; font: 12px ui-monospace, Menlo, Consolas, monospace; }
/* Вкладки, оставшиеся внутри тела (вложенные) — горизонтально */
.mbody .tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.mbody .tabs button { flex: 1; padding: 6px; border-radius: 8px; border: 1.5px solid var(--brown-2); background: var(--btn); }
.mbody .tabs button.active { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }

/* Строки в окнах: значок · название и пояснение · цена · кнопки */
.row { display: grid; grid-template-columns: 34px 1fr auto auto; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.row .ic { font-size: 24px; text-align: center; }
.row .price { font-weight: 700; white-space: nowrap; color: #5a4210; }
.row .btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.row .btns button { padding: 3px 9px; font-size: 13px; }
.stall-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.stall-row .ic { font-size: 24px; text-align: center; }
.stall-row .ctl { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.stall-row input { width: 62px; padding: 3px 5px; font: inherit; font-size: 13px; border: 1.5px solid var(--brown-2); border-radius: 6px; background: var(--paper-3); }
.stall-row label { font-size: 11px; color: var(--muted); }
.row:hover, .stall-row:hover, .recipe:hover, .ads-row:hover { background: rgba(255, 250, 240, .8); }
.helper-row { grid-template-columns: 34px 1fr; }
.helper-row .ctl { grid-column: 2; justify-content: flex-start; margin-top: 4px; }
.store-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.store-grid h3 { margin: 4px 0; }
.store-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.store-row .nm { flex: 1; min-width: 0; }
.store-row .btn { font-size: 13px; padding: 2px 6px; }

/* Рюкзак: плитки */
/* Фильтры рюкзака: строка кнопок-таблеток над плитками */
.bag-filters { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 10px; }
.bag-filters button { padding: 4px 10px; border-radius: 14px; border: 1.5px solid var(--brown-2); background: var(--btn); font-size: 13px; line-height: 1.2; }
.bag-filters button:hover { background: var(--btn-hover); }
.bag-filters button.active { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }
.bag { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.bag-item { display: flex; flex-direction: column; background: var(--paper-3); border: 1.5px solid var(--line); border-radius: 10px; padding: 5px 7px 7px; text-align: center; user-select: none; -webkit-user-select: none; }
/* Плитка в три ряда: сверху полоса (слева «в руках» и номер ячейки панели, справа количество, если больше одного),
   по середине картинка, снизу название; кнопки — под названием */
.bag-item .bi-top { display: flex; justify-content: space-between; align-items: center; min-height: 18px; }
.bag-item .marks { display: flex; gap: 3px; align-items: center; }
.bag-item .inhand-mark { font-size: 14px; line-height: 16px; }
.bag-item .hotkey { min-width: 16px; padding: 0 4px; font-size: 11px; font-weight: 700; line-height: 16px; color: #5a4a35; background: var(--accent-bg); border: 1px solid var(--accent); border-radius: 5px; }
.bag-item .qty { margin-left: auto; font-size: 11px; font-weight: 700; line-height: 16px; color: #5a4a35; }
.bag-item .bi-img { display: flex; align-items: center; justify-content: center; min-height: 48px; font-size: 34px; line-height: 1; }
.bag-item .bi-name { font-size: 12px; line-height: 1.15; margin-top: 2px; }
.bag-item.best { background: #fbe9b0; border-color: #d6a92a; }
.bag-item { cursor: pointer; }
.bag-item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(209, 138, 0, .35); }
/* Карточка выбранного предмета под куклой */
.item-info { margin-top: 10px; padding: 10px 12px; border: 1.5px solid var(--accent); border-radius: 10px; background: #fff8e3; }
.item-info.empty { border-color: var(--line); background: var(--paper-3); font-size: 13px; }
.ii-head { display: flex; align-items: center; gap: 10px; }
.ii-ic { font-size: 34px; line-height: 1; }
.ii-head b { font-size: 15px; }
.ii-lines { margin-top: 8px; font-size: 13px; color: #5a4a35; line-height: 1.35; }
.ii-close { float: right; width: 30px; height: 30px; margin: -4px -4px 0 6px; padding: 0; border-radius: 8px; border: 1px solid var(--brown-2); background: var(--btn); font-size: 14px; line-height: 1; }
.ii-btns { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.ii-btns:empty { display: none; }
.ii-btns .btn.active { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }
/* Выбор количества: съесть или на семена */
.qty-pick { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--paper-3); border: 1px solid var(--line); }
.qp-head { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.qp-row { display: flex; align-items: center; gap: 8px; }
.qp-row input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.qp-row input[type=number] { width: 64px; padding: 3px 5px; font: inherit; font-size: 13px; border: 1.5px solid var(--brown-2); border-radius: 6px; background: var(--paper); }
.qp-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.qp-chips .btn { padding: 1px 8px; font-size: 12px; }
.qp-chips .btn.active { background: var(--accent-bg); border-color: var(--accent); font-weight: 600; }
.qp-sum { margin-top: 8px; font-size: 13px; font-weight: 600; color: #3f6b2a; }
.bag-item .rot { color: #a0522d; }
.bag-item[data-drag] { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.bag-item.inhand { border-color: var(--accent); background: var(--accent-bg); }
.bag-item.dragging, .tool.dragging { opacity: .45; }
/* Копия предмета под курсором: размером с ячейку панели, событий не ловит */
.drag-ghost { position: fixed; z-index: 1000; width: 56px; height: 56px; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center;
  font-size: 30px; border-radius: 12px; background: rgba(252, 246, 230, .96); border: 2px solid var(--accent); box-shadow: 0 6px 16px rgba(0,0,0,.35); pointer-events: none; }
.dslot.drop { outline: 3px dashed var(--accent); outline-offset: -3px; }
.char-inv.drop { outline: 3px dashed var(--accent); outline-offset: 2px; border-radius: 10px; }
/* Сетка рюкзака тянется до низа окна: вернуть предмет из руки или снять можно, отпустив его в любом месте колонки */
body.char-open .mbody { display: flex; flex-direction: column; }
/* Окно дачника — постоянной высоты: разделы разной длины не дёргают рамку, длинное прокручивается внутри */
body.char-open .modal-box { height: min(740px, calc(100vh - 108px)); }   /* заканчивается над панелью быстрого доступа, которая лежит поверх окна */
body.help-open .modal-box, body.board-open .modal-box, body.set-open .modal-box { height: min(740px, calc(100vh - 32px)); }   /* справка и доска: разделы разной длины, высота не меняется при переключении */
body.char-open .char-wrap { flex: 1; align-items: stretch; }
.dslot.filled { cursor: grab; user-select: none; -webkit-user-select: none; }
#hotbar .tool { touch-action: pan-x; user-select: none; -webkit-user-select: none; }

/* Окно дачника: слева портрет и экипировка, справа раздел рюкзака. На широком экране панель быстрого доступа
   остаётся над окном: в ячейки перетаскивают прямо из рюкзака и берут из них в руку, не закрывая окно */
@media (min-width: 761px) { body.char-open #toolbar { z-index: 45; } }
.char-wrap { display: flex; gap: 16px; align-items: flex-start; }
.char-doll { flex: 0 0 300px; }
.doll { display: grid; grid-template-columns: 64px 150px 64px; gap: 6px; align-items: start; justify-content: center; margin-bottom: 8px; }
.doll canvas { display: block; border-radius: 12px; background: var(--paper-3); border: 1.5px solid var(--line); }
.doll-col { display: flex; flex-direction: column; gap: 5px; }
/* Ряд под фигурой: место под две ячейки, пока занята одна — обувь */
.doll-below { grid-column: 2; display: flex; justify-content: center; gap: 6px; }
.dslot { width: 64px; height: 64px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; margin: 0 auto;
  background: var(--paper-3); border: 1.5px solid var(--line); border-radius: 10px; }
.dslot .ic { font-size: 30px; line-height: 1; }
.dslot.filled { border-color: var(--brown-2); background: var(--btn); }
.dslot.hand { border-color: var(--accent); }
.dslot.empty .ic { opacity: .3; }
.dslot[data-rodcycle] { cursor: pointer; }
.char-slots { display: flex; flex-direction: column; gap: 5px; }
.char-slot { display: flex; gap: 8px; align-items: center; background: var(--paper-3); border: 1.5px solid var(--line); border-radius: 8px; padding: 5px 8px; font-size: 13px; }
.char-slot .ic { font-size: 22px; width: 28px; text-align: center; flex: none; }
.char-slot .cs-body { flex: 1; min-width: 0; }
.char-slot .cs-name { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.char-slot select { font: inherit; font-size: 12px; max-width: 100%; margin-top: 2px; border: 1.5px solid var(--brown-2); border-radius: 6px; background: var(--btn); padding: 2px 4px; }
.char-slot .btn { font-size: 12px; padding: 2px 7px; }
.char-slot.hand { border-color: var(--accent); }
.char-inv { flex: 1; min-width: 0; }
@media (max-width: 760px) {
  .char-wrap { flex-direction: column; }
  .char-doll { flex: none; width: 100%; order: -1; }
}

/* Плашки-сводки и карточки */
.sales-box { background: #e3f1d4; border: 1.5px solid #7fae5a; border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.sales-box.spoiled { background: #f6e3d6; border-color: #c98a5a; }
.order { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; background: var(--paper-3); }
.order.rare { border-color: var(--accent); background: #fff4d6; }
.order-head { display: flex; justify-content: space-between; gap: 8px; }
.order-want { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.want { background: var(--btn); border-radius: 8px; padding: 2px 8px; font-size: 13px; }
.want.ok { background: #d8ecc4; }
.want.miss { background: #f3d6cc; }
.order-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.reward { font-weight: 700; color: #5a4210; }
.progress { position: relative; height: 18px; background: #d9ccb0; border-radius: 9px; overflow: hidden; margin: 6px 0; }
.progress div { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#9fd67a, #5c9a3a); }
.progress span { position: relative; display: block; text-align: center; font-size: 12px; font-weight: 700; }
.recipe { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.recipe .ic { font-size: 26px; text-align: center; }
.recipe.locked { opacity: .55; }
.help p, .help li { margin: 5px 0; }
.help ul { padding-left: 20px; }
.tips-opt { display: block; margin: 6px 0; font-size: 13px; }
#view-opts.disabled, #models-opts.disabled { opacity: 0.45; }   /* «Вид» и «Модели» в плоской графике — неактивны */
.help kbd { background: var(--btn); border: 1px solid var(--brown-2); border-radius: 4px; padding: 0 5px; font: 12px monospace; }

/* Справка «Как играть»: карточки (значок + суть), шаги первого дня, клавиши, участок «было → стало» */
.help .lead { margin: 0 0 8px; color: var(--muted); }
/* Подзаголовки внутри раздела — как h3, но не попадают в оглавление слева */
.hp-h { margin: 18px 0 6px; padding-bottom: 4px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--brown); border-bottom: 1px solid var(--line); }
.hp-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px 8px; margin: 10px 0 14px; counter-reset: step; }
.hp-step { position: relative; background: var(--paper-3); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 6px 8px; text-align: center; }
.hp-step::before {
  counter-increment: step; content: counter(step); position: absolute; top: -9px; left: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; line-height: 20px;
}
.hp-step .ic { font-size: 30px; line-height: 1.1; }
.hp-step b { display: block; font-size: 13px; margin-top: 4px; line-height: 1.2; }
.hp-step span { display: block; font-size: 12px; color: var(--muted); line-height: 1.25; margin-top: 3px; }
.hp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.hp-card { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; background: var(--paper-3); border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px; line-height: 1.35; }
.hp-card .ic { font-size: 26px; line-height: 1.1; text-align: center; }
.hp-card b { display: block; font-size: 14px; margin-bottom: 2px; }
.hp-card.warn { background: #fff4d6; border-color: var(--accent); }
.hp-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 20px; margin: 4px 0 12px; }
.hp-key { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hp-key .k { text-align: right; white-space: nowrap; }
.hp-key kbd + kbd { margin-left: 3px; }
.hp-plots { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; margin: 8px 0 6px; }
.hp-plots figure { margin: 0; }
.hp-plots figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }
.hp-plots .arrow { align-self: center; font-size: 26px; color: var(--muted); }
.hp-plot { display: grid; grid-template-columns: repeat(7, 32px); gap: 2px; padding: 3px; width: max-content; background: #4d7f3a; border-radius: 3px; outline: 2px dashed #ffd23f; outline-offset: 1px; }
.hp-plot i { width: 32px; height: 32px; display: grid; place-items: center; font-style: normal; font-size: 19px; line-height: 1; border-radius: 2px; }
.hp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 12px; font-size: 13px; }
.hp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.hp-legend i { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .18); }
.keybox { display: inline-flex; align-items: center; gap: 8px; background: var(--btn); border-radius: 8px; padding: 3px 10px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; letter-spacing: 1px; }
.keybox .btn { font: inherit; font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 0; padding: 2px 8px; }

/* Новости */
.news-block { margin-top: 12px; }
.news-block h3 { font-size: 15px; text-transform: none; letter-spacing: 0; }
.news-item { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.news-item .ic { font-size: 24px; text-align: center; }
.news-item b { display: block; }
.new-badge { background: #d6453a; color: #fff; font-size: 11px; border-radius: 8px; padding: 1px 7px; vertical-align: middle; }

/* Дневник дачника: таблица по дням */
table.diary { width: 100%; border-collapse: collapse; font-size: 13px; }
table.diary th, table.diary td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--line); }
table.diary th { color: var(--brown); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.diary td:first-child, table.diary th:first-child { text-align: left; white-space: nowrap; }
table.diary tr.total td { font-weight: 600; border-bottom: none; }

/* Карта мира */
/* Большая карта (bigmap.js): холст на всю обёртку, двигается и приближается сам */
.mapwrap { position: relative; height: min(62vh, 640px); min-height: 260px; border-radius: 12px; overflow: hidden; background: #e8e0cb;
  box-shadow: inset 0 0 0 1px rgba(80, 60, 30, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15); margin-bottom: 8px; }
.mapwrap canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.mapwrap .map-home { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(80, 60, 30, 0.35);
  background: rgba(255, 253, 245, 0.95); font-size: 18px; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); }
.mapwrap .map-home:hover { background: #fff; }
.mapwrap .map-tip { position: absolute; max-width: 240px; padding: 6px 9px; border-radius: 8px; background: rgba(32, 28, 20, 0.88); color: #fff;
  font-size: 12px; line-height: 1.35; pointer-events: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.mapwrap .map-hint { position: absolute; left: 10px; top: 10px; margin-right: 58px; transition: opacity 0.6s; padding: 3px 8px; border-radius: 6px; background: rgba(255, 253, 245, 0.8);
  color: #5a4b33; font-size: 11px; pointer-events: none; }
.mapwrap .map-hint.gone { opacity: 0; }
.modal-box:has(.mapwrap) { height: min(740px, calc(100vh - 32px)); }   /* карта — на всю высоту окна, без прокрутки */
.mbody:has(> .mapwrap) { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 12px; }
.mbody:has(> .mapwrap) .mapwrap { flex: 1; height: auto; min-height: 200px; margin-bottom: 10px; }
.mapwrap .map-legend { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 3px; padding: 7px 10px; border-radius: 8px;
  background: rgba(255, 253, 245, 0.9); font-size: 11px; color: #5a4b33; pointer-events: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.map-legend .lg-me { border-radius: 50%; width: 9px; height: 9px; background: #e74c3c; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.map-legend .lg-plot { background: rgba(255, 205, 40, 0.45); border: 2px solid #e0a200; }
.map-legend .lg-snt { border: 3px solid #f2b600; background: transparent; }
.map-legend .lg-closed { background: repeating-linear-gradient(45deg, #cecbc0, #cecbc0 3px, #b9b5a8 3px, #b9b5a8 5px); border: 1px dashed #6e695f; }
.map-legend .lg-paper { background: #efe9dc; border: 1px solid #d2c8b0; }
.map-layers { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; flex: none; }
.map-layers button { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--brown-2); background: var(--btn); font-size: 19px; line-height: 1;
  cursor: pointer; transition: opacity 0.15s, filter 0.15s; }
.map-layers button:hover { border-color: var(--accent); }
.map-layers button.off { opacity: 0.4; filter: grayscale(1); border-style: dashed; }

/* Фото штрафа в окне 🚲: снимок с места эвакуации в белой рамке, как карточка-полароид */
.tow-photo { margin: 8px 0 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tow-photo canvas { width: 480px; max-width: 100%; height: auto; image-rendering: pixelated; background: #fff; padding: 6px;
  border-radius: 3px; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,0.35); transform: rotate(-1.2deg); }
.tow-photo span { font-size: 12px; }

/* Обратная связь */
#fb-text { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; padding: 8px 10px;
  border: 1.5px solid var(--brown-2); border-radius: 8px; background: var(--paper-3); color: inherit; }
#fb-text:focus { outline: 2px solid #8fb06a; }
.fb-status { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #e7e1cf; white-space: nowrap; }
.fb-status.fb-noted { background: #dbe9f6; }
.fb-status.fb-done { background: #d9eccc; }
.fb-status.fb-no { background: #f0ddd8; }
.fb-text, .fb-answer { white-space: pre-line; }
.tax-photo { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.tax-photo canvas { border-radius: 6px; border: 2px solid #3a3a3a; display: block; max-width: 100%; }
.fb-shots { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.fb-shots img { height: 56px; max-width: 110px; object-fit: cover; border-radius: 4px; border: 1px solid #c9b99a; display: block; }
.fb-shot { position: relative; }
.fb-shot-x { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: none; background: #b3402a; color: #fff; font-size: 11px; line-height: 18px; cursor: pointer; }
.fb-answer { margin-top: 4px; padding: 6px 8px; border-left: 3px solid #8fb06a; background: #f3f7ec; border-radius: 0 6px 6px 0; }
#btn-settings.has-answer, #btn-feedback.has-answer { position: relative; }
#btn-settings.has-answer::after, #btn-feedback.has-answer::after { content: ''; position: absolute; top: 2px; right: 2px; width: 8px; height: 8px;
  border-radius: 50%; background: #d64535; box-shadow: 0 0 0 2px rgba(255,255,255,0.8); }

/* Бонусы за рекламу */
.ads-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); border-radius: 6px; }
.ads-ico { font-size: 28px; text-align: center; }
.ads-text b { display: block; }
.ads-row .btn { white-space: nowrap; }

/* ---------- Меню стройки (та же рамка, высота постоянная — карточки) ---------- */
.bm-box { height: min(740px, calc(100vh - 32px)); }
.bm-head { flex-wrap: wrap; }
.bm-head .mh-title { flex: 0 1 auto; }
#bm-search { flex: 1; min-width: 160px; padding: 7px 12px; font: inherit; border: 1.5px solid var(--brown-2); border-radius: 8px; background: var(--paper-3); }
.bm-avail { font-size: 13px; white-space: nowrap; }
.bm-actions { display: flex; gap: 6px; align-items: center; }
.bm-actions .btn { font-size: 13px; }
.bm-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; align-content: start; padding: 12px 16px 16px; }
.bcard { background: var(--paper-3); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.bcard:hover { background: var(--btn-hover); border-color: var(--accent); }
.bcard.active { background: var(--accent-bg); border-color: var(--accent); }
.bcard.locked { opacity: .55; cursor: not-allowed; }
.bcard .bc-top { display: flex; align-items: center; gap: 6px; }
.bcard .bc-ico { font-size: 26px; }
.bcard .bc-name { font-weight: 700; line-height: 1.15; }
.bcard .bc-cost { font-size: 12px; font-weight: 600; }
.bcard .bc-desc { font-size: 11px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bm-empty { grid-column: 1 / -1; color: var(--muted); padding: 20px; text-align: center; }

/* ---------- Чат, подсказка, всплывашки ---------- */
#chat { position: fixed; left: 12px; bottom: 12px; width: 310px; }   /* при 1280 px не заходит под панель ячеек (10 × 56 px по центру) */
#chatlog {
  max-height: 170px; overflow-y: auto; padding: 6px 8px; font-size: 13px; color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
#chatlog .sys { color: #ffe39a; font-style: italic; }
/* лента чата не перехватывает клики по полю и панелям под ней (плейтест: закрывала панель пакостей);
   прокрутить и выделить историю — когда открыто поле ввода (Enter) */
#chatlog { pointer-events: none; }
#chat:focus-within #chatlog { pointer-events: auto; -webkit-user-select: text; user-select: text; }
#chatinput {
  width: 100%; padding: 7px 10px; border-radius: 10px; border: 2px solid var(--brown); background: rgba(252,246,230,.9); font: inherit;
}
#chatinput:focus { outline: none; background: var(--paper-3); }

#tooltip { position: fixed; pointer-events: none; padding: 6px 10px; font-size: 12px; white-space: pre-line; max-width: 300px; border-radius: 8px; z-index: 70; }

/* Окно «Задание выполнено»: вверху по центру; у завершённой главы — крупнее, с наградой предметами */
/* ---------- Приветствие при первом входе (ui.openWelcome) ----------
   Карточка поверх игры: картинка «небо — домик — грядка», адрес дачи, три шага (Путь, Помощь, ключ) и «Начать» */
#welcome, #levelup { position: fixed; inset: 0; z-index: 39; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(20, 30, 15, .5); }
.wl-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--paper); border: 2px solid var(--brown);
  border-radius: 18px; box-shadow: var(--shadow); animation: wl-in .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes wl-in { from { transform: translateY(18px) scale(.96); opacity: 0; } }
.wl-scene { position: relative; height: 150px; overflow: hidden; border-radius: 16px 16px 0 0;
  background: linear-gradient(#8fd0f5 0%, #c9ecff 58%, #7fbf4d 58%, #5c9a3a 100%); }
.wl-scene span { position: absolute; line-height: 1; filter: drop-shadow(0 3px 3px rgba(0,0,0,.18)); }
.wl-sun { top: 14px; right: 26px; font-size: 42px; animation: wl-sun 12s linear infinite; }
@keyframes wl-sun { to { transform: rotate(360deg); } }
.wl-cloud { top: 20px; font-size: 30px; opacity: .9; animation: wl-cloud 26s linear infinite; }
@keyframes wl-cloud { from { left: -60px; } to { left: 110%; } }
.wl-house { left: 50%; bottom: 26px; transform: translateX(-50%); font-size: 74px; }
.wl-tree { bottom: 30px; font-size: 44px; }
.wl-bed { bottom: 8px; font-size: 22px; letter-spacing: 6px; }
.wl-body { padding: 14px 22px 20px; text-align: center; }
.wl-kicker { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #3f7d2c; }
.wl-body h2 { font-size: 24px; margin: 2px 0 8px; }
.wl-addr { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--accent-bg);
  border: 1px solid #e8c56a; font-weight: 600; color: #5a4210; }
.wl-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 14px; text-align: left; }
.wl-step { background: var(--paper-3); border: 1px solid var(--line); border-radius: 12px; padding: 10px 11px; }
.wl-step .wl-ic { font-size: 26px; line-height: 1; }
.wl-step b { display: block; margin: 6px 0 2px; font-size: 14px; }
.wl-step p { margin: 0; font-size: 12.5px; color: #5a4a35; line-height: 1.35; }
.wl-key { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; padding: 3px 4px 3px 8px;
  border-radius: 8px; background: var(--btn); font: 700 14px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; }
.wl-key .btn { font: 12px system-ui, sans-serif; padding: 2px 7px; }
.wl-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.wl-actions .btn { padding: 8px 20px; font-size: 15px; }
.wl-actions .btn.primary { padding: 8px 34px; }
@media (max-width: 560px) {
  .wl-steps { grid-template-columns: 1fr; gap: 8px; }
  .wl-step { display: grid; grid-template-columns: 30px 1fr; column-gap: 8px; align-items: start; }
  .wl-step .wl-ic { grid-row: span 3; font-size: 24px; }
  .wl-step b { margin-top: 0; }
  .wl-scene { height: 120px; }
  .wl-house { font-size: 60px; }
}

/* ---------- Новый уровень (ui.levelUp): карточка как у приветствия — золотая шапка с лучами, значок с номером,
   конфетти, что открылось — плашками ---------- */
.lv-card { width: min(460px, 100%); }
.lv-scene { position: relative; height: 150px; overflow: hidden; border-radius: 16px 16px 0 0;
  background: radial-gradient(circle at 50% 58%, #fff0a8 0%, #ffcf4a 38%, #f0a132 72%, #d9822b 100%); }
.lv-rays { position: absolute; left: 50%; top: 58%; width: 520px; height: 520px; margin: -260px 0 0 -260px;
  background: repeating-conic-gradient(rgba(255, 255, 255, .28) 0 9deg, transparent 9deg 18deg); animation: lv-spin 24s linear infinite; }
@keyframes lv-spin { to { transform: rotate(360deg); } }
.lv-badge { position: absolute; left: 50%; top: 58%; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; border: 4px solid #fff;
  background: radial-gradient(circle at 35% 30%, #fffbe0, #ffd84d 55%, #e8a200); box-shadow: 0 6px 18px rgba(120, 60, 0, .35);
  color: #7a4300; animation: lv-pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }
.lv-badge b { font-size: 40px; line-height: .95; font-weight: 800; }
.lv-badge small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
@keyframes lv-pop { from { transform: scale(.2) rotate(-25deg); opacity: 0; } }
.lv-conf span { position: absolute; top: -24px; font-size: 18px; animation: lv-fall 2.6s linear infinite; }
@keyframes lv-fall { to { transform: translateY(200px) rotate(320deg); } }
.lv-open { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 16px; }
.lv-chip { padding: 5px 11px; border-radius: 999px; background: var(--paper-3); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.lv-chip.lv-more { background: var(--accent-bg); border-color: #e8c56a; color: #5a4210; }
.lv-none { margin: 8px 0 16px; color: var(--muted); }

#questdone { position: fixed; left: 50%; top: 120px; transform: translateX(-50%); z-index: 46; width: min(360px, calc(100vw - 24px));
  padding: 14px 16px; border: 2px solid #7fae5a; border-radius: 14px; background: #f1f9e8; box-shadow: var(--shadow); text-align: center; animation: qd-in .4s ease-out; }
#questdone.hidden { display: none; }
#questdone.chapter { width: min(460px, calc(100vw - 24px)); border-color: var(--accent); background: #fff8e3; }
.qd-head { display: flex; align-items: center; gap: 12px; text-align: left; }
.qd-ic { font-size: 40px; line-height: 1; }
.qd-kicker { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #3f7d2c; }
.qd-head b { font-size: 16px; }
.qd-pay { display: flex; justify-content: center; gap: 18px; margin: 10px 0 4px; font-size: 18px; font-weight: 700; color: #5a4210; }
.qd-chapter { margin: 10px 0 8px; font-weight: 700; }
#questdone .qreward-items { justify-content: center; }
#questdone { cursor: pointer; }
@keyframes qd-in { 0% { transform: translate(-50%, -16px) scale(.92); opacity: 0; } 70% { transform: translate(-50%, 0) scale(1.03); } }
/* Подсказка «впервые»: карточка над панелью быстрого доступа */
#tipcard { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 45; display: flex; align-items: center; gap: 12px;
  width: min(520px, calc(100vw - 24px)); padding: 12px 14px; border: 2px solid var(--accent); border-radius: 14px; background: #fff8e3; box-shadow: var(--shadow);
  animation: tip-in .35s ease-out; font-size: 13px; line-height: 1.35; }
#tipcard.hidden { display: none; }
/* Пока открыто окно, карточка-подсказка под ним не видна и клики не перехватывает (игра 12.10.2026: «Мелочь — с запущенной
   грядки» лежала поверх рюкзака и закрывала плитки, пока не нажмёшь «Понятно»); окно закрыли — карточка снова на месте */
body:has(#modal:not(.hidden), #buildmenu:not(.hidden), #levelup:not(.hidden), #welcome:not(.hidden)) #tipcard { display: none; }
#tipcard .tc-ic { font-size: 40px; line-height: 1; }
#tipcard .tc-body { flex: 1; min-width: 0; }
#tipcard .tc-body b { display: block; font-size: 15px; margin-bottom: 2px; }
#tipcard kbd { background: var(--btn); border: 1px solid var(--brown-2); border-radius: 4px; padding: 0 5px; font: 12px ui-monospace, Menlo, Consolas, monospace; }
@keyframes tip-in { from { transform: translate(-50%, 20px); opacity: 0; } }
/* На телефоне карточки подсказки и «Задание выполнено» — вверху, под плашками: внизу слева джойстик, справа не накрывают
   кнопки #touchpad. «Задание выполнено» там ниже окон (закрывается касанием по полю, touch.js) */
body.touch #tipcard { bottom: auto; top: 108px; left: calc(50% - 32px); width: min(520px, calc(100vw - 76px)); }
body.touch #questdone { top: 108px; left: calc(50% - 32px); width: min(360px, calc(100vw - 76px)); z-index: 38; }
body.touch #questdone.chapter { width: min(460px, calc(100vw - 76px)); }
body.touch:has(#questdone:not(.hidden)) #tipcard { display: none; }   /* обе вверху: подсказка ждёт, пока уйдёт «Задание выполнено» */
#toasts { position: fixed; top: 104px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 50; }
.toast { background: rgba(40, 32, 20, .9); color: #fff; padding: 8px 16px; border-radius: 10px; animation: pop .2s ease-out; box-shadow: 0 3px 10px rgba(0,0,0,.3); }
.toast.error { background: rgba(150, 45, 30, .93); }
.toast.good { background: rgba(40, 110, 45, .93); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- Вход ---------- */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(30, 50, 25, .55); z-index: 60; }
.pick-box { width: min(980px, calc(100vw - 24px)); height: calc(100vh - 24px); height: calc(100dvh - 24px); padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.pick-box h2 { margin: 0; }
.pick-lead { margin: 0; }
.pick-snts { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-snts { flex-wrap: nowrap; }
.pick-snts button { flex: 1 1 0; min-width: 0; padding: 7px 6px; border-radius: 8px; border: 1.5px solid var(--line); cursor: pointer; font: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #3a2e1e; }
.pick-snts button.active { border-color: #3a2e1e; box-shadow: inset 0 0 0 1.5px #3a2e1e; font-weight: 700; }
.pick-hint { text-align: center; color: #5a4a32; font-weight: 600; line-height: 20px; height: 20px; margin-top: -2px; }
.pick-hint.off { visibility: hidden; }   /* место остаётся — план не прыгает */
.pick-map { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pick-map canvas { border-radius: 8px; border: 1.5px solid var(--line); cursor: pointer; }
.pick-legend { text-align: center; }
.pick-bar { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.pick-bar.warn .pick-card:first-child { background: #fbe6df; border-color: #e3a894; }
.pick-card { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: #fff; border: 1px solid #dde6cf; min-width: 0; flex: 1 1 0; }
.pick-card > span:last-child { display: flex; flex-direction: column; justify-content: center; }
.pick-card > span:last-child { min-width: 0; }
.pick-card small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-card .ic { font-size: 24px; }
.pick-card b { display: block; font-size: 18px; line-height: 1.15; color: #3a2e1e; }
.pick-card small { display: block; color: #7a6a52; font-size: 12px; }
.pick-card b.good { color: #2d7a2a; }
.pick-card b.mid { color: #b08a10; }
.pick-card b.bad { color: #b3402a; }
.pick-card b.none { color: #a89a82; }
.pick-note { flex: 1; align-self: center; color: #5a4a32; padding: 0 6px; }
.pick-bar button { padding: 0 22px; font-size: 16px; font-weight: 600; border-radius: 10px; border: none; background: var(--green); color: #fff; cursor: pointer; align-self: stretch; }
.pick-bar button:disabled { opacity: .5; cursor: default; }
/* Телефон: шесть СНТ в строку и три карточки с кнопкой не помещались — названия обрезались до «Ра…», а от карточек
   оставались одни значки. СНТ — по три в ряд, адрес — отдельной строкой, кнопка — во всю ширину */
@media (max-width: 560px) {
  .pick-box { padding: 12px; }
  .pick-snts { flex-wrap: wrap; }
  .pick-snts button { flex: 1 1 30%; padding: 7px 2px; font-size: 14px; }
  .pick-bar { gap: 6px; }
  .pick-card { padding: 6px 10px; flex: 1 1 40%; }
  .pick-card:first-child { flex: 1 1 100%; }
  .pick-card .ic { font-size: 20px; }
  .pick-card b { font-size: 16px; }
  .pick-bar button { flex: 1 1 100%; padding: 12px 22px; }
}
.login-box { padding: 24px 28px; width: min(380px, calc(100vw - 32px)); text-align: center; }
.login-box .logo { font-size: 54px; }
.login-box h1 { margin: 4px 0 6px; }
.login-box p { color: #6a5a45; margin: 0 0 14px; }
.login-box input { width: 100%; padding: 10px; font: inherit; font-size: 16px; border-radius: 10px; border: 2px solid var(--brown-2); margin-bottom: 10px; }
.login-box button { width: 100%; padding: 10px; font-size: 16px; font-weight: 600; border-radius: 10px; border: none; background: var(--green); color: #fff; }
.login-box button:hover { background: #4d8a2f; }
.login-error { color: var(--red); margin-top: 8px; min-height: 1em; }
.login-version, .settings-version { color: var(--muted); font-size: 12px; margin-top: 10px; }
.login-box button.ghost { background: var(--btn); color: #4a3a22; margin-top: 8px; }
.login-box button.ghost:hover { background: var(--btn-hover); }
.login-box button.linkbtn { width: auto; background: none; color: var(--brown); font-size: 13px; font-weight: 400; padding: 8px 0 0; text-decoration: underline dotted; }
.login-box button.linkbtn:hover { background: none; color: #5a4210; }
#login-keyval { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; text-align: center; text-transform: uppercase; }

/* ---------- Узкие экраны ---------- */
@media (max-width: 900px) {
  #side { width: 180px; }
  #chat { width: 240px; }
  .tool { width: 52px; height: 58px; }
  .tool .lbl { display: none; }
  .bm-body { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-width: 760px) {
  .modal-box, .bm-box { width: 100vw; height: 100vh; border-radius: 0; border: 0; }
  .mwrap { flex-direction: column; }
  .mnav { flex: 0 0 auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px; }
  .mnav .tabs, .mnav-toc { flex-direction: row; gap: 4px; }
  .mnav button, .mnav-toc button { width: auto; white-space: nowrap; padding: 6px 10px; flex: none; }   /* flex: none — иначе 16 разделов стройки сжимались до одной буквы; лента прокручивается */
  .mnav-sep { display: none; }
  .mbody { padding: 10px 12px 16px; }
  .mh { padding: 10px 12px; }
  /* окно во весь экран лежит под панелью инструментов: низ списка (кнопка «Выставить» в ларьке) докручивается выше неё;
     высота — по видимой части экрана, без адресной строки браузера (плейтест: окно ларька на телефоне) */
  .modal-box { height: 100dvh; }
  body.touch .mbody { padding-bottom: 120px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .mh-title h2 { font-size: 17px; }
  .row { grid-template-columns: 30px 1fr auto; }
  .row .btns { grid-column: 1 / -1; justify-content: flex-start; }
  .store-grid { grid-template-columns: 1fr; }
  .hp-plots { gap: 8px; }
  .hp-plots .arrow { font-size: 20px; }
  .hp-plot { grid-template-columns: repeat(7, 20px); }
  .hp-plot i { width: 20px; height: 20px; font-size: 13px; }
  .hp-steps { grid-template-columns: repeat(3, 1fr); }
  .hp-key { grid-template-columns: 96px 1fr; }
}

/* ---------- Сенсорное управление ---------- */
body.touch #game { touch-action: none; cursor: default; }
body.touch #tooltip { max-width: 60vw; }

/* Джойстик появляется там, где палец коснулся экрана */
#stick {
  position: fixed; width: 132px; height: 132px; margin: -66px 0 0 -66px; border-radius: 50%;
  background: rgba(255, 250, 240, .18); border: 2px solid rgba(255, 250, 240, .45);
  pointer-events: none; z-index: 30;
}
#stick i {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(255, 250, 240, .55); border: 2px solid rgba(90, 66, 16, .35);
}

/* Кнопки, которых на телефоне нет на клавиатуре */
#touchpad { position: fixed; right: 10px; bottom: 96px; display: none; flex-direction: column; gap: 8px; z-index: 25; }
body.touch #touchpad { display: flex; }
#touchpad button {
  width: 54px; height: 54px; border-radius: 50%; font-size: 24px; line-height: 1;
  background: rgba(247, 240, 222, .92); border: 2px solid var(--brown-2); color: var(--ink);
}
#touchpad button.off { display: none; }

/* На телефоне всё крупнее, а панели — компактнее: места мало */
body.touch .hud-btns button, body.touch .btn { min-height: 34px; }
body.touch .hud-btns button { flex: 0 0 auto; min-width: 38px; font-size: 17px; }
body.touch #chatlog { max-height: 96px; }
body.touch .tool { width: 56px; height: 64px; }
body.touch .mnav button, body.touch .mnav-toc button { min-height: 34px; }

body.touch #menu { top: calc(92px + var(--bonus-h, 0px)); }   /* значки бонусов на телефоне и планшете — под плашкой ресурсов */
@media (max-width: 760px) {
  body.touch #hud { top: 6px; left: 46px; right: auto; max-width: calc(100vw - 52px); padding: 5px 9px; font-size: 13px; }
  body.touch #hud-home { top: 6px; left: 6px; width: 36px; font-size: 17px; }
  body.touch #hud-res { top: calc(10px + var(--hud-h, 52px)); left: 6px; padding: 3px 9px; font-size: 12px; gap: 8px; }   /* под строкой показателей, сколько бы строк она ни заняла */
  body.touch .hud-stats { gap: 7px; font-size: 12px; }
  body.touch #hud-env { top: calc(10px + var(--hud-h, 52px)); right: 6px; left: auto; transform: none; font-size: 11px; padding: 3px 8px; white-space: normal; max-width: 48vw; text-align: center; }   /* рядом с плашкой ресурсов, строка показателей — на всю ширину */
  body.touch #menu { left: 6px; top: calc(42px + var(--hud-h, 52px) + var(--bonus-h, 0px)); }   /* под плашкой ресурсов и не ниже чата: на 360×640 столбец из 10 кнопок заходил на чат */
  body.touch #menu .hud-btns { gap: 3px; flex-wrap: wrap; max-height: calc(100vh - 304px - var(--hud-h, 52px) - var(--bonus-h, 0px)); }   /* на телефоне в один столбец не влезает — переламывается на второй */
  body.touch #menu .hud-btns button { min-width: 34px; height: 30px; font-size: 15px; }
  body.touch #menu .mi { width: 34px; }
  body.touch #menu:not(.wide) .ml { display: none; }   /* пальцем наведения нет — подписи только в развёрнутом меню */
  body.touch #menu.wide .hud-btns { flex-wrap: nowrap; max-height: none; }
  body.touch #side { top: auto; bottom: 228px; right: 6px; width: 132px; max-height: 30vh; gap: 6px; }
  body.touch #minibox { bottom: 86px; right: 6px; width: 132px; }
  body.touch .minimap-wrap { padding: 5px; }
  body.touch #chat { left: 6px; right: 150px; bottom: 82px; width: auto; }
  body.touch #chatlog { max-height: 64px; }
  body.touch #toolbar { bottom: 6px; left: 6px; right: 6px; transform: none; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  body.touch #subbar { bottom: 78px; left: 6px; right: 144px; transform: none; overflow-x: auto; }   /* справа — миникарта, панель под неё не заходит */
  body.touch.subbar-on #chat { bottom: calc(84px + var(--subbar-h, 72px)); }   /* панель снасти и наживки видна — чат над ней */
  body.touch #ridepanel { bottom: 78px; left: 6px; right: 6px; transform: none; overflow-x: auto; }
  body.touch #touchpad { top: 108px; bottom: auto; gap: 6px; }   /* справа вверху: внизу справа панель участка и задание */
  body.touch #touchpad button { width: 48px; height: 48px; font-size: 22px; }
  body.touch .tool { width: 50px; height: 58px; }
  body.touch #buildpanel { bottom: auto; top: 108px; left: 6px; right: 66px; transform: none; gap: 5px 8px; padding: 5px 8px; font-size: 13px; }   /* внизу — чат и джойстик */
  body.touch #buildpanel > span:nth-child(2) { flex: 1 1 200px; min-width: 0; }   /* значок и название с подсказкой — в одну строку, кнопки ниже */
  body.touch #buildpanel .bb-ico { font-size: 20px; }
  body.touch #buildpanel .bb-hint { font-size: 11px; }
  body.touch #buildpanel .btn { font-size: 12px; padding: 2px 7px; min-height: 30px; }
  /* Карточка задания в узкой панели: заголовок переносится, а не режется до «Пут…» */
  body.touch #questpanel h3 { padding: 6px 8px; font-size: 12px; }
  body.touch #questpanel h3 > span:first-child { white-space: normal; }
  body.touch #questpanel > *:not(h3) { margin-left: 8px; margin-right: 8px; }
  /* значок — обтекаемый: длинное слово («Подкрепитесь», 109 px) уходит под него на всю ширину карточки, а не рвётся */
  body.touch .quest-row { display: block; overflow: hidden; }
  body.touch .quest-ic { font-size: 22px; float: left; margin-right: 6px; }
  body.touch .quest-row { position: relative; }
  body.touch .quest-row .quest-nav { position: absolute; right: 0; top: 0; }
  body.touch .quest-row:has(.quest-nav) .quest-title { clear: left; padding-top: 6px; }   /* значок и 🧭 — строкой сверху, название — под ними во всю ширину */
  body.touch .quest-row .quest-title { font-size: 13px; min-width: 0; overflow-wrap: break-word; hyphens: auto; }   /* anywhere рвал «Поймайт|е» посреди слова */
  body.touch #questpanel .progress { margin: 8px 8px 0; }
  body.touch #questpanel .quest-reward { font-size: 13px; }
  /* Рюкзак: вещи — сразу, кукла — под ними; карточка вещи — поверх окна внизу и плитки под пальцем не сдвигает */
  body.touch .char-doll { order: 0; }
  body.touch .char-doll .item-info:not(.empty) { position: fixed; left: 6px; right: 6px; bottom: 6px; z-index: 41; max-height: 55vh; overflow-y: auto; margin: 0; box-shadow: var(--shadow); }
}

/* Узкий экран лёжа: панель участка мешает — оставляем самое нужное */
@media (max-height: 460px) {
  body.touch #side, body.touch #minibox { display: none; }
  body.touch #chat { right: 76px; }
}
/* Телефон лёжа (667×375, 844×390): плашка сезона ложилась на строку показателей, чат — на меню и первые ячейки
   панели, а меню из 10 кнопок уходило за нижний край. Меню — в два столбца под ресурсами, чат — правее него и выше
   панели ячеек (и панели снасти, когда она видна) */
@media (max-height: 460px) {
  body.touch #menu { top: calc(92px + var(--bonus-h, 0px)); transform: none; }
  body.touch #menu .hud-btns { flex-wrap: wrap; max-height: calc(100vh - 92px - 78px - var(--bonus-h, 0px)); }
  body.touch #menu:not(.wide) .ml { display: none; }
  body.touch #chat { left: 150px; right: auto; bottom: 76px; width: 240px; }   /* правее меню: с бонусами новичка оно в три столбца */
  body.touch.subbar-on #chat { bottom: calc(90px + var(--subbar-h, 72px)); }
  body.touch #chatlog { max-height: 48px; }
}
@media (max-height: 460px) and (max-width: 760px) {
  body.touch #subbar { left: 150px; right: 6px; }   /* миникарты лёжа нет — место справа свободно, а слева меню */
}
/* Узкое окно на компьютере и планшет (761…1240 px): панели рассчитаны на 1280 — плашка сезона ложилась на показатели
   или на задание, чат — на панель ячеек, панель снасти — на миникарту. Сезон — во вторую строку рядом с ресурсами,
   чат — над панелью ячеек */
@media (min-width: 761px) and (max-width: 1240px) and (min-height: 461px) {
  #hud-env { top: 54px; left: 196px !important; transform: none; white-space: normal; max-width: calc(100vw - 460px); font-size: 12px; }   /* left на компьютере ставит код — здесь он не нужен */
  #chat { bottom: 84px; }
  #subbar { left: 340px; right: 240px; transform: none; }   /* в одном ряду с чатом, между ним и миникартой */
}
@media (min-width: 761px) and (max-width: 900px) and (min-height: 461px) {
  #subbar { left: 264px; }
}
@media (max-height: 460px) and (min-width: 761px) {
  body.touch #hud-env { top: 54px; left: auto; right: 12px; transform: none; }
}
/* Окно транспорта, открытое кликом по машине на карте: она подсвечена */
#modal-body .row.focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

/* «Магазины» → вкладка «Магазины»: карточка магазина — значок, что продаёт, далеко ли, дорога и доставка */
.shop-card { display: grid; grid-template-columns: 44px 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 12px; margin-bottom: 8px;
  background: var(--paper-3); border: 1px solid var(--line); border-radius: 12px; }
.sc-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--paper-2); font-size: 24px; }
.sc-main b { font-size: 15px; }
.sc-main .ok { color: var(--green); }
.sc-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 760px) {
  .shop-card { grid-template-columns: 44px 1fr; }
  .sc-btns { grid-column: 2; justify-content: flex-start; }
}
.shop-card.pick { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.shop-card.pick:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.sc-cart { font-size: 12px; padding: 1px 7px; border-radius: 9px; background: var(--accent-bg); border: 1px solid var(--accent); }

/* Витрина магазина: шапка с возвратом, корзина сверху (прилипает), строки товаров */
.cat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.cat-name { font-size: 17px; font-weight: 700; }
.cat-cart { position: sticky; top: -14px; z-index: 2; box-shadow: 0 4px 10px rgba(0,0,0,.06); }
.row.in-cart { background: #fff6d8; border-radius: 10px; }
.ani-row { margin: 4px 0 6px 38px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Заказы: карточка со статусом, шагами и полосой пути */
.ord-card { padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-3); }
.ord-card.go { border-color: #8fb06a; background: #f6faef; }
.ord-card.cancelled { opacity: .75; }
.ord-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ord-sum { margin-left: auto; font-weight: 700; }
.ord-st { font-size: 12px; padding: 1px 8px; border-radius: 9px; background: #d9eccc; }
.ord-card.cancelled .ord-st { background: #f0ddd8; }
.ord-lines { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.ord-chip { font-size: 12px; padding: 2px 8px; border-radius: 9px; background: var(--paper-2); border: 1px solid var(--line); }
.ord-stage { font-weight: 600; margin: 6px 0 4px; }
.ord-bar { height: 8px; border-radius: 4px; background: #e3ead8; overflow: hidden; }
.ord-bar i { display: block; height: 100%; background: linear-gradient(90deg, #9bbf7a, #5f8a3a); transition: width .9s linear; }
.ord-steps { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin: 4px 0 8px; }
.ord-steps .done { color: var(--green); }
.ord-steps .cur { color: var(--ink); font-weight: 700; }
.ord-card .btn { margin-top: 2px; }

/* Витрина: шапка прилипает, справа — корзина значком с суммой */
.cat-head { position: sticky; top: -14px; z-index: 3; margin: -14px -20px 6px; padding: 10px 20px; background: var(--paper); border-bottom: 1px solid var(--line); }
.cart-pill { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; font-size: 16px;
  background: var(--btn); border: 1.5px solid var(--brown-2); }
.cart-pill i { font-style: normal; font: 700 11px/18px system-ui, sans-serif; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #e0443a; color: #fff; text-align: center; margin-left: -6px; transform: translateY(-8px); }
.cart-pill b { font-size: 14px; }
.cart-pill.full { background: var(--accent-bg); border-color: var(--accent); }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper b { min-width: 26px; text-align: center; }
.stepper .btn { min-width: 30px; padding: 3px 8px; }
.cart-line .btns { gap: 6px; align-items: center; }
.cart-sum { margin: 14px 0 6px; padding: 12px 14px; border-radius: 12px; background: var(--paper-3); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.cart-sum > div { display: flex; justify-content: space-between; gap: 10px; }
.cart-total { border-top: 1px dashed var(--line); padding-top: 8px; font-size: 17px; }
.cart-go { padding: 10px; font-size: 16px; margin-top: 4px; }
@media (max-width: 760px) { .cat-head { top: -10px; margin: -10px -12px 6px; padding: 8px 12px; } }
.stepper .qty { width: 56px; padding: 4px 4px; text-align: center; font: 600 14px system-ui, sans-serif; border: 1.5px solid var(--brown-2); border-radius: 8px; background: #fff; -moz-appearance: textfield; }
.stepper .qty::-webkit-outer-spin-button, .stepper .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .qty:focus { outline: 2px solid var(--accent); }

/* Скорость графики (perf.js): счётчик кадров и ход замера — полоски вверху по центру, сквозь них можно кликать */
#perf, #perf-bench-bar { position: fixed; left: 50%; transform: translateX(-50%); z-index: 60; pointer-events: none;
  background: rgba(30, 24, 18, 0.72); color: #fff8e6; border-radius: 8px; padding: 4px 10px; white-space: pre;
  font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace; text-align: center; }
#perf { top: 66px; }
#perf-bench-bar { top: 106px; font-size: 14px; }
.perf-report { white-space: pre-wrap; background: var(--paper-2, #f4ead3); border-radius: 8px; padding: 8px 10px;
  font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; user-select: text; -webkit-user-select: text; }
