* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0a1929 0%, #1a2332 50%, #0d1b2a 100%);
    color: #e0e7ff;
    min-height: 100vh;
    padding: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    margin-top: 20px;
}

/* === СЕКЦИЯ КАТЕГОРИЙ === */
.category-section {
    margin-top: 30px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
    gap: 10px;
}

.category-title {
    font-size: 28px;
    font-weight: 700;
    color: #a5d8ff;
    text-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

.view-all {
    color: #60a5fa;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.view-all:hover {
    color: #93c5fd;
    transform: translateX(5px);
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

/* === СЕТКА ФИЛЬМОВ === */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.movie-card {
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(96, 165, 250, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    /* Оптимизация производительности */
    will-change: transform;
    -webkit-tap-highlight-color: transparent;
}

.movie-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(56, 189, 248, 0.4);
    border-color: rgba(96, 165, 250, 0.6);
    background: linear-gradient(145deg, rgba(30, 58, 88, 0.6), rgba(15, 32, 51, 0.8));
}

/* Активное состояние для мобильных */
.movie-card:active {
    transform: scale(0.98);
}

.movie-card.clickable {
    cursor: pointer;
}

.movie-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.movie-poster {
    width: 100%;
    height: 300px;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
}

.movie-poster > div {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.movie-poster img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    transition: transform 0.3s ease;
    display: block;
    /* Ленивая загрузка изображений */
    loading: lazy;
}

.movie-card:hover .movie-poster img {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.movie-info {
    padding: 12px;
    background: rgba(10, 25, 41, 0.5);
}

.movie-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #dbeafe;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.movie-year {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.movie-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.genre-tag {
    font-size: 12px;
    padding: 4px 10px;
    background: rgba(56, 189, 248, 0.15);
    border-radius: 12px;
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.3);
    transition: all 0.3s ease;
}

.genre-tag:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* === АДАПТИВНОСТЬ === */

/* Планшеты (768px - 1024px) */
@media (max-width: 1024px) {
    .container {
        margin-top: 20px;
    }

    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 18px;
    }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        margin-top: 15px;
    }

    .category-section {
        margin-top: 25px;
    }

    .category-header {
        margin-bottom: 12px;
        padding: 0 2px;
    }

    .category-title {
        font-size: 20px;
    }

    .view-all {
        font-size: 14px;
    }

    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        margin-bottom: 30px;
    }

    .movie-poster {
        height: 210px;
    }

    .movie-info {
        padding: 10px;
    }

    .movie-title {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .movie-year {
        font-size: 12px;
        margin-bottom: 6px;
    }

    .genre-tag {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Отключаем эффект hover на мобильных */
    .movie-card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }

    .movie-card:hover .movie-poster img {
        transform: none;
        filter: none;
    }
}

/* Маленькие мобильные (до 480px) */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .category-title {
        font-size: 18px;
    }

    .view-all {
        font-size: 13px;
    }

    .movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .movie-poster {
        height: 180px;
    }

    .movie-info {
        padding: 8px;
    }

    .movie-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
    }

    .movie-year {
        font-size: 11px;
    }

    .genre-tag {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* Очень маленькие экраны (до 360px) */
@media (max-width: 360px) {
    .movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .movie-poster {
        height: 160px;
    }

    .category-title {
        font-size: 16px;
    }
}

/* Улучшение производительности для мобильных */
@media (hover: none) and (pointer: coarse) {
    .movie-card {
        transition: transform 0.2s ease;
    }

    .movie-poster img {
        transition: none;
    }

    /* Оптимизация touch событий */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
        touch-action: manipulation;
    }
}

/* Landscape ориентация на мобильных */
@media (max-width: 768px) and (orientation: landscape) {
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .movie-poster {
        height: 160px;
    }
}