/* ================================================= */
/* 1. БАЗОВЫЙ КОНТЕЙНЕР (ВЕРСТАК)                    */
/* ================================================= */
.craft-bench {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    margin: 20px auto;
    position: relative;
    padding: 35px;
    background: radial-gradient(100% 100% at 50% 0%, rgba(30, 30, 50, 0.8) 0%, rgba(10, 10, 20, 0.9) 100%);
    border-radius: 45px;
    border: 1px solid rgba(169, 217, 248, 0.15);
    z-index: 10;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    
    /* Оставляем visible, чтобы частицы и вспышки выходили за края */
    overflow: visible; 
    
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.4),
        inset 0 0 20px rgba(169, 217, 248, 0.05);
}

.bench-chaos {
    animation: bench-pulse 2s infinite ease-in-out;
    border-color: rgba(169, 217, 248, 0.5);
    box-shadow: 
        0 0 50px rgba(169, 217, 248, 0.2),
        inset 0 0 30px rgba(169, 217, 248, 0.1);
}

@keyframes bench-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.01); border-color: rgba(169, 217, 248, 0.7); }
    100% { transform: scale(1); }
}

/* ================================================= */
/* 2. СЛОТЫ И СЕТКА                                 */
/* ================================================= */
.slot-row {
    display: flex;
    gap: 18px;
    z-index: 2;
}

.craft-slot {
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(169, 217, 248, 0.1);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: rgba(169, 217, 248, 0.3);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    backdrop-filter: blur(10px);
}

.craft-slot img {
    width: 75%;
    height: 75%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.3));
    animation: slotItemEntry 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slotItemEntry {
    from { opacity: 0; transform: scale(0.4) rotate(-15deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
}

/* ================================================= */
/* 3. МОДАЛЬНОЕ ОКНО ВЫБОРА ПРЕДМЕТОВ (ИСПРАВЛЕНО)   */
/* ================================================= */
.modal {
    display: none;
    position: fixed;
    top: 0; 
    left: 0;
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    /* Ставим z-index ВЫШЕ всех остальных элементов */
    z-index: 10000 !important; 
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1a 100%);
    width: 100%;
    max-width: 420px;
    max-height: 85vh;
    border-radius: 35px;
    padding: 25px;
    border: 1px solid rgba(169, 217, 248, 0.3);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
    position: relative;
}

/* СЕТКА ИНВЕНТАРЯ: Фиксируем размер предметов */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Ровно 3 колонки */
    gap: 12px;
    overflow-y: auto;
    margin: 15px 0;
    padding-right: 5px;
}

.inv-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    padding: 10px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.inv-item:hover {
    background: rgba(169, 217, 248, 0.1);
    border-color: rgba(169, 217, 248, 0.5);
    transform: translateY(-2px);
}

.inv-item img {
    width: 60px; /* Ограничиваем ширину картинки */
    height: 60px;
    object-fit: contain;
}

/* ================================================= */
/* 4. МАГИЯ КРАФТА (АНИМАЦИЯ ПРЕДМЕТОВ)             */
/* ================================================= */
.item-storm {
    position: absolute !important;
    z-index: 100;
    width: 75px !important;
    height: 75px !important;
    pointer-events: none;
    animation: card-deck-shuffle 3s cubic-bezier(0.645, 0.045, 0.355, 1) forwards !important;
}

@keyframes card-deck-shuffle {
    0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
    30% { transform: translate(var(--x1), var(--y1)) rotate(140deg) scale(1.2); filter: blur(2px); }
    60% { transform: translate(var(--x2), var(--y2)) rotate(280deg) scale(0.7); filter: blur(4px); }
    100% { transform: translate(0, 0) rotate(720deg) scale(0); opacity: 0; }
}

/* Центровой вихрь */
.craft-bench::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 150px; height: 150px;
    background: radial-gradient(circle, rgba(169, 217, 248, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    z-index: 1;
    pointer-events: none;
}

.bench-chaos::before {
    animation: vortex-core 3s ease-in-out infinite;
}

@keyframes vortex-core {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    50% { transform: translate(-50%, -50%) scale(2.5); opacity: 0.5; filter: blur(30px); }
    100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

/* Финальная вспышка */
.craft-bench::after {
    content: '';
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
}

.bench-chaos::after {
    animation: flash-impact 3s cubic-bezier(0.95, 0.05, 0.795, 0.035) forwards;
}

@keyframes flash-impact {
    0%, 90% { opacity: 0; }
    93% { opacity: 1; }
    100% { opacity: 0; }
}

/* ================================================= */
/* 5. ИНТЕРФЕЙС И КНОПКИ                            */
/* ================================================= */
.main-craft-btn {
    width: 100%;
    height: 65px;
    border-radius: 22px;
    border: none;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000;
    font-size: 19px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(255, 165, 0, 0.25);
    transition: all 0.3s ease;
    cursor: pointer;
}

.main-craft-btn:disabled {
    background: #2a2a2a;
    color: #666;
}

/* Частицы */
.particle {
    position: absolute;
    top: 50%; left: 50%;
    width: 2px; height: 2px;
    background: #A9D9F8;
    box-shadow: 0 0 10px #A9D9F8;
    border-radius: 50%;
    pointer-events: none;
}

/* ================================================= */
/* 7. ПАНЕЛЬ ПРЕДПРОСМОТРА КРАФТА                    */
/* ================================================= */

.craft-result-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    width: 100%;
}

/* Контейнер стоимости */
.craft-total-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.total-label {
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Обёртка суммы и валюты */
.total-amount-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 215, 0, 0.05);
    padding: 8px 24px;
    border-radius: 16px;
    border: 1px solid rgba(255, 215, 0, 0.15);
    box-shadow: inset 0 0 15px rgba(255, 215, 0, 0.05);
}

.coin-icon {
    font-size: 18px;
    filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
}

.total-price {
    font-size: 26px;
    font-weight: 900;
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    font-family: 'Inter', sans-serif;
}

.currency-label {
    font-size: 18px;
    font-weight: 800;
    color: #FFD700;
    opacity: 0.8;
}

/* Текст шанса */
.chance-text {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
}

#craft-chance {
    color: #A9D9F8; /* Голубой акцент */
    font-weight: 800;
    text-shadow: 0 0 10px rgba(169, 217, 248, 0.3);
}

/* Синяя стрелка */
.arrow-down {
    font-size: 22px;
    color: #4facfe;
    filter: drop-shadow(0 0 8px rgba(79, 172, 254, 0.8));
    animation: arrow-bounce 2s infinite ease-in-out;
    margin: 5px 0;
}

@keyframes arrow-bounce {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(8px); opacity: 0.5; }
}

/* Квадрат под стрелкой (результат) */
.result-box {
    font-size: 32px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.1);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(255, 255, 255, 0.05);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
}

/* Базовый стиль слота (дополни или замени свой) */
.craft-slot {
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(169, 217, 248, 0.1);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: rgba(169, 217, 248, 0.3);
    cursor: pointer;
    position: relative;
    backdrop-filter: blur(10px);
    
    /* Плавный переход для всех свойств */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

/* ЭФФЕКТ ПРИ НАВЕДЕНИИ */
.craft-slot:hover {
    /* Слегка увеличиваем ячейку */
    transform: translateY(-5px) scale(1.02);
    
    /* Делаем границы ярче */
    border-color: rgba(169, 217, 248, 0.5);
    
    /* Добавляем внешнее и внутреннее свечение */
    box-shadow: 
        0 10px 20px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(169, 217, 248, 0.15),
        inset 0 0 10px rgba(169, 217, 248, 0.1);
    
    /* Делаем фон чуть светлее */
    background: rgba(169, 217, 248, 0.08);
    
    /* Цвет плюсика становится ярче */
    color: rgba(169, 217, 248, 0.8);
}

/* Добавляем эффект "блика" при наведении */
.craft-slot::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -150%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg, 
        transparent, 
        rgba(255, 255, 255, 0.05), 
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.6s ease;
}

.craft-slot:hover::after {
    left: 150%;
}

/* Если в слоте уже есть картинка предмета */
.craft-slot img {
    transition: transform 0.3s ease;
}

.craft-slot:hover img {
    transform: scale(1.1); /* Картинка внутри тоже слегка увеличивается */
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.5));
}

/* Стиль для кнопки Отмена */
.modal-content button[onclick="closeSelector()"], 
.cancel-btn {
    width: 100%;
    height: 48px;
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.05); /* Еле заметный белый фон */
    color: rgba(255, 255, 255, 0.6); /* Приглушенный текст */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    font-size: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(5px); /* Эффект матового стекла */
}

/* Эффект при наведении */
.modal-content button[onclick="closeSelector()"]:hover,
.cancel-btn:hover {
    background: rgba(255, 59, 48, 0.1); /* Легкий красный оттенок */
    border-color: rgba(255, 59, 48, 0.3);
    color: #ff3b30; /* Красный цвет текста при наведении */
    transform: translateY(-2px);
}

/* Эффект при нажатии */
.modal-content button[onclick="closeSelector()"]:active,
.cancel-btn:active {
    transform: scale(0.97);
    background: rgba(255, 59, 48, 0.2);
}