/* Агент «game2»: чат по вкладкам, инвентарь с перетаскиванием, админ-панель, телескоп, окно взаимодействия. */
.ctabs button { position: relative; }
.ctabs .cb { position: absolute; top: -5px; right: -5px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: #ff3a6a; color: #fff; font: 700 10px/15px 'Ubuntu Mono', monospace; font-style: normal; }
.ctabs button.small { font-size: 11px; opacity: .55; }
.ctabs button.small.on { opacity: 1; }

/* ---- инвентарь */
.slot { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.slot .lv { position: absolute; left: 2px; right: 2px; top: 1px; font-size: 9px; color: #9fe8ff; text-shadow: 1px 1px 0 #000; overflow: hidden; white-space: nowrap; pointer-events: none; }
.slot.q { background: rgba(40, 30, 10, 0.85); border-color: #6a5a2a; }
.slot.over { border-color: #a03a3a; background: rgba(60, 10, 10, 0.7); }
.inv-sec { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.inv-sec .hint { font-size: 12px; opacity: .75; flex: 1; }
.inv-sec button.small { padding: 2px 9px; }
.inv-sec button.small.on { background: #ffc03a; color: #000; }
.invgrid.quick { grid-template-columns: repeat(8, 1fr); }
.invgrid.main { grid-template-columns: repeat(8, 1fr); max-height: 46vh; overflow-y: auto; padding-right: 2px; }
@media (max-width: 640px) { .invgrid.main, .invgrid.quick { grid-template-columns: repeat(6, 1fr); } }
.desc .dimg { width: var(--ic48, 40px); height: var(--ic48, 40px); image-rendering: var(--icr48, pixelated); float: left; margin: 0 8px 4px 0; }
#drag-ghost { position: fixed; left: 0; top: 0; width: 48px; height: 48px; pointer-events: none; z-index: 9999; border: 2px solid #3af0ff; border-radius: 8px; background: rgba(16, 12, 30, .8); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 14px rgba(58, 240, 255, .5); }
#drag-ghost img { width: var(--ic48, 38px); height: var(--ic48, 38px); image-rendering: var(--icr48, pixelated); }
#drag-ghost span { position: absolute; right: 3px; bottom: 0; font-size: 12px; text-shadow: 1px 1px 0 #000; }
#drag-ghost.out { border-color: #ff5a3a; box-shadow: 0 0 14px rgba(255, 90, 58, .7); }
#drag-ghost.out::after { content: '⤓ выбросить'; position: absolute; top: 50px; left: -20px; width: 90px; text-align: center; font-size: 11px; color: #ff8a6a; text-shadow: 1px 1px 0 #000; }
body.dragging, body.dragging * { cursor: grabbing !important; }
#hotbar .slot { cursor: grab; }

/* ---- админ-режим */
#adm-btn.adm-on { background: #8a1a2a; box-shadow: 0 0 10px #ff3a5a; }
#admwin { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(880px, calc(100vw - 16px)); height: min(640px, calc(100vh - 16px)); z-index: 30; border-color: #8a1a2a; }
.adm-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 2px solid #3a1a2a; color: #ff8a9a; }
.adm-head b { flex: 1; font-size: 15px; }
.adm-flag { font-size: 16px; }
.adm-tabs { display: flex; flex-wrap: wrap; gap: 3px; padding: 6px 8px; }
.adm-tabs button { font-size: 12px; padding: 5px 8px; }
.adm-tabs button.on, .adm-bodies button.on, .adm-time button.on { background: #8a1a2a; color: #fff; }
.adm-msg { min-height: 18px; padding: 0 10px; font-size: 13px; color: #9fe8ff; }
.adm-body { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.adm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.adm-row label { margin: 0; font-size: 12px; opacity: .8; }
.adm-row input:not(.sm) { flex: 1; min-width: 160px; padding: 6px; }
.adm-row select { padding: 5px; }
.adm-tgt { padding: 6px 8px; margin-bottom: 6px; border-radius: 6px; background: rgba(255, 192, 58, .08); border: 1px solid #5a4a1a; font-size: 13px; }
.adm-p { border: 1px solid #2a2440; border-radius: 6px; margin: 4px 0; padding: 5px 7px; background: rgba(10, 8, 20, .5); }
.adm-p.on { border-color: #ffc03a; box-shadow: 0 0 8px rgba(255, 192, 58, .3); }
.adm-pn { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.adm-pn small { opacity: .75; font-size: 12px; }
.adm-tags i { font-style: normal; font-size: 11px; background: #3a2440; border-radius: 4px; padding: 1px 5px; margin-left: 3px; }
.adm-pb { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.adm-pb button.small, .adm-bf button.small { padding: 3px 7px; font-size: 12px; }
.adm-places { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px; }
.adm-places button { text-align: left; font-size: 12px; padding: 5px 7px; }
.adm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px; }
.adm-bf { border: 1px solid #2a2440; border-radius: 6px; padding: 6px; display: flex; flex-direction: column; gap: 3px; }
.adm-bf small { opacity: .75; font-size: 12px; flex: 1; }
.adm-bf span { display: flex; gap: 4px; }
.adm-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.adm-it { display: flex; align-items: center; gap: 6px; text-align: left; padding: 4px 6px !important; font-size: 12px !important; }
.adm-it img { width: var(--ic32, 32px); height: var(--ic32, 32px); image-rendering: var(--icr32, pixelated); flex: none; }
.adm-log { font: 12px/1.45 'Ubuntu Mono', monospace; max-height: 60vh; overflow-y: auto; }
.adm-split { display: grid; grid-template-columns: 240px 1fr; gap: 8px; min-height: 0; }
@media (max-width: 700px) { .adm-split { grid-template-columns: 1fr; } }
.adm-nl { max-height: 62vh; overflow-y: auto; }
.adm-n { padding: 4px 6px; border-radius: 5px; cursor: pointer; border: 1px solid transparent; }
.adm-n small { display: block; opacity: .7; font-size: 11px; }
.adm-n.on, .adm-n:hover { border-color: #ffc03a; background: rgba(255, 192, 58, .06); }
.adm-kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 13px; }
.adm-kv span { opacity: .7; }
.adm-traits div { display: grid; grid-template-columns: 110px 1fr 40px 28px 28px; align-items: center; gap: 4px; font-size: 12px; margin: 2px 0; }
.adm-traits i { display: block; height: 6px; background: linear-gradient(90deg, #3af0ff, #ff3aa0); border-radius: 3px; }
.adm-ul { margin: 2px 0 4px 18px; padding: 0; font-size: 12px; }
.adm-rel div { font-size: 12px; margin: 3px 0; }
.adm-rel span { opacity: .8; margin-left: 6px; }
.adm-rel small { display: block; opacity: .6; }
/* полная админка (12.11): цель, предметы, эффекты, здоровье, коды; телефон — во весь экран */
.adm-tgt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.adm-tgt select { max-width: 160px; padding: 4px; }
.adm-chips { gap: 4px; }
.adm-chips button.on, .adm-row button.on, .adm-big button.on { background: #8a1a2a; color: #fff; }
.adm-it2 { border: 1px solid #2a2440; border-radius: 6px; display: flex; flex-direction: column; }
.adm-it2 .adm-it { border: 0; background: none; width: 100%; }
.adm-it span { display: flex; flex-direction: column; min-width: 0; }
.adm-it small { opacity: .6; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adm-itq { display: flex; gap: 3px; padding: 0 4px 4px; }
.adm-itq button { flex: 1; padding: 3px 2px !important; font-size: 11px !important; }
.adm-items { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.adm-bf.on { border-color: #3af0a0; background: rgba(58, 240, 160, .07); }
.adm-chip { display: inline-flex; align-items: center; gap: 4px; background: #3a2440; border-radius: 12px; padding: 2px 4px 2px 9px; font-size: 12px; }
.adm-chip button { padding: 0 6px !important; border-radius: 10px; }
.adm-body details { border: 1px solid #2a2440; border-radius: 6px; margin: 6px 0; padding: 0 8px 6px; }
.adm-body summary { cursor: pointer; padding: 8px 0; font-weight: bold; color: #ffc03a; }
.adm-stat { display: grid; grid-template-columns: 150px 1fr 80px auto; align-items: center; gap: 6px; margin: 4px 0; font-size: 13px; }
.adm-stat input[type=range] { width: 100%; }
.adm-stat input.sm { width: 80px; }
.adm-stat input.wide { grid-column: span 2; width: 100%; }
.adm-stat span { display: flex; gap: 3px; }
.adm-parts > div { display: grid; grid-template-columns: 120px 1fr 44px 70px auto; align-items: center; gap: 5px; font-size: 12px; margin: 3px 0; }
.adm-parts i { display: block; height: 8px; border-radius: 4px; }
.adm-parts small { opacity: .6; }
.adm-parts em { display: flex; gap: 2px; font-style: normal; }
.adm-inv { display: grid; grid-template-columns: repeat(auto-fill, 46px); gap: 4px; margin: 4px 0; }
.adm-slot { position: relative; width: 46px; height: 46px; padding: 3px !important; border: 1px solid #3a3450; border-radius: 6px; background: rgba(10, 8, 20, .6); }
.adm-slot img { width: 36px; height: 36px; image-rendering: pixelated; }
.adm-slot b { position: absolute; right: 3px; bottom: 1px; font-size: 11px; text-shadow: 0 0 3px #000; }
.adm-slot i { position: absolute; left: 3px; bottom: 2px; height: 3px; background: #3af0a0; border-radius: 2px; max-width: 38px; }
.adm-slot.empty { opacity: .45; }
.adm-slot.sep { margin-left: 10px; }
.adm-slot.on { border-color: #ffc03a; box-shadow: 0 0 8px rgba(255, 192, 58, .5); }
.adm-islot img { width: 32px; height: 32px; image-rendering: pixelated; }
.adm-skills > div { display: grid; grid-template-columns: 1fr 56px auto 80px auto; align-items: center; gap: 4px; font-size: 12px; margin: 2px 0; }
.adm-skills input.sm { width: 100%; }
.adm-snap, .adm-code { display: flex; align-items: center; gap: 8px; justify-content: space-between; border-bottom: 1px solid #2a2440; padding: 5px 0; flex-wrap: wrap; }
.adm-snap small, .adm-code small { display: block; opacity: .7; font-size: 12px; }
.adm-code span { display: flex; gap: 4px; flex-wrap: wrap; }
.adm-code.off b { text-decoration: line-through; opacity: .6; }
#adm-specbar { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 31; display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; background: rgba(40, 10, 20, .92); border: 1px solid #8a1a2a; color: #ffd0d8; font-size: 14px; }
#adm-specbar.hidden { display: none; }
@media (max-width: 700px) {
  #admwin { left: 0; top: 0; transform: none; width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .adm-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .adm-tabs button { flex: none; }
  .adm-stat { grid-template-columns: 1fr 80px; }
  .adm-stat input[type=range] { grid-column: 1 / -1; grid-row: 2; }
  .adm-stat span { grid-column: 1 / -1; }
  .adm-parts > div { grid-template-columns: 1fr 44px 60px; }
  .adm-parts i { grid-column: 1 / -1; grid-row: 2; }
  .adm-parts em { grid-column: 1 / -1; }
  .adm-skills > div { grid-template-columns: 1fr 50px auto; }
  .adm-skills input[id^=adm-sx], .adm-skills button[data-act^="adm-skxp"] { display: none; }
  .adm-items { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .adm-row input:not(.sm) { min-width: 120px; }
}
@media (pointer: coarse) {
  #admwin button, #adm-specbar button { min-height: 38px; min-width: 38px; }
  #admwin .adm-itq button { min-height: 34px; }
  #admwin input, #admwin select { min-height: 36px; font-size: 16px; }
}

/* ---- телескоп */
#scope { position: fixed; inset: 0; z-index: 28; background: #000; display: grid; grid-template-columns: 1fr 260px; }
#scope.hidden { display: none; }
#scope-cv { width: 100%; height: 100%; display: block; grid-column: 1; grid-row: 1; }
#scope-side { grid-column: 2; grid-row: 1; overflow-y: auto; background: rgba(10, 8, 20, .92); border-left: 2px solid #3a3058; padding: 8px; }
#scope-side button { display: block; width: 100%; text-align: left; margin: 2px 0; padding: 5px 7px; font-size: 12px; }
#scope-side button small { display: block; opacity: .65; font-size: 11px; }
#scope-side button.on { border-color: #ffc03a; background: rgba(255, 192, 58, .12); }
.sc-h { font-size: 15px; color: #ffd890; margin: 2px 0 6px; }
.sc-g { color: #9fe8ff; font-size: 12px; margin: 8px 0 2px; }
#scope-info { position: absolute; left: 16px; bottom: 16px; max-width: min(520px, calc(100vw - 300px)); display: flex; flex-direction: column; gap: 3px; background: rgba(0, 0, 0, .6); padding: 8px 12px; border-radius: 8px; border: 1px solid #3a3058; font-size: 13px; pointer-events: none; }
#scope-info b { color: #ffd890; font-size: 15px; }
#scope-info small { opacity: .75; }
.scope-ctl { position: absolute; top: 12px; right: 276px; display: flex; gap: 6px; }
.scope-ctl button { width: 42px; height: 42px; font-size: 20px; }
@media (max-width: 720px) {
  #scope { grid-template-columns: 1fr; grid-template-rows: 1fr 34vh; }
  #scope-side { grid-column: 1; grid-row: 2; border-left: 0; border-top: 2px solid #3a3058; }
  .scope-ctl { right: 12px; }
  #scope-info { bottom: calc(34vh + 10px); max-width: calc(100vw - 32px); }
}

/* ---- эмоции реплик (журнал окна взаимодействия) */
.emo i { font-style: normal; display: inline-block; }
.emo-angry { color: #ff6a5a; font-weight: bold; }
.emo-angry i { animation: emo-shake .12s infinite; animation-delay: calc(var(--k) * -17ms); }
.emo-shout { color: #ff4a3a; font-weight: bold; font-size: 1.18em; text-transform: none; }
.emo-shout i { animation: emo-shake .1s infinite; animation-delay: calc(var(--k) * -13ms); }
.emo-scared { color: #8ab4ff; }
.emo-scared i { animation: emo-shake .09s infinite; animation-delay: calc(var(--k) * -23ms); }
.emo-happy { color: #8aff9a; }
.emo-happy i { animation: emo-wave 1.1s ease-in-out infinite; animation-delay: calc(var(--k) * -90ms); }
.emo-excited { color: #ffc03a; }
.emo-excited i { animation: emo-wave .55s ease-in-out infinite; animation-delay: calc(var(--k) * -60ms); }
.emo-sad { color: #8a9ab8; }
.emo-tired { color: #8a8a8a; letter-spacing: .04em; }
.emo-whisper { color: #9a9ea8; font-size: .84em; font-style: italic; }
.emo-sarcastic { color: #d08aff; font-style: italic; }
.emo-suspicious { color: #d8c46a; font-style: italic; }
.emo-hesitant { color: #b0b0b0; }
@keyframes emo-shake { 0% { transform: translate(0, 0); } 25% { transform: translate(1px, -1px); } 50% { transform: translate(-1px, 1px); } 75% { transform: translate(1px, 1px); } 100% { transform: translate(-1px, 0); } }
@keyframes emo-wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---- окно взаимодействия: карточка + действия по группам */
#sess { width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 120px); left: 12px; }
.sw-top { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 2px solid var(--line); position: sticky; top: 0; background: #100e1e; z-index: 2; }
.sw-ttl { color: var(--gold); font-size: 13px; white-space: nowrap; }
.sw-top .sw-tabs { flex: 1; padding: 0; }
.sw-top .cx { margin-left: auto; }
.sw-main { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.sw-card { padding: 10px; border-right: 2px solid var(--line); background: linear-gradient(180deg, rgba(40, 30, 70, .35), rgba(0, 0, 0, 0)); }
#sess-face { width: 120px; height: 150px; display: block; margin: 0 auto 6px; border: 2px solid #3a3058; border-radius: 8px; background: #07060c; image-rendering: pixelated; }
.cd-name { font-family: "Press Start 2P", monospace; font-size: 11px; line-height: 1.5; text-align: center; word-break: break-word; }
.cd-fac { font-size: 12px; color: var(--dim); text-align: center; margin: 4px 0 6px; }
.cd-fac .emb { display: inline-block; width: 16px; height: 16px; line-height: 16px; border-radius: 4px; color: #000; font-size: 11px; margin-right: 5px; text-align: center; }
.sw-card .sw-hints { justify-content: center; margin-bottom: 6px; }
.cd-row { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; margin: 3px 0; }
.cd-row span { color: var(--dim); }
.cd-row b { text-align: right; }
.cd-bars { margin: 6px 0; }
.cd-bar { display: grid; grid-template-columns: 82px 1fr 32px; gap: 5px; align-items: center; font-size: 11px; margin: 3px 0; }
.cd-bar b { text-align: right; font-weight: normal; color: #cfc8e8; }
.cd-tr { position: relative; height: 8px; background: #1e1a30; border-radius: 4px; overflow: hidden; }
.cd-tr::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #5a5078; }
.cd-tr.pity::after { display: none; }
.cd-tr i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.cd-tr i.po { background: linear-gradient(90deg, #2a8a5a, #3cff9e); }
.cd-tr i.ne { background: linear-gradient(90deg, #ff4a4a, #8a2a2a); }
.cd-tr i.pi { background: linear-gradient(90deg, #3a6aa0, #9fe8ff); }
.cd-note { font-size: 11px; color: #b0a8c8; font-style: italic; margin: 4px 0; }
.cd-known { font-size: 11px; margin-top: 6px; }
.cd-known span { color: var(--gold); }
.cd-known ul { margin: 3px 0 0 14px; padding: 0; color: #cfc8e8; }
.sw-right { display: flex; flex-direction: column; min-width: 0; }
#sess-log { max-height: 30vh; min-height: 90px; }
.sw-right .sw-in { position: static; border-top: 1px solid var(--line); }
#sess-wh { white-space: nowrap; }
.sw-groups { padding: 4px 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.sw-groups:empty { display: none; }
.ag { border: 1px solid #2a2440; border-radius: 8px; padding: 4px 6px 6px; background: rgba(10, 8, 20, .45); }
.ag-t { font-size: 11px; color: var(--gold); margin-bottom: 4px; letter-spacing: .03em; }
.ag-b { display: flex; flex-wrap: wrap; gap: 4px; }
.ag-b button { position: relative; padding: 5px 8px; font-size: 12px; }
.ag-x { display: flex; gap: 4px; }
.od { font-style: normal; font-size: 10px; margin-left: 6px; padding: 0 4px; border-radius: 4px; background: #222; }
.od.g { color: #3cff9e; } .od.y { color: #ffd84a; } .od.r { color: #ff6a5a; }
.cost { font-style: normal; font-size: 10px; margin-left: 4px; color: #ffe08a; }
#sess.trading { width: min(940px, calc(100vw - 24px)); }
.tr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tr-col { border: 1px solid #2a2440; border-radius: 8px; padding: 6px; background: rgba(10, 8, 20, .45); }
.tr-col.give { border-color: #6a5a1a; } .tr-col.want { border-color: #1a6a7a; }
.tr-h { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 4px; }
.tr-sum { color: #ffe08a; font-weight: normal; font-size: 12px; }
.tr-bal { text-align: center; font-size: 12px; margin: 5px 0; }
.tr-bal.ok { color: #3cff9e; } .tr-bal.bad { color: #ffb03a; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 30px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 2px; border: 1px solid #3a3058; border-radius: 6px; font-size: 12px; background: #15122a; }
.chip img { width: var(--ic32, 26px); height: var(--ic32, 26px); image-rendering: var(--icr32, pixelated); }
.chip em { font-style: normal; color: #ffe08a; }
.tr-table { margin-top: 8px; }
.tr-th { color: var(--gold); font-size: 12px; margin-bottom: 4px; }
.tr-sh { color: #ffe08a; margin-top: 3px; }
.tr-want { display: flex; gap: 6px; margin: 6px 0; }
.tr-want input:first-child { flex: 1; }
.tr-wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 3px; max-height: 26vh; overflow-y: auto; }
.tr-wgrid .tw { display: flex; align-items: center; gap: 4px; padding: 2px 4px; font-size: 11px; text-align: left; }
.tr-wgrid img { width: var(--ic32, 26px); height: var(--ic32, 26px); image-rendering: var(--icr32, pixelated); flex: none; }
@media (max-width: 700px) {
  #sess, #sess.trading { left: 6px; right: 6px; width: auto; max-height: 78vh; }
  .sw-main { grid-template-columns: 1fr; }
  .sw-card { border-right: 0; border-bottom: 2px solid var(--line); display: grid; grid-template-columns: 70px 1fr; gap: 8px; padding: 6px 8px; }
  #sess-face { width: 70px; height: 88px; margin: 0; }
  .cd-name { text-align: left; }
  .cd-fac, .sw-card .sw-hints { text-align: left; justify-content: flex-start; }
  .cd-known { display: none; }
  .tr-cols { grid-template-columns: 1fr; }
  #sess-log { max-height: 20vh; }
}

/* перетаскивание: куда кладём — подсветка, откуда — приглушено; призрак полупрозрачный */
.slot.drop-tgt { outline: 3px solid #3af0ff; outline-offset: -3px; box-shadow: 0 0 12px rgba(58, 240, 255, .7) inset; }
.slot.drag-src { opacity: .35; }
#drag-ghost { opacity: .75; }

/* ---- сетка сборки (агент «craft-inv», 13.11): левая колонка окна инвентаря + окно книги рецептов */
#panel.inv-wide { width: min(1000px, calc(100vw - 24px)); }
#panel.inv-wide #p-body { overflow: hidden; display: flex; flex-direction: column; padding: 8px; }
.invwrap { --crc: 44px; flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(270px, 410px) 1fr; gap: 10px; position: relative; }
.invwrap.big { grid-template-columns: minmax(300px, 600px) 1fr; --crc: 42px; }
.invwrap .craft { min-height: 0; overflow-y: auto; touch-action: pan-y; padding-right: 4px; border-right: 2px solid var(--line); }
.invwrap .invmain { min-height: 0; overflow-y: auto; touch-action: pan-y; }
.invwrap .invmain .invgrid.main { max-height: none; overflow: visible; }
.cr-strip { display: none; }
.cr-head { display: flex; align-items: center; gap: 6px; margin: 2px 0 6px; }
.cr-head b { color: var(--gold); font-size: 14px; flex: 1; }
.cr-head button.small { padding: 5px 9px; }
.cr-x { display: none; padding: 4px 12px; }
.cr-gridwrap { overflow-x: auto; touch-action: pan-x pan-y; padding: 6px; border: 2px dashed #5a4a2a; border-radius: 8px; background: rgba(40, 30, 10, .35); }
.cr-grid { display: grid; gap: 3px; width: max-content; }
.cr-grid .slot.cr-cell { width: var(--crc); height: var(--crc); background: rgba(10, 8, 22, .85); }
.cr-grid .slot.cr-cell img { width: calc(var(--crc) - 8px); height: calc(var(--crc) - 8px); }
.cr-grid .slot.cr-cell.no { border-color: #c03a3a; background: rgba(70, 12, 12, .7); }
.cr-out { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.cr-out .slot.cr-res { width: 56px; height: 56px; flex: none; border-color: var(--gold); }
.cr-out .slot.cr-res.ok { border-color: #3cff9e; box-shadow: 0 0 10px rgba(60, 255, 158, .4); }
.cr-on { display: flex; flex-direction: column; min-width: 0; }
.cr-on b { font-size: 14px; }
.cr-on small { font-size: 12px; color: var(--dim); }
.cr-q { font-style: normal; color: #ffd060; }
.cr-plus { font-size: 22px; color: var(--dim); pointer-events: none; }
.cr-tip, .cr-empty { font-size: 12px; color: var(--dim); margin: 6px 2px; }
.cr-tip button.small { padding: 3px 8px; font-size: 12px; }
.cr-where { font-size: 12px; color: #c9b8a0; margin-top: 6px; line-height: 1.4; }
.cr-btns { display: flex; gap: 6px; margin-top: 8px; }
.cr-btns button { min-height: 44px; padding: 8px 10px; }
.cr-btns .cr-make { flex: 1; background: #1f5a3a; border-color: #3cff9e; font-weight: bold; }
.cr-btns .cr-make:disabled { background: #221d3c; border-color: var(--line); }
.cr-pal-h { font-size: 12px; color: var(--dim); margin: 10px 2px 4px; }
.cr-pal { display: flex; flex-wrap: wrap; gap: 4px; }
.cr-pal .slot { width: 44px; height: 44px; }
.cr-pal .slot img { width: 34px; height: 34px; }
/* книга рецептов — отдельное окно (ПК: слева; телефон: на весь экран) */
#bookwin { position: fixed; z-index: 16; left: 12px; top: 64px; bottom: calc(76px + var(--safe-b)); width: min(440px, calc(100vw - 24px)); background: var(--panel); border: 3px solid #6a5a2a; border-radius: 10px; display: flex; flex-direction: column; box-shadow: 0 0 0 3px #000; }
#bookwin.hidden { display: none; }
#bk-body { overflow-y: auto; padding: 8px 10px; touch-action: pan-y; flex: 1; overscroll-behavior: contain; }
.bk-sum { font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.bk-sum b { color: var(--gold); font-weight: normal; }
.cr-tabs, .bk-cats { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.cr-tabs button { flex: 1; padding: 7px 4px; font-size: 12px; min-height: 38px; }
.bk-cats button { padding: 4px 8px; font-size: 11px; min-height: 32px; }
.bk-cats button i { font-style: normal; opacity: .6; }
.bk-cats button.empty { opacity: .45; }
#bk-q { margin: 2px 0 6px; padding: 7px 8px; font-size: 14px; }
#bk-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 10px; }
.bk-sec { margin: 8px 2px 2px; font-size: 12px; color: var(--gold); border-bottom: 1px solid #3a3460; padding-bottom: 2px; }
.cr-row { display: flex; align-items: center; gap: 8px; text-align: left; padding: 5px 7px; min-height: 50px; width: 100%; }
.cr-row .cr-oi { width: var(--ic40, 38px); height: var(--ic40, 38px); image-rendering: var(--icr40, pixelated); flex: none; pointer-events: none; }
.cr-nm { flex: 1; min-width: 0; display: flex; flex-direction: column; pointer-events: none; }
.cr-nm b { font-size: 13px; font-weight: normal; }
.cr-nm small { font-size: 11px; color: var(--dim); }
.cr-row.cr-st { opacity: .55; filter: grayscale(.7); background: #18152a; }
.cr-row.cr-hand { border-color: #6a5a2a; background: rgba(60, 45, 15, .55); }
.cr-row.cr-hand .cr-nm small { color: #e8c45a; }
.cr-row.cr-ready { border-color: #3cff9e; background: rgba(20, 70, 45, .75); box-shadow: 0 0 8px rgba(60, 255, 158, .35); }
.cr-row.cr-ready .cr-nm b { color: #fff; font-weight: bold; }
.cr-row.cr-ready .cr-nm small { color: #3cff9e; }
.cr-row.lock { background: #120f20; border-style: dashed; opacity: .75; }
.cr-row.on { border-color: var(--cyan); opacity: 1; filter: none; }
.bk-lock { width: 38px; height: 38px; flex: none; display: flex; align-items: center; justify-content: center; border: 2px dashed #5a4a7a; border-radius: 6px; color: #9a8ac0; font-weight: bold; font-size: 12px; pointer-events: none; }
.bk-det { border: 2px solid var(--line); border-radius: 8px; padding: 8px; margin: 2px 0 6px; background: rgba(10, 8, 22, .85); }
.bk-dh { display: flex; gap: 8px; align-items: center; }
.bk-dh img { width: var(--ic48, 48px); height: var(--ic48, 48px); image-rendering: var(--icr48, pixelated); flex: none; }
.bk-dh div { display: flex; flex-direction: column; }
.bk-dh small { color: var(--dim); font-size: 12px; }
.bk-dh small.bk-pl { color: var(--gold); }
.bk-pat { display: grid; gap: 2px; margin: 8px 0 4px; width: max-content; max-width: 100%; overflow-x: auto; padding: 4px; background: rgba(40, 30, 10, .35); border-radius: 6px; }
.bk-c { width: 34px; height: 34px; border: 1px solid #3a3460; border-radius: 4px; background: rgba(10, 8, 22, .8); display: flex; align-items: center; justify-content: center; }
.bk-c img { width: 28px; height: 28px; image-rendering: pixelated; }
.bk-c.opt { opacity: .45; border-style: dashed; border-color: #ffd060; }
.cr-ings { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.cr-ing { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 4px; border-radius: 4px; background: rgba(255, 255, 255, .03); }
.cr-ing img { width: 28px; height: 28px; image-rendering: pixelated; }
.cr-ing span { flex: 1; }
.cr-ing.ok b { color: #3cff9e; }
.cr-ing.no b { color: #ff6a5a; }

/* телефон: сборка — выдвижная панель слева (ручка «🛠»), рюкзак не сжимается; книга — на весь экран */
@media (max-width: 640px) {
  #panel.inv-wide #p-body { padding: 6px; }
  .invwrap { display: flex; gap: 6px; --crc: 42px; }
  .cr-strip { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; flex: none; width: 40px; padding: 8px 0; border-color: #6a5a2a; background: rgba(60, 45, 15, .55); }
  .cr-si { font-size: 20px; }
  .cr-sv { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; letter-spacing: 1px; color: var(--gold); }
  .invwrap .invmain { flex: 1; }
  .invwrap .craft { display: none; position: absolute; left: 0; top: 0; bottom: 0; width: calc(100% - 24px); z-index: 4; background: #110e22; border: 2px solid #6a5a2a; border-radius: 8px; padding: 6px 8px; box-shadow: 6px 0 18px rgba(0, 0, 0, .7); overscroll-behavior: contain; }
  .invwrap.cr-open .craft { display: block; }
  .cr-x { display: block; min-height: 40px; }
  #bookwin { left: 6px; right: 6px; top: 52px; bottom: 6px; width: auto; z-index: 17; }
  .cr-row { min-height: 54px; }
}
/* книга открыта — окно инвентаря сдвигается вправо, чтобы сетка оставалась видна */
@media (min-width: 900px) {
  body.book-open #panel.inv-wide { width: calc(100vw - 480px); }
  body.book-open #panel.inv-wide .invwrap { grid-template-columns: minmax(250px, 380px) 1fr; }
  body.book-open #panel.inv-wide .invwrap.big { grid-template-columns: minmax(280px, 1fr) minmax(200px, 0.6fr); }
}
@media (max-width: 640px) { #bookwin { background: #110e22; } }
.cd-fac .emb.emb-real { background: #000a; border-radius: 4px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
