/* ========== ОСНОВНЫЕ СТИЛИ ИНВЕНТАРЯ ========== */
.inventory-items {
    display: grid;
    /* ФИКСИРОВАННЫЕ КОЛОНКИ - не растягиваются */
    grid-template-columns: repeat(auto-fill, 120px); /* Только 120px, без 1fr */
    gap: 16px;
    padding: 20px;
    
    /* ФИКСИРОВАННАЯ ВЫСОТА ДЛЯ ПРОКРУТКИ */
    max-height: 500px;
    height: 500px;
    overflow-y: auto;
    
    /* Центрируем сетку */
    justify-content: center;
    
    /* Улучшаем скроллбар */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) rgba(255, 255, 255, 0.05);
    
    /* Фон и границы */
    background: rgba(15, 23, 42, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Альтернативный вариант с фиксированным количеством колонок */
.inventory-items.fixed-columns {
    grid-template-columns: repeat(4, 120px); /* Всегда 4 колонки */
    justify-content: center;
}

/* Для мобильных - 3 колонки */
@media (max-width: 768px) {
    .inventory-items {
        grid-template-columns: repeat(3, 100px); /* 3 колонки по 100px */
        gap: 12px;
        padding: 15px;
        max-height: 400px;
        height: 400px;
        justify-content: center; /* Центрируем */
    }
}

/* Для очень маленьких экранов - 2 колонки */
@media (max-width: 480px) {
    .inventory-items {
        grid-template-columns: repeat(2, 90px); /* 2 колонки по 90px */
        gap: 10px;
        max-height: 350px;
        height: 350px;
    }
}

/* ========== СТИЛИ ПРЕДМЕТОВ (ФИКСИРОВАННЫЕ РАЗМЕРЫ) ========== */
.inventory-item {
    position: relative;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-radius: 16px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    /* ФИКСИРОВАННАЯ ШИРИНА */
    width: 120px; /* Такая же как в grid-template-columns */
    min-width: 120px;
    max-width: 120px;
    
    /* ФИКСИРОВАННАЯ ВЫСОТА */
    height: 200px;
    min-height: 20px;
    max-height: 200px;
}

/* Для мобильных */
@media (max-width: 768px) {
    .inventory-item {
        width: 100px;
        min-width: 100px;
        max-width: 100px;
        height: 140px;
        min-height: 140px;
        max-height: 140px;
        padding: 12px 8px;
    }
}

@media (max-width: 480px) {
    .inventory-item {
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        height: 130px;
        min-height: 130px;
        max-height: 130px;
        padding: 10px 6px;
    }
}

/* Контейнер для изображения - фиксированный размер */
.inventory-item .item-image-container {
    position: relative;
    width: 60px; /* Фиксированная ширина */
    height: 60px; /* Фиксированная высота */
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0; /* Не сжимается */
}

/* Для мобильных */
@media (max-width: 768px) {
    .inventory-item .item-image-container {
        width: 50px;
        height: 50px;
    }
}

/* Изображение предмета - заполняет контейнер */
.inventory-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.7));
    transition: all 0.4s ease;
    z-index: 1;
    position: relative;
}

/* Название предмета - обрезаем если длинное */
.inventory-item span {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.2;
    width: 100%;
    
    /* Обрезаем длинный текст */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

/* Для мобильных */
@media (max-width: 768px) {
    .inventory-item span {
        font-size: 0.75rem;
    }
}

/* Индикатор редкости */
.inventory-item .rarity-label {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--rarity-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Остальные стили (цвета рамок, анимации и т.д.) остаются как были */
/* ========== СТИЛИ ПРЕДМЕТОВ ========== */
.inventory-item {
    position: relative;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border-radius: 16px;
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Эффект свечения рамки */
.inventory-item::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 18px;
    background: linear-gradient(45deg, 
        transparent, 
        rgba(255, 255, 255, 0.1), 
        transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: -1;
}

.inventory-item:hover::before {
    opacity: 1;
}

/* Эффект наведения */
.inventory-item:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5),
                0 0 30px var(--rarity-glow);
}

/* Контейнер для изображения */
.inventory-item .item-image-container {
    position: relative;
    width: 70px;
    height: 70px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Изображение предмета */
.inventory-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.7));
    transition: all 0.4s ease;
    z-index: 1;
    position: relative;
}

.inventory-item:hover img {
    transform: scale(1.15) rotate(5deg);
    filter: drop-shadow(0 8px 25px rgba(0, 0, 0, 0.9));
}

/* Свечение за изображением */
.inventory-item .item-glow {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    background: var(--rarity-glow);
    filter: blur(15px);
    opacity: 0.4;
    z-index: 0;
    transition: all 0.4s ease;
}

.inventory-item:hover .item-glow {
    opacity: 0.7;
    filter: blur(20px);
}

/* Количество предметов */
.inventory-item .item-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 2;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Название предмета */
.inventory-item span {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-top: 4px;
    line-height: 1.3;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Индикатор редкости */
.inventory-item .rarity-label {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--rarity-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========== ЦВЕТА РАМОК ПО РЕДКОСТИ ========== */
/* Обычный (Common) */
.inventory-item.common {
    --rarity-color: #94a3b8;
    --rarity-glow: rgba(148, 163, 184, 0.3);
    border-color: #94a3b8;
    background: linear-gradient(145deg, 
        rgba(148, 163, 184, 0.05), 
        rgba(148, 163, 184, 0.02));
}

/* Необычный (Uncommon) */
.inventory-item.uncommon {
    --rarity-color: #22c55e;
    --rarity-glow: rgba(34, 197, 94, 0.3);
    border-color: #22c55e;
    background: linear-gradient(145deg, 
        rgba(34, 197, 94, 0.05), 
        rgba(34, 197, 94, 0.02));
}

/* Редкий (Rare) */
.inventory-item.rare {
    --rarity-color: #3b82f6;
    --rarity-glow: rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
    background: linear-gradient(145deg, 
        rgba(59, 130, 246, 0.05), 
        rgba(59, 130, 246, 0.02));
}

/* Эпический (Epic) */
.inventory-item.epic {
    --rarity-color: #a855f7;
    --rarity-glow: rgba(168, 85, 247, 0.3);
    border-color: #a855f7;
    background: linear-gradient(145deg, 
        rgba(168, 85, 247, 0.05), 
        rgba(168, 85, 247, 0.02));
}

/* Легендарный (Legendary) */
.inventory-item.legendary {
    --rarity-color: #f59e0b;
    --rarity-glow: rgba(245, 158, 11, 0.4);
    border-color: #f59e0b;
    background: linear-gradient(145deg, 
        rgba(245, 158, 11, 0.08), 
        rgba(245, 158, 11, 0.04));
    border-width: 3px;
}

/* Мифический (Mythic) */
.inventory-item.mythic {
    --rarity-color: #ef4444;
    --rarity-glow: rgba(239, 68, 68, 0.4);
    border-color: #ef4444;
    background: linear-gradient(145deg, 
        rgba(239, 68, 68, 0.08), 
        rgba(239, 68, 68, 0.04));
    border-width: 3px;
}

/* ========== ПУСТОЙ ИНВЕНТАРЬ ========== */
.inventory-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #94a3b8;
    height: 100%;
}

.inventory-empty::before {
    content: '';
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
    animation: float 3s ease-in-out infinite;
}

.inventory-empty h4 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.inventory-empty p {
    font-size: 0.9rem;
    max-width: 300px;
    line-height: 1.5;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    .inventory-items {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
        padding: 15px;
        max-height: 400px;
        height: 400px;
    }
    
    .inventory-item {
        padding: 15px 8px;
    }
    
    .inventory-item .item-image-container {
        width: 60px;
        height: 60px;
    }
    
    .inventory-item span {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .inventory-items {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        max-height: 350px;
        height: 350px;
    }
}

/* Для маленьких экранов */
@media (max-height: 700px) {
    .inventory-items {
        max-height: 400px;
        height: 400px;
    }
}

@media (max-height: 600px) {
    .inventory-items {
        max-height: 300px;
        height: 300px;
    }
}

/* ========== МОДАЛЬНОЕ ОКНО ========== */
#inventoryModal .modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Важно! */
}

/* ========== АНИМАЦИИ ========== */


.item-new {
    animation: itemAppear 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ========== СОСТОЯНИЕ ЗАГРУЗКИ ========== */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: #94a3b8;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading::before {
    content: '';
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}







/* Рулетка - фиксированные размеры */
.roulette-container {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.rewards-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    margin: 10px 0;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.2);
    border: 2px solid var(--primary);
}

.reward-slots {
    display: flex;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    transition: transform 3s cubic-bezier(0.1, 0.8, 0.2, 1);
    padding: 10px 0;
}

/* Карточки - фиксированный размер */
.reward-slot {
    width: 140px !important; /* ФИКСИРОВАННАЯ ширина */
    height: 140px !important; /* ФИКСИРОВАННАЯ высота */
    margin: 0 5px;
    flex-shrink: 0 !important; /* Не сжимать */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.reward-slot img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    margin-bottom: 8px;
}

.reward-slot .material-symbols-rounded {
    font-size: 50px;
    margin-bottom: 8px;
}

.reward-name {
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 5px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Указатель по центру */
.roulette-pointer {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: gold;
    z-index: 10;
}

.roulette-pointer::before {
    content: '▼';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    color: gold;
    font-size: 24px;
}

/* Кнопки - всегда видимые */
.roulette-controls {
    position: relative;
    z-index: 20;
    margin-top: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    width: 100%;
}

.btn-spin, .btn-claim {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    display: block;
    padding: 12px 24px;
    font-size: 1.1rem;
}

/* Модальное окно */
#caseRouletteModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.9);
    overflow-y: auto;
}

#caseRouletteModal .modal-content {
    width: 95%;
    max-width: 500px;
    margin: 20px auto;
    max-height: 90vh;
    overflow-y: auto;
    padding: 15px;
}

/* Для мобильных */
@media (max-width: 768px) {
    .rewards-container {
        height: 160px;
    }
    
    .reward-slot {
        width: 120px !important;
        height: 120px !important;
    }
    
    .reward-slot img {
        width: 50px;
        height: 50px;
    }
    
    #caseRouletteModal .modal-content {
        width: 98%;
        margin: 10px auto;
    }
}

/* Ограничиваем высоту списка шансов */
.chances-list {
    max-height: 100px;
    overflow-y: auto;
    padding: 10px;
    margin-top: 10px;
}


/* ФИКСИРОВАННАЯ рулетка */
.roulette-container {
    width: 100%;
    max-width: 100vw;
    padding: 10px;
    box-sizing: border-box;
    overflow-x: hidden;
}

.rewards-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    margin: 10px 0;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--primary);
}

.reward-slots {
    display: flex;
    height: 100%;
    align-items: center;
    position: absolute;
    left: 0;
    top: 0;
}

/* Указатель по центру */
.roulette-pointer {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: gold;
    z-index: 10;
    box-shadow: 0 0 10px gold;
}

.roulette-pointer::before {
    content: '▼';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    color: gold;
    font-size: 24px;
    text-shadow: 0 0 10px gold;
}

/* Карточка при выигрыше */
.reward-slot.won {
    border: 3px solid gold !important;
    background: linear-gradient(145deg, rgba(255,215,0,0.2), rgba(255,165,0,0.1)) !important;
    box-shadow: 0 0 20px gold !important;
    transform: scale(1.05) !important;
    z-index: 5;
}

/* Кнопки */
.roulette-controls {
    width: 100%;
    padding: 15px 10px;
    text-align: center;
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    margin-top: 10px;
}

.btn-spin, .btn-claim {
    width: 100%;
    max-width: 300px;
    padding: 12px 24px;
    font-size: 1.1rem;
    margin: 5px auto;
    display: block;
}

/* Модальное окно */
#caseRouletteModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.9);
    display: none;
}

#caseRouletteModal .modal-content {
    width: 95%;
    max-width: 500px;
    margin: 20px auto;
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(145deg, var(--bg-dark), var(--bg-darker));
    border-radius: 15px;
    padding: 15px;
    border: 2px solid var(--primary);
}

/* Для мобильных */
@media (max-width: 480px) {
    .rewards-container {
        height: 160px;
    }
    
    #caseRouletteModal .modal-content {
        width: 98%;
        margin: 10px auto;
        padding: 10px;
    }
}

/* Анимации для модального окна */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideUp {
    from { 
        transform: translateY(50px) scale(0.9); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Стили для кнопки */
.reward-card button {
    transition: all 0.3s ease !important;
}

.reward-card button:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 0 20px rgba(255,255,255,0.2) !important;
}

/* Модальное окно - центрирование */
#caseRouletteModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.9);

}

#caseRouletteModal .modal-content {
    width: 95%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    background: linear-gradient(145deg, var(--bg-dark), var(--bg-darker));
    border-radius: 15px;
    padding: 20px;
    border: 2px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease-out;
    /* Убираем margin: auto, так как теперь центрируется через flex */
}

/* Анимация появления */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        transform: translateY(30px) scale(0.95); 
        opacity: 0; 
    }
    to { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
}

/* Для мобильных устройств */
@media (max-width: 480px) {
    #caseRouletteModal {
        padding: 10px;
        align-items: flex-start; /* Начинаем сверху на мобильных */
    }
    
    #caseRouletteModal .modal-content {
        width: 100%;
        max-width: 100%;
        margin-top: 20px;
        max-height: calc(100vh - 40px);
        padding: 15px;
    }
}

/* Для очень маленьких экранов */
@media (max-height: 600px) {
    #caseRouletteModal {
        align-items: flex-start; /* Начинаем сверху если экран маленький */
        padding-top: 10px;
    }
    
    #caseRouletteModal .modal-content {
        max-height: calc(100vh - 20px);
    }
}

/* Если нужна поддержка старых браузеров */
#caseRouletteModal {
    display: none; /* По умолчанию скрыто */
}

#caseRouletteModal.active {
    display: flex; /* Показываем с flex */
}

/* Альтернативный вариант для старых браузеров */
@supports not (display: flex) {
    #caseRouletteModal {
        display: block;
        text-align: center;
        white-space: nowrap;
    }
    
    #caseRouletteModal:before {
        content: '';
        display: inline-block;
        height: 100%;
        vertical-align: middle;
        margin-right: -0.25em;
    }
    
    #caseRouletteModal .modal-content {
        display: inline-block;
        vertical-align: middle;
        white-space: normal;
        text-align: left;
        margin: 0;
    }
}



