/* Вид интерфейса — «наклейки»: бумажные плашки с тёмной обводкой и жёсткой тенью, круглый жирный шрифт.
   Цвета — переменные ниже; тот же тёмно-фиолетовый («тушь») вместо чёрного, что и в мире (render.json → style.ink). */
@font-face { font-family: "Nunito"; src: url("../../vendor/fonts/Nunito.ttf") format("truetype"); font-weight: 200 1000; font-display: swap; }

:root {
  --ink: #2a2340; --ink2: #4a4168; --paper: #fff6e2; --paper2: #f3e3bf; --paper3: #e6d1a3;
  --accent: #ffb238; --coral: #f2634d; --green: #6cc24a; --teal: #2fbfb3; --gold: #f5b83d;
  --edge: 3px solid var(--ink);
  --drop: 0 5px 0 var(--ink), 0 12px 22px rgba(42, 35, 64, .28);
  /* обводка текста, лежащего прямо на мире */
  --stroke: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink), 1.5px 1.5px 0 var(--ink), -1.5px 1.5px 0 var(--ink), 1.5px -1.5px 0 var(--ink), -1.5px -1.5px 0 var(--ink), 0 4px 0 var(--ink);
  --i-hp: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 20.5S3.5 15.3 3.5 9.4A4.6 4.6 0 0 1 12 7a4.6 4.6 0 0 1 8.5 2.4c0 5.900-8.500 11.100-8.500 11.100z' fill='%23f2634d' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-food: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.500 12c3-5.500 9.500-6.500 13.500-3l5-3.500v13l-5-3.500c-4 3.500-10.500 2.500-13.500-3z' fill='%23f5b83d' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='7.500' cy='11' r='1.300' fill='%232a2340'/%3E%3C/svg%3E");
  --i-stam: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13.500 2 4.500 13.500h6L9 22l10-12.500h-6.200z' fill='%236cc24a' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-warm: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.500c1 4 6 6 6 11.500a6 6 0 0 1-12 0c0-3 2-4.500 2.200-7 1.800.800 3 1.500 3.800-4.500z' fill='%23ff8a3c' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-o2: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='13' r='7' fill='%238fe3f0' stroke='%232a2340' stroke-width='2'/%3E%3Ccircle cx='18.500' cy='5.500' r='3' fill='%238fe3f0' stroke='%232a2340' stroke-width='2'/%3E%3C/svg%3E");
  --i-jet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2c4 3 5 8 4 13H8C7 10 8 5 12 2z' fill='%23fff6e2' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M9.500 16h5l-2.500 6z' fill='%23ffb238' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='8' y='2' width='8' height='13' rx='4' fill='%23fff6e2' stroke='%232a2340' stroke-width='2'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v4M8 22h8' fill='none' stroke='%232a2340' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-talk: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'%3E%3Cpath d='M2 7h4l6-5v16l-6-5H2z' fill='%23fff6e2' stroke='%232a2340' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M15 6c2 2 2 6 0 8M18 3c4 4 4 10 0 14' fill='none' stroke='%232a2340' stroke-width='2.200' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-cat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 80'%3E%3Cpath d='M14 36 10 6l24 14h28L86 6l-4 30c2 4 3 8 3 12 0 16-16 26-37 26S11 64 11 48c0-4 1-8 3-12z' fill='%23eaa45a' stroke='%232a2340' stroke-width='5' stroke-linejoin='round'/%3E%3Cpath d='M17 14l3 16 11-9zM79 14l-3 16-11-9z' fill='%23ef8f9a'/%3E%3Cpath d='M30 60c0-9 8-14 18-14s18 5 18 14c0 6-8 9-18 9s-18-3-18-9z' fill='%23fff3e0'/%3E%3Crect x='28' y='36' width='8' height='13' rx='4' fill='%232a2340'/%3E%3Crect x='60' y='36' width='8' height='13' rx='4' fill='%232a2340'/%3E%3Cpath d='M43 52h10l-5 6z' fill='%23ef8f9a' stroke='%232a2340' stroke-width='2.500' stroke-linejoin='round'/%3E%3Cpath d='M4 50l16 3M4 60l16-2M92 50l-16 3M92 60l-16-2' stroke='%232a2340' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3f2; }
body { font: 700 15px/1.35 "Nunito", "Segoe UI", system-ui, sans-serif; color: #fff; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: fixed; inset: 0; pointer-events: none; text-shadow: var(--stroke); }
/* чат (ui/chat.js): журнал внизу слева над шкалами, свежие строки гаснут сами; строка ввода — по T или Enter */
#chat { position: absolute; left: 22px; bottom: 210px; width: min(420px, 40vw); display: flex; flex-direction: column; gap: 6px; }
#chat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 15px; }
#chat-log li { transition: opacity .6s; overflow-wrap: anywhere; }
#chat-log li.old { opacity: 0; }
#chat-log b { margin-right: 6px; padding: 0 7px 1px; border: 2px solid var(--ink); border-radius: 999px; background: var(--c); font-size: 13px; text-shadow: 0 1px 0 var(--ink); }
#chat-log .sys { color: #ffe08a; font-style: italic; }
#chat-line { display: none; pointer-events: auto; font: inherit; color: var(--ink); text-shadow: none; padding: 6px 10px; border: var(--edge); border-radius: 10px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); outline: none; user-select: text; }
#chat.open #chat-line { display: block; }
#chat.open #chat-log { max-height: 40vh; overflow-y: auto; padding: 6px 8px; border-radius: 10px; background: rgba(42, 35, 64, .35); pointer-events: auto; }
#chat-log:empty { display: none; } /* строк ещё нет — без пустой подложки над строкой */
/* закрытый — не выше шести строк, новые внизу: погасшие держат место (гаснут плавно), а на телефоне журнал висит сверху
   и иначе уводил бы новые строки за нижний край */
#chat:not(.open) #chat-log { max-height: 10em; overflow: hidden; justify-content: flex-end; }
/* микрофон (audio/voice.js): виден там, где есть голос; светится, пока голос уходит */
#mic { position: absolute; left: 240px; bottom: 22px; width: 34px; height: 34px; border: var(--edge); border-radius: 50%; background: var(--paper) var(--i-mic) center / 20px no-repeat; box-shadow: 0 3px 0 var(--ink); opacity: .5; }
#mic.on { opacity: 1; background-color: var(--accent); animation: talk .5s ease-in-out infinite alternate; }
/* оформление строк по состоянию говорящего (core/chat.js): в журнале — на мире, в облачке — на бумаге */
.fx-water { color: #9fdcff; }
.fx-cold { display: inline-block; color: #d8f0ff; animation: shiver .09s infinite alternate; }
.fx-poison { display: inline-block; color: #b4ec7a; animation: wobble 1.6s ease-in-out infinite; }
.fx-tired { letter-spacing: .05em; opacity: .85; }
.fx-down, .fx-sleep { opacity: .65; font-size: .92em; }
.fx-vacuum { font-family: ui-monospace, Consolas, monospace; color: #c8f7c5; }
#tags .bubble.fx-water { color: #1d6ea6; }
#tags .bubble.fx-cold { color: #2a6f9a; }
#tags .bubble.fx-poison { color: #3d8a1f; }
#tags .bubble.fx-vacuum { color: #2f7a3a; }
@keyframes shiver { from { transform: translateX(-.7px); } to { transform: translate(.8px, -.4px); } }
@keyframes wobble { 0%, 100% { transform: skewX(-7deg); } 50% { transform: skewX(7deg) translateY(1px); } }
@media (prefers-reduced-motion: reduce) { .fx-cold, .fx-poison, #tags .tag.talk::after { animation: none; } }
/* ники над котами (кооп, render/avatars.js): под HUD и меню; цвет — платка игрока */
#tags { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
/* облачко чата над ником (render/avatars.js): тает вместе с подписью; волна у ника — говорит голосом */
#tags .bubble { position: absolute; left: 50%; bottom: calc(100% + 9px); translate: -50% 0; width: max-content; max-width: 260px; padding: 4px 10px 5px; border: 2px solid var(--ink); border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 800; text-shadow: none; box-shadow: 0 3px 0 var(--ink); white-space: normal; overflow-wrap: anywhere; }
#tags .bubble::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--ink); }
#tags .tag.talk::after { content: ""; display: inline-block; width: 16px; height: 13px; margin-left: 5px; vertical-align: -1px; background: var(--i-talk) center / contain no-repeat; animation: talk .5s ease-in-out infinite alternate; }
@keyframes talk { to { transform: scale(1.18); } }
#tags .tag { position: absolute; left: 0; top: 0; padding: 1px 9px 2px; border: 2px solid var(--ink); border-radius: 999px; background: var(--c); color: #fff; font-weight: 900; font-size: 15px; text-shadow: 0 1px 0 var(--ink); box-shadow: 0 3px 0 var(--ink); white-space: nowrap; will-change: transform, opacity; }
/* лёгкое затемнение по краям кадра: взгляд собирается к середине, картинка — как в диораме */
#hud::before { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at center, transparent 60%, rgba(42, 35, 64, .26) 100%); }

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -6px;
  border-radius: 50%; background: #fff; border: 2px solid var(--ink);
  transition: transform .12s, background .12s;
}
#crosshair.active { transform: scale(1.5); background: var(--accent); }

/* кольцо удержания (разбор детали) */
#hold {
  --p: 0;
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), rgba(42, 35, 64, .45) 0);
  -webkit-mask: radial-gradient(circle, transparent 14px, #000 15px);
  mask: radial-gradient(circle, transparent 14px, #000 15px);
  opacity: 0;
}
#hold.on { opacity: 1; }

/* подсказки и шкала действия — внизу, над ячейками и ношей: под прицелом они закрывали то, на что игрок смотрит */
#tips { position: absolute; left: 50%; bottom: 160px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#prompt {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; white-space: pre-line; font-weight: 800;
}
#prompt .label {
  padding: 3px 14px 4px; border-radius: 14px; border: var(--edge); background: var(--paper); color: var(--ink);
  font-size: 17px; text-shadow: none; box-shadow: 0 3px 0 var(--ink);
}
#prompt .label.bad { background: #ffd9d2; color: #a52a1c; }
#prompt .pips { margin-left: 8px; font-style: normal; font-size: 13px; letter-spacing: 3px; color: var(--ink2); } /* какой вариант установки выбран: точками, не цифрами */
#prompt .keys { font-weight: 700; font-size: 14.5px; }
#prompt .bad { color: #ffb4a8; }

/* ноша: полоска на предмет, ширина — по грузу, цвет — из палитры модели, вид — по форме предмета; .held — то, что в руках */
#carry { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; }
#carry i { height: 18px; border-radius: 9px; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }
#carry i.cylinder { box-shadow: inset -9px 0 0 rgba(255, 240, 200, .6), 0 3px 0 var(--ink); }
#carry i.box { border-radius: 5px; box-shadow: inset 0 3px 0 rgba(255, 255, 255, .28), 0 3px 0 var(--ink); }
#carry i.held { outline: 3px solid var(--accent); outline-offset: 2px; }
#carry i.empty { background: rgba(255, 246, 226, .3); border-style: dashed; box-shadow: none; }

/* ячейка инвентаря: значок (.ico-<вид> заводит render/icons.js), число в стопке, полоска прочности */
.slot {
  position: relative; width: 54px; height: 54px; border-radius: 13px; border: 2.5px solid var(--ink); box-sizing: border-box;
  background: linear-gradient(var(--paper), var(--paper2)); box-shadow: 0 3px 0 var(--ink);
  text-shadow: none; color: var(--ink);
}
.slot.on { border-color: var(--ink); background: linear-gradient(#fff3c4, var(--accent)); box-shadow: 0 6px 0 var(--ink); transform: translateY(-5px); }
.slot .ico { position: absolute; inset: 2px; background-position: center; background-size: contain; background-repeat: no-repeat; filter: drop-shadow(0 2px 0 rgba(42, 35, 64, .25)); }
.slot b { position: absolute; left: 5px; top: 1px; font-size: 11px; font-weight: 900; opacity: .55; }
.slot u {
  position: absolute; right: -5px; bottom: -5px; min-width: 14px; padding: 0 4px; border-radius: 9px; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 800; line-height: 18px; text-align: center; text-decoration: none;
}
.slot s { position: absolute; left: 6px; right: 6px; bottom: 4px; height: 4px; border-radius: 2px; background: rgba(42, 35, 64, .35); }
.slot s::after { content: ""; display: block; height: 100%; width: calc(var(--d) * 100%); border-radius: 2px; background: hsl(calc(var(--d) * 110), 72%, 46%); }

/* ячейки под рукой: цифра — клавиша; с ношей на плече лапы заняты — ряд тусклый */
#hotbar { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); text-align: center; }
#hotbar .row { display: flex; gap: 8px; }
#hotbar .row.busy { opacity: .5; }
#hotbar .slot { width: 60px; height: 60px; }
#hotbar .name { min-height: 1.4em; margin-bottom: 9px; font-size: 17px; font-weight: 800; }

/* здоровье, сытость, силы, тепло: значок слева, шкала-пилюля */
#vitals { position: absolute; left: 22px; bottom: 22px; width: 208px; display: flex; flex-direction: column; gap: 7px; }
.bar {
  position: relative; height: 20px; margin-left: 30px; border-radius: 11px; border: 2.5px solid var(--ink); box-sizing: border-box;
  background: rgba(42, 35, 64, .55); box-shadow: 0 3px 0 var(--ink);
}
.bar::before {
  content: ""; position: absolute; left: -33px; top: -6px; width: 28px; height: 28px;
  background: var(--icon) center / contain no-repeat; filter: drop-shadow(0 2px 0 var(--ink));
}
.bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 8px; transition: width .25s; box-shadow: inset 0 4px 0 rgba(255, 255, 255, .3), inset 0 -3px 0 rgba(42, 35, 64, .16); }
.bar b { position: absolute; left: 9px; top: -1.5px; font-size: 11.5px; font-weight: 800; letter-spacing: .03em; text-shadow: 0 1px 0 var(--ink), 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 -1px 0 var(--ink); }
.bar.hp { --icon: var(--i-hp); } .bar.hp i { background: var(--coral); }
.bar.food { --icon: var(--i-food); } .bar.food i { background: var(--gold); }
.bar.stam { --icon: var(--i-stam); } .bar.stam i { background: var(--green); }
.bar.warm { --icon: var(--i-warm); } .bar.warm i { background: #ff8a3c; }
.bar.low { animation: low .9s infinite; }
#vitals .cozy { margin-left: 30px; font-size: 13.5px; font-weight: 800; color: #ffe08a; }
@keyframes low { 50% { box-shadow: 0 3px 0 var(--ink), 0 0 0 4px rgba(242, 99, 77, .85); } }

/* инвентарь и крафт: окно по центру; щелчок мимо окна с предметом «в курсоре» выбрасывает его */
#inventory { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(42, 35, 64, .38); color: var(--ink); }
#inventory .panel {
  display: flex; gap: 26px; padding: 22px 26px 24px; border-radius: 24px; border: var(--edge); background: var(--paper);
  box-shadow: var(--drop); max-height: 88vh;
}
#inventory h2 { margin: 0 0 10px; font-size: 19px; font-weight: 900; color: var(--ink); }
#inventory h2 button[data-menu] { float: right; }
#inventory h2 button { margin-left: 8px; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper2); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
#inventory .grid { display: grid; grid-template-columns: repeat(6, 54px); gap: 9px 8px; max-height: 60vh; overflow-y: auto; padding: 6px 6px 6px 0; margin-top: -6px; scrollbar-width: thin; } /* поля — под то, что выступает из ячеек: сверху приподнятая выбранная, справа и снизу счётчики стопок; иначе листаемая сетка их срезает или заводит лишнюю полосу прокрутки */
/* ячеек много (большой сундук, рюкзак) — ряд шире: ui/box.js → gridClass; не влезло по высоте — сетка листается */
#inventory .grid.c8 { grid-template-columns: repeat(8, 54px); }
#inventory .grid.c10 { grid-template-columns: repeat(10, 54px); }
#inventory .slot { cursor: pointer; }
#inventory .slot:hover { background: linear-gradient(#fff, var(--paper)); }
#inventory .slot.picked { border-color: var(--coral); background: #ffe2d6; }
#inventory .slot.mat { background: linear-gradient(#e2f7c8, #bfe89a); }
#inventory .picked, #inventory .hint { margin: 10px 0 0; min-height: 1.3em; max-width: 364px; }
#inventory .hint { font-size: 12.5px; font-weight: 600; color: var(--ink2); }
#inventory .book { width: 380px; display: flex; flex-direction: column; min-height: 0; }
#inventory .list { overflow-y: auto; padding: 2px 8px 6px 2px; scrollbar-width: thin; scrollbar-color: var(--paper3) transparent; }
#inventory .recipe { display: flex; gap: 12px; align-items: center; padding: 5px 6px; border-radius: 14px; opacity: .45; cursor: default; }
#inventory .recipe.ok { opacity: 1; cursor: pointer; }
#inventory .recipe.ok:hover { background: var(--paper2); }
#inventory .recipe .slot { flex: none; width: 46px; height: 46px; }
#inventory .what { display: flex; flex-direction: column; line-height: 1.25; font-weight: 800; }
#inventory .what span { font-size: 12.5px; font-weight: 600; color: var(--ink2); }
#inventory .what .miss { color: #c2392b; }
#inventory .recipe mark { margin-left: 7px; padding: 0 7px 1px; border-radius: 8px; background: var(--coral); color: #fff; font-size: 10.5px; font-weight: 900; letter-spacing: .04em; vertical-align: 2px; }
#inventory .lore { margin-top: 8px; }

#clock {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); padding: 2px 16px 3px; border-radius: 16px; border: var(--edge);
  background: var(--paper); color: var(--ink); font-weight: 800; text-shadow: none; box-shadow: 0 3px 0 var(--ink);
}

/* ночь орды: сколько ночных осталось; полоска — сколько уже перебито */
#horde { position: absolute; left: 50%; top: 50px; transform: translateX(-50%); min-width: 230px; text-align: center; }
#horde:empty { display: none; }
#horde b { display: inline-block; padding: 2px 14px 3px; border-radius: 14px; border: var(--edge); background: #ffd9d2; color: #a52a1c; font-weight: 800; text-shadow: none; box-shadow: 0 3px 0 var(--ink); }
#horde b.ok { background: #dff5c8; color: #2f7a22; }
#horde div { height: 8px; margin: 6px 12px 0; border-radius: 5px; border: 2px solid var(--ink); background: rgba(42, 35, 64, .55); overflow: hidden; }
#horde i { display: block; height: 100%; background: var(--coral); transition: width .3s; }
#horde:not(:empty) ~ #bossbar.on { top: 104px; }

/* плашки в углу: достижение, новый рецепт (src/ui/popups.js) */
#popups { position: fixed; right: 18px; top: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; pointer-events: none; z-index: 20; color: var(--ink); }
.popup {
  display: flex; align-items: center; gap: 10px; min-width: 250px; max-width: 340px; padding: 7px 14px 8px 8px; border-radius: 18px; border: var(--edge);
  background: var(--paper); box-shadow: var(--drop); animation: popup-in .3s cubic-bezier(.2, 1.4, .4, 1); transition: opacity .35s, transform .35s;
}
.popup.out { opacity: 0; transform: translateX(30px); }
.popup .ico { flex: none; width: 48px; height: 48px; border-radius: 13px; border: 2.5px solid var(--ink); background-color: var(--paper2); background-position: center; background-size: 86%; background-repeat: no-repeat; box-sizing: border-box; }
.popup em { display: block; font-style: normal; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.popup b { display: block; font-size: 16px; font-weight: 900; line-height: 1.2; }
.popup span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); line-height: 1.25; }
.popup.feat { background: linear-gradient(#fff3c4, #ffe08a); }
.popup.feat .ico { background-color: #fff; border-color: #b8791a; }
.popup.feat em { color: #a8650f; }
@keyframes popup-in { from { opacity: 0; transform: translateX(40px) scale(.9); } }

/* шкала действия (вываживание рыбы и т. п.): --p — ход, --t — натяжение */
#meter { width: 230px; display: none; }
#meter.on { display: block; }
#meter div { height: 14px; margin: 5px 0; border-radius: 8px; border: 2.5px solid var(--ink); background: rgba(42, 35, 64, .55); overflow: hidden; box-shadow: 0 3px 0 var(--ink); }
#meter i { display: block; height: 100%; }
#meter .p i { width: calc(var(--p) * 100%); background: var(--green); }
#meter .t i { width: calc(var(--t) * 100%); background: hsl(calc((1 - var(--t)) * 110), 80%, 55%); }

/* затемнение экрана: сон, потеря сознания, урон */
#fade { position: fixed; inset: 0; pointer-events: none; background: var(--ink); opacity: 0; transition: opacity .6s; }
#fade.hurt { background: radial-gradient(ellipse at center, transparent 52%, rgba(242, 99, 77, .6)); opacity: 1; transition: opacity .1s; }

#toast {
  position: absolute; left: 50%; top: 112px; transform: translateX(-50%) scale(.9);
  padding: 4px 16px 5px; border-radius: 16px; border: var(--edge); background: var(--paper); color: var(--ink); font-weight: 800;
  text-shadow: none; box-shadow: 0 4px 0 var(--ink); opacity: 0; transition: opacity .2s, transform .2s;
}
#toast.on { opacity: 1; transform: translateX(-50%) scale(1); }

#debug {
  position: absolute; left: 10px; top: 10px; margin: 0; padding: 8px 10px; border-radius: 10px;
  background: rgba(42, 35, 64, .75); font: 12px/1.35 Consolas, monospace; text-shadow: none;
}

/* меню: на корне — маленькая плашка поверх игры (щелчок мимо кнопок — играть), мир за ней виден: игра на паузу
   не встаёт; страницы — шире, со своим курсором и приглушённым фоном */
#menu {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(42, 35, 64, .16); cursor: pointer; color: var(--ink);
}
#menu.sub { background: rgba(42, 35, 64, .34); backdrop-filter: blur(3px); cursor: default; }
#menu[hidden], #menu [hidden], #hud[hidden], #debug[hidden], #inventory[hidden] { display: none; }
#menu .panel {
  position: relative; box-sizing: border-box; min-width: 320px; max-width: min(860px, 92vw); max-height: calc(100vh - 36px); overflow-y: auto; padding: 50px 32px 24px; border-radius: 28px; text-align: center;
  border: var(--edge); background: var(--paper); box-shadow: var(--drop); scrollbar-width: thin; scrollbar-color: var(--paper3) transparent;
}
/* кот над заголовком */
#menu .panel::before { content: ""; position: absolute; left: 50%; top: 8px; width: 74px; height: 46px; margin-left: -37px; background: var(--i-cat) center / contain no-repeat; }
#menu h1 { margin: 6px 0 6px; font-size: 44px; font-weight: 1000; letter-spacing: .03em; line-height: 1; color: var(--coral); text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink), 0 6px 0 var(--ink); }
#menu-hint {
  display: inline-block; margin: 10px 0 16px; padding: 5px 20px 6px; border-radius: 18px; border: var(--edge);
  background: var(--accent); font-size: 17px; font-weight: 900; box-shadow: 0 4px 0 var(--ink);
}
#menu-nav { display: flex; flex-direction: column; gap: 9px; width: 252px; margin: 0 auto; }
#menu-head { display: flex; align-items: center; gap: 14px; margin: 6px 0 10px; }
#menu-head h2 { margin: 0; font-size: 20px; font-weight: 900; }
/* управление — в две колонки: список длинный, а окно должно помещаться в экран */
#menu-controls { list-style: none; margin: 0 0 6px; padding: 0; text-align: left; font-weight: 600; font-size: 13.5px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; }
#menu-controls li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 3px 0; border-bottom: 2px dotted var(--paper3); text-align: right; line-height: 1.2; }
#menu-controls b { padding: 0 8px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; font-weight: 800; font-size: 13.5px; box-shadow: 0 2px 0 var(--ink); white-space: nowrap; }
#menu button {
  padding: 6px 16px 7px; border: var(--edge); border-radius: 14px; background: var(--teal); color: #fff;
  font: inherit; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 var(--ink); text-shadow: 0 1px 0 var(--ink); white-space: nowrap;
}
#menu button.quiet { background: var(--paper2); color: var(--ink); text-shadow: none; }
#menu button:hover { filter: brightness(1.08); transform: translateY(-1px); }
#menu button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* страницы меню: настройки, острова, управление */
#menu-page { min-width: min(520px, 84vw); text-align: left; font-weight: 600; }
#menu-page h3 { margin: 14px 0 4px; font-size: 13px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
#menu-page .row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 2px dotted var(--paper3); }
#menu-page .row.cur { padding: 9px 12px; border: var(--edge); border-radius: 16px; background: #fff; }
#menu-page .what { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
#menu-page .what b { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menu-page .what span { font-size: 12.5px; color: var(--ink2); }
#menu-page button { padding: 3px 12px 4px; font-size: 14px; box-shadow: 0 3px 0 var(--ink); }
#menu-page button.wide { display: block; margin-top: 12px; padding: 6px 16px 7px; }
#menu-page .what b.nick { align-self: flex-start; padding: 0 9px 1px; border: 2px solid var(--ink); border-radius: 999px; background: var(--c); color: #fff; text-shadow: 0 1px 0 var(--ink); } /* «Игроки»: ник — как над котом */
/* «Облик» (ui/look.js): кот в окошке слева, выбор справа; выбранное — обведено и приподнято */
#menu-page .look { display: flex; gap: 16px; align-items: flex-start; }
#menu-page .look-cat canvas { display: block; width: 240px; height: 280px; border: var(--edge); border-radius: 16px; background: linear-gradient(#bfe3f2, #fff6e2); cursor: grab; touch-action: none; }
#menu-page .look-pick { flex: 1; min-width: 0; }
#menu-page .look-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 2px dotted var(--paper3); }
#menu-page .look-row > b { width: 100%; font-size: 13px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
#menu-page .look-row .sw { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 3px 3px; font-size: 13px; }
#menu-page .look-row .sw:not(:has(i)) { padding-left: 9px; }
#menu-page .look-row .sw i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); }
#menu-page .look-row .sw.on { background: var(--accent); transform: translateY(-2px); box-shadow: 0 5px 0 var(--ink); }
#menu-page .note { margin: 10px 0 0; max-width: 540px; font-size: 12.5px; color: var(--ink2); }
#menu-page .status { min-height: 1.4em; margin: 8px 0 0; color: #b0561a; font-weight: 800; }
#menu-page .set { display: grid; grid-template-columns: 1fr 210px 48px; align-items: center; gap: 12px; padding: 8px 2px; border-bottom: 2px dotted var(--paper3); font-weight: 700; cursor: pointer; }
#menu-page .set input { margin: 0; accent-color: var(--coral); }
#menu-page .set input[type="range"] { width: 100%; }
#menu-page .set input[type="checkbox"] { width: 20px; height: 20px; justify-self: start; }
#menu-page .set b { text-align: right; font-weight: 900; }
/* достижения: значок, название, условие; полученные — яркие, остальные — приглушены */
#menu-page .feats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin-top: 8px; }
#menu-page .feat { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 16px; border: 2.5px dashed var(--paper3); opacity: .7; }
#menu-page .feat .ico { flex: none; width: 44px; height: 44px; border-radius: 12px; background-color: var(--paper2); background-position: center; background-size: 86%; background-repeat: no-repeat; filter: grayscale(.8); }
#menu-page .feat.got { border: var(--edge); background: linear-gradient(#fff3c4, #ffe08a); opacity: 1; box-shadow: 0 3px 0 var(--ink); }
#menu-page .feat.got .ico { background-color: #fff; filter: none; }
/* вопрос перед тем, что меняет мир: поверх всего меню */
#menu-ask { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(42, 35, 64, .5); cursor: default; }
#menu-ask .card { max-width: 470px; padding: 22px 26px; border-radius: 22px; border: var(--edge); background: var(--paper); box-shadow: var(--drop); text-align: center; }
#menu-ask p { margin: 0 0 14px; font-weight: 700; line-height: 1.4; }
#menu-ask input { box-sizing: border-box; width: 100%; margin: 0 0 14px; padding: 6px 10px; border: var(--edge); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; }
#menu-ask .row { display: flex; justify-content: center; gap: 10px; }

/* страница «Игра с друзьями»: её наполняет ui/lan.js */
#menu-net { text-align: left; cursor: default; max-width: 470px; font-weight: 600; }
#menu-net h2 { margin: 10px 0 6px; font-size: 17px; font-weight: 900; }
#menu-net p { margin: 6px 0; }
#menu-net .status { min-height: 1.4em; color: #b0561a; font-weight: 800; }
#menu-net .row { display: flex; gap: 8px; }
#menu-net input { flex: 1; min-width: 0; padding: 6px 10px; border: var(--edge); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; }
#menu-net button { white-space: nowrap; }
#menu-net ul { list-style: none; margin: 8px 0 0; padding: 0; }
#menu-net li { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
#menu-net li span { flex: 1; color: var(--ink2); }
#menu-net li.hint { color: var(--ink2); }
#menu-net li button { padding: 2px 10px 3px; box-shadow: 0 3px 0 var(--ink); }
#menu-net [hidden] { display: none; }

/* главное меню: картина острова за меню, плашка слева, крупный заголовок; версия — в углу */
#title { position: fixed; inset: 0; overflow: hidden; background: linear-gradient(#8fd3ef, #d9f1f7 55%, #f6e7c1); }
#title[hidden] { display: none; }
#title::before {
  content: ""; position: absolute; inset: 0; background: url("../../data/ui/title.jpg") center / cover no-repeat;
  animation: drift 46s ease-in-out infinite alternate; transform-origin: 60% 55%;
}
#title::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(42, 35, 64, .5), rgba(42, 35, 64, .12) 46%, transparent 70%); }
@keyframes drift { from { transform: scale(1.04); } to { transform: scale(1.13) translate(-1.6%, -1.2%); } }
@media (prefers-reduced-motion: reduce) { #title::before { animation: none; } }
#menu.title { background: none; justify-content: flex-start; cursor: default; }
#menu.title.sub { background: rgba(42, 35, 64, .3); }
#menu.title .panel { margin-left: max(6vw, 28px); padding-top: 64px; }
#menu.title .panel::before { top: 12px; width: 92px; height: 58px; margin-left: -46px; }
#menu.title h1 { font-size: 62px; margin-bottom: 4px; }
#menu.title #menu-hint { background: var(--paper2); font-size: 15px; font-weight: 800; max-width: 340px; white-space: normal; }
#menu-nav button.main { padding: 10px 16px 11px; font-size: 20px; background: var(--coral); }
#menu-nav input { box-sizing: border-box; width: 100%; padding: 8px 12px; border: var(--edge); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-weight: 700; text-align: center; }
#menu-nav .fields { display: flex; flex-direction: column; gap: 9px; } /* ник и пароли */
#menu-nav .nick { display: flex; gap: 8px; } /* ник и кнопка «Облик» с котом */
#menu-nav .nick input { flex: 1; min-width: 0; }
#menu-nav button.look { flex: none; width: 46px; padding: 0; background: #fff var(--i-cat) center / 32px no-repeat; }
#menu-nav input.bad { border-color: var(--coral); background: #ffe9e4; } /* ник не по правилу */
#menu-nav button:disabled { filter: grayscale(.6) opacity(.6); cursor: wait; transform: none; }
#menu-version { position: absolute; right: 18px; bottom: 12px; margin: 0; color: #fff; font-weight: 800; font-size: 14px; text-shadow: var(--stroke); }
#menu:not(.title) #menu-version { display: none; }

/* заставка: кот, название, студия — и плавно гаснет */
#splash {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: var(--ink); color: var(--paper); transition: opacity .6s ease; cursor: pointer;
}
#splash.gone { opacity: 0; } /* пока гаснет, касания — ей: щелчок вслед пропуску не нажмёт кнопку меню под ней */
#splash .cat { width: 128px; height: 106px; background: var(--i-cat) center / contain no-repeat; animation: splash-pop .9s cubic-bezier(.2, 1.6, .4, 1) both; }
#splash .name {
  font-size: 76px; font-weight: 1000; line-height: 1; color: var(--coral); letter-spacing: .03em; animation: splash-rise .8s .25s both;
  text-shadow: 0 4px 0 #120e20, 3px 0 0 #120e20, -3px 0 0 #120e20, 0 -3px 0 #120e20, 0 8px 0 #120e20;
}
#splash .studio { margin-top: 10px; font-size: 14px; font-weight: 800; letter-spacing: .32em; text-transform: uppercase; opacity: .72; animation: splash-fade 1s .7s both; }
@keyframes splash-pop { from { transform: scale(.3) rotate(-8deg); opacity: 0; } }
@keyframes splash-rise { from { transform: translateY(20px); opacity: 0; } }
@keyframes splash-fade { from { opacity: 0; } }

/* страница настроек: группы */
#menu-page h3:first-child { margin-top: 0; }

/* сундук в экране инвентаря (ui/box.js): его ячейки — слева от своих, пока он открыт; в узком окне книга рецептов уступает ему место */
#inventory .chest { padding-right: 26px; border-right: 3px dotted var(--paper3); }
@media (max-width: 1400px) { #inventory .panel:has(.chest) .book { display: none; } }
@media (max-width: 1720px) { #inventory .panel:has(.chest):has(.grid.c8, .grid.c10) .book { display: none; } }
@media (max-width: 1400px) { #inventory .panel:has(.chest) .grid.c10 { grid-template-columns: repeat(8, 54px); } } /* узкое окно: два широких ряда не влезут — сетка листается */

/* карта острова (src/ui/map.js): лист у правого края, пока в лапе бутылка с картой; середину кадра не занимает */
#map { position: fixed; right: 22px; top: 50%; transform: translateY(-58%) rotate(1.2deg); width: min-content; padding: 10px 12px 12px; border-radius: 14px; border: var(--edge); background: #f3e3b8; box-shadow: var(--drop); color: var(--ink); pointer-events: none; } /* в index.html стоит раньше инвентаря и меню: они ложатся поверх */
#map h2 { margin: 0 0 6px; font-size: 16px; font-weight: 900; text-align: center; }
#map canvas { display: block; border-radius: 8px; border: 2px solid #5a4630; } /* размер листа задаёт ui/map.js */
#map p { margin: 6px 0 0; font-size: 12.5px; font-weight: 700; line-height: 1.25; text-align: center; color: #5a4630; }

/* --- путь к другому миру (src/ui/frontier.js): компас, страж, кислород, зелья, прыжок */
#compass, #bossbar, #air, #warpcount { display: none; }
#compass.on { display: flex; position: absolute; right: 24px; bottom: 96px; flex-direction: column; align-items: center; gap: 4px; width: 150px; text-align: center; }
#compass .dial { width: 66px; height: 66px; border-radius: 50%; border: 5px solid var(--gold); outline: var(--edge); background: var(--paper); position: relative; box-shadow: 0 5px 0 var(--ink); }
#compass .dial i { position: absolute; left: 50%; top: 6px; width: 8px; height: 27px; margin-left: -4px; border-radius: 4px 4px 0 0; background: var(--coral); border: 2px solid var(--ink); box-sizing: border-box; transform-origin: 50% 27px; }
#compass b { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
#compass span { font-size: 13px; }
#bossbar.on { display: block; position: absolute; left: 50%; top: 56px; transform: translateX(-50%); width: 440px; text-align: center; }
#bossbar b { font-size: 16px; font-weight: 900; letter-spacing: .2em; color: #ffd24a; }
#bossbar div { height: 18px; margin-top: 5px; border-radius: 10px; border: var(--edge); background: rgba(42, 35, 64, .6); overflow: hidden; box-shadow: 0 4px 0 var(--ink); }
#bossbar i { display: block; height: 100%; background: linear-gradient(#ff8a70, var(--coral)); transition: width .2s; }
#air.on { display: block; position: absolute; left: 22px; bottom: 132px; width: 208px; }
.bar.o2 { --icon: var(--i-o2); } .bar.o2 i { background: #8fe3f0; }
#buffs { position: absolute; left: 244px; bottom: 22px; font-size: 12.5px; white-space: pre; color: #e4f3ff; }
#warpcount.on { display: block; position: absolute; left: 50%; top: 30%; transform: translateX(-50%); font-size: 30px; font-weight: 900; letter-spacing: .06em; }
#warp { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; display: none; z-index: 5; }
#warp.on { display: block; }

/* --- снаряжение и закладки книги рецептов (src/ui/inventory.js) */
#inventory .gear { display: grid; grid-template-columns: repeat(6, 54px); gap: 8px; }
#inventory .gear .slot { background: var(--paper2); border-style: dashed; box-shadow: none; }
#inventory .gear .slot:has(.ico) { background: linear-gradient(var(--paper), var(--paper2)); border-style: solid; box-shadow: 0 3px 0 var(--ink); }
#inventory .gear .slot em { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-style: normal; font-size: 10px; font-weight: 800; color: var(--ink2); opacity: .7; text-align: center; }
#inventory .gear .slot.can { border-color: #3f9a2f; background: #dff5c8; }
#inventory .stats { margin: 8px 0 14px; max-width: 364px; font-size: 13px; font-weight: 700; color: var(--ink2); }
#inventory .tabs { display: flex; flex-wrap: wrap; gap: 5px; margin: -2px 0 10px; }
#inventory .tabs button { padding: 2px 10px 3px; border: 2px solid var(--ink); border-radius: 11px; background: var(--paper2); color: var(--ink); font: inherit; font-size: 12.5px; font-weight: 800; cursor: pointer; }
#inventory .tabs button:hover { background: #fff; }
#inventory .tabs button.on { background: var(--accent); box-shadow: 0 3px 0 var(--ink); transform: translateY(-2px); }
#inventory .book { width: 430px; }
#jet { display: none; }
#jet.on { display: block; position: absolute; left: 22px; bottom: 160px; width: 208px; }
.bar.jet { --icon: var(--i-jet); } .bar.jet i { background: var(--accent); }

/* ---------- сенсорный экран (body.touch, ui/touch.js): джойстик, кнопки, раскладка под большие пальцы ---------- */
body.touch { touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; overscroll-behavior: none; }
body.touch #menu-page, body.touch #menu .panel, body.touch #inventory .list, body.touch #inventory .grid { touch-action: pan-y; } /* листать пальцем */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
#touch.off { display: none; }
.tb {
  position: absolute; box-sizing: border-box; width: calc(var(--size) * var(--k) * 1px); height: calc(var(--size) * var(--k) * 1px);
  display: flex; align-items: center; justify-content: center; padding: 0; border-radius: 50%; border: var(--edge);
  background: rgba(255, 246, 226, .82); color: var(--ink); font: 900 calc(var(--size) * var(--k) * .42px) / 1 "Nunito", system-ui, sans-serif;
  box-shadow: 0 4px 0 var(--ink); pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent;
}
.tb.down { transform: translateY(3px) scale(.94); box-shadow: 0 1px 0 var(--ink); background: var(--accent); }
.tb { right: calc(env(safe-area-inset-right) + (var(--x) - var(--size) / 2) * var(--k) * 1px); }
.tb.at-br { bottom: calc(env(safe-area-inset-bottom) + (var(--y) - var(--size) / 2) * var(--k) * 1px); }
.tb.at-tr { top: calc(env(safe-area-inset-top) + (var(--y) - var(--size) / 2) * var(--k) * 1px); }
.tb.fan { display: none; }
#touch.fanned .tb.fan { display: flex; }
#touch.bag .tb:not([data-id="inventory"]), #touch.bag .stick { display: none; } /* инвентарь открыт: только «сумка» — закрыть */
/* джойстик: появляется под пальцем; пока пальца нет — бледный, на своём обычном месте */
.stick { position: absolute; width: calc(var(--k) * 112px); height: calc(var(--k) * 112px); margin: calc(var(--k) * -56px) 0 0 calc(var(--k) * -56px); border-radius: 50%; border: 3px solid rgba(42, 35, 64, .4); background: rgba(255, 255, 255, .16); }
.stick:not(.on) { left: calc(env(safe-area-inset-left) + var(--k) * 110px) !important; top: calc(100% - env(safe-area-inset-bottom) - var(--k) * 110px) !important; opacity: .45; }
.stick .knob { position: absolute; left: 50%; top: 50%; width: 46%; height: 46%; margin: -23% 0 0 -23%; border-radius: 50%; border: var(--edge); background: rgba(255, 246, 226, .9); box-shadow: 0 3px 0 var(--ink); }
/* под большие пальцы: шкалы — наверх слева, ячейки — помельче и под палец, плашки — ниже кнопок справа */
body.touch #vitals { top: calc(env(safe-area-inset-top) + 12px); bottom: auto; left: calc(env(safe-area-inset-left) + 14px); width: 168px; gap: 5px; }
body.touch #hotbar { bottom: calc(env(safe-area-inset-bottom) + 10px); }
body.touch #hotbar .slot { width: 48px; height: 48px; pointer-events: auto; }
body.touch #hotbar .name { margin-bottom: 6px; font-size: 14px; }
body.touch #tips { bottom: calc(env(safe-area-inset-bottom) + 120px); }
body.touch #carry { bottom: calc(env(safe-area-inset-bottom) + 96px); }
body.touch #popups { top: calc(env(safe-area-inset-top) + 70px); right: calc(env(safe-area-inset-right) + 14px); }
/* чат на телефоне — слева сверху под шкалами: снизу джойстик */
body.touch #chat { top: calc(env(safe-area-inset-top) + 150px); bottom: auto; left: calc(env(safe-area-inset-left) + 14px); width: min(360px, 46vw); }
/* клавиатура поднята (страница сжата до полосы над ней, лёжа ~150 px): строка — у нижнего края, над клавиатурой, а то, что
   стоит от низа и въехало бы в ту же полосу, прячется. Клавиатуру убрали («Назад») — всё на своих местах */
@media (max-height: 300px) {
  body.touch #chat.open { top: auto; bottom: calc(env(safe-area-inset-bottom) + 10px); }
  body.touch:has(#chat.open) :is(#hotbar, #carry, #buffs, .stick, .tb.at-br) { display: none; }
}
/* телефон лёжа: окна меню и инвентаря мельче, чтобы влезали по высоте */
@media (max-height: 520px) {
  /* телефон лёжа: кот уступает место кнопкам; заголовок — помельче, а у паузы и страниц его нет: игра и так видна */
  #menu .panel, #menu.title .panel { zoom: .8; padding-top: 14px; }
  #menu .panel::before, #menu:not(.title) h1 { display: none; }
  #menu.title h1 { font-size: 32px; }
  #menu-hint { margin: 6px 0 12px; }
  /* кнопки меню — в два столбца (главная и поле пароля — во всю ширину): семь кнопок паузы влезают без листания */
  #menu-nav { display: grid; grid-template-columns: 1fr 1fr; width: 440px; gap: 8px; }
  #menu-nav button.main, #menu-nav .fields { grid-column: 1 / -1; }
  #menu-nav .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } /* поля — по два в ряд */
  #menu-nav .fields > :last-child:nth-child(odd) { grid-column: 1 / -1; } /* последнее без пары (и ряд ника с котом) — во всю ширину */
  #menu.title .panel:has(.fields input:nth-child(3)) h1 { display: none; } /* вход на сервер (три-четыре поля): без заголовка всё влезает */
  /* только ник (одиночная, своё окно, у друга): поле и главная кнопка — в один ряд, кнопки меню не уходят за край */
  #menu-nav .fields:has(> .nick:only-child), #menu-nav .fields:has(> .nick:only-child) + button.main { grid-column: auto; }
  #inventory .panel { zoom: .74; max-height: 96vh; overflow-y: auto; }
  #inventory .grid { max-height: 34vh; } /* ячейки листаются, окно влезает целиком */
  #menu-page .look-cat canvas { width: 170px; height: 198px; } /* кот поменьше: выбор облика влезает рядом */
}
/* телефон стоя: просьба повернуть (играть можно и так, но кнопки рассчитаны на альбомный экран) */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  body.touch #rotate { display: block; position: fixed; left: 0; right: 0; top: 0; z-index: 40; padding: calc(env(safe-area-inset-top) + 8px) 14px 8px; background: var(--coral); color: #fff; text-align: center; font-weight: 900; text-shadow: 0 1px 0 var(--ink); pointer-events: none; }
}
