/* Окна, подсказки, меню. Подключается после hud.css. Единый стиль окон — REFERENCES 4E (раздел «Окна 4E» ниже). */
:root {
  --w-gold: #e8c26a; --w-gold-hi: #fff1b8; --w-gold-lo: #8a6424;
  --w-line: #5a4420; --w-ink: #ddd2bb; --w-dim: #a89670;
  --w-plaque: linear-gradient(#2e2418, #17110a 55%, #0c0805);
  --w-btn: linear-gradient(#3e3020, #1d160d 60%, #0f0b06);
  --w-btn-go: linear-gradient(#ffe08a, #d79a2c 55%, #8a5a14);
  --w-row: linear-gradient(90deg, rgba(255,236,180,0.05), rgba(0,0,0,0.25));
}

/* ---------- Списки: задания и врата (плотные строки) ---------- */
.q-box { width: min(620px, calc(100vw - 12px)); }
.q-list { gap: 6px; padding: 0 2px 2px 0; }
.q-card {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 1px; align-items: center;
  padding: 6px 6px 6px 10px; border-radius: 4px; font-size: 13px; line-height: 1.35;
  border-left: 3px solid var(--w-gold-lo);
}
.q-card > * { grid-column: 1; min-width: 0; }
.q-card > .q-btns { grid-column: 2; grid-row: 1 / span 4; margin: 0; align-self: center; }
.q-card.active { border-left-color: var(--w-gold); }
.q-card.locked { opacity: 0.55; border-left-color: #3a3a3a; }
.q-card.done { border-left-color: #4be07a; }
.q-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-text { margin: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-goal { font-size: 12.5px; }
.q-rew { margin-top: 0; gap: 2px 10px; font-size: 12.5px; }
.q-rew img.mini { width: 16px; height: 16px; vertical-align: -3px; }
.q-btns button { min-height: 44px; min-width: 96px; padding: 0 12px; border-radius: 4px; font-size: 13px; }
.q-lock { display: inline-block; min-width: 80px; text-align: center; font-size: 12px; padding: 4px 6px; border: 1px dashed #5a4420; border-radius: 4px; }
.q-foot { font-size: 12px; }

/* ---------- Рейтинг ---------- */
.r-tabs { gap: 0; margin: -8px -10px 8px; padding: 0 10px; border-bottom: 1px solid rgba(232,194,106,0.35); background: rgba(0,0,0,0.35); }
.r-tabs button { min-height: 44px; border-radius: 0; border: 0; border-bottom: 3px solid transparent; background: transparent; box-shadow: none; color: var(--w-dim); font-size: 13.5px; }
.r-tabs button.on, #settings .st-tab.on { color: #fff2c8; text-shadow: 0 0 8px rgba(255,200,110,0.45), 0 1px 1px #000; border-bottom-color: transparent;
  background: linear-gradient(90deg, rgba(232,194,106,0), #f4d48a 25%, #fff3cc 50%, #f4d48a 75%, rgba(232,194,106,0)) bottom / 100% 3px no-repeat, linear-gradient(rgba(255,210,120,0), rgba(255,210,120,0.16)); }
.r-row { min-height: 36px; padding: 4px 8px; border-radius: 4px; font-size: 13px; }
.r-row .nm { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Меню группы ---------- */
#pmenu, #pinvite { padding: 10px; gap: 8px; font-size: 14px; min-width: 200px; border-radius: 4px; }
#pmenu > div:first-child, #pinvite > div:first-child { color: #ffe7a0; padding-bottom: 6px; border-bottom: 1px solid rgba(232,194,106,0.25); }
#pmenu button, #pinvite button { min-height: 44px; padding: 0 16px; border-radius: 4px; font-size: 14px; }
#pinvite { top: calc(18% + env(safe-area-inset-top)); }
#pinvite .row2 { gap: 8px; }
#pinvite .row2 button { flex: 1; min-width: 100px; }
#pinvite .yes, .q-btns .q-turn { color: #2a1c06; background: var(--w-btn-go); border-color: #ffe08a; }

/* ===== Надёжная высота окон на iPhone (Chrome/Safari): --app-h = реально видимая высота ===== */
#quests, #gates, #rank {
  align-items: flex-start !important; justify-content: center; overflow-y: auto; -webkit-overflow-scrolling: touch;
  height: var(--app-h, 100%) !important; padding: calc(12px + var(--sat)) 4px calc(4px + var(--sab)); box-sizing: border-box;
  touch-action: pan-y;
}
#quests .q-box, #gates .q-box, #rank .q-box {
  margin: auto 0; max-height: calc(var(--app-h, 100vh) - 16px - var(--sat) - var(--sab)) !important;
}
#quests .q-box, #gates .q-box, #rank .q-box { display: flex; flex-direction: column; }
#quests .q-list, #gates .q-list, #rank .q-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* крестик закрытия всегда доступен */
#q-close, #g-close, #r-close { position: relative; z-index: 5; }

/* Плашка «Локации» */
#locs { position: fixed; inset: 0; z-index: 12; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch;
  height: var(--app-h, 100%); background: rgba(4, 3, 2, 0.62); box-sizing: border-box; padding: calc(12px + var(--sat, 0px)) 4px calc(4px + var(--sab, 0px)); }
#locs.hidden { display: none; }
#locs .q-box { margin: auto 0; display: flex; flex-direction: column; width: min(560px, calc(100vw - 12px)); max-height: calc(var(--app-h, 100vh) - 16px - var(--sat, 0px) - var(--sab, 0px)); }
#locs .q-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
#l-close { position: relative; z-index: 5; min-width: 44px; min-height: 44px; }
#locs .l-hint { font-size: 12px; color: #b9a98a; padding: 2px 12px 6px; }
#locs .l-card { display: flex; gap: 10px; align-items: flex-start; margin: 6px 8px; padding: 9px 10px; border-radius: 8px;
  background: linear-gradient(180deg, rgba(40,32,22,.92), rgba(22,18,13,.92)); border: 1px solid #5a4526; }
#locs .l-card.fit { border-color: #e8c25a; box-shadow: 0 0 0 1px rgba(232,194,90,.35), 0 0 14px rgba(232,194,90,.18); }
#locs .l-card.cur { border-color: #7fe08a; }
#locs .l-card.locked { opacity: .55; filter: saturate(.5); }
#locs .l-ic { font-size: 26px; line-height: 1; width: 34px; text-align: center; }
#locs .l-body { flex: 1; min-width: 0; font-size: 12px; color: #d9cba8; }
#locs .l-top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
#locs .l-top b { font-size: 15px; color: #ffe7a0; }
#locs .l-st { font-size: 11.5px; white-space: nowrap; color: #b9a98a; }
#locs .l-st.fit { color: #ffd34a; font-weight: 700; } #locs .l-st.here { color: #8ff09a; font-weight: 700; }
#locs .l-st.lock { color: #e07a5a; } #locs .l-st.easy { color: #8a8070; }
#locs .l-lv { margin-top: 3px; } #locs .l-lv b { color: #fff1c4; font-size: 13px; }
#locs .l-mobs, #locs .l-boss { margin-top: 2px; color: #b9a98a; } #locs .l-boss { color: #ffb48a; }
/* ---------- Врата: описание переносится, не обрезается по высоте ---------- */
.q-text { white-space: normal; overflow: visible; text-overflow: clip; display: block; -webkit-line-clamp: unset; }
@media (orientation: portrait) {
  .q-text { display: block; -webkit-line-clamp: unset; overflow: visible; }
}


/* =====================================================================
   Окна 4E (REFERENCES 4E.1–4E.6, тултип 4F.4): тёмный сине-серый металл, кованые уголки,
   заголовок по центру + подзаголовок, синяя квадратная «X», снизу квадратные кнопки (синее стекло,
   золотая иконка). Цвета текста — CSS-переменные --pal-* из client/palette.js (ставит inventory.js).
   ===================================================================== */
:root {
  /* фактура окон: зерно металла и шлифовка — процедурный шум SVG (feTurbulence), растеризуется браузером один раз */
  --wn-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .78  0 0 0 0 .84  0 0 0 0 .92  .55 0 0 0 -.24'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  --wn-brush: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='120'%3E%3Cfilter id='b' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .55' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .72  0 0 0 0 .8  0 0 0 0 .9  0 0 .5 0 -.25'/%3E%3C/filter%3E%3Crect width='240' height='120' filter='url(%23b)'/%3E%3C/svg%3E");
  /* кованая кромка 7 px: чёрный контур · золотая нить · сталь с гравировкой и заклёпками (border-image) */
  --wn-edge-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='35' height='35'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23f6dc94'/%3E%3Cstop offset='.5' stop-color='%23b8863a'/%3E%3Cstop offset='1' stop-color='%235e3e10'/%3E%3C/linearGradient%3E%3ClinearGradient id='s' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%235a6574'/%3E%3Cstop offset='.5' stop-color='%23323a45'/%3E%3Cstop offset='1' stop-color='%231c2128'/%3E%3C/linearGradient%3E%3CradialGradient id='r' cx='.35' cy='.35' r='.7'%3E%3Cstop offset='0' stop-color='%23fff4c8'/%3E%3Cstop offset='.6' stop-color='%23c8963e'/%3E%3Cstop offset='1' stop-color='%234a3008'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect width='35' height='35' fill='%23040507'/%3E%3Crect x='1' y='1' width='33' height='33' fill='url(%23g)'/%3E%3Crect x='2.2' y='2.2' width='30.6' height='30.6' fill='url(%23s)'/%3E%3Crect x='4.1' y='4.1' width='26.8' height='26.8' fill='none' stroke='%23000' stroke-opacity='.7' stroke-width='.9'/%3E%3Crect x='4.8' y='4.8' width='25.4' height='25.4' fill='none' stroke='%23fff' stroke-opacity='.13' stroke-width='.6'/%3E%3Crect x='6' y='6' width='23' height='23' fill='%2306080b'/%3E%3Cg fill='url(%23r)' stroke='%23000' stroke-width='.5'%3E%3Ccircle cx='17.5' cy='3.6' r='1.35'/%3E%3Ccircle cx='17.5' cy='31.4' r='1.35'/%3E%3Ccircle cx='3.6' cy='17.5' r='1.35'/%3E%3Ccircle cx='31.4' cy='17.5' r='1.35'/%3E%3C/g%3E%3C/svg%3E");
  --wn-bg: var(--wn-noise), var(--wn-brush),
    radial-gradient(120% 50% at 50% 0, rgba(150,170,200,0.12), transparent 60%),
    linear-gradient(#242b35, #171c23 40%, #11151b);
  --wn-blue: linear-gradient(rgba(255,255,255,0.34), rgba(255,255,255,0.06) 48%, rgba(255,255,255,0) 50%), linear-gradient(#4a8fec, #2160c4 50%, #143a82);
  --wn-glass: linear-gradient(rgba(255,255,255,0.3), rgba(255,255,255,0.05) 46%, rgba(255,255,255,0) 50%), radial-gradient(circle at 50% 30%, #4d93ea, #1d4f9e 58%, #0e2a5c);
  --wn-cell: #0a0d11; --wn-cell-line: #262d36; --wn-edge: #3b434e;
  /* внутренняя тень каждой ячейки сетки (сумка, хранилище, магазин, наковальня) */
  --wn-cells: linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0) 26%), linear-gradient(90deg, rgba(0,0,0,0.45), rgba(0,0,0,0) 24%),
    linear-gradient(0deg, rgba(120,140,165,0.10), rgba(0,0,0,0) 14%), linear-gradient(var(--wn-cell-line) 1px, transparent 1px), linear-gradient(90deg, var(--wn-cell-line) 1px, transparent 1px);
  --wn-orn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23fff4c8'/%3E%3Cstop offset='.4' stop-color='%23e2b45a'/%3E%3Cstop offset='1' stop-color='%237a5216'/%3E%3C/linearGradient%3E%3CradialGradient id='r' cx='.35' cy='.32' r='.75'%3E%3Cstop offset='0' stop-color='%23ffe0c8'/%3E%3Cstop offset='.35' stop-color='%23e8442c'/%3E%3Cstop offset='1' stop-color='%234a0804'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 42V12Q5.5 5.5 12 5.5h30' stroke='%23000' stroke-opacity='.8' stroke-width='5'/%3E%3Cpath d='M5.5 42V12Q5.5 5.5 12 5.5h30' stroke='url(%23g)' stroke-width='2.8'/%3E%3Cpath d='M10.5 32V15.5q0-5 5-5H32' stroke='%23000' stroke-opacity='.6' stroke-width='2.6'/%3E%3Cpath d='M10.5 32V15.5q0-5 5-5H32' stroke='url(%23g)' stroke-width='1.2'/%3E%3Cpath d='M38 5.5q4.5 0 4.5 4 0 2.8-2.7 2.8-2.1 0-2.1-2M5.5 38q0 4.5 4 4.5 2.8 0 2.8-2.7 0-2.1-2-2.1' stroke='%23000' stroke-opacity='.7' stroke-width='3'/%3E%3Cpath d='M38 5.5q4.5 0 4.5 4 0 2.8-2.7 2.8-2.1 0-2.1-2M5.5 38q0 4.5 4 4.5 2.8 0 2.8-2.7 0-2.1-2-2.1' stroke='url(%23g)' stroke-width='1.4'/%3E%3Cpath d='M15 21c0-4 2-6 6-6M19 25c0-2 1-3 3-3' stroke='url(%23g)' stroke-width='1.1'/%3E%3C/g%3E%3Cpath d='M12.5 12.5l9 4.2 4.5 9.3-9.3-4.5z' fill='url(%23g)' stroke='%23000' stroke-width='.8' stroke-opacity='.8'/%3E%3Cpath d='M9.5 2.2l7.3 7.3-7.3 7.3-7.3-7.3z' fill='url(%23g)' stroke='%23000' stroke-width='1'/%3E%3Ccircle cx='9.5' cy='9.5' r='3.4' fill='url(%23r)' stroke='%23200' stroke-width='.6'/%3E%3Ccircle cx='8.5' cy='8.4' r='1' fill='%23fff' fill-opacity='.9'/%3E%3C/svg%3E");
  --wn-sq: 44px;
  --wn-ease: cubic-bezier(.2, .8, .2, 1);
}
@media (min-height: 340px) { :root { --wn-sq: 48px; } }

.wn {
  position: relative; box-sizing: border-box; display: flex; flex-direction: column; min-height: 0; isolation: isolate;
  color: #d6dbe3; font: 13px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; text-align: left;
  background: var(--wn-bg); border: 0; border-radius: 3px;
  box-shadow: 0 0 0 1px #000, 0 14px 34px rgba(0,0,0,0.75), inset 0 0 30px rgba(0,0,0,0.55);
}
/* рамка и уголки — две подложки поверх содержимого (касания проходят насквозь):
   ::before — кованая кромка + левый верхний уголок; ::after — правый верхний (зеркально). Крестик — выше подложек. */
.wn::before, .wn::after, .q-box::before, .q-box::after {
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none; margin: 0; border-radius: 0; width: auto; height: auto;
  background: var(--wn-orn) left 0 top 0 / 44px 44px no-repeat; background-origin: border-box;
}
.wn::before, .q-box::before { border: 7px solid transparent; border-image: var(--wn-edge-img) 7 round; }
.wn::after, .q-box::after { transform: scaleX(-1); }
/* где в правом верхнем углу крестик — правый уголок не рисуем (не выглядывает из-под кнопки) */
.wn:has(> .wn-head .wn-x, > .wn-head #inv-close, > .wn-head #side-close)::after, .q-box::after { background: none; }
/* нижние уголки — у подвала окна */
.wn > .wn-foot { position: relative; }
.wn > .wn-foot::before, .wn > .wn-foot::after {
  content: ''; position: absolute; bottom: 0; width: 36px; height: 36px; pointer-events: none; z-index: 4;
  background: var(--wn-orn) center / contain no-repeat;
}
.wn > .wn-foot::before { left: 0; transform: scaleY(-1); }
.wn > .wn-foot::after { right: 0; transform: scale(-1, -1); }
.wn button { font-family: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* шапка — кованая плашка: сталь с зерном, золотой брус с заклёпками снизу; заголовок на тёмной ленте с золотыми нитями */
.wn-head, .q-head {
  background:
    radial-gradient(circle, #fff1c0 0 1px, #8a5a14 1.4px, rgba(0,0,0,0) 2px) left 14px bottom -1px / 28px 4px repeat-x,
    linear-gradient(#f4d488, #b8863a 45%, #5e3e10) bottom / 100% 3px no-repeat,
    var(--wn-noise),
    radial-gradient(60% 120% at 50% 0, rgba(170,190,220,0.18), rgba(0,0,0,0) 70%),
    linear-gradient(#343c48, #1f252e 70%, #181d24);
  border-bottom: 1px solid #000; box-shadow: 0 3px 6px rgba(0,0,0,0.45);
}
.wn-head {
  flex: none; position: relative; display: grid; grid-template-columns: 50px minmax(0, 1fr) 50px; align-items: center;
  padding: calc(12px + var(--sat, 0px)) 7px 6px; min-height: 44px;
}
.wn-tt { grid-column: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; min-height: 44px; text-align: center; }
.wn-tt > b, .wn-tt > .wn-pg b, .q-head > b {
  color: #fff7e2; font-size: 15px; font-weight: 700; letter-spacing: 0.5px; line-height: 1.25; padding: 1px 18px;
  text-shadow: 0 1px 0 #000, 0 0 2px #000, 0 0 10px rgba(255,196,110,0.3);
  background:
    linear-gradient(90deg, rgba(232,194,106,0), rgba(232,194,106,0.75) 25%, rgba(232,194,106,0.75) 75%, rgba(232,194,106,0)) top / 100% 1px no-repeat,
    linear-gradient(90deg, rgba(232,194,106,0), rgba(232,194,106,0.55) 25%, rgba(232,194,106,0.55) 75%, rgba(232,194,106,0)) bottom / 100% 1px no-repeat,
    linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,0.5) 18%, rgba(0,0,0,0.5) 82%, rgba(0,0,0,0));
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-sizing: border-box;
}
.wn-tt > .wn-pg b { padding: 1px 10px; }
.wn-sub { display: block; max-width: 100%; margin-top: 2px; font-style: normal; font-size: 11.5px; line-height: 1.25; color: #c9d0da;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wn-sub b { font-weight: 700; } .wn-sub .ok { color: var(--pal-exc); } .wn-sub .bad { color: var(--pal-warn); } .wn-sub .g { color: var(--pal-set); }
/* шапка окна NPC: портрет-иконка функции в золотом кольце + «Имя — роль» (client/interact.js npcHead) */
.npc-ava { display: inline-block; width: 24px; height: 24px; margin: 0 7px 0 0; vertical-align: middle; border-radius: 50%; object-fit: contain;
  border: 1px solid #c9a24a; background: radial-gradient(circle at 50% 42%, #3b311f, #0c0a07 72%); box-shadow: 0 0 6px rgba(255,200,90,0.35), inset 0 0 4px #000; }
.wn-sub .npc-ava { width: 16px; height: 16px; margin: 0 4px 0 0; }
.wn-sub .npc-who { color: #ffe7a0; font-weight: 700; }
.wn-sub .wn-sub-l { display: block; overflow: hidden; text-overflow: ellipsis; } /* подзаголовок в несколько строк (окно Хранилища) */
/* крестик: синее стекло (реф 21) с фаской и бликом, всегда над рамкой и уголками */
.wn-x, #inv-close, #side-close, .tip .t-x {
  grid-column: 3; right: auto; top: auto; justify-self: end; position: relative; z-index: 6; width: 44px; height: 44px; margin: 0; padding: 0; border-radius: 4px;
  border: 1px solid #000; background: var(--wn-blue); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(210,228,255,0.75), inset 0 -3px 6px rgba(0,0,30,0.4), 0 0 0 1px #8a6424, 0 2px 5px rgba(0,0,0,0.6);
  transition: transform 0.08s var(--wn-ease);
}
.wn-x svg, .tip .t-x svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.6)); }
.wn-x:active, #inv-close:active, #side-close:active, .tip .t-x:active { transform: scale(0.92); filter: brightness(1.25); }

/* оранжевые стрелки ‹ Снаряжение › */
.wn-pg { display: flex; align-items: center; justify-content: center; gap: 2px; max-width: 100%; }
.wn-pg b { min-width: 0; }
.wn-arr { flex: none; width: 44px; height: 44px; padding: 0; border: 0; background: none; position: relative; }
.wn-arr::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 16px; height: 22px; margin: -11px 0 0 -8px;
  background: linear-gradient(#ffe0a0, #ff9a2a 45%, #c25a0c); clip-path: polygon(100% 0, 0 50%, 100% 100%, 72% 50%);
  filter: drop-shadow(0 1px 1px #000);
}
.wn-arr.r::before { clip-path: polygon(0 0, 100% 50%, 0 100%, 28% 50%); }
.wn-arr:active::before { transform: scale(0.88); }

/* серые текст-вкладки под шапкой ([Персонаж] [Бонусы]) */
.wn-tabs { display: flex; justify-content: center; gap: 4px; margin: -4px 0 2px; }
.wn-tabs.hidden { display: none; }
.wn-ttab { min-height: 44px; padding: 0 8px; border: 0; background: none; color: #8a94a3; font-size: 12.5px; font-weight: 700; letter-spacing: 0.2px; }
.wn-ttab.on { color: #fff2c8; text-shadow: 0 0 8px rgba(255,200,110,0.5), 0 1px 1px #000; }
.wn-ttab.pulse { color: var(--pal-set); }

.wn-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  touch-action: pan-y; padding: 6px 11px 8px;
}
/* утопленные панели внутри окон: карточки, группы, строки списков */
.q-card, #locs .l-card, .bn-grp, .sk-row, .r-row, #shop-win .sh-grid > *, #prof-win .pw-card, #wing-win .pw-card {
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.7), inset 0 0 0 1px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.06);
}
#locs .l-card.fit { box-shadow: inset 0 2px 5px rgba(0,0,0,0.7), 0 0 0 1px rgba(232,194,90,0.35), 0 0 14px rgba(232,194,90,0.18); }
/* нижний ряд квадратных кнопок: синее стекло, серебряная фаска, золотая иконка, первая — закрыть */
.wn-foot {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 10px calc(7px + var(--sab, 0px));
  border-top: 1px solid #000; box-shadow: inset 0 1px 0 #39424d, inset 0 3px 6px rgba(0,0,0,0.4); background: var(--wn-noise), linear-gradient(rgba(0,0,0,0.18), rgba(0,0,0,0.42));
}
.wn-foot:empty { display: none; }
.wn-sq, .coin-sq {
  border: 2px solid; border-color: #e1e8f2 #7b8798 #4a5462 #a2adbb; border-radius: 4px; background: var(--wn-glass);
  box-shadow: inset 0 0 0 1px #000, inset 0 -6px 10px rgba(0,0,30,0.45), 0 0 0 1px #000, 0 3px 5px rgba(0,0,0,0.55);
}
.wn-sq {
  flex: none; position: relative; width: var(--wn-sq); height: var(--wn-sq); padding: 0; color: var(--pal-leg);
  transition: transform 0.08s var(--wn-ease), filter 0.12s;
}
.wn-sq svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 1px #000) drop-shadow(0 0 3px rgba(255,170,60,0.4)); }
.wn-sq[data-a="close"] svg, .wn-sq[data-a="side-close"] svg { stroke-width: 3.2; }
.wn-sq:active:not(:disabled) { transform: scale(0.93); filter: brightness(1.25); }
.wn-sq[data-on] { border-color: #fff0b8 #d6a64a #8a6424 #e8c26a; box-shadow: inset 0 0 0 1px #000, inset 0 0 12px rgba(255,210,120,0.5), 0 0 0 1px #000, 0 0 10px rgba(255,190,80,0.5); }
.wn-sq[data-pts]::after { content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--pal-set); box-shadow: 0 0 6px var(--pal-set); }
.wn-sq:disabled { filter: grayscale(0.9) brightness(0.6); }
.wn-big { --wn-sq: 64px; margin: 0 auto; }
.wn-sq-gap { flex: none; width: var(--wn-sq); }
@media (max-height: 300px) { .wn-big { --wn-sq: 52px; } }
/* текстовые кнопки окон: secondary — синее стекло; primary — золото; danger — красный */
.tip .t-btns button, .sh-foot button, .sh-dbtns button, .sh-qty button, .q-btns .q-go {
  min-height: 44px; padding: 0 12px; border-radius: 4px; border: 1px solid #000; color: #fff; font: 700 13px -apple-system, system-ui, sans-serif;
  background: linear-gradient(rgba(255,255,255,0.24), rgba(255,255,255,0.04) 46%, rgba(255,255,255,0) 50%), linear-gradient(#3a76d0, #1a4590 55%, #0f2a5c);
  box-shadow: inset 0 0 0 1px rgba(170,200,245,0.55), inset 0 -3px 6px rgba(0,0,30,0.35), 0 0 0 1px #000, 0 3px 6px rgba(0,0,0,0.5);
  transition: transform 0.08s var(--wn-ease), filter 0.12s;
}
.sh-qty button.on { box-shadow: inset 0 0 0 1px #ffe08a, 0 0 0 1px #000, 0 0 10px rgba(255,200,100,0.4); }
.q-btns .q-turn, #pinvite .yes, .tip .t-btns button.go, .sh-foot button.go, .sh-dbtns button.go, .so-btns .go {
  color: #2a1a04; text-shadow: 0 1px 0 rgba(255,245,210,0.6); font-weight: 800; border: 1px solid #000; border-radius: 4px;
  background: linear-gradient(rgba(255,255,255,0.45), rgba(255,255,255,0.08) 46%, rgba(255,255,255,0) 50%), linear-gradient(#ffe7a0, #e0aa44 52%, #9a6418);
  box-shadow: inset 0 0 0 1px rgba(255,246,210,0.7), inset 0 -3px 6px rgba(90,50,0,0.35), 0 0 0 1px #6a4a14, 0 3px 6px rgba(0,0,0,0.55);
}
.tip .t-btns .danger, .sh-dbtns .cancel, .sh-foot button.sure, .so-btns .danger, .q-btns button[data-a="abandon"] {
  color: #fff1ea; border: 1px solid #000;
  background: linear-gradient(rgba(255,255,255,0.24), rgba(255,255,255,0.04) 46%, rgba(255,255,255,0) 50%), linear-gradient(#c8402e, #7c1a10 55%, #420806);
  box-shadow: inset 0 0 0 1px rgba(255,170,150,0.5), inset 0 -3px 6px rgba(40,0,0,0.4), 0 0 0 1px #000, 0 3px 6px rgba(0,0,0,0.5);
}
.q-btns button, .so-btns button, #pinvite button, #pmenu button { transition: transform 0.08s var(--wn-ease), filter 0.12s; }
.q-btns button:active, .tip .t-btns button:active, .sh-foot button:active, .sh-dbtns button:active, .sh-qty button:active, .so-btns button:active { transform: scale(0.96); filter: brightness(1.2); }
.tip .t-btns button:disabled, .sh-foot button:disabled, .sh-dbtns button:disabled, .q-btns button:disabled { filter: grayscale(0.85) brightness(0.6); transform: none; }

/* ---------- Сумка (4E.2, 4E.3): на всю высоту, прижата к правому краю ---------- */
#inv {
  position: fixed; inset: 0; z-index: 10; display: block; height: var(--app-h, 100%); box-sizing: border-box;
  padding: 0 var(--sar, 0px) 0 var(--sal, 0px); background: rgba(0, 0, 0, 0.55); overflow: hidden; --cell: 36px;
}
#inv .inv-main, #inv .inv-side { position: absolute; top: 0; height: var(--app-h, 100%); width: var(--win-w, 320px); max-width: 100%; }
#inv .inv-main { right: var(--sar, 0px); }
#inv .inv-side { right: calc(var(--sar, 0px) + var(--inv-w, 320px)); }
#inv.portrait .inv-main { right: auto; left: 50%; transform: translateX(-50%); }
#inv.portrait .inv-side { right: auto; left: 50%; transform: translateX(-50%); z-index: 2; }
#inv .inv-body { display: block; padding: 4px 11px 8px; }
#inv .doll { position: relative; width: calc(var(--cell) * 8); margin: 2px auto 10px; }
#inv .slot {
  position: absolute; display: flex; align-items: center; justify-content: center; overflow: visible; border-radius: 3px;
  border: 1px solid var(--wn-edge); background: radial-gradient(circle at 50% 40%, #202831, #0c1015 80%);
  box-shadow: inset 0 3px 8px #000, inset 2px 0 6px rgba(0,0,0,0.7), inset 0 -1px 0 rgba(140,160,185,0.18), 0 0 0 1px #000;
}
#inv .slot .sil { position: absolute; inset: 0; margin: auto; max-width: 84%; max-height: 84%; pointer-events: none;
  filter: grayscale(1) brightness(1.7) sepia(0.4) hue-rotate(175deg) saturate(1.6); opacity: 0.2; }
#inv .slot.disabled { opacity: 0.35; }
#inv .grid, .sh-grid, #inv .anvil {
  position: relative; width: calc(var(--cell) * 8); margin: 0 auto; box-sizing: content-box;
  background-color: var(--wn-cell); background-image: var(--wn-cells); background-size: var(--cell) var(--cell);
  border: 1px solid #4a5462; box-shadow: inset 0 0 12px #000, 0 0 0 1px #000, 0 0 0 2px rgba(201,160,80,0.25); border-radius: 0;
}
#inv .grid { height: calc(var(--cell) * 8); }
/* редкость и заточка не красят ячейку — светится только сама вещь */
#inv .item, #inv .grid .item { background: transparent; box-shadow: none; border-radius: 0; }
/* редкость — тонкая рамка по краю ячейки (!important — против .item.rN из style.css) */
#inv .item.r1 { box-shadow: inset 0 0 0 1px rgba(111,168,255,0.55), inset 0 -8px 10px -6px rgba(111,168,255,0.35) !important; }
#inv .item.r2 { box-shadow: inset 0 0 0 1px rgba(244,227,107,0.6), inset 0 -8px 10px -6px rgba(244,227,107,0.35) !important; }
#inv .item.r3 { box-shadow: inset 0 0 0 1px rgba(255,165,61,0.7), inset 0 -8px 10px -6px rgba(255,165,61,0.4) !important; }
#inv .item.exc { box-shadow: inset 0 0 0 1px rgba(94,224,106,0.6), inset 0 -8px 10px -6px rgba(94,224,106,0.38) !important; }
#inv .item.exc canvas { filter: drop-shadow(0 0 3px rgba(94,224,106,0.55)); }
/* счётчик стека — правый верхний угол, крупные светлые цифры с обводкой (4E.3) */
#inv .item .count, .sh-cell em {
  position: absolute; right: 2px; top: 1px; bottom: auto; font: 800 12px/1 -apple-system, system-ui, sans-serif; font-style: normal; color: #fff3c4;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 3px #000; pointer-events: none;
}
#inv .item .plus { left: 2px; top: 1px; font-size: 11px; color: #fff; }
#inv .item .lifeo { font-size: 11px; }
.grid-hl { position: absolute; display: none; pointer-events: none; z-index: 4; box-sizing: border-box; }
.grid-hl.on { display: block; }
.grid-hl.ok { background: rgba(60, 220, 90, 0.28); border: 2px solid #5fe07a; }
.grid-hl.bad { background: rgba(230, 50, 50, 0.3); border: 2px solid #e05f5f; }
/* деньги: иконка монет в квадратной кнопке + поле суммы красно-оранжевым с разделителями */
.inv-money { display: flex; gap: 6px; width: calc(var(--cell) * 8); margin: 10px auto 2px; height: 40px; }
.coin-sq { flex: none; width: 46px; display: flex; align-items: center; justify-content: center; border: 2px solid #8c97a5; border-radius: 3px; background: var(--wn-glass); color: var(--pal-leg);
  box-shadow: inset 0 0 0 1px #000, inset 0 3px 0 rgba(255,255,255,0.25), 0 0 0 1px #000; }
.coin-sq svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; filter: drop-shadow(0 1px 1px #000); }
.inv-money b { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 10px; font: 700 14px -apple-system, system-ui, sans-serif; color: var(--pal-warn);
  background: #06080b; border: 1px solid var(--wn-edge); box-shadow: inset 0 0 8px #000, 0 0 0 1px #000; overflow: hidden; }
#inv .inv-main.npc .wn-foot { justify-content: flex-start; }
/* страница «Бонусы» */
.inv-bonus { width: calc(var(--cell) * 8); margin: 2px auto 10px; }
.bn-grp { margin-bottom: 8px; padding: 6px 8px; background: rgba(0,0,0,0.3); border: 1px solid #2c333d; }
.bn-h { text-align: center; font-weight: 700; color: #fff; margin-bottom: 3px; }
.bn-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.bn-row b { color: var(--pal-leg); }
.bn-note { text-align: center; font-size: 12px; color: #9aa4b2; }
#enh-bar { bottom: auto; top: calc(14px + var(--sat, 0px)); z-index: 6; }
#enh-bar button { min-height: 44px; }

/* ---------- Окно персонажа (4E.4) ---------- */
.ch-prof { display: flex; align-items: center; gap: 8px; padding: 8px; background: rgba(0,0,0,0.35); border: 1px solid #2c333d; box-shadow: inset 0 0 10px rgba(0,0,0,0.6); }
.ch-port {
  --port: 64px; flex: none; position: relative; width: var(--port); height: var(--port); border-radius: 50%; overflow: hidden;
  border: 3px solid #d9a441; background: radial-gradient(circle at 50% 35%, #34486a, #0c121c 75%);
  box-shadow: 0 0 0 2px #4a320c, 0 0 0 3px #e9c46a, 0 0 12px rgba(255,190,80,0.35), inset 0 0 10px #000;
}
#inv .ch-port #doll-preview { position: absolute; left: 50%; top: calc(var(--port) * 0.12); transform: translateX(-50%); border-radius: 0; background: none; }
.ch-lv { font-size: 13px; color: #fff; white-space: nowrap; }
.ch-lv b, .ch-rk b { color: var(--pal-set); }
.ch-sep { flex: none; align-self: stretch; width: 1px; background: #3b434e; }
.ch-rk { font-size: 12px; color: #c3cbd6; line-height: 1.6; min-width: 0; }
.ch-free { margin: 8px 2px 2px; font-size: 13px; font-weight: 700; color: #fff; }
.ch-free b { color: var(--pal-set); }
.ch-stat { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 44px; gap: 4px; height: 44px; margin-top: 8px; }
.ch-nm { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--pal-set);
  border: 1px solid #9fb2cc; border-radius: 2px; background: linear-gradient(#2d6fcc, #19468f 55%, #123570);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), inset 0 -3px 6px rgba(0,0,0,0.3), 0 0 0 1px #000; text-shadow: 0 1px 1px #000; overflow: hidden; }
.ch-val { display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--pal-leg); background: #06080b; border: 1px solid var(--wn-edge); box-shadow: inset 0 0 8px #000, 0 0 0 1px #000; }
.ch-plus { width: 44px; height: 44px; padding: 0; border-radius: 3px; border: 2px solid #8c97a5; background: var(--wn-glass); color: var(--pal-leg);
  box-shadow: inset 0 0 0 1px #000, inset 0 3px 0 rgba(255,255,255,0.28), 0 0 0 1px #000; }
.ch-plus svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; filter: drop-shadow(0 1px 1px #000); }
.ch-plus:disabled { filter: grayscale(0.9) brightness(0.55); }
.ch-der { padding: 4px 6px 0; font-size: 12.5px; line-height: 1.5; }
.ch-der .pp { color: var(--pal-epic); } .ch-der .wh { color: var(--pal-normal); }

/* ---------- Наковальня (4E.6) ---------- */
#inv .forge { display: flex; flex-direction: column; gap: 6px; width: auto; }
.f-err { min-height: 18px; font-size: 12.5px; font-weight: 700; color: var(--pal-warn); text-shadow: 0 1px 1px #000; }
.f-err.none { display: none; }
#inv .f-chance { padding: 0; border: 0; background: none; font-size: 13px; color: #e6ebf2; }
#inv .f-chance b { font-size: 15px; color: var(--pal-set); }
#inv .anvil { display: flex; align-items: center; justify-content: center; border-radius: 0; }
#inv .anvil::before, #inv .anvil::after { display: none; }
#inv .anvil .item { margin: 0; }
#inv .anvil-empty { font-size: 12px; margin: 0; opacity: 1; color: var(--pal-warn); letter-spacing: 0.5px; }
#inv .f-name { top: 2px; font-size: 11.5px; }
#inv .f-info { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: #d6dbe3; }
#inv .f-step { font-size: 16px; font-weight: 700; color: #e6ebf2; text-align: center; }
#inv .f-step b { color: var(--pal-set); } #inv .f-step em { font-size: 11.5px; font-weight: 400; color: #9aa4b2; }
.f-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.f-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 44px; padding: 2px; background: var(--wn-cell); border: 1px solid var(--wn-edge); box-shadow: inset 0 0 8px #000; }
.f-cell img.mini { width: 22px; height: 22px; }
.f-cell i { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--pal-leg); }
.f-cell.f-bad i { color: var(--pal-warn); }
.f-goldc span svg { width: 22px; height: 22px; fill: none; stroke: var(--pal-leg); stroke-width: 2; }
#inv .f-hx { color: var(--pal-option); text-align: center; font-weight: 700; }
#inv .f-ward { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 6px; background: rgba(0,0,0,0.3); border: 1px solid #2c333d; font-size: 12.5px; }
#inv .f-ward input { width: 22px; height: 22px; flex: none; accent-color: #4a8fec; }
#inv .f-ward.f-off { opacity: 0.55; }
#inv .f-warn { padding: 0; border: 0; background: none; text-align: center; font-size: 12px; color: var(--pal-warn); }
#inv .f-table { display: grid; grid-template-columns: repeat(6, auto) !important; gap: 2px 6px; padding: 6px; font-size: 11.5px; background: rgba(0,0,0,0.35); border: 1px solid #2c333d; text-align: center; }
#inv .f-table img.mini { width: 16px; height: 16px; }
#inv .f-hint { font-size: 11.5px; color: #9aa4b2; }
#inv .inv-side .wn-foot { justify-content: space-between; }

/* ---------- Окна NPC слева вплотную к сумке (магазин — shop.css; профессия и крылья — здесь) ---------- */
#prof-win.pw-root, #wing-win.pw-root { display: block; padding: 0; overflow: hidden; background: transparent; pointer-events: none; z-index: 13; }
#prof-win.hidden, #wing-win.hidden { display: none; }
#prof-win .pw-box, #wing-win .pw-box {
  pointer-events: auto; position: absolute; top: 0; margin: 0; right: calc(var(--sar, 0px) + var(--inv-w, 320px));
  width: var(--win-w, 320px); max-width: 100%; height: var(--app-h, 100%); max-height: none;
}
html:not(.inv-open) #prof-win .pw-box, html:not(.inv-open) #wing-win .pw-box { right: auto; left: 50%; transform: translateX(-50%); }
#prof-win .pw-body, #wing-win .pw-body { padding: 4px 6px 8px; }
#prof-win .pw-foot, #wing-win .pw-foot { justify-content: space-between; }
#prof-win .pw-path { flex-wrap: wrap; }
#prof-win .pw-node { min-width: 0; padding: 3px 6px; }
#prof-win .pw-prow, #prof-win .pw-trow { flex-wrap: wrap; }
#prof-win .pw-pbar { min-width: 80px; }
#wing-win .pw-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
#wing-win .pw-tab { min-width: 0; min-height: 44px; }
.pw-err { margin: 2px 4px 4px; font-size: 12.5px; font-weight: 700; color: var(--pal-warn); text-shadow: 0 1px 1px #000; }
.pw-err.none { color: var(--pal-exc); }
#wing-win .pw-chance b { color: var(--pal-set); }
#prof-win .pw-card, #wing-win .pw-card { background: rgba(0,0,0,0.32); border-color: #2c333d; border-radius: 2px; }

/* ---------- Остальные окны (задания, врата, рейтинг, локации, умения) — та же рамка и шапка ---------- */
/* !important: у .q-box — против старой .q-box из style.css; у крестика — против #r-close/#q-close из style.css (селектор по id) */
.q-box { position: relative; isolation: isolate; background: var(--wn-bg) !important; border: 0 !important; border-radius: 3px !important;
  box-shadow: 0 0 0 1px #000, 0 14px 34px rgba(0,0,0,0.75), inset 0 0 30px rgba(0,0,0,0.55) !important; }
.q-head {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; height: auto;
  margin: 0 -10px 8px; padding: 0 50px; text-align: center;
  font: 700 15px -apple-system, system-ui, sans-serif; letter-spacing: 0.3px; color: #fff;
}
.q-head b { -webkit-background-clip: border-box; background-clip: border-box; filter: none;
  font: 700 15px/1.25 -apple-system, system-ui, sans-serif; white-space: normal; flex: 0 1 auto; }
.q-head > button:last-child {
  position: absolute !important; right: 0; top: 0; z-index: 6; width: 44px; height: 44px; min-width: 44px; min-height: 44px; margin: 0; padding: 0; border-radius: 4px;
  border: 1px solid #000 !important; background: var(--wn-blue) !important; color: #fff !important; font-size: 20px; font-weight: 800; line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(210,228,255,0.75), inset 0 -3px 6px rgba(0,0,30,0.4), 0 0 0 1px #8a6424, 0 2px 5px rgba(0,0,0,0.6) !important;
  transition: transform 0.08s var(--wn-ease);
}
.q-head > button:last-child:active { transform: scale(0.92); filter: brightness(1.25); }

/* ---------- Подсказка предмета (4F.4): панель ~85%, шапка цветом редкости, строки по центру ---------- */
.tip {
  position: fixed; z-index: 40; width: min(300px, calc(100vw - 12px)); min-width: 0; max-width: none; box-sizing: border-box;
  max-height: calc(var(--app-h, 100vh) - 22px - var(--sat, 0px)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 0; text-align: center; font: 13px/1.45 -apple-system, system-ui, sans-serif; color: #d6dbe3;
  background: rgba(10, 12, 16, 0.85); border: 1px solid #4a5462; border-radius: 2px; box-shadow: 0 0 0 1px #000, 0 10px 30px rgba(0,0,0,0.8);
}
.tip .t-x { position: sticky; top: 0; float: right; margin: 0 0 0 4px; }
.tip .t-name { margin: 0; padding: 12px 8px 2px 52px; font-size: 15px; font-weight: 700; line-height: 1.25; background: rgba(255,255,255,0.07); text-shadow: 0 1px 2px #000; }
.tip .t-sub { margin: 0; padding: 0 8px 7px 52px; font-size: 11.5px; color: #9aa4b2; opacity: 1; background: rgba(255,255,255,0.07); border-bottom: 1px solid #2c333d; }
.tip .t-name:only-of-type { padding-bottom: 10px; border-bottom: 1px solid #2c333d; }
.tip .t-body { clear: both; padding: 8px 12px 10px; }
.tip .t-grp + .t-grp { margin-top: 10px; }
.tip .t-ln { font-size: 13px; }
.tip .t-ln b { color: inherit; }
.tip .t-ln .ok { color: var(--pal-exc); } .tip .t-ln .bad { color: var(--pal-warn); }
.tip .t-gem-big img { width: 48px; height: 48px; }
.tip .t-btns { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 8px;
  background: linear-gradient(rgba(16,19,24,0.97), rgba(8,10,13,0.98)); border-top: 1px solid #2c333d; }
.tip .t-btns button { flex: 1 1 auto; min-width: 84px; }
.tip .t-btns:empty { display: none; }
/* старые правила вкладки сумки (style.css) — сброс под серые текст-вкладки 4E.3 */
#inv-tab, #inv-tab2 { position: static; height: auto; min-height: 44px; padding: 0 8px; border: 0; border-radius: 0; background: none; box-shadow: none;
  font: 700 12.5px -apple-system, system-ui, sans-serif; color: #8a94a3; animation: none; }
#inv-tab.on, #inv-tab2.on { color: #e9eef5; text-shadow: 0 0 8px rgba(120,170,255,0.6); }
#inv-tab.pulse { color: var(--pal-set); border: 0; animation: none; background: none; }
/* «Боссы и события»: окно ниже верхнего края, крестик не у самой кромки экрана (iOS) */
#hud #world { padding-top: calc(12px + var(--sat, 0px)); }
#hud #world .w-box { background: var(--wn-bg); border: 1px solid #05070a; border-radius: 3px; box-shadow: var(--wn-frame); }
/* узкие окна (568–700 px экрана): заголовок со стрелками не обрезается */
@media (max-width: 700px) {
  .wn-head { grid-template-columns: 2px minmax(0, 1fr) 46px; }
  .wn-arr { margin: 0 -9px; }
}

/* ===== Сумка v2: сетка 8×8 всегда целиком; один — 2 столбца, рядом окно слева — компактная кукла ===== */
#inv .inv-main { width: auto; }
#inv .inv-cols { flex: 1 1 auto; min-height: 0; display: flex; gap: 6px; padding: 0 8px 0 0; }
#inv .inv-left { flex: 1 1 auto; min-width: 0; padding: 4px 4px 8px 10px; }
#inv .inv-right { flex: none; padding: 6px 0 6px; }
#inv .inv-right .grid { margin: 0; }
#inv .inv-left .doll { margin: 0 auto 8px; }
#inv .inv-left .inv-money { width: auto; margin: 6px 0; }
.inv-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 4px 0; }
.inv-btns:empty { display: none; }
#inv .inv-main.compact .wn-tabs, #inv .inv-main.compact .inv-money, #inv .inv-main.compact .inv-btns, #inv .inv-main.compact .inv-bonus { display: none; }
#inv .inv-main.compact .inv-left { flex: none; overflow: hidden; padding: 6px 0 6px 8px; }
#inv .inv-main.compact .doll { margin: 0; }
#inv .inv-main.compact .slot .item .plus, #inv .inv-main.compact .slot .item .luck, #inv .inv-main.compact .slot .item .lifeo { display: none; }
#inv-sub .gold { color: var(--pal-warn); font-size: 12.5px; }
#inv .inv-main.compact .wn-arr { display: none; }
/* Наковальня v2: сетка ингредиентов + шанс рядом, ниже читаемый список «нужно / есть», Оберег, предупреждение */
#inv .f-top { display: flex; gap: 10px; align-items: center; }
#inv .f-top .anvil { margin: 0; flex: none; }
#inv .f-top .f-chance { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; }
#inv .f-top .f-chance b { font-size: 26px; line-height: 1; }
.f-reqs { display: flex; flex-direction: column; gap: 3px; }
#inv .f-req { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; align-items: center; gap: 6px; min-height: 30px; padding: 2px 6px;
  background: rgba(0,0,0,0.3); border: 1px solid #2c333d; border-radius: 0; font-size: 12.5px; }
#inv .f-req img.mini, #inv .f-req .f-coin svg { width: 20px; height: 20px; }
#inv .f-req .f-coin svg { fill: none; stroke: var(--pal-leg); stroke-width: 2; }
#inv .f-req b { color: var(--pal-leg); } #inv .f-req em { font-style: normal; font-size: 11.5px; color: #9aa4b2; }
#inv .f-req.f-bad { border-color: rgba(255,100,100,0.5); background: rgba(120,20,10,0.25); }
#inv .f-req.f-bad em { color: var(--pal-warn); }
#inv .f-warn { font-weight: 700; }

/* ---------- Хранилище (4E.7, реф 25): слева вплотную к сумке ---------- */
#stg-win { position: fixed; inset: 0; z-index: 12; display: block; height: var(--app-h, 100%); padding: 0; background: transparent; pointer-events: none; }
#stg-win.hidden { display: none; }
#stg-win .stg-box { pointer-events: auto; position: absolute; top: 0; margin: 0; right: calc(var(--sar, 0px) + var(--inv-w, 320px));
  width: var(--win-w, 320px); max-width: 100%; height: var(--app-h, 100%); }
html:not(.inv-open) #stg-win .stg-box { right: auto; left: 50%; transform: translateX(-50%); }
#stg-win .wn-body { padding: 6px 11px 8px; }
/* шапка и подвал закреплены: прокручивается только содержимое (сетка, деньги) */
#stg-win .stg-box { overflow: hidden; }
#stg-win .wn-head { position: sticky; top: 0; z-index: 3; } /* ниже кромки окна (z 4), крестик в шапке кромку не задевает */
#stg-win .wn-arr[hidden] { display: none; }
.stg-grid { position: relative; width: calc(var(--cell) * 8); height: calc(var(--cell) * var(--gh, 15)); margin: 0 auto; box-sizing: content-box;
  background-color: var(--wn-cell); background-image: var(--wn-cells); background-size: var(--cell) var(--cell);
  border: 1px solid #4a5462; box-shadow: inset 0 0 12px #000, 0 0 0 1px #000, 0 0 0 2px rgba(201,160,80,0.25); }
.stg-it { position: absolute; box-sizing: border-box; padding: 0; margin: 0; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; }
.stg-it img { max-width: 100%; max-height: 100%; pointer-events: none; }
.stg-it:active { filter: brightness(1.35); }
.stg-it i, .stg-it em { position: absolute; font: 800 12px/1 -apple-system, system-ui, sans-serif; font-style: normal; pointer-events: none;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }
.stg-it i { right: 2px; top: 1px; color: #fff3c4; }
.stg-it em { left: 2px; top: 1px; color: #fff; font-size: 11px; }
.stg-money { display: flex; align-items: center; gap: 6px; height: 40px; margin: 8px auto 0; width: calc(var(--cell) * 8); }
.stg-money b { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: flex-end; padding: 0 10px; font-size: 14px; color: var(--pal-warn);
  background: #06080b; border: 1px solid var(--wn-edge); box-shadow: inset 0 0 8px #000; overflow: hidden; }
.stg-lbl { flex: none; font-size: 12px; font-weight: 700; color: #c3cbd6; }
.stg-lbl.bad { color: var(--pal-warn); }
.stg-fee { height: 32px; margin-top: 4px; }
.stg-fee b { font-size: 13px; color: #e6ebf2; }
.stg-amt { display: flex; flex-wrap: wrap; gap: 4px; width: calc(var(--cell) * 8); margin: 6px auto 0; }
.stg-amt input { flex: 1 1 100%; min-width: 0; height: 44px; box-sizing: border-box; padding: 0 8px; font-size: 16px; color: var(--pal-set); background: #06080b; border: 1px solid var(--wn-edge); border-radius: 0; }
.stg-amt button { flex: 1 1 0; min-width: 44px; height: 44px; padding: 0 6px; border-radius: 3px; border: 1px solid #9fb2cc; color: #fff; font: 700 12px -apple-system, system-ui, sans-serif;
  background: linear-gradient(#2c5fae, #173a73 55%, #0f2650); box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 0 0 1px #000; }
.stg-hint { width: calc(var(--cell) * 8); margin: 6px auto 0; font-size: 11.5px; color: #9aa4b2; }
#stg-sub b.bad { color: var(--pal-warn); }
/* кнопки сумки (одна, 2 столбца) — всегда видны внизу левого столбца */
#inv .inv-main:not(.compact) .inv-btns { position: sticky; bottom: -8px; z-index: 3; margin: 0 -4px -8px -10px; padding: 6px 4px calc(6px + var(--sab, 0px));
  background: linear-gradient(rgba(17,21,27,0.92), #11151b); border-top: 1px solid #000; box-shadow: inset 0 1px 0 #39424d; }
.inv-btns { flex-wrap: nowrap; }

/* =====================================================================
   Окно «Настройки» (client/settings.js): стиль окон 4E, вкладки, строки с переключателями,
   сегментами и ползунками под палец (цели ≥ 44 px, шрифт ≥ 11 px), прокрутка тела, крестик 44 px.
   ===================================================================== */
#settings {
  position: fixed; inset: 0; z-index: 30; display: flex; justify-content: center; align-items: flex-start;
  height: var(--app-h, 100%); box-sizing: border-box; padding: 4px calc(4px + var(--sar, 0px)) calc(4px + var(--sab, 0px)) calc(4px + var(--sal, 0px));
  background: rgba(0, 0, 0, 0.55); overflow: hidden; touch-action: pan-y;
}
#settings.hidden { display: none; }
#settings .st-box { width: min(600px, 100%); max-height: calc(var(--app-h, 100vh) - 8px - var(--sab, 0px)); margin: auto 0; }
#settings .wn-head { padding-top: calc(4px + var(--sat, 0px)); }
#settings .st-tabs {
  flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: 0 8px;
  border-bottom: 1px solid #000; box-shadow: 0 1px 0 #3d4652; background: rgba(0, 0, 0, 0.3);
}
#settings .st-tab {
  min-height: 44px; padding: 0 4px; border: 0; border-bottom: 3px solid transparent; background: none; color: #8a94a3;
  font-size: 13px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap;
}
/* узкий экран (320–420): «Бой и управление» в две строки, у каждой вкладки ≥ 44 px, ничего не вылезает по ширине */
@media (max-width: 420px) {
  #settings .st-tabs { grid-template-columns: repeat(4, minmax(44px, auto)); justify-content: space-between; padding: 0 4px; }
  #settings .st-tab { white-space: normal; font-size: 12px; line-height: 1.15; text-align: center; padding: 2px 4px; }
}
#settings .st-body { padding: 4px 10px 10px; }
#settings .st-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 5px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
#settings .st-row.st-col { flex-direction: column; align-items: stretch; gap: 4px; }
#settings .st-row.off { opacity: 0.6; }
#settings .st-lab { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; flex: 1 1 auto; }
#settings .st-lab b { color: #e9eef5; font-size: 13.5px; font-weight: 700; }
#settings .st-lab em { margin-left: auto; font-style: normal; font-size: 13px; font-weight: 700; color: var(--w-gold); min-width: 44px; text-align: right; }
#settings .st-hint { flex-basis: 100%; font-style: normal; font-size: 11.5px; line-height: 1.3; color: #9aa5b4; }
#settings .st-phint { display: block; margin-top: 2px; }
#settings .st-phint b { color: #e9eef5; }
#settings .st-load { font-size: 11.5px; color: #c9a85a; letter-spacing: 1px; margin-left: auto; }
#settings .st-chip { font-size: 11px; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--w-gold-lo); color: var(--w-gold); }
#settings .st-note { font-size: 12px; color: #9aa5b4; }
/* сегменты: квадратные кнопки окна, выбранная — синее стекло с золотой рамкой */
#settings .st-segs { display: flex; flex-wrap: wrap; gap: 5px; }
#settings .st-seg {
  flex: 1 0 auto; min-width: 52px; min-height: 44px; padding: 0 8px; border-radius: 4px; white-space: nowrap;
  border: 1px solid #4a5462; background: linear-gradient(rgba(255,255,255,0.08), rgba(255,255,255,0) 50%), linear-gradient(#29313c, #141920); color: #c3cbd6; font-size: 13px; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 0 1px #000; transition: transform 0.08s var(--wn-ease), filter 0.12s;
}
#settings .st-seg.on { color: #fff; border-color: #000; background: linear-gradient(rgba(255,255,255,0.3), rgba(255,255,255,0.05) 46%, rgba(255,255,255,0) 50%), linear-gradient(#3f85e6, #1d50a8 55%, #123574);
  box-shadow: inset 0 0 0 1px #ffe08a, 0 0 0 1px #000, 0 0 10px rgba(255,200,100,0.4); }
#settings .st-seg:active, #settings .st-btn:active, #settings .st-tog:active { filter: brightness(1.25); transform: scale(0.96); }
#settings .st-btn {
  flex: none; min-height: 44px; padding: 0 14px; border-radius: 4px; border: 1px solid #000; color: #fff; font-size: 13px; font-weight: 700;
  background: linear-gradient(rgba(255,255,255,0.24), rgba(255,255,255,0.04) 46%, rgba(255,255,255,0) 50%), linear-gradient(#3a76d0, #1a4590 55%, #0f2a5c);
  box-shadow: inset 0 0 0 1px rgba(170,200,245,0.55), 0 0 0 1px #000, 0 3px 6px rgba(0,0,0,0.5); transition: transform 0.08s var(--wn-ease), filter 0.12s;
}
/* переключатель: поле 60×44, дорожка 52×28 */
#settings .st-tog { flex: none; position: relative; width: 60px; height: 44px; padding: 0; border: 0; background: none; }
#settings .st-tog i {
  position: absolute; left: 4px; top: 8px; width: 52px; height: 28px; border-radius: 14px; background: #10141a;
  box-shadow: inset 0 0 0 1px #4a5462, inset 0 2px 4px rgba(0, 0, 0, 0.7); transition: background 0.15s;
}
#settings .st-tog i::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(#e3e8ef, #9aa5b4); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); transition: transform 0.15s;
}
#settings .st-tog.on i { background: linear-gradient(#3a7fe0, #1d50a8); box-shadow: inset 0 0 0 1px #ffd27a, 0 0 8px rgba(255, 200, 100, 0.3); }
#settings .st-tog.on i::after { transform: translateX(24px); background: linear-gradient(#fff6d8, #e8c26a); }
#settings .st-tog:disabled { filter: grayscale(1) brightness(0.7); }
/* ползунок: поле касания 44 px, бегунок 28 px */
#settings .st-rng { -webkit-appearance: none; appearance: none; width: 100%; height: 44px; margin: 0; background: none; touch-action: pan-x; }
#settings .st-rng::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #1d50a8, #3a7fe0); box-shadow: inset 0 0 0 1px #000, 0 0 0 1px #4a5462; }
#settings .st-rng::-moz-range-track { height: 8px; border-radius: 4px; background: linear-gradient(90deg, #1d50a8, #3a7fe0); }
#settings .st-rng::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; border: 2px solid #ffd27a;
  background: radial-gradient(circle at 50% 35%, #fff6d8, #e8c26a 60%, #8a6424); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}
#settings .st-rng::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #ffd27a; background: #e8c26a; }
#settings .st-rng:disabled { opacity: 0.5; }
@media (min-width: 560px) {
  #settings .st-row:not(.st-col) .st-hint { max-width: 420px; }
}
/* счётчик FPS (Настройки → Графика → «Показывать FPS») */
#fps-meter {
  position: fixed; z-index: 40; left: 0; top: 0; transform: translate(-9999px, 0); pointer-events: none; /* место — settings.js fpsPlace: свободный угол */
  padding: 1px 8px; border-radius: 3px; background: rgba(0, 0, 0, 0.55); color: #9fe08a; font: 700 11px/14px ui-monospace, Menlo, monospace;
}
#fps-meter.hidden { display: none; }

/* =====================================================================
   6. ПОЯВЛЕНИЕ / ИСЧЕЗНОВЕНИЕ ОКОН (≤ 180 мс, только opacity + transform).
   Окна прячутся классом .hidden (display:none) — исчезновение доигрывает transition-behavior: allow-discrete
   (Safari 17.4+ / Chrome 117+; на старых — мгновенно, как раньше). Состояние окна в JS не меняется.
   ===================================================================== */
#inv, #shop-win, #stg-win, #quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg {
  transition: opacity 0.16s ease-out, display 0.16s allow-discrete, overlay 0.16s allow-discrete;
  opacity: 1;
}
:is(#inv, #shop-win, #stg-win, #quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg).hidden {
  opacity: 0; pointer-events: none !important;
}
:is(#inv, #shop-win, #stg-win, #quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg) :is(.wn, .q-box, .mw-box, .lo-box) {
  transition: transform 0.18s var(--wn-ease);
}
:is(#quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg).hidden :is(.wn, .q-box, .mw-box, .lo-box) { transform: scale(0.97); }
:is(#inv, #shop-win, #stg-win).hidden .wn { transform: translateX(14px); }
@starting-style {
  :is(#inv, #shop-win, #stg-win, #quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg):not(.hidden) { opacity: 0; }
  :is(#quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg):not(.hidden) :is(.wn, .q-box, .mw-box, .lo-box) { transform: scale(0.96); }
  :is(#inv, #shop-win, #stg-win):not(.hidden) .wn { transform: translateX(16px); }
}
@keyframes pmPop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  #inv, #shop-win, #stg-win, #quests, #gates, #rank, #locs, #skills-win, #settings, #mapwin, #soc-win, #chat-win, #apcfg, #prof-win, #wing-win, #world, #lo-confirm, #dlg { transition: none; }
}
