* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    overflow-x: hidden;
    touch-action: manipulation;
}

/* Загрузочный экран */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader-content {
    text-align: center;
}

.loader-content i {
    font-size: 48px;
    color: #ff375f;
    margin-bottom: 20px;
}

.loader-content p {
    font-size: 18px;
    color: #aaa;
}

/* Главное меню категорий */
.main-categories-panel {
    display: flex;
    gap: 10px;
    padding: 12px 15px 8px;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 2px solid #ff375f;
    overflow-x: auto;
    white-space: nowrap;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 99;
    -webkit-overflow-scrolling: touch;
}

.main-categories-panel::-webkit-scrollbar {
    display: none;
}

.main-categories-panel .category-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    /* 👇 Ключевое: фиксированный padding, чтобы текст "дышал" */
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    /* 👇 Текст всегда в одну строку */
    white-space: nowrap;
    font-size: 15px;
    /* 👇 Убираем минимальную ширину — кнопка растягивается по контенту */
    min-width: auto;
    /* 👇 Не сжимается при скролле */
    flex-shrink: 0;
    text-align: center;
    outline: none;
    transition: all 0.2s;
    touch-action: manipulation;
    /* 👇 Центрируем текст вертикально */
    display: flex;
    align-items: center;
    justify-content: center;
}

.main-categories-panel .category-btn:hover,
.main-categories-panel .category-btn.active,
.main-categories-panel .category-btn:focus {
    background: linear-gradient(90deg, #ff375f, #ff5e41);
    color: white;
}

.main-categories-panel .category-btn:focus {
    outline: 3px solid #ff375f;
    outline-offset: 2px;
}

/* Подменю подкатегорий */
.sub-categories-panel {
    display: none;
    gap: 8px;
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 1px solid #555;
    overflow-x: auto;
    white-space: nowrap;
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    z-index: 98;
    -webkit-overflow-scrolling: touch;
}

.sub-categories-panel::-webkit-scrollbar {
    display: none;
}

.sub-categories-panel .subcategory-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 18px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 13px;
    min-width: auto;
    flex-shrink: 0;
    text-align: center;
    outline: none;
    transition: all 0.2s;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sub-categories-panel .subcategory-btn:hover,
.sub-categories-panel .subcategory-btn.active,
.sub-categories-panel .subcategory-btn:focus {
    background: linear-gradient(90deg, #ff375f, #ff5e41);
    color: white;
}

.sub-categories-panel .subcategory-btn:focus {
    outline: 3px solid #ff375f;
    outline-offset: 2px;
}

/* Сетка каналов — сдвинута вниз, чтобы не перекрывалась меню */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
    padding: 130px 15px 80px;
}

/* Карточка канала */
.channel-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    outline: none;
    height: 200px;
    display: flex;
    flex-direction: column;
    tabindex: 0;
    touch-action: manipulation;
}

.channel-card:focus {
    transform: scale(1.02);
    outline: 3px solid #ff375f;
    outline-offset: 2px;
}

/* Медиа-контейнер */
.channel-media {
    height: 70%;
    position: relative;
    background: linear-gradient(135deg, #333, #111);
    overflow: hidden;
}

.channel-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-media i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    color: #ff375f;
}

/* Мини-плеер */
.mini-player {
    width: 100%;
    height: 100%;
    background: #000;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

.mini-player video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Информация о канале */
.channel-info {
    padding: 8px;
    background: rgba(0, 0, 0, 0.7);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.channel-info h3 {
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
    color: white;
}

.channel-info p {
    font-size: 12px;
    color: #aaa;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Модальное окно плеера */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    outline: none;
    backdrop-filter: blur(5px);
    touch-action: manipulation;
}

.close-btn:focus {
    outline: 3px solid #ff375f;
}

#videoPlayerElement {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Уведомления */
.toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
    animation: fadeInOut 3s ease-in-out;
    text-align: center;
    font-size: 15px;
    min-width: 240px;
    pointer-events: auto;
    touch-action: manipulation;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    10% { opacity: 1; transform: translateY(0); }
    90% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-10px); }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        padding: 120px 10px 70px;
    }
    
    .channel-card {
        height: 180px;
    }
    
    .channel-info h3 {
        font-size: 14px;
    }
    
    .channel-info p {
        font-size: 11px;
    }
    
    .main-categories-panel {
        padding: 10px 12px 6px;
        top: 0;
    }
    
    .main-categories-panel .category-btn {
        padding: 6px 14px;
        font-size: 14px;
    }
    
    .sub-categories-panel {
        top: 55px;
        padding: 6px 12px;
    }
    
    .sub-categories-panel .subcategory-btn {
        padding: 5px 12px;
        font-size: 12px;
    }
    
    .close-btn {
        top: 10px;
        right: 10px;
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .toast {
        top: 60px;
        font-size: 14px;
        min-width: 220px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .channels-grid {
        grid-template-columns: 1fr;
        padding: 110px 10px 60px;
    }
    
    .channel-card {
        height: 160px;
    }
    
    .main-categories-panel {
        gap: 8px;
        padding: 8px 10px 5px;
    }
    
    .main-categories-panel .category-btn {
        padding: 5px 12px;
        font-size: 13px;
    }
    
    .sub-categories-panel {
        top: 50px;
        gap: 6px;
        padding: 5px 10px;
    }
    
    .sub-categories-panel .subcategory-btn {
        padding: 4px 10px;
        font-size: 11px;
    }
    
    .channel-info h3 {
        font-size: 13px;
    }
    
    .channel-info p {
        font-size: 10px;
    }
}
