/* Телефон: полноэкранная карта, морда кота и бронзовое меню. */

body.m-app {
    --m-tabs: calc(72px + env(safe-area-inset-bottom, 0px));
    --m-bronze: url("/arena/bronze-grain.webp") 0 0 / 220px 220px repeat,
        linear-gradient(155deg, #3e3228, #24201b 54%, #151211);
    --m-control: linear-gradient(155deg, #43372c, #28211a 58%, #1b1713);
    --m-edge: #806848;
    --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)); }

/* Круглая морда кота и короткое название при переходе. */
#mobile-cat-button, .m-cat-dialog-title { display: none; }
body.m-app .bg-pet-summary { display: block; margin: 0 0 8px; color: #f3e3c8; }
body.m-app > .top {
    position: fixed;
    inset: 0 0 auto;
    height: 0;
    z-index: 28;
    display: block;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}
body.m-app.mobile-chat-open > .top,
body.m-app > .top::after,
body.m-app .top > :is(.brand, .download),
body.m-app #trio { display: none; }
body.m-app .top > .strip { display: block; margin: 0; }
body.m-app #live-pet {
    position: absolute;
    display: flex;
    align-items: center;
    left: max(12px, env(safe-area-inset-left));
    top: calc(12px + var(--m-top));
    width: 54px;
    height: 54px;
    min-height: 0;
    max-height: none;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #b29362;
    background: var(--m-control);
    box-shadow: 0 0 0 2px #292019, 0 5px 14px #080508b3;
    transition: transform 140ms ease, filter 140ms ease;
}
body.m-app #live-pet > .avatar {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: visible;
    background: radial-gradient(circle at 50% 38%, #6b4d37, #211818 85%);
}
body.m-app #live-pet::before,
body.m-app #live-pet .avatar::after,
body.m-app #live-pet :is(.pet-info, .pet-side, .plaque-flip) { display: none; }
body.m-app #live-pet .live-pet-image {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border-radius: 50%;
    object-fit: cover;
}
body.m-app #live-pet .live-pet-stub { font-size: 0; }
body.m-app #live-pet .live-pet-stub::after { content: "Кот"; font: 700 15px var(--title); color: #f5e6ce; }
body.m-app #mobile-cat-button {
    display: block;
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: inherit;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}
body.m-app #live-pet:has(#mobile-cat-button:active) { transform: scale(.94); filter: brightness(1.15); }
body.m-app #mobile-cat-button:focus-visible { outline: 2px solid #e4bd7f; outline-offset: 3px; }
.m-place {
    position: fixed;
    z-index: 22;
    top: calc(16px + var(--m-top));
    right: max(14px, env(safe-area-inset-right));
    max-width: 64vw;
    color: #fff0d1;
    font: 700 clamp(19px, 5vw, 26px)/1.1 var(--title);
    text-align: right;
    text-shadow: 0 1px 4px #100b0a, 0 2px 10px #070408;
    overflow-wrap: anywhere;
    pointer-events: none;
    opacity: 0;
    transition: opacity 220ms ease;
}
.m-place.shown { opacity: 1; }
body.mobile-chat-open .m-place { visibility: hidden; }

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

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(4, minmax(0, 1fr));
    gap: 5px;
    height: var(--m-tabs);
    box-sizing: border-box;
    padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--m-edge);
    background: var(--m-bronze);
    box-shadow: inset 0 2px #d0b28c35, 0 -6px 20px #07050799;
}
body.m-app.mobile-chat-open :is(.m-tabs, .m-sheet, .talk-inline) { display: none; }
.m-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    padding: 2px;
    border: 1px solid #65543e;
    border-radius: 7px;
    background: var(--m-control);
    box-shadow: inset 0 1px #c8ab7d40, 0 2px 5px #0d0b0a90;
    color: #f5e6ce;
    font: 700 14px/1 var(--title);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: filter 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.m-tab-icon {
    width: 36px;
    height: 36px;
    background: url("img/mobile-toolbar.webp") no-repeat 0 center / 300% 100%;
    filter: drop-shadow(0 2px 3px #140b0a);
    transition: transform 140ms ease;
}
.m-tab[data-tab="bag"] .m-tab-icon { background-image: url("/arena/island-actions.webp"); background-position-x: 50%; }
.m-tab[data-tab="journal"] .m-tab-icon { background-position-x: 50%; }
.m-tab[data-tab="more"] .m-tab-icon { background-position-x: 100%; }
.m-tab[aria-current="true"] {
    border-color: #ca9656;
    box-shadow: inset 0 0 9px #b87b3f62, inset 0 -2px #c8975b;
}
.m-tab:focus-visible { outline: 2px solid #e4bd7f; outline-offset: -3px; }
.m-tab.off .m-tab-icon { opacity: .65; }
.m-tab:active { box-shadow: inset 0 2px 7px #090605d9; filter: brightness(1.08); }
.m-tab:active .m-tab-icon { transform: scale(.92); }
.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: #782f24;
    color: #fff0d7;
    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: 10px 10px 0 0;
    background: var(--m-bronze);
    border: 1px solid var(--m-edge);
    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; }
}

/* Разговор открывается отдельным листом над меню, вместе с ответами и полями входа. */
body.m-app > .talk-inline:not([hidden]) {
    position: fixed;
    z-index: 27;
    inset: auto max(8px, env(safe-area-inset-right)) calc(var(--m-tabs) + 5px) max(8px, env(safe-area-inset-left));
    max-height: min(52dvh, 440px);
    padding: 12px 13px;
    box-sizing: border-box;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--m-edge);
    border-radius: 9px;
    background: var(--m-bronze);
    box-shadow: inset 0 1px #d5b69255, 0 10px 28px #080608bf;
    animation: m-cat-rise 220ms ease both;
}
@keyframes m-cat-rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
body.m-app .m-cat-dialog-title {
    display: block;
    margin: 0 44px 7px 0;
    padding: 0 0 7px;
    border-bottom: 1px solid #af8c5b59;
    color: #f8e4bf;
    font: 700 22px/1.15 var(--title);
}
body.m-app > .talk-inline .talk-bubble { margin: 0; padding: 0; background: none; border: 0; box-shadow: none; }
body.m-app > .talk-inline :is(.talk-says, .talk-recovery) { overflow-wrap: anywhere; }
body.m-app > .talk-inline .talk-hush {
    top: 5px; right: 5px; width: 42px; height: 42px;
    border: 0; background: none; color: #e6c791;
}
body.m-app > .talk-inline .guest-answers {
    position: static;
    display: grid;
    gap: 6px;
    justify-content: stretch;
    max-width: none;
    margin: 9px 0 0;
    padding: 0;
}
body.m-app > .talk-inline .guest-answers[hidden] { display: none; }
body.m-app > .talk-inline :is(.talk-answer, .talk-identity) { width: 100%; }
body.m-app > .talk-inline .talk-answer {
    min-height: 42px;
    border-color: #896d49;
    border-radius: 6px;
    background: var(--m-control);
}
body.m-app > .talk-inline .talk-answer:active { filter: brightness(1.18); }
body.m-app > .talk-inline #cat-guide-home:not([hidden]) { width: 100%; min-height: 42px; margin-top: 7px; }
body.m-app.m-cat-open .m-acts {
    bottom: min(calc(var(--m-tabs) + var(--m-cat-height, 0px) + 14px), 68dvh);
    transition: bottom 220ms ease;
}
body.m-app .m-sheet .online-badge { justify-self: start; align-self: flex-start; color: #ead8bc; }
body.m-app > #map-frame::before { display: none; }
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; }
@media (prefers-reduced-motion: reduce) {
    body.m-app > .talk-inline, body.m-app #live-pet, .m-place, .m-tab, .m-tab-icon,
    body.m-app.m-cat-open .m-acts { animation: none; transition: none; }
}

/* ---------------------------------------------------------------- действия на карте у правого края (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 { 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)); }
/* Охота: круглые кнопки — одним столбиком у края, надписи («Красться», «Автовыбор», приманка) — над ним
   короткими плашками; столбик ниже и уже — не налезает на подсказку и «Назад». */
.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: 48px; height: 48px;
    border: 1px solid var(--m-edge);
    border-radius: 8px;
    background: var(--m-control);
    color: #f5dfba;
}
.m-acts .act-eye svg { display: none; }
.m-acts .act-eye::after {
    content: "";
    width: 32px;
    height: 32px;
    background: url("/arena/command-icons.webp") no-repeat 50% center / 300% 100%;
    filter: drop-shadow(0 2px 3px #130c09);
}
