/* Cat Fighting — Алхимик для планшетов и VK Mini App desktop.
   Страница по центру через #content, масштаб cqw. Без изменений JS/API.
   Обычная/высшая алхимия и волшебный котёл. */
@media (min-width: 601px) and (min-height: 600px) {
    /* Оба вида алхимии: баннер, ресурсы и 4 кнопки по краям. */
    body.catfight-tablet-layout #content .forge-container.alchemy-page {
        box-sizing: border-box;
        min-width: 0;
        min-height: 0;
        padding: clamp(5px, 1.25cqw, 10px);
        border-radius: clamp(12px, 3cqw, 24px);
    }
    body.catfight-tablet-layout #content .alchemy-page .forge-banner-wrapper {
        height: clamp(160px, 40cqw, 250px) !important;
        min-width: 0;
        margin-bottom: clamp(8px, 2cqw, 16px);
        border-radius: clamp(12px, 3cqw, 24px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemyResourcesPanel,#advancedAlchemyResourcesPanel) {
        top: clamp(5px, 1.25cqw, 10px);
        left: clamp(5px, 1.25cqw, 10px);
        bottom: clamp(5px, 1.25cqw, 10px);
        padding: clamp(5px, 1.25cqw, 10px) clamp(8px, 2cqw, 16px);
        border-radius: clamp(8px, 2cqw, 16px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemyResourcesPanel,#advancedAlchemyResourcesPanel) .resource-row {
        gap: clamp(6px, 1.5cqw, 12px);
        font-size: clamp(14px, 3.5cqw, 25px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemyResourcesPanel,#advancedAlchemyResourcesPanel) .resource-row img {
        width: clamp(20px, 5cqw, 38px) !important;
        height: clamp(20px, 5cqw, 38px) !important;
        flex-shrink: 0;
    }
    body.catfight-tablet-layout #content .alchemy-page #alchemyNavButtons {
        top: clamp(3px, .75cqw, 6px) !important;
        right: clamp(8px, 2cqw, 16px) !important;
        gap: clamp(3px, .75cqw, 6px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #alchemyNavButtons .alchemy-nav-slot,
    body.catfight-tablet-layout #content .alchemy-page #alchemyNavButtons .alchemy-nav-btn {
        height: clamp(34px, 8.5cqw, 52px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #alchemyNavButtons .alchemy-nav-btn {
        width: auto !important;
        max-width: 100%;
        object-fit: contain;
    }
    body.catfight-tablet-layout #content .alchemy-page #alchemyNavButtons .cauldron-badge {
        width: clamp(16px, 4cqw, 28px) !important;
        height: clamp(16px, 4cqw, 28px) !important;
    }

    /* Выбранный предмет и его параметры, оба экрана. */
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeMainContent,#advancedAlchemyMain) {
        min-height: 0;
        min-width: 0;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeMainContent,#advancedAlchemyMain) > div:first-child {
        min-width: 0;
        gap: clamp(10px, 2.5cqw, 20px) !important;
        padding: clamp(10px, 2.5cqw, 20px) !important;
        flex-shrink: 0;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemySlot,#advancedAlchemySlot) {
        box-sizing: border-box;
        width: clamp(80px, 20cqw, 145px) !important;
        height: clamp(80px, 20cqw, 145px) !important;
        flex: 0 0 clamp(80px, 20cqw, 145px);
        font-size: clamp(14px, 3.5cqw, 25px) !important;
        border-radius: clamp(8px, 2cqw, 16px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemySlot,#advancedAlchemySlot) img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    body.catfight-tablet-layout #content .alchemy-page #alchemyItemInfo,
    body.catfight-tablet-layout #content .alchemy-page #advancedAlchemyMain > div:first-child > div:nth-child(2) {
        min-width: 0;
        padding: 0 clamp(10px, 2.5cqw, 20px) !important;
        overflow-wrap: anywhere;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemyItemName,#advancedAlchemyItemName) {
        font-size: clamp(16px, 4cqw, 30px) !important;
        line-height: 1.3;
        overflow-wrap: anywhere;
        padding-right: clamp(20px, 5cqw, 38px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemyItemClass,#advancedAlchemyItemClass,#alchemyItemStats,#advancedAlchemyItemStats) {
        font-size: clamp(13px, 3.25cqw, 24px) !important;
        line-height: 1.35;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#alchemyHelpBtn,#advancedAlchemyHelpBtn) {
        font-size: clamp(24px, 6cqw, 45px) !important;
        right: clamp(5px, 1.25cqw, 10px) !important;
        top: clamp(5px, 1.25cqw, 10px) !important;
    }

    /* Обычная алхимия: стоимость и кнопка «Наложить чары».
       Кнопка переносится при длинных ценах, инвентарь остаётся прокручиваемым. */
    body.catfight-tablet-layout #content .alchemy-page #forgeMainContent > div:nth-child(2) {
        box-sizing: border-box;
        min-width: 0;
        gap: clamp(8px, 2cqw, 16px) !important;
        padding: clamp(10px, 2.5cqw, 20px) !important;
        flex-wrap: wrap;
    }
    body.catfight-tablet-layout #content .alchemy-page #forgeMainContent > div:nth-child(2) > div {
        min-width: 0;
        font-size: clamp(13px, 3.25cqw, 25px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #forgeMainContent > div:nth-child(2) > div > img {
        width: clamp(20px, 5cqw, 38px) !important;
        height: clamp(20px, 5cqw, 38px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #enchantBtnContainer {
        flex: 1 1 clamp(140px, 35cqw, 250px);
        min-width: 0 !important;
        margin-left: 0 !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #enchantBtn {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        min-width: 0 !important;
        font-size: clamp(14px, 3.5cqw, 26px) !important;
        padding: clamp(10px, 2.5cqw, 20px) clamp(12px, 3cqw, 24px) !important;
        white-space: normal !important;
    }

    /* Высшая алхимия: 2×2 параметры, их блокировка, стоимость и действие.
       Не изменяем выбор и логику сохранения защищённых параметров. */
    body.catfight-tablet-layout #content .alchemy-page #advancedAlchemyMain {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    body.catfight-tablet-layout #content .alchemy-page #advancedLocksPanel {
        min-width: 0;
        padding: 0 clamp(10px, 2.5cqw, 20px) clamp(10px, 2.5cqw, 20px) !important;
        font-size: clamp(14px, 3.5cqw, 26px);
    }
    body.catfight-tablet-layout #content .alchemy-page #advancedLocksPanel > div:nth-child(2) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: clamp(7px, 1.75cqw, 14px) !important;
        min-width: 0;
    }
    body.catfight-tablet-layout #content .alchemy-page .advanced-parameter-card {
        min-width: 0;
        min-height: clamp(72px, 18cqw, 130px) !important;
        box-sizing: border-box;
        padding: clamp(9px, 2.25cqw, 17px) clamp(10px, 2.5cqw, 19px) !important;
        border-radius: clamp(10px, 2.5cqw, 19px) !important;
        overflow-wrap: anywhere;
    }
    body.catfight-tablet-layout #content .alchemy-page .advanced-parameter-card > div:first-child {
        font-size: clamp(12px, 3cqw, 22px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page .advanced-parameter-card > div:nth-child(2) {
        gap: clamp(7px, 1.75cqw, 13px) !important;
        font-size: clamp(14px, 3.5cqw, 26px) !important;
        flex-wrap: wrap;
    }
    body.catfight-tablet-layout #content .alchemy-page .advanced-parameter-card > div:nth-child(2) img {
        width: clamp(32px, 8cqw, 58px) !important;
        height: clamp(32px, 8cqw, 58px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page .advanced-parameter-card .fa-lock {
        font-size: clamp(27px, 6.75cqw, 48px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #advancedEnchantAction {
        min-width: 0;
        padding: 0 clamp(10px, 2.5cqw, 20px) clamp(10px, 2.5cqw, 20px) !important;
        gap: clamp(8px, 2cqw, 16px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #advancedEnchantCost {
        gap: clamp(10px, 2.5cqw, 20px) !important;
        flex-wrap: wrap;
        font-size: clamp(13px, 3.25cqw, 24px);
    }
    body.catfight-tablet-layout #content .alchemy-page #advancedEnchantCost img {
        width: clamp(18px, 4.5cqw, 34px) !important;
        height: clamp(18px, 4.5cqw, 34px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page #advancedEnchantBtn {
        min-width: 0;
        width: 100%;
        font-size: clamp(14px, 3.5cqw, 26px) !important;
        padding: clamp(10px, 2.5cqw, 20px) clamp(12px, 3cqw, 24px) !important;
        white-space: normal;
    }

    /* Список снаряжения в обоих видах алхимии. */
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeMainContent > div:last-child,#advancedAlchemyInventorySection) {
        min-width: 0;
        min-height: 0;
        padding: clamp(10px, 2.5cqw, 20px) !important;
    }
    body.catfight-tablet-layout #content .alchemy-page .forge-inventory-header {
        gap: clamp(12px, 3cqw, 24px);
        padding: clamp(10px, 2.5cqw, 20px) 0;
        font-size: clamp(18px, 4.5cqw, 34px);
        flex-shrink: 0;
    }
    body.catfight-tablet-layout #content .alchemy-page .forge-inventory-header::before,
    body.catfight-tablet-layout #content .alchemy-page .forge-inventory-header::after {
        height: clamp(2px, .5cqw, 4px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) {
        min-height: 0;
        min-width: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .inventory-item {
        min-width: 0;
        flex-shrink: 0;
        gap: clamp(12px, 3cqw, 23px);
        padding: clamp(6px, 1.5cqw, 12px) clamp(12px, 3cqw, 23px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .item-slot {
        box-sizing: border-box;
        width: clamp(52px, 13cqw, 98px);
        height: clamp(52px, 13cqw, 98px);
        flex: 0 0 clamp(52px, 13cqw, 98px);
        border-radius: clamp(8px, 2cqw, 15px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .item-slot img {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .item-content {
        min-width: 0;
        flex: 1 1 0;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .item-name {
        font-size: clamp(13px, 3.25cqw, 24px);
        overflow-wrap: anywhere;
        line-height: 1.3;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .rarity-badge {
        font-size: clamp(11px, 2.75cqw, 20px);
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .item-stats {
        font-size: clamp(12px, 3cqw, 22px) !important;
        line-height: 1.35;
    }
    body.catfight-tablet-layout #content .alchemy-page :is(#forgeInventory,#advancedAlchemyInventory) .inv-action-btn {
        box-sizing: border-box;
        width: clamp(70px, 17.5cqw, 132px);
        height: clamp(52px, 13cqw, 98px);
        flex: 0 0 clamp(70px, 17.5cqw, 132px);
        font-size: clamp(12px, 3cqw, 22px);
        padding: clamp(4px, 1cqw, 8px);
        border-radius: clamp(8px, 2cqw, 15px);
        white-space: normal;
        overflow-wrap: anywhere;
    }
    /* Результат «Было / Стало» использует общее окно roleModal.
       Подстраиваем изображения, но не изменяем обработчики принятия/отката. */
    body.catfight-tablet-layout #roleModal :is(#rollbackBtn,#acceptBtn,#advancedAcceptBtn) {
        font-size: clamp(14px, 2.5vw, 20px) !important;
        white-space: normal;
        min-width: 0;
    }
    body.catfight-tablet-layout #roleModal:has(#rollbackBtn) .modal-body > div:first-child,
    body.catfight-tablet-layout #roleModal:has(#advancedAcceptBtn) .modal-body > div:first-child {
        min-width: 0;
        gap: clamp(10px, 2vw, 20px) !important;
    }
    body.catfight-tablet-layout #roleModal:has(#rollbackBtn) .item-slot-lg,
    body.catfight-tablet-layout #roleModal:has(#advancedAcceptBtn) .item-slot-lg {
        width: clamp(60px, 10vw, 90px) !important;
        height: clamp(60px, 10vw, 90px) !important;
    }

    /* Котёл — самостоятельный экран, не имеет класса .alchemy-page. */
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) {
        box-sizing: border-box;
        min-width: 0;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: clamp(5px, 1.25cqw, 10px);
        border-radius: clamp(12px, 3cqw, 24px);
    }
    body.catfight-tablet-layout #content #backToAlchemyBtn {
        font-size: clamp(14px, 3.5cqw, 26px) !important;
        padding: clamp(8px, 2cqw, 15px) clamp(10px, 2.5cqw, 19px) !important;
        white-space: normal;
    }
    body.catfight-tablet-layout #content #cauldronHelpBtn {
        flex-shrink: 0;
        font-size: clamp(24px, 6cqw, 45px) !important;
        padding: clamp(6px, 1.5cqw, 12px);
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) .forge-inventory-header {
        font-size: clamp(18px, 4.5cqw, 34px);
        padding: clamp(10px, 2.5cqw, 20px) 0;
        gap: clamp(12px, 3cqw, 24px);
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div[style*="font-size: 15px"] {
        font-size: clamp(15px, 3.75cqw, 27px) !important;
        gap: clamp(20px, 5cqw, 36px) !important;
        flex-wrap: wrap;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div[style*="font-size: 15px"] img {
        width: clamp(20px, 5cqw, 38px) !important;
        height: clamp(20px, 5cqw, 38px) !important;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) {
        gap: clamp(12px, 3cqw, 24px) !important;
        padding: clamp(10px, 2.5cqw, 20px) !important;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) > div {
        min-width: 0;
        gap: clamp(10px, 2.5cqw, 20px) !important;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) > div > div:first-child {
        width: clamp(90px, 22.5cqw, 160px) !important;
        height: auto !important;
        min-height: clamp(80px, 20cqw, 140px);
        flex-shrink: 0;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) > div > div:nth-child(2) {
        min-width: 0;
        font-size: clamp(13px, 3.25cqw, 24px);
        overflow-wrap: anywhere;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) > div > div:nth-child(2) > div:first-child {
        font-size: clamp(18px, 4.5cqw, 34px) !important;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) > div > div:nth-child(2) > div:nth-child(2) {
        font-size: clamp(13px, 3.25cqw, 24px) !important;
    }
    body.catfight-tablet-layout #content .forge-container:has(#cauldronProgressContainer) > div:nth-last-child(2) > div > div:nth-child(2) > div:nth-child(3) {
        font-size: clamp(14px, 3.5cqw, 26px) !important;
    }
    body.catfight-tablet-layout #content .upgrade-cauldron-btn {
        box-sizing: border-box;
        min-width: clamp(90px, 22.5cqw, 160px) !important;
        padding: clamp(8px, 2cqw, 15px) clamp(10px, 2.5cqw, 19px) !important;
        font-size: clamp(12px, 3cqw, 23px) !important;
        white-space: normal;
    }
    body.catfight-tablet-layout #content .upgrade-cauldron-btn img {
        width: clamp(16px, 4cqw, 29px) !important;
        height: clamp(16px, 4cqw, 29px) !important;
    }
    body.catfight-tablet-layout #content #cauldronProgressContainer {
        height: clamp(48px, 12cqw, 88px) !important;
        border-radius: clamp(24px, 6cqw, 44px) !important;
    }
    body.catfight-tablet-layout #content #cauldronTimer {
        font-size: clamp(16px, 4cqw, 29px) !important;
    }
}
