        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --cob-bg-1: #1a1a2e;
            --cob-bg-2: #16213e;
            --cob-bg-3: #0f3460;
            --cob-glass: rgba(255, 255, 255, 0.06);
            --cob-glass-2: rgba(255, 255, 255, 0.12);
            --cob-border: rgba(255, 255, 255, 0.18);
            --cob-accent: #4ecdc4;
            --cob-accent-2: #45b7d1;
            --cob-danger: #ff6b6b;
            --cob-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
        }

        html {
            -webkit-text-size-adjust: 100%;
        }

        body {
            font-family: 'Germania One', 'Open Sans', sans-serif;
            background: linear-gradient(135deg, var(--cob-bg-1) 0%, var(--cob-bg-2) 50%, var(--cob-bg-3) 100%);
            color: #fff;
            min-height: 100vh;
            min-height: 100dvh;
            margin: 0;
            overflow-x: hidden;
        }

        /* === Effect token styling (spans from parseCardEffect) === */
        .mana { color: #4ecdc4; font-weight: 700; }
        .threshold { color: #ff6b6b; font-weight: 700; }
        .special { color: #ffd700; font-weight: 600; }
        .op-to { color: #ffd700; font-weight: 800; padding: 0 6px; }
        .op-or { color: #45b7d1; font-weight: 800; padding: 0 6px; }

        .game-container {
            display: grid;
            grid-template-columns: 300px 1fr 300px;
            grid-template-rows: auto auto auto 1fr;
            min-height: 100vh;
            min-height: 100dvh;
            height: auto;
            gap: 10px;
            padding: 10px;
            width: 100%;
            max-width: 100vw;
            box-sizing: border-box;
        }

        /* Заголовок */
        .header {
            grid-column: 1 / -1;
            grid-row: 1;
            position: relative;
            z-index: 100;
            background: rgba(139, 86, 86, 0.1);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 15px;
            padding: 15px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            pointer-events: auto;
        }
        
        /* ИИ зона сверху */
        .ai-top-zone {
            grid-column: 1 / -1;
            grid-row: 2;
            background: rgba(255, 107, 107, 0.1);
            border: 2px solid rgba(255, 107, 107, 0.3);
            border-radius: 10px;
            padding: 5px; /* Уменьшаем padding */
            display: flex;
            align-items: center;
            gap: 8px; /* Уменьшаем расстояние между элементами */
            min-height: 110px; /* Высота зоны ИИ */
            max-height: 110px; /* Ограничиваем максимальную высоту */
            overflow: hidden; /* Скрываем переполнение */
        }
        
        .ai-stats-column {
            display: flex;
            flex-direction: column;
            gap: 3px; /* Уменьшаем gap с 5px до 3px */
            flex-shrink: 0;
            font-size: 0.85rem;
            min-width: 120px;
        }
        
        .ai-stats-column .stat {
            padding: 3px 6px; /* Уменьшаем padding */
            font-size: 0.85rem;
        }
        
        .card-back-button {
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            flex-shrink: 0 !important;
            position: relative;
            z-index: 10;
        }
        
        .card-back-button:hover {
            transform: scale(1.1);
            box-shadow: 0 0 10px rgba(78, 205, 196, 0.6);
        }
        
        .ai-hand-zone {
            flex: 1; /* Возвращаем ширину зоны руки ИИ */
            display: flex;
            align-items: center;
            gap: 5px; /* Уменьшаем gap с 10px до 5px */
            min-width: 0;
            overflow: hidden; /* Скрываем переполнение */
            max-height: 110px; /* Ограничиваем высоту зоны карт */
        }
        
        .ai-hand-zone .hand {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 5px; /* Уменьшаем gap с 10px до 5px */
            overflow-x: auto;
            width: 100%;
            padding: 3px 0; /* Уменьшаем padding */
            max-height: 110px; /* Ограничиваем высоту контейнера карт */
            align-items: center; /* Выравниваем карты по центру вертикально */
        }
        
        .ai-hand-zone .hand .card {
            width: 70px !important; /* Уменьшенный размер карт ИИ для полоски */
            min-height: 98px !important; /* Уменьшенный размер карт ИИ */
            max-height: 98px !important; /* Уменьшенный размер карт ИИ */
            font-size: 0.65rem !important; /* Уменьшенный размер шрифта */
            flex-shrink: 0;
            margin: 0;
            padding: 0;
        }
        
        .ai-hand-toggle-btn {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            border: 2px solid rgba(255, 255, 255, 0.4);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.2rem;
            transition: all 0.3s;
            flex-shrink: 0;
        }
        
        .ai-hand-toggle-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }
        
        .ai-hand-toggle-btn.visible {
            background: rgba(100, 200, 255, 0.4);
            border-color: rgba(100, 200, 255, 0.6);
        }
        
        .ai-attire-zone {
            display: flex;
            align-items: center;
            gap: 3px; /* Уменьшаем gap еще больше */
            flex-shrink: 1; /* Позволяем сжиматься при необходимости */
            min-width: 0; /* Позволяем сжиматься меньше минимального размера контента */
            max-width: 100%; /* Не выходим за границы родителя */
            padding: 3px; /* Добавляем небольшой padding для уменьшения окна */
            overflow-x: auto; /* Добавляем горизонтальный скролл при необходимости */
            overflow-y: hidden; /* Скрываем вертикальный скролл */
        }
        
        .ai-attire-zone .attire-area {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 3px; /* Уменьшаем gap с 5px до 3px */
            min-width: 0; /* Позволяем сжиматься */
        }
        
        .ai-attire-zone .attire-area .card {
            width: 100px !important; /* Такой же размер как у игрока */
            min-height: 140px !important; /* Такой же размер как у игрока */
            max-height: 180px !important; /* Такой же размер как у игрока */
            font-size: 0.8rem !important; /* Такой же размер как у игрока */
            flex-shrink: 0;
        }

        .game-title {
            font-family: 'Cinzel', serif;
            font-size: 1.8rem;
            font-weight: 600;
        }

        .nav-buttons {
            display: flex;
            gap: 10px;
        }

        .btn {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.22);
            color: #fff;
            padding: 8px 16px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
            box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
            backdrop-filter: blur(8px);
        }
        
        .admin-btn {
            background: rgba(255, 107, 107, 0.2);
            border: 1px solid rgba(255, 107, 107, 0.5);
            color: #ff6b6b;
            padding: 6px 10px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            font-weight: bold;
            box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
        }
        
        .admin-btn:hover {
            background: rgba(255, 107, 107, 0.4);
            border-color: rgba(255, 107, 107, 0.7);
            transform: scale(1.05);
        }
        
        .admin-btn:active {
            transform: scale(0.95);
        }

        #admin-panel {
            display: none; /* По умолчанию скрыта */
            transition: all 0.3s ease;
            /* Override inline styles to look cleaner (still "danger" themed) */
            background: rgba(15, 20, 35, 0.65) !important;
            border: 1px solid rgba(255, 107, 107, 0.35) !important;
            box-shadow: var(--cob-shadow);
            backdrop-filter: blur(10px);
        }

        #admin-panel.visible {
            display: block;
        }

        .admin-controls {
            display: flex;
            gap: 10px;
            margin-top: 10px;
            justify-content: center;
        }

        .btn:hover {
            background: rgba(255, 255, 255, 0.14);
            transform: translateY(-1px);
        }

        .btn.primary {
            background: linear-gradient(45deg, var(--cob-accent), var(--cob-accent-2));
            border-color: transparent;
        }

        .btn:active {
            transform: translateY(0);
        }

        .btn:focus-visible,
        .admin-btn:focus-visible {
            outline: 2px solid rgba(78, 205, 196, 0.85);
            outline-offset: 2px;
        }

        /* Панели игроков */
        .player-panel {
            background: rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
            overflow-y: auto;
        }

        .panel-title {
            font-family: 'Cinzel', serif;
            font-size: 1.3rem;
            margin-bottom: 15px;
            text-align: center;
            color: #4ecdc4;
        }

        .player-stats {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            padding: 15px;
            margin-bottom: 15px;
        }

        .stat-item {
            display: flex;
            justify-content: space-between;
            margin-bottom: 8px;
        }

        .stat-value {
            font-weight: 600;
            color: #4ecdc4;
        }

        /* HP should be very visible */
        #player-hp, #ai-hp {
            font-size: 1.9rem;
            font-weight: 900;
            color: #51cf66;
            text-shadow: 0 2px 10px rgba(0,0,0,0.7);
            background: rgba(0, 0, 0, 0.35);
            border: 1px solid rgba(81, 207, 102, 0.35);
            padding: 4px 10px;
            border-radius: 999px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 56px;
        }

        /* === Attire: per-turn property badges (A/B/C) === */
        .attire-effect-badges {
            position: absolute;
            top: 6px;
            right: 6px;
            display: inline-flex;
            gap: 4px;
            padding: 4px 6px;
            border-radius: 999px;
            background: rgba(0, 0, 0, 0.55);
            border: 1px solid rgba(255, 255, 255, 0.18);
            backdrop-filter: blur(6px);
            z-index: 20;
            pointer-events: none; /* не мешаем клику по карте */
        }

        .attire-effect-badge {
            width: 22px;
            height: 22px;
            border-radius: 7px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: 900;
            font-size: 0.85rem;
            line-height: 1;
            border: 1px solid rgba(255, 255, 255, 0.22);
            box-shadow: 0 2px 6px rgba(0,0,0,0.35);
        }

        .attire-effect-badge.available {
            background: rgba(0, 255, 128, 0.85);
            color: #062014;
        }

        .attire-effect-badge.used {
            background: rgba(255, 107, 107, 0.88);
            color: #2a0000;
        }

        /* Карты */
        .card {
            background: linear-gradient(145deg, #2c3e50, #34495e);
            border: 2px solid #3498db;
            border-radius: 15px;
            padding: 12px;
            margin: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            min-height: 150px;
            position: relative;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
            font-family: 'Germania One', sans-serif;
            letter-spacing: 0.5px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }
        
        .card.with-image {
            color: white;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
            background-size: cover !important;
            background-position: center center !important;
            background-repeat: no-repeat !important;
        }
        
        /* Стили для изображений карт в игре - заполняют всю карту */
        .card-image {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 15px;
            object-fit: cover;
            z-index: 0;
        }
        
        .card-image-sprite {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 15px;
            z-index: 0;
            /* background-size и background-position устанавливаются через inline стили из sprite-utils.js */
            background-repeat: no-repeat;
            /* background-size будет установлен через inline стили из sprite-utils.js */
        }
        
        /* Специальный стиль для спрайт-листов - не перекрываем background-size */
        .card.with-sprite {
            background: transparent !important; /* Убираем фон карты для спрайт-листа */
        }
        
        /* Все элементы карты должны быть поверх изображения */
        .card.with-image .card-name,
        .card.with-image .card-cost,
        .card.with-image .card-type,
        .card.with-image .card-effect,
        .card.with-image .card-type-icon,
        .card.with-image .card-clean-space,
        .card.with-sprite .card-name,
        .card.with-sprite .card-cost,
        .card.with-sprite .card-type,
        .card.with-sprite .card-effect,
        .card.with-sprite .card-type-icon,
        .card.with-sprite .card-clean-space {
            position: relative;
            z-index: 1;
        }
        
        .card.with-image .card-name,
        .card.with-image .card-cost {
            background: rgba(0,0,0,0.8);
            padding: 5px 8px;
            border-radius: 6px;
            margin: 2px 0;
            backdrop-filter: blur(5px);
        }
        
        .card.with-image .card-clean-space::before {
            background: rgba(0,0,0,0.8);
            padding: 4px 8px;
            border-radius: 4px;
            backdrop-filter: blur(5px);
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        .card.card-back {
            color: white;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
        }
        
        .card.card-back .card-name,
        .card.card-back .card-cost,
        .card.card-back .card-type,
        .card.card-back .card-effect {
            background: rgba(0,0,0,0.9);
            padding: 5px 8px;
            border-radius: 5px;
            margin: 2px 0;
            border: 1px solid rgba(255,255,255,0.3);
        }

        .card:hover {
            transform: translateY(-2px) scale(1.04);
            transform-origin: center center;
            border-color: var(--cob-accent);
            box-shadow: 0 22px 44px rgba(0, 0, 0, 0.45);
            background: linear-gradient(145deg, #34495e, #3c5f75);
            z-index: 10;
        }
        
        /* Модальное окно для большого просмотра карт */
        .card-preview-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            backdrop-filter: blur(10px);
        }
        
        .card-preview-content {
            max-width: 90vw;
            max-height: 90vh;
            width: auto;
            height: auto;
            min-width: 300px;
            min-height: 420px;
            position: relative;
            animation: cardZoomIn 0.3s ease;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .card-preview-content .card {
            width: 100% !important;
            height: 100% !important;
            margin: 0 !important;
            font-size: 1.2rem !important;
            cursor: default;
            transform: none !important;
            max-width: 400px;
            max-height: 560px;
            aspect-ratio: 5/7;
            object-fit: contain;
        }
        
        /* Отрисовка фоновых картинок на карточках без обрезки */
        .card.with-image {
            background-size: contain;
            background-position: center center;
            background-repeat: no-repeat;
        }
        .card.no-image {
            background: linear-gradient(145deg, #2c3e50, #34495e);
        }
        
        .card-preview-close {
            position: absolute;
            top: -40px;
            right: 0;
            background: #e74c3c;
            color: white;
            border: none;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            cursor: pointer;
            font-size: 18px;
        }
        
        @keyframes cardZoomIn {
            from { transform: scale(0.5); opacity: 0; }
            to { transform: scale(1); opacity: 1; }
        }

        /* Tooltip для карт */
        .card-tooltip {
            position: fixed;
            background: linear-gradient(145deg, #2c3e50, #34495e);
            border: 2px solid #3498db;
            border-radius: 15px;
            padding: 15px;
            color: white;
            font-family: 'Germania One', sans-serif;
            font-size: 0.9rem;
            z-index: 1001;
            min-width: 250px;
            max-width: 350px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
            pointer-events: none;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
        }

        .card-tooltip.show {
            opacity: 1;
            transform: translateY(0);
        }

        .tooltip-name {
            font-size: 1.1rem;
            color: #4ecdc4;
            margin-bottom: 8px;
            border-bottom: 1px solid rgba(76, 205, 196, 0.3);
            padding-bottom: 5px;
            text-align: center;
        }

        .tooltip-cost {
            background: linear-gradient(145deg, #e74c3c, #c0392b);
            color: white;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            float: right;
            margin-bottom: 10px;
            border: 2px solid #fff;
        }

        .tooltip-effects {
            clear: both;
            line-height: 1.4;
            margin-top: 8px;
        }

        .tooltip-type {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            padding: 5px 10px;
            margin: 5px 0;
            font-size: 0.8rem;
            text-align: center;
            color: #bbb;
        }

        .card-name {
            font-family: 'Germania One', sans-serif;
            font-weight: 600;
            margin-bottom: 8px;
            color: #4ecdc4;
            font-size: 1.1rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
            text-align: center;
            border-bottom: 1px solid rgba(76, 205, 196, 0.3);
            padding-bottom: 5px;
        }

        .card-cost {
            position: absolute;
            top: 8px;
            right: 8px;
            background: linear-gradient(145deg, #e74c3c, #c0392b);
            color: white;
            border-radius: 50%;
            width: 35px;
            height: 35px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Germania One', sans-serif;
            font-weight: bold;
            font-size: 1rem;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
            border: 2px solid #fff;
        }

        .card-clean-space {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Germania One', sans-serif;
            font-size: 0.8rem;
            color: rgba(255, 255, 255, 0.3);
            font-style: italic;
            text-align: center;
            margin-top: 10px;
        }
        
        .card-clean-space::before {
            content: "Наведи для деталей • Ctrl+Click для увеличения";
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .card:hover .card-clean-space::before {
            opacity: 1;
        }



        .card-type-icon {
            position: absolute;
            top: 8px;
            left: 8px;
            background: rgba(0, 0, 0, 0.7);
            border-radius: 50%;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1rem;
            border: 1px solid rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(5px);
        }

        .card-modal-effects {
            font-family: 'Germania One', sans-serif;
            font-size: 1rem;
            color: #e8e8e8;
            line-height: 1.5;
            margin-top: 15px;
            padding: 15px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(5px);
            flex: 1;
        }

        /* Стили для эффектов карт */
        .card-effects .damage { color: #ff6b6b; font-weight: bold; }
        .card-effects .blessing { color: #4ecdc4; font-weight: bold; }
        .card-effects .heal { color: #51cf66; font-weight: bold; }
        .card-effects .poison { color: #8e44ad; font-weight: bold; }
        .card-effects .bleed { color: #e74c3c; font-weight: bold; }
        .card-effects .draw { color: #3498db; font-weight: bold; }
        .card-effects .stun { color: #f39c12; font-weight: bold; }
        .card-effects .trash { color: #95a5a6; font-weight: bold; }
        .card-effects .def-y { color: #2ecc71; font-weight: bold; }
        .card-effects .def-n { color: #e67e22; font-weight: bold; }
        .card-effects .trigger { color: #ffd700; font-weight: bold; border-bottom: 1px dotted #ffd700; }

        /* Интерактивные цели для атаки */
        .attack-target {
            cursor: pointer;
            transition: all 0.3s ease;
            border-radius: 8px;
            padding: 5px;
        }
        
        .attack-target:hover {
            background: rgba(255, 107, 107, 0.2);
            box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
            transform: scale(1.05);
        }
        
        /* Короткий зум при активации карты */
        .played-card.zoomed {
            position: relative;
            z-index: 5;
            transform: scale(1.12);
            box-shadow: 0 0 16px rgba(255, 215, 0, 0.7);
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }
        
        .protected-attire {
            border: 2px solid #2ecc71 !important;
            box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
        }

        /* Модальное окно для просмотра сброса */
        .discard-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            z-index: 1000;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .discard-modal-content {
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 15px;
            padding: 20px;
            width: 80%;
            max-width: 800px;
            max-height: 80%;
            overflow-y: auto;
        }

        .discard-modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            padding-bottom: 10px;
        }

        .discard-modal-cards {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
        }

        .discard-modal-close {
            background: #ff6b6b;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
        }

        /* Настройки игры */
        .game-settings {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .settings-content {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 20px;
            padding: 40px;
            text-align: center;
            min-width: 400px;
        }

        .settings-content h2 {
            color: #4ecdc4;
            margin-bottom: 30px;
            font-size: 28px;
        }

        .setting-group {
            margin: 20px 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .setting-group label {
            color: white;
            font-size: 18px;
            font-weight: bold;
        }

        .setting-group input {
            background: rgba(255, 255, 255, 0.2);
            border: 1px solid rgba(255, 255, 255, 0.3);
            border-radius: 10px;
            padding: 8px 12px;
            color: white;
            font-size: 16px;
            width: 100px;
            text-align: center;
        }

        .start-game-btn {
            background: linear-gradient(45deg, #4ecdc4, #44a08d);
            color: white;
            border: none;
            padding: 15px 30px;
            border-radius: 15px;
            cursor: pointer;
            font-size: 20px;
            font-weight: bold;
            margin-top: 30px;
            transition: all 0.3s ease;
        }

        .start-game-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4);
        }

        /* Layout containers for adaptive placement */
        .top-row-section {
            display: flex;
            gap: 10px;
            align-items: stretch;
            max-height: 320px;
        }
        
        .market-section {
            flex: 3;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 8px 10px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            max-height: 320px;
        }

        .market {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            justify-content: center;
        }

        .market .card {
            width: 170px !important;
            min-height: 238px !important;
            max-height: 270px !important;
            font-size: 1rem !important;
            flex-shrink: 0;
        }

        /* Секция монстров */
        .monsters-section {
            flex: 1;
            background: linear-gradient(135deg, #2d1b69 0%, #1a1a2e 50%, #16213e 100%);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 15px;
            padding: 8px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            min-width: 360px; /* Расширяем зону монстров для алтаря */
            max-width: 100%; /* Не выходить за границы */
            overflow: hidden; /* Скрывать переполнение */
        }

        .monster-deck {
            margin-bottom: 15px;
            text-align: center;
        }

        .deck-info {
            color: #95a5a6;
            font-size: 14px;
            padding: 5px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 5px;
        }

        .monster-area {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 120px;
        }

        .no-monster {
            color: #95a5a6;
            font-style: italic;
            font-size: 18px;
        }

        .played-cards-section {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            padding: 10px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            min-height: 180px;
            display: flex;
            gap: 10px;
            align-items: stretch;
            overflow-x: auto; /* Разрешаем горизонтальный скролл если нужно */
        }
        
        .player-equipment-left {
            background: rgba(100, 150, 255, 0.1);
            border-radius: 10px;
            padding: 5px;
            display: flex;
            flex-direction: row;
            gap: 3px;
            flex-wrap: nowrap;
            overflow: visible; /* Видим все карты */
            flex-shrink: 0;
            min-width: 110px; /* Минимум для 1 карты */
            width: fit-content; /* Подстраивается под содержимое */
            max-width: 100%; /* Не выходит за границы контейнера */
        }
        
        .player-equipment-left .attire-area {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 5px;
            align-items: flex-start;
            min-height: 140px;
            height: auto; /* Автоматическая высота */
            overflow: visible; /* Видим все карты */
        }
        
        .player-equipment-left .attire-area .card,
        #player-attire .card {
            width: 100px;
            min-height: 140px;
            max-height: none; /* Убираем ограничение высоты */
            height: 140px;
            font-size: 0.8rem;
            flex-shrink: 0;
            overflow: visible; /* Видим всю карту */
        }
        
        /* Дублирующие стили удалены - используются стили выше */
        
        .played-center {
            flex: 1;
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-width: 0;
            overflow-x: auto; /* Разрешаем скролл если карт много */
        }
        
        .played-header {
            display: flex;
            align-items: center;
            gap: 20px;
            padding-bottom: 8px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            flex-wrap: wrap;
        }
        
        .play-area-info {
            display: flex;
            gap: 15px;
            align-items: center;
            flex-wrap: wrap;
        }
        
        .play-area-resources {
            display: flex;
            gap: 15px;
            align-items: center;
        }
        
        .play-area-info .effect-stats {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
        }
        
        .resource-stat {
            background: rgba(255, 255, 255, 0.1);
            padding: 6px 14px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: bold;
            color: #4ecdc4;
            white-space: nowrap;
        }
        
        .resource-stat span {
            color: #ffffff;
            font-size: 1.1rem;
        }
        
        .resource-stat.primary {
            background: rgba(78, 205, 196, 0.2);
            border: 2px solid rgba(78, 205, 196, 0.4);
            padding: 8px 16px;
        }
        
        .resource-stat.primary span {
            font-size: 1.4rem;
            font-weight: 900;
        }
        
        .played-center .played-area {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            align-items: flex-start;
            overflow-y: auto;
        }
        
        .controls-right {
            flex: 0 0 180px;
            display: none; /* дублирует кнопки снизу; скрываем чтобы всё влезало в экран */
            flex-direction: column;
            gap: 10px;
            align-items: stretch;
        }
        
        .controls-right .btn {
            width: 100%;
        }
        
        .controls-right .turn-info {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            padding: 10px;
            text-align: center;
            margin-top: auto;
        }

        .player-bottom-zone {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            padding: 8px 12px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            gap: 12px;
            align-items: center;
            min-height: 150px;
        }
        
        .player-stats-compact {
            flex: 0 0 200px;
            display: flex;
            flex-direction: column;
            gap: 8px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 10px;
            padding: 10px;
        }
        
        .player-hand-horizontal {
            flex: 1;
            min-width: 0;
            display: flex;
            align-items: center;
        }
        
        .player-hand-horizontal .hand {
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            gap: 10px;
            overflow-x: auto;
            width: 100%;
            padding: 6px 0;
        }
        
        .player-side {
            flex: 1;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 15px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .left-side {
            border: 2px solid rgba(78, 205, 196, 0.3);
            grid-column: 1;
            grid-row: 4;
        }

        .right-side {
            border: 2px solid rgba(255, 107, 107, 0.3);
            grid-column: 3;
            grid-row: 4;
        }
        .center-control {
            flex: 0 0 200px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 20px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            padding: 20px;
        }

        .player-header h2 {
            margin: 0;
            color: #4ecdc4;
            text-align: center;
        }

        .base-stats {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: space-between;
            background: rgba(0, 0, 0, 0.3);
            padding: 10px;
            border-radius: 10px;
        }

        .base-stats .stat {
            flex: 1;
            min-width: 80px;
            text-align: center;
            padding: 5px;
            border-radius: 5px;
            background: rgba(255, 255, 255, 0.1);
        }

        .effect-stats {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            min-height: 30px;
        }

        .effect-item {
            background: rgba(255, 255, 255, 0.2);
            padding: 4px 8px;
            border-radius: 5px;
            font-size: 12px;
            color: #fff;
        }

        .hand-section, .attire-section, .discard-section {
            flex: 1;
        }

        .hand {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            min-height: 200px;
            max-height: 600px;
            overflow-y: auto;
            background: rgba(0, 0, 0, 0.3);
            padding: 15px;
            border-radius: 15px;
            border: 2px solid rgba(255, 255, 255, 0.1);
        }

        .hand .card {
            width: 170px !important;
            min-height: 238px !important;
            max-height: 270px !important;
            font-size: 1rem !important;
            margin: 5px !important;
            flex-shrink: 0;
        }

        .attire-area {
            display: flex;
            flex-wrap: nowrap; /* Горизонтальное расположение без переноса */
            gap: 8px;
            min-height: 100px;
            max-height: 150px;
            overflow-x: visible; /* Без скролла */
            overflow-y: hidden; /* Убираем вертикальный скролл */
            background: rgba(0, 0, 0, 0.2);
            padding: 10px;
            border-radius: 10px;
        }

        .discard-area {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            min-height: 80px;
            max-height: 120px;
            overflow-y: auto;
            background: rgba(0, 0, 0, 0.2);
            padding: 8px;
            border-radius: 10px;
        }

        .discard-area .card {
            width: 80px !important;
            min-height: 60px !important;
            max-height: 80px !important;
            font-size: 0.7rem !important;
            margin: 1px !important;
        }

        .played-area {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            min-height: 200px;
            background: rgba(0, 0, 0, 0.2);
            padding: 20px;
            border-radius: 12px;
            border: 2px solid rgba(255, 255, 255, 0.1);
        }
        .played-area .card {
            width: 81px !important;
            min-height: 108px !important;
            max-height: 126px !important;
            font-size: 0.675rem !important;
            margin: 3px !important;
            flex-shrink: 0;
        }

        .no-items, .hidden-hand {
            color: #666;
            font-style: italic;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 100%;
        }

        .turn-info {
            text-align: center;
            color: #ccc;
        }

        .turn-info div {
            margin: 5px 0;
        }

        /* Лог игры - выдвижная шторка справа */
        .game-log-drawer {
            position: fixed;
            right: 0;
            top: 80px;
            width: 50vw;
            max-width: 600px;
            height: calc(100vh - 100px);
            background: rgba(26, 26, 46, 0.95);
            backdrop-filter: blur(10px);
            border-left: 2px solid rgba(255, 255, 255, 0.2);
            border-radius: 15px 0 0 15px;
            box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
            transform: translateX(100%);
            transition: transform 0.3s ease;
            z-index: 500;
            display: flex;
            flex-direction: column;
        }
        
        .game-log-drawer:not(.open) {
            pointer-events: none; /* не перехватывать клики в закрытом состоянии */
        }
        .game-log-drawer.open {
            transform: translateX(0);
        }
        
        .game-log-header {
            padding: 15px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: rgba(0, 0, 0, 0.3);
        }
        
        .game-log-header h3 {
            margin: 0;
            font-size: 1.2rem;
            color: #4ecdc4;
        }
        
        .game-log-toggle {
            position: fixed;
            right: 0;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(26, 26, 46, 0.9);
            border: 2px solid rgba(255, 255, 255, 0.2);
            border-right: none;
            border-radius: 10px 0 0 10px;
            padding: 15px 10px;
            cursor: pointer;
            z-index: 499;
            transition: all 0.3s ease;
            writing-mode: vertical-rl;
            text-orientation: mixed;
            font-size: 1rem;
            color: #fff;
        }
        
        .game-log-toggle:hover {
            background: rgba(26, 26, 46, 1);
            padding-right: 15px;
        }
        
        .game-log-content {
            flex: 1;
            overflow-y: auto;
            padding: 15px;
            font-size: 12px;
            color: #ddd;
        }
        
        .game-log {
            background: transparent;
        }
        
        .game-log div {
            margin: 4px 0;
            padding: 6px 10px;
            border-radius: 5px;
            word-wrap: break-word;
        }

        .game-log .player1 {
            background: rgba(78, 205, 196, 0.2);
            border-left: 3px solid #4ecdc4;
        }

        .game-log .player2 {
            background: rgba(255, 107, 107, 0.2);
            border-left: 3px solid #ff6b6b;
        }
        
        .game-log .system {
            background: rgba(255, 255, 255, 0.1);
            border-left: 3px solid #ccc;
        }

        /* Игровая зона */
        .game-area {
            background: rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 15px;
            padding: 20px;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .section {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 10px;
            padding: 15px;
        }

        .section-title {
            font-family: 'Cinzel', serif;
            font-size: 1.1rem;
            margin-bottom: 10px;
            color: #4ecdc4;
        }

        .hand-area {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            min-height: 150px;
            max-height: 200px;
            overflow-y: auto;
        }

        .market-area {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 10px;
            max-height: 250px;
            overflow-y: auto;
        }

        .log-area {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 8px;
            padding: 10px;
            height: 150px;
            overflow-y: auto;
            font-size: 0.85rem;
            line-height: 1.4;
        }

        .log-entry {
            margin-bottom: 3px;
        }

        .log-entry.player1 { color: #4ecdc4; }
        .log-entry.player2 { color: #ff6b6b; }
        .log-entry.system { color: #ffd93d; }

        /* Модальные окна */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.8);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        
        #choice-modal {
            z-index: 2000; /* Выше других модальных окон */
        }

        .modal-content {
            background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 15px;
            padding: 30px;
            max-width: 90vw;
            width: auto;
            max-height: 90vh;
            overflow-y: auto;
            position: relative;
        }

        .close-modal {
            position: absolute;
            top: 15px;
            right: 20px;
            background: none;
            border: none;
            color: #fff;
            font-size: 1.5rem;
            cursor: pointer;
            line-height: 1;
        }

        .choice-grid {
            display: flex;
            /* flex-direction задается динамически через inline стили */
            gap: 15px;
            margin-top: 20px;
        }

        .choice-card {
            background: rgba(240, 240, 250, 0.95);
            border: 2px solid rgba(78, 205, 196, 0.5);
            border-radius: 10px;
            padding: 15px;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            justify-content: center;
            flex: 1;
            min-height: 100px;
            color: #222;
            margin: 5px;
            text-align: left;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            position: relative;
        }
        
        .choice-card > div {
            width: 100%;
        }

        .choice-card:hover,
        .choice-card.selected {
            border-color: #4ecdc4;
            background: rgba(78, 205, 196, 0.2);
        }
        
        .choice-card.skip-choice {
            background: rgba(255, 240, 240, 0.95);
            border-color: #ff6b6b;
            color: #cc0000;
        }
        
        .choice-card.skip-choice:hover {
            background: rgba(255, 220, 220, 0.95);
            border-color: #ff4444;
            transform: translateY(-2px) scale(1.02);
        }

        .choice-card.choice-card--card {
            align-items: center;
            text-align: center;
            min-height: 240px;
        }

        .choice-card.disabled {
            opacity: 0.55;
            cursor: not-allowed;
        }

        .choice-message {
            margin-top: 10px;
            color: rgba(255, 255, 255, 0.85);
            font-size: 0.95rem;
            line-height: 1.35;
        }

        .choice-hint {
            margin-top: 10px;
            color: rgba(255, 255, 255, 0.65);
            font-size: 0.85rem;
        }

        .choice-warning {
            margin-top: 10px;
            padding: 10px 12px;
            border-radius: 10px;
            background: rgba(255, 107, 107, 0.18);
            border: 1px solid rgba(255, 107, 107, 0.35);
            color: #ffdede;
            font-size: 0.9rem;
        }

        .choice-preview-btn {
            position: absolute;
            top: 8px;
            right: 8px;
            border: 1px solid rgba(255,255,255,0.25);
            background: rgba(0,0,0,0.55);
            color: #fff;
            border-radius: 10px;
            padding: 6px 8px;
            cursor: pointer;
            backdrop-filter: blur(6px);
        }

        .choice-preview-btn:hover {
            background: rgba(0,0,0,0.75);
        }

        .choice-disabled-reason {
            margin-top: 8px;
            font-size: 0.8rem;
            color: rgba(255, 107, 107, 0.95);
            text-align: center;
        }

        .card.compact .card-clean-space::before {
            content: "";
        }

        /* Цвета карт */
        .card.red { border-left: 4px solid #ff4444; }
        .card.blue { border-left: 4px solid #4444ff; }
        .card.green { border-left: 4px solid #44ff44; }
        .card.white { border-left: 4px solid #ffffff; }
        .card.attire { border: 2px solid #ffd700; }
        
        /* Подсветка карт для различных эффектов */
        .card.highlighted {
            transform: scale(1.05);
            transition: all 0.3s ease;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
        }
        
        .card.highlighted-acquire {
            border: 3px solid #4ecdc4;
            box-shadow: 0 0 20px rgba(78, 205, 196, 0.8);
        }
        
        .card.highlighted-destroy {
            border: 3px solid #ff6b6b;
            box-shadow: 0 0 20px rgba(255, 107, 107, 0.8);
        }
        
        .card.highlighted-stun {
            border: 3px solid #ffd93d;
            box-shadow: 0 0 20px rgba(255, 217, 61, 0.8);
        }

        /* Адаптивность */
        @media (max-width: 1200px) {
            .game-container {
                grid-template-columns: 250px 1fr 250px;
            }
        }

        @media (max-width: 900px) {
            .game-container {
                grid-template-columns: 1fr;
                grid-template-rows: auto auto 1fr auto;
            }
            
            .player-panel {
                order: 1;
            }
            
            .game-area {
                order: 2;
            }
        }

        /* Карты монстров - такой же размер как на рынке */
        .monster-area .card {
            width: 200px !important;
            min-height: 280px !important;
            max-height: 320px !important;
            font-size: 1rem !important;
            flex-shrink: 0;
        }
        
        /* Кнопка атаки монстра */
        #attack-monster-btn {
            background: linear-gradient(45deg, #ff6b6b, #ee5a24);
            border: 2px solid #c44569;
            color: white;
            font-weight: bold;
            padding: 12px 20px;
            border-radius: 10px;
            font-size: 1.1rem;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
            box-shadow: 0 4px 8px rgba(0,0,0,0.3);
            transition: all 0.3s ease;
        }
        
        #attack-monster-btn:hover {
            background: linear-gradient(45deg, #ff5252, #d63031);
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.4);
        }
        
        #attack-monster-btn:disabled {
            background: #95a5a6;
            cursor: not-allowed;
            transform: none;
        }

        /* Кнопка смены монстра (стрелки по кругу) */
        .change-monster-btn {
            background: linear-gradient(45deg, #6c5ce7, #a29bfe);
            border: 2px solid #5b4fd4;
            color: white;
            font-weight: 600;
            padding: 8px 14px;
            border-radius: 10px;
            font-size: 0.95rem;
            transition: all 0.25s ease;
        }
        .change-monster-btn:hover {
            background: linear-gradient(45deg, #5b4fd4, #8b7de8);
        }

        /* === Clean board layout (reset, keep JS logic intact) === */
        :root {
            --board-gap: 12px;
            /* Card size used for market + altar + monster (fits 1080p comfortably) */
            --board-card-w: clamp(150px, 9vw, 180px);
            --board-card-h: calc(var(--board-card-w) * 1.4);

            /* Unified panel style */
            --panel-bg: rgba(255, 255, 255, 0.06);
            --panel-border: rgba(255, 255, 255, 0.16);
            --panel-radius: 16px;
        }

        .ai-top-zone,
        .market-section,
        .monsters-section,
        .played-cards-section,
        .player-bottom-zone {
            background: var(--panel-bg);
            border: 1px solid var(--panel-border);
            border-radius: var(--panel-radius);
            box-shadow: var(--cob-shadow);
            backdrop-filter: blur(10px);
        }

        /* Main stack: market+monsters / play area / hand */
        .new-game-layout {
            grid-column: 1 / -1;
            grid-row: 3 / -1; /* use remaining viewport height */
            display: flex;
            flex-direction: column;
            gap: var(--board-gap);
            min-height: 0;
            overflow: visible !important; /* allow content to grow; no clipping */
        }

        /* Hide legacy side layout ("Игрок" big panel) */
        .main-layout,
        .player-side,
        .left-side,
        .right-side {
            display: none !important;
        }

        .top-row-section {
            display: flex;
            flex-direction: row;
            gap: var(--board-gap);
            align-items: stretch;
            flex-wrap: nowrap; /* IMPORTANT: never drop monster under market on wide screens */
            max-height: none !important; /* override legacy max-height that clipped cards */
        }

        @media (max-width: 1200px) {
            .top-row-section {
                flex-direction: column;
                flex-wrap: wrap;
            }
        }

        .market-section {
            flex: 1 1 auto;
            min-width: 0;
            overflow: hidden;
            max-height: none !important; /* override legacy max-height that clipped cards */
        }

        .monsters-section {
            flex: 0 0 clamp(360px, 28vw, 520px);
            min-width: 360px;
            overflow: hidden;
            max-height: none !important; /* override legacy max-height that clipped cards */
        }

        @media (max-width: 1200px) {
            .monsters-section {
                flex: 1 1 auto;
                min-width: 0;
            }
        }

        /* Market row: always aligned, no "crooked" cards */
        #market.market {
            display: flex !important;
            flex-direction: row !important;
            flex-wrap: nowrap !important;
            gap: var(--board-gap);
            align-items: flex-start;
            justify-content: flex-start;
            overflow-x: auto;
            overflow-y: hidden;
            padding: 6px 4px;
            scroll-snap-type: x proximity;
        }

        .market-slot {
            width: var(--board-card-w);
            min-width: var(--board-card-w);
            height: var(--board-card-h);
            flex: 0 0 auto;
            display: flex;
            align-items: stretch;
            justify-content: center;
            scroll-snap-align: start;
        }

        .market-slot .card,
        .market-empty-slot {
            width: 100% !important;
            min-height: 100% !important;
            max-height: 100% !important;
            margin: 0 !important;
        }

        .market-empty-slot {
            opacity: 0.25;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
        }

        /* Encounter: altar + monster ALWAYS visible side-by-side */
        .monster-altar-row {
            display: flex;
            gap: var(--board-gap);
            align-items: flex-start;
            justify-content: center;
            flex-wrap: nowrap;
            margin-top: 8px;
        }

        @media (max-width: 420px) {
            .monster-altar-row { flex-wrap: wrap; }
        }

        .monster-altar-cell {
            display: flex;
            justify-content: center;
            min-width: 0;
        }

        #altar-card-container .card:not(.altar-horizontal),
        #current-monster .card {
            width: var(--board-card-w) !important;
            min-height: var(--board-card-h) !important;
            max-height: var(--board-card-h) !important;
            margin: 0 !important;
        }

        /* Алтарь: горизонтальная карта (широкая рамка, арт не сжимается — contain) */
        .altar-wrapper {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
        }
        .altar-card-horizontal {
            width: 300px;
            max-width: 100%;
            /* Базовая карта ~5/7, «положили боком» → 7/5 */
            aspect-ratio: 7 / 5;
            min-height: 85px;
            border-radius: 12px;
            overflow: hidden;
            position: relative;
            background: rgba(0,0,0,0.4);
            border: 2px solid rgba(255,255,255,0.3);
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        }
        .altar-card-horizontal .altar-image {
            width: 100%;
            height: 100%;
            object-fit: contain;
            object-position: center;
            display: block;
        }
        .altar-card-horizontal .altar-image-sprite {
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
        }
        .altar-card-horizontal .altar-tokens-count {
            position: absolute;
            top: 6px;
            left: 6px;
            background: rgba(30, 144, 255, 0.95);
            color: #fff;
            padding: 4px 10px;
            border-radius: 50%;
            font-weight: bold;
            font-size: 1rem;
            min-width: 28px;
            min-height: 28px;
            z-index: 11;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
            line-height: 1;
        }
        .altar-buttons-row {
            display: flex;
            gap: 10px;
            justify-content: center;
            flex-wrap: wrap;
            margin-top: 6px;
        }
        .altar-buttons-row .btn-altar {
            min-width: 48px;
            padding: 8px 14px;
            font-size: 0.8rem;
            border-radius: 20px;
            border: 1px solid rgba(255,255,255,0.35);
            background: rgba(78, 205, 196, 0.2);
            color: #fff;
            cursor: pointer;
            transition: background 0.2s, border-color 0.2s;
        }
        .altar-buttons-row .btn-altar.altar-btn-up,
        .altar-buttons-row .btn-altar.altar-btn-down {
            font-size: 1.4rem;
            line-height: 1;
        }
        .altar-buttons-row .btn-altar:hover:not(:disabled) {
            background: rgba(78, 205, 196, 0.4);
            border-color: #4ecdc4;
        }
        .altar-buttons-row .btn-altar:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }
        .altar-select-row {
            margin-top: 6px;
            font-size: 0.75rem;
            color: rgba(255,255,255,0.8);
        }
        .altar-select-row select {
            margin-left: 6px;
            padding: 4px 8px;
            border-radius: 8px;
            background: rgba(0,0,0,0.3);
            color: #fff;
            border: 1px solid rgba(255,255,255,0.25);
            cursor: pointer;
        }

        /* Play Area: no internal scroll, everything fits by wrapping + smaller cards */
        :root {
            --play-card-w: clamp(84px, 5.2vw, 114px);
            --play-card-h: calc(var(--play-card-w) * 1.4);
        }

        .played-cards-section {
            flex: 0 0 auto;
            min-height: auto !important;
            overflow: visible !important;
            padding: 10px !important;
        }

        .played-center {
            min-height: auto !important;
            overflow: visible !important;
        }

        .played-center .played-area {
            overflow: visible !important;
            max-height: none !important;
        }

        .played-area .card {
            width: var(--play-card-w) !important;
            min-height: var(--play-card-h) !important;
            max-height: var(--play-card-h) !important;
            margin: 0 !important;
        }

        /* Bottom zone: compact, no wasted height, responsive */
        .player-bottom-zone {
            min-height: auto !important;
            height: auto !important;
            align-items: start !important;
            padding: 10px 12px !important;
            display: grid !important;
            grid-template-columns: minmax(160px, 240px) 1fr;
            gap: var(--board-gap) !important;
        }

        .player-stats-compact {
            width: 100%;
            max-width: 100%;
            min-width: 0;
            padding: 10px !important;
        }

        .player-stats-compact .hp-row {
            flex-direction: column !important;
            align-items: flex-start !important;
            gap: 6px !important;
        }

        .player-tag-mini {
            font-size: 0.72rem !important;
            padding: 2px 6px !important;
        }

        /* HP pill slightly smaller inside bottom stats so it never overflows */
        .player-stats-compact #player-hp {
            font-size: 1.55rem !important;
            padding: 3px 10px !important;
            min-width: 52px !important;
        }

        .player-hand-horizontal {
            align-items: flex-start !important;
            min-width: 0;
        }

        .player-hand-horizontal .hand {
            padding: 4px 0 !important;
        }

        /* Mobile: stack everything, make buttons/nav wrap */
        @media (max-width: 900px) {
            .player-bottom-zone {
                grid-template-columns: 1fr !important;
            }

            .header {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .nav-buttons {
                width: 100%;
                flex-wrap: wrap;
                justify-content: flex-start;
            }

            #dev-marker {
                display: none;
            }
        }

        @media (max-width: 520px) {
            :root {
                --board-card-w: clamp(120px, 40vw, 160px);
                --play-card-w: clamp(72px, 22vw, 96px);
            }

            .ai-hand-zone img[title*="справочника"] {
                width: 90px !important;
            }
        }

        /* Compact "Игрок" label near HP */
        .player-tag-mini {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 0.85rem;
            font-weight: 800;
            color: var(--cob-accent);
            padding: 2px 8px;
            border-radius: 999px;
            background: rgba(78, 205, 196, 0.14);
            border: 1px solid rgba(78, 205, 196, 0.28);
        }

        .player-stats-compact .stat.hp-row {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        /* === Телефоны и WebView (Capacitor): без горизонтального «вылезания», крупные зоны нажатия === */
        @media (max-width: 900px) {
            :root {
                --board-gap: 8px;
                --board-card-w: clamp(100px, 28vw, 148px);
                --play-card-w: clamp(64px, 18vw, 96px);
            }

            .game-container {
                padding: 6px;
                gap: 8px;
            }

            .header {
                flex-wrap: wrap;
                padding: 10px 12px;
                align-items: flex-start;
            }

            .game-title {
                font-size: clamp(0.95rem, 4vw, 1.25rem);
            }

            .nav-buttons {
                width: 100%;
                flex-wrap: nowrap;
                overflow-x: auto;
                -webkit-overflow-scrolling: touch;
                gap: 6px;
                padding-bottom: 4px;
                scrollbar-width: thin;
            }

            .nav-buttons .btn {
                flex: 0 0 auto;
                min-height: 44px;
                padding: 0 12px;
                font-size: 0.82rem;
                touch-action: manipulation;
            }

            .ai-top-zone {
                min-height: auto !important;
                max-height: none !important;
                height: auto;
                flex-wrap: wrap;
                overflow-x: hidden;
                align-items: flex-start;
                padding: 6px;
            }

            .ai-top-zone .ai-attire-zone {
                flex: 1 1 100%;
                min-width: 0;
                max-height: 120px;
                overflow-x: auto;
                overflow-y: hidden;
            }

            .ai-hand-zone img[title*="справочника"] {
                width: 56px !important;
                max-width: 56px !important;
                height: auto !important;
            }

            .top-row-section {
                flex-direction: column;
            }

            .monsters-section {
                flex: 1 1 auto !important;
                min-width: 0 !important;
            }

            /* Модалки: не шире экрана */
            .modal,
            #choice-modal,
            .card-preview-modal,
            .discard-modal,
            .discard-modal-content {
                max-width: calc(100vw - 16px) !important;
                box-sizing: border-box;
            }

            .modal-content {
                max-width: calc(100vw - 24px) !important;
            }
        }

        @media (max-width: 480px) {
            :root {
                --board-card-w: clamp(92px, 26vw, 132px);
                --play-card-w: clamp(58px, 17vw, 84px);
            }

            .nav-buttons .btn {
                font-size: 0.75rem;
                padding: 0 10px;
            }

            .altar-card-horizontal {
                width: min(300px, 92vw);
            }
        }
