/* Телефоны и планшеты. Все правила — под body.mobile (класс ставит mobile.js), на компьютере файл ничего не меняет. */
.m-acts, .m-top, .m-menu, .m-joy, .m-rotate, .m-qpage, .m-chat-x, .m-tg-x { display: none; }

html.mobile, body.mobile { overscroll-behavior: none; -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body.mobile { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.mobile input, body.mobile textarea { -webkit-user-select: text; user-select: text; font-size: 16px; }   /* 16px — иначе iPhone приближает страницу при вводе */
body.mobile canvas#view { touch-action: none; }
body.mobile .drag-grip { display: none; }

/* ---------- игра: рамка с учётом «чёлки» и полоски iPhone ---------- */
body.mobile #hud { left: env(safe-area-inset-left); right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom); }
body.mobile .panel { border-radius: 6px; }

/* я, цель, группа */
body.mobile .me { left: 6px; top: 6px; width: 172px; padding: 5px 7px; }
body.mobile .me-name { font-size: 13px; margin-bottom: 2px; gap: 6px; white-space: nowrap; }
body.mobile .me-name #meName { overflow: hidden; text-overflow: ellipsis; }
body.mobile .me-lvl { font-size: 10px; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 60%; }
body.mobile .me .bar { height: 11px; margin-top: 3px; }
body.mobile .me .bar em { font-size: 9px; line-height: 11px; }
body.mobile .me-status:empty { display: none; }
body.mobile .target { top: 6px; width: 200px; padding: 5px 30px 5px 8px; left: calc(50% - 20px); }
body.mobile .target .bar { height: 11px; }
body.mobile .target .bar em { font-size: 9px; line-height: 11px; }
body.mobile .tg-name { font-size: 12px; }
body.mobile .tg-sub { font-size: 10px; }
body.mobile .m-tg-x { display: flex; position: absolute; right: 2px; top: 2px; width: 26px; height: 26px; padding: 5px; background: none; border: 0; color: #cdbb93; pointer-events: auto; }
body.mobile #party { left: 6px; top: 92px; width: 150px; padding: 4px; font-size: 11px; }
body.mobile .petbar { left: 6px !important; top: 92px !important; bottom: auto !important; min-width: 0; width: 150px; font-size: 11px; padding: 4px 6px; }
body.mobile .fxwin { left: 6px; top: 6px; width: min(300px, 60vw); max-height: 80vh; overflow: auto; z-index: 14; }
body.mobile .pinvite { top: 60px; z-index: 30; }

/* мини-карта и задания */
body.mobile .world { right: 6px; top: 6px; width: 92px; padding: 3px 4px 4px; }
body.mobile .world .floor { font-size: 9px; }
body.mobile .world .timer { font-size: 11px; }
body.mobile .world .online { display: none; }
body.mobile #minimap { width: 84px; height: 84px; }
body.mobile .qpanel { right: 104px; top: 44px; width: 168px; gap: 3px; }
body.mobile .qpanel { max-height: calc(100vh - 44px - 218px); overflow: hidden; }
body.mobile .qpanel .qtrack { padding: 3px 6px; gap: 0; }
body.mobile .qpanel .qtrack b { font-size: 10px; }
body.mobile .qpanel .qtrack span { font-size: 10px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
body.mobile .qpanel .qtrack small { display: none; }
body.mobile .qpanel .qt-btns { flex-wrap: nowrap; overflow-x: auto; }
body.mobile .qpanel .qt-btn { min-height: 30px; font-size: 11px; white-space: nowrap; flex: none; }
body.mobile .qpanel:has(.qt-btn) { width: 250px; }
body.mobile .side-col, body.mobile .corner .round-btn { display: none; }
body.mobile .corner { right: 6px; bottom: auto; top: 44px; }

/* верхние кнопки: чат и меню */
body.mobile .m-top { display: flex; gap: 6px; position: absolute; right: 104px; top: 6px; pointer-events: auto; }
body.mobile .m-tbtn { position: relative; width: 36px; height: 34px; padding: 7px; border-radius: 6px; border: 1px solid var(--line); background: rgba(14, 11, 8, .78); color: #e9cf8f; }
body.mobile .m-tbtn.down { background: rgba(80, 62, 30, .9); }
body.mobile .m-dot { position: absolute; right: 3px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: #ff5a4a; }
body.mobile .m-dot.hidden { display: none; }
body.mobile .m-menu { display: flex; position: fixed; inset: 0; z-index: 30; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); padding: 12px; }
body.mobile .m-menu.hidden { display: none; }
body.mobile .m-menu-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(560px, 100%); padding: 12px; background: rgba(14, 11, 8, .96); border: 1px solid var(--line); border-radius: 10px; }
body.mobile .m-item { min-height: 48px; padding: 6px; border-radius: 6px; border: 1px solid var(--gold-dim); background: linear-gradient(#2a2118, #15100b); color: #f0e2bd; font: inherit; font-size: 14px; }
body.mobile .m-item:active { background: #4a3a1c; }
body.mobile .m-fs { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; }
body.mobile .m-fs svg { width: 18px; height: 18px; }

/* системные строки — две последние, без рамки; чат — по кнопке */
body.mobile .syswin { left: 6px; bottom: auto; top: 96px; width: min(300px, 40vw); padding: 0; background: none; border: 0; box-shadow: none; pointer-events: none; }
body.mobile .syswin .sys-head { display: none; }
body.mobile .syswin .sys-log { max-height: 30px; overflow: hidden; font-size: 11px; line-height: 15px; display: flex; flex-direction: column; justify-content: flex-end; text-shadow: 0 1px 2px #000, 0 0 3px #000; pointer-events: none; }
body.mobile:has(#party:not(.hidden)) .syswin, body.mobile:has(.petbar:not(.hidden)) .syswin { top: 150px; }
body.mobile .chat { display: none; }
body.mobile.m-chat .chat { display: flex; position: fixed; left: env(safe-area-inset-left); right: env(safe-area-inset-right); top: 0; bottom: var(--kb, 0px); width: auto; z-index: 16; padding: 6px 8px; border-radius: 0; background: rgba(10, 8, 6, .88); }
body.mobile.m-chat .chat-log { flex: 1; max-height: none; height: auto; font-size: 13px; }
body.mobile.m-chat .chat-tabs { padding-right: 44px; }
body.mobile .ctab { min-height: 30px; padding: 4px 12px; }
body.mobile.m-chat .m-chat-x { display: flex; position: absolute; right: 6px; top: 4px; width: 34px; height: 30px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: rgba(30, 24, 14, .9); color: #e9cf8f; }
body.mobile #chatInput { min-height: 36px; }
body.mobile.m-chat .m-acts, body.mobile.m-chat .quickbar, body.mobile.m-chat .m-joy { display: none; }

/* ---------- бой: кнопки справа, умения сеткой 3×3 ---------- */
body.mobile .m-acts { display: block; position: absolute; right: 8px; bottom: 26px; width: 128px; height: 128px; pointer-events: none; }
body.mobile .m-btn { position: absolute; display: flex; align-items: center; justify-content: center; padding: 0; border-radius: 50%; border: 1px solid var(--gold-dim); background: rgba(20, 15, 9, .72); color: #f0dba0; pointer-events: auto; touch-action: none; }
body.mobile .m-btn svg { width: 54%; height: 54%; }
body.mobile .m-btn.down { background: rgba(120, 90, 36, .9); transform: scale(.94); }
body.mobile .m-atk { right: 0; bottom: 0; width: 72px; height: 72px; border-color: var(--gold); background: rgba(70, 20, 14, .78); color: #ffd9b0; }
body.mobile .m-tab { right: 80px; bottom: 2px; width: 44px; height: 44px; }
body.mobile .m-pick { right: 66px; bottom: 54px; width: 44px; height: 44px; }
body.mobile .m-jump { right: 12px; bottom: 82px; width: 44px; height: 44px; }
body.mobile .m-fish { right: 86px; bottom: 100px; width: 44px; height: 44px; border-color: #6fd3ff; color: #bfeaff; }
body.mobile .m-btn.hidden { display: none; }

body.mobile .quickbar { --slot: clamp(38px, 11.2vh, 46px) !important; left: auto; right: 142px; bottom: 24px; transform: none; margin: 0; }
body.mobile .qb-side { display: none; }
body.mobile .qb-rows { display: block; }
body.mobile .qb-row { display: none; grid-template-columns: repeat(3, var(--slot)); gap: 3px; padding: 3px; }
body.mobile .quickbar[data-page="0"] .qb-row:nth-last-child(1), body.mobile .quickbar[data-page="1"] .qb-row:nth-last-child(2), body.mobile .quickbar[data-page="2"] .qb-row:nth-last-child(3) { display: grid; }
body.mobile .qs { touch-action: none; }
body.mobile .qs .key { display: none; }
body.mobile .m-qpage { display: block; position: absolute; left: -30px; bottom: 3px; width: 26px; height: 34px; padding: 0; border-radius: 5px; border: 1px solid var(--gold-dim); background: rgba(14, 11, 8, .8); color: #e9cf8f; font: 700 13px var(--text); pointer-events: auto; touch-action: none; }
body.mobile .shot-cell { display: none; }

body.mobile .m-joy { display: block; position: fixed; width: 116px; height: 116px; margin: -58px 0 0 -58px; border-radius: 50%; border: 2px solid rgba(233, 207, 143, .45); background: rgba(10, 8, 6, .28); pointer-events: none; z-index: 9; }
body.mobile .m-joy.hidden { display: none; }
body.mobile .m-joy i { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(233, 207, 143, .55); box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }

body.mobile .castbar { bottom: auto; top: 58px; width: 200px; height: 20px; pointer-events: auto; }
body.mobile .center-msg { top: 20%; font-size: clamp(16px, 5vh, 24px); white-space: normal; width: 70vw; }
body.mobile .xpline { height: 16px; }
body.mobile .xp-l, body.mobile .xp-r { line-height: 16px; font-size: 10px; }
body.mobile .xp-clan { height: 16px; }
body.mobile .fps-meter { top: 2px; font-size: 10px; }
body.mobile .update-note { top: 50px; font-size: 13px; padding: 8px 12px; max-width: 90vw; }
body.mobile .lbl { font-size: 11px; }
body.mobile .fl { font-size: 15px; }
body.mobile .drop-lbl { padding: 6px 8px; }

/* ---------- окна: на весь экран ---------- */
body.mobile .inv, body.mobile .npcwin, body.mobile .tradewin, body.mobile .charwin, body.mobile .clanwin, body.mobile .clansearch {
  position: fixed !important; left: env(safe-area-inset-left) !important; right: env(safe-area-inset-right) !important; top: 0 !important; bottom: 0 !important;
  width: auto !important; height: auto !important; max-width: none !important; max-height: none !important; transform: none !important; margin: 0 !important;
  border-radius: 0; border-width: 0; z-index: 18; overflow: auto; -webkit-overflow-scrolling: touch; background: rgba(12, 9, 6, .97);
}
body.mobile .inv { z-index: 17; }
body.mobile .whatsnew { position: fixed !important; left: 50% !important; top: 50% !important; right: auto !important; bottom: auto !important; transform: translate(-50%, -50%) !important; width: min(520px, 94vw) !important; max-height: 88vh; overflow: auto; z-index: 25; }
body.mobile .qdlg { top: auto !important; left: 0 !important; right: 0 !important; bottom: 0 !important; max-height: 78vh !important; border-top: 1px solid var(--line); border-radius: 10px 10px 0 0; }
body.mobile .enchwin { z-index: 19; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; max-height: 96vh; overflow: auto; }
body.mobile .confirm { z-index: 46; top: 50%; max-height: 92vh; overflow: auto; }
body.mobile .confirm button, body.mobile .cf-row button { min-height: 40px; }
body.mobile .tpmenu { position: fixed; right: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(340px, 92vw); max-height: 92vh; overflow: auto; z-index: 18; }
body.mobile .tpmenu button { min-height: 40px; }
body.mobile .pop { position: fixed; right: auto; left: 50%; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(420px, 92vw); max-height: 92vh; overflow: auto; z-index: 31; }
body.mobile .pop button { min-height: 40px; }
body.mobile .pop.help { display: none; }
body.mobile .btn-main, body.mobile .btn-ghost { min-height: 38px; }
body.mobile .inv-x, body.mobile .x, body.mobile #nwClose, body.mobile #qjClose, body.mobile #qdClose, body.mobile #skClose, body.mobile #mwClose, body.mobile #clClose, body.mobile #csClose { min-width: 40px; min-height: 36px; }

/* сумка: слева кукла, справа вещи; подсказка — отдельной полосой снизу */
body.mobile .inv-head { padding: 6px 10px; }
body.mobile .inv-head h2 { font-size: 18px; }
body.mobile .inv-body { grid-template-columns: 190px 1fr !important; gap: 8px; padding: 0 8px; min-height: 0; flex: 1; overflow: hidden; }
body.mobile .inv-left { overflow: auto; }
body.mobile .inv-right { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
body.mobile .inv-grid { overflow: auto; -webkit-overflow-scrolling: touch; flex: 1; align-content: start; }
body.mobile .inv-tabs { flex-wrap: nowrap; overflow-x: auto; }
body.mobile .inv-tab { min-height: 32px; white-space: nowrap; }
body.mobile .inv-hint { display: none; }
body.mobile .inv-foot { padding: 4px 8px 6px; gap: 6px; flex-wrap: nowrap; }
body.mobile .m-iacts { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; }
body.mobile .m-iacts button { min-height: 36px; padding: 4px 10px; font-size: 13px; flex: none; white-space: nowrap; }
body.mobile .itip { left: auto !important; top: auto !important; right: calc(8px + env(safe-area-inset-right)); bottom: 52px; max-width: min(300px, 46vw); max-height: calc(100vh - 110px); overflow: auto; font-size: 12px; pointer-events: none; }

/* умения */
body.mobile .skillwin .sk-body { height: auto; flex: 1; min-height: 90px; }
body.mobile .skillwin .sk-info { height: auto; max-height: 34vh; }
body.mobile .sk-tile { touch-action: manipulation; }
body.mobile .nw-body { -webkit-overflow-scrolling: touch; }
body.mobile .nw-tabs { flex-wrap: nowrap; overflow-x: auto; }
body.mobile .nw-tabs button { min-height: 34px; white-space: nowrap; }

/* настройки, карта, смерть */
body.mobile .screen { padding: 0; }
body.mobile .settings-box { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; overflow: auto; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
body.mobile .set-tabs { flex-wrap: nowrap; overflow-x: auto; }
body.mobile .set-tabs button[data-set="keys"] { display: none; }
body.mobile .seg button { min-height: 36px; }
body.mobile .wm-box { width: 100%; height: 100%; max-width: none; max-height: none; border-radius: 0; padding: 6px; }
body.mobile .wm-legend, body.mobile .wm-note { display: none; }
body.mobile .wm-view { flex: 1; min-height: 0; touch-action: none; }
body.mobile .wm-zoom button { width: 40px; height: 40px; }
body.mobile .death-box { max-width: 92vw; }

/* сцены */
body.mobile #cinema .cn-sub { font-size: clamp(13px, 4.4vh, 18px); width: 92vw; }
body.mobile #cinema .cn-skip { min-height: 36px; right: max(12px, env(safe-area-inset-right)); }

/* ---------- вертикальное положение в игре ---------- */
@media (orientation: portrait) {
  body.mobile:has(#hud:not(.hidden)) .m-rotate { display: flex; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; text-align: center; background: #0b0906; color: #e9cf8f; }
  body.mobile .m-rotate div { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; }
  body.mobile .m-rotate svg { width: 72px; height: 72px; }
  body.mobile .m-rotate b { font: 22px var(--title); }
  body.mobile .m-rotate span { font-size: 14px; color: #bfae86; }
}

/* ---------- маленькие экраны по высоте (телефон лёжа) ---------- */
@media (max-height: 380px) {
  body.mobile .me { width: 156px; }
  body.mobile .m-acts { transform: scale(.9); transform-origin: right bottom; }
}

/* ---------- сайт, вход, кабинет: телефон стоя ---------- */
@media (max-width: 640px) {
  body.mobile .site-nav { flex-wrap: wrap; gap: 4px 10px; }
  body.mobile .site-menu { display: flex; flex: 1 1 100%; order: 2; max-width: 100%; overflow-x: auto; white-space: nowrap; }
  body.mobile .site-menu button { flex: none; }
  body.mobile .site-acc { order: 1; margin-left: 0; }
}

/* окна-списки занимают всю высоту экрана */
body.mobile .npcwin .nw-body, body.mobile .npcwin .qj-body { flex: 1; max-height: none; height: auto; }
body.mobile .set-tabs { flex: none; min-height: 40px; }
body.mobile .set-tabs button { min-height: 36px; white-space: nowrap; }

/* рынок */
body.mobile .mk-search, body.mobile .mk-kind { min-height: 36px; }
body.mobile .mk-opt { min-height: 34px; }
body.mobile .mk-bag { max-height: 96px; }
body.mobile .mktwin .nw-right { flex-wrap: wrap; justify-content: flex-end; }
