/* Телефон — вариант А (16.11.2026, слово Архитектора; макет «Миросток — мобильный экран, варианты»).
   Карта на весь экран; сверху плашка пэта и место; снизу пять вкладок; окна выезжают снизу.
   Включает mobile.js — класс body.m-app при ширине ≤ 700 px. Компьютер не затронут. */

body.m-app {
    --m-tabs: calc(64px + env(safe-area-inset-bottom, 0px));
    --m-top: env(safe-area-inset-top, 0px);
    display: block;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
}

/* Карта — весь экран (в чате у неё своя раскладка, localchat.js). */
body.m-app:not(.mobile-chat-open) > #map-frame {
    position: fixed !important;
    inset: 0 !important;
    width: auto !important;
    height: auto !important;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 1;
}
body.m-app > #map-frame::after { display: none; }

/* Затемнение сверху и снизу — чтобы надписи читались поверх карты. */
.m-shade { display: none; }
body.m-app .m-shade { display: block; position: fixed; left: 0; right: 0; z-index: 2; pointer-events: none; }
body.m-app .m-shade.top { top: 0; height: calc(110px + var(--m-top)); background: linear-gradient(180deg, rgba(9, 7, 12, 0.82), rgba(9, 7, 12, 0)); }
body.m-app .m-shade.bottom { bottom: 0; height: 170px; background: linear-gradient(0deg, rgba(9, 7, 12, 0.85), rgba(9, 7, 12, 0)); }

/* ---------------------------------------------------------------- верх: плашка пэта слева, место справа */

body.m-app > .top {
    display: block;
    position: fixed;
    left: 0; right: 0; top: 0;
    z-index: 22;
    height: 0;
    padding: 0;
}
body.m-app.mobile-chat-open > .top { display: none; }
body.m-app > .top::after { display: none; }

body.m-app .top > .brand {
    position: absolute;
    right: 12px;
    top: calc(12px + var(--m-top));
    max-width: 44vw;
    margin: 0;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 4px;
    pointer-events: none;
}
body.m-app .brand-mark { display: none; }
body.m-app .brand-top { display: flex; justify-content: flex-end; }
body.m-app .online-badge { pointer-events: auto; font-size: 12px; }
body.m-app h1.place-title {
    margin: 0;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-align: right;
    overflow-wrap: anywhere;
    text-shadow: 0 2px 8px #000;
}
body.m-app .top > .download { display: none; }
body.m-app .top > .strip { display: block; margin: 0; }
body.m-app #trio { display: none; }

body.m-app #live-pet {
    position: absolute;
    left: 10px;
    top: calc(10px + var(--m-top));
    display: flex;
    align-items: center;
    gap: 10px;
    height: auto;
    min-height: 0;
    max-width: 52vw;
    padding: 5px 14px 5px 5px;
    border-radius: 16px;
    background: rgba(18, 13, 27, 0.82);
    border: 1px solid rgba(var(--gold-rgb), 0.42);
}
body.m-app #live-pet::before { display: none; }
body.m-app #live-pet .avatar { width: 42px; height: 52px; border-radius: 11px; }
body.m-app #live-pet .live-pet-image { max-width: 38px; max-height: 48px; }
body.m-app #live-pet .live-pet-stub { font-size: 24px; }
body.m-app #live-pet .live-pet-name { font-size: 17px; }
body.m-app #live-pet .live-pet-note,
body.m-app #live-pet .pet-line { font-size: 11px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.m-app #live-pet .pet-line:not([hidden]) ~ .live-pet-note,
body.m-app #live-pet .live-pet-note:has(~ .pet-line:not([hidden])) { display: none; }
body.m-app #live-pet .pet-side { display: none; }

/* Кот-проводник (cat-guide.js) — под плашкой пэта, когда нужен. */
.m-cat { display: none; }
body.m-app .m-cat { display: flex; flex-wrap: wrap; gap: 6px; position: fixed; z-index: 22; left: 10px; top: calc(76px + var(--m-top)); max-width: 70vw; }
body.m-app .m-cat .ghost-button { min-height: 36px; background: rgba(18, 13, 27, 0.88); font-size: 13px; }

/* ---------------------------------------------------------------- низ карты: подсказка, «Назад», поиск, чат */

body.m-app .map-bottom { bottom: calc(var(--m-tabs) + 12px); }
body.m-app .search-panel { top: calc(84px + var(--m-top)); right: 10px; }
body.m-app #map-frame .kr-map-launcher { display: none; }
body.m-app .lc-dock { bottom: calc(var(--m-tabs) + 10px); }
body.m-app.m-sheet-open .lc-dock { display: none; }

/* ---------------------------------------------------------------- вкладки */

.m-tabs, .m-sheet { display: none; }
body.m-app .m-tabs {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 26;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    height: var(--m-tabs);
    box-sizing: border-box;
    padding: 4px 4px env(safe-area-inset-bottom, 0px);
    background: rgba(18, 13, 27, 0.96);
    border-top: 1px solid rgba(var(--gold-rgb), 0.26);
}
body.m-app.mobile-chat-open .m-tabs, body.m-app.mobile-chat-open .m-sheet { display: none; }
.m-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: none;
    color: #c9bfd6;
    font: 600 11px/1.1 var(--body);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.m-tab .fill { fill: currentColor; stroke: none; }
.m-tab[aria-current="true"] { color: var(--gold); }
.m-tab.off { color: #7d7390; }
.m-tab:active { background: rgba(255, 255, 255, 0.05); }
.m-badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 9px;
    background: var(--accent);
    color: #1a0f05;
    font: 700 11px/18px var(--body);
    text-align: center;
}
.m-badge[hidden] { display: none; }

/* ---------------------------------------------------------------- окно снизу */

body.m-app .m-sheet {
    position: fixed;
    left: 0; right: 0;
    bottom: var(--m-tabs);
    z-index: 25;
    display: flex;
    flex-direction: column;
    max-height: 62vh;
    max-height: 62dvh;
    box-sizing: border-box;
    padding: 6px 16px 14px;
    border-radius: 22px 22px 0 0;
    background: rgba(18, 13, 27, 0.97);
    border-top: 1px solid rgba(var(--gold-rgb), 0.42);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(calc(100% + var(--m-tabs)));
    visibility: hidden;
    transition: transform 0.28s ease, visibility 0s linear 0.28s;
}
body.m-app .m-sheet.open { transform: translateY(var(--m-drag, 0px)); visibility: visible; transition: transform 0.28s ease; }
body.m-app .m-sheet.dragging { transition: none; }
.m-grip { align-self: center; width: 44px; height: 5px; margin: 4px 0 6px; border-radius: 3px; background: rgba(var(--gold-rgb), 0.5); }
.m-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; touch-action: none; }
.m-sheet-title { margin: 0; font: 700 25px/1.2 var(--title); color: var(--text); }
.m-close {
    display: grid; place-items: center; flex: none;
    width: 44px; height: 44px; padding: 0;
    border: 1px solid rgba(var(--gold-rgb), 0.26); border-radius: 50%;
    background: none; color: #c9bfd6; cursor: pointer;
}
.m-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.m-sheet-body { overflow-y: auto; overscroll-behavior: contain; padding-top: 10px; }
.m-page { display: flex; flex-direction: column; gap: 12px; }
.m-page[hidden] { display: none; }
.m-label { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.m-hint { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.m-hint[hidden] { display: none; }

/* Плашки, перенесённые в окно, — без своей рамки и значка: окно уже рамка. */
.m-sheet .tile {
    display: block;
    height: auto;
    min-height: 0;
    padding: 0;
    background: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    cursor: default;
}
.m-sheet .tile::before, .m-sheet .tile::after, .m-sheet .tile .panel-icon, .m-sheet .tile .panel-title { display: none; }
.m-sheet .letters-text { font-size: 15px; line-height: 1.5; }
.m-sheet .news { display: flex; flex-wrap: wrap; gap: 8px; }
.m-sheet .news-chip { min-height: 44px; padding: 0 14px; }
.m-sheet .acts { flex-wrap: wrap; }
.m-sheet .account { display: flex; gap: 8px; flex-wrap: wrap; }
.m-sheet .account-link, .m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 16px;
    border: 1px solid rgba(var(--gold-rgb), 0.42); border-radius: 22px;
    background: none; color: var(--text); font: 600 14px var(--body); text-decoration: none; cursor: pointer;
}
.m-sheet .download { width: auto; height: auto; min-height: 44px; flex-flow: row nowrap; justify-content: flex-start; padding: 0 16px; border-radius: 22px; box-shadow: none; }
.m-sheet .download-note { flex-basis: auto; display: inline; }
.m-sheet .kr-launcher { position: static; display: inline-flex; align-items: center; gap: 10px; width: auto; height: auto; color: var(--text); font-size: 14px; text-decoration: none; }
.m-sheet .kr-launcher img { width: 40px; height: 40px; }

@media (prefers-reduced-motion: reduce) {
    body.m-app .m-sheet, body.m-app .m-sheet.open { transition: none; }
}

/* ---------------------------------------------------------------- поправки после проверки 16.11 */

body.m-app > .top { background: none; border: 0; box-shadow: none; }
body.m-app > #map-frame::before { display: none; }                 /* ромбики рамки — у краёв экрана не нужны */
body.m-app #live-pet .live-pet-name { padding-right: 0; }
/* Кот говорит в плашке (гость, знакомство) — плашка во всю ширину, название места на это время прячется. */
body.m-app #live-pet.cat-talking { right: 10px; max-width: none; max-height: 46vh; max-height: 46dvh; align-items: flex-start; }
body.m-app #live-pet.cat-talking .pet-info { max-height: calc(46dvh - 12px); }
body.m-app:has(#live-pet.cat-talking) .top > .brand { display: none; }
/* Беседа рядом (localchat.js): кнопки «Обрывки» и «Продолжить» — над вкладками, слева. */
body.m-app .lc-dock { left: 10px; right: auto !important; bottom: calc(var(--m-tabs) + 10px) !important; }
body.m-app .m-sheet .kr-launcher { border: 0; background: none; box-shadow: none; border-radius: 0; }
body.m-app .m-sheet .kr-launcher::before, body.m-app .m-sheet .kr-launcher::after { display: none; }
/* «❤ 30/30 · дома, у костра» — в две строки, а не обрывать. */
body.m-app #live-pet .pet-line:not([hidden]) { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

/* ---------------------------------------------------------------- действия на карте у правого края (16.11, шаг 2) */

.m-acts { display: none; }
body.m-app .m-acts {
    display: block;
    position: fixed;
    z-index: 21;
    right: 12px;
    bottom: calc(var(--m-tabs) + 14px);
    max-width: calc(100vw - 24px);
    pointer-events: none;
}
body.m-app.m-sheet-open .m-acts, body.m-app.mobile-chat-open .m-acts { display: none; }
.m-acts .acts { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin: 0; }
.m-acts .acts-extra { order: -1; pointer-events: auto; max-width: calc(100vw - 24px); box-sizing: border-box; padding: 8px 10px;
    border: 1px solid rgba(var(--gold-rgb), 0.42); border-radius: 14px; background: rgba(14, 10, 18, 0.92); }
.m-acts .acts-extra:empty { display: none; }
.m-acts .acts-scroll { flex-direction: column; gap: 10px; overflow: visible; pointer-events: auto; }
.m-acts .act { width: 54px; height: 54px; background: rgba(18, 13, 27, 0.88); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5); }
.m-acts .act svg { width: 24px; height: 24px; }
.m-acts .act-chip { min-height: 40px; }
/* «Назад», «Перейти сюда» и подсказка — по середине, мимо столбика справа. */
body.m-app .map-bottom { left: 12px; right: 78px; }
/* «Обрывки» в «Ещё» */
.m-chat-words[hidden] { display: none; }
.m-chat-words button { min-height: 44px; padding: 0 16px; border: 1px solid rgba(var(--gold-rgb), 0.42); border-radius: 22px; background: none; color: var(--text); font: 600 14px var(--body); }

/* ---------------------------------------------------------------- бой на телефоне (16.11, скриншот Архитектора) */

/* Бой с жителем: полоски здоровья и «Окно боя» — под плашкой пэта, а не поверх названия места. */
body.m-app .fight-arena.fight-dock.fight-bars { top: calc(86px + var(--m-top)); left: 10px; width: min(300px, calc(100vw - 130px)); }
/* Бой с управлением внизу — над вкладками, а не под ними. */
body.m-app .fight-arena.fight-dock:not(.fight-bars) { bottom: calc(var(--m-tabs) + 8px); }
/* Во время боя столбик действий (поиск, осмотры) не нужен и мешает полоске боя. */
body.m-app:has(.fight-arena.fight-dock) .m-acts { display: none; }

/* ---------------------------------------------------------------- поправки по скриншотам 16.11 (охота, Оксиминог) */

body.m-app { --menu-safe-top: calc(84px + env(safe-area-inset-top, 0px)); }
/* Название места и «в мире» — на тёмной подложке: на светлой траве Моховика читались плохо. */
body.m-app .top > .brand { padding: 6px 10px 6px 12px; border-radius: 12px; background: rgba(14, 10, 18, 0.72); opacity: 1; }
body.m-app h1.place-title { color: #f6efe0; font-size: 21px; }
body.m-app .online-badge { color: #ddd4e8; }
/* Портрет в плашке — светлее фон: тёмный пэт на тёмном не различался. */
body.m-app #live-pet .avatar { background: radial-gradient(circle at 50% 35%, rgba(212, 168, 87, 0.45), rgba(70, 52, 90, 0.95) 80%); }
/* Охота: круглые кнопки — одним столбиком у края, надписи («Красться», «Автовыбор», приманка) — над ним
   короткими плашками; столбик ниже и уже — не налезает на подсказку и «Назад». */
.m-acts .acts-scroll { display: grid; justify-items: end; gap: 8px; }
.m-acts .acts-scroll > .act-chip { order: -1; min-height: 34px; padding: 0 12px; font-size: 13px; background: rgba(18, 13, 27, 0.9); }
.m-acts .act { width: 50px; height: 50px; }
