/* === СБРОС И ПЕРЕМЕННЫЕ === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-light: #1f3050;
    --primary: #0f95d4;
    --primary-hover: #0b7db5;
    --accent: #fd79a8;
    --text: #e8e8e8;
    --text-secondary: #a0a8b8;
    --border: #2a3a55;
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 60px;
    --sidebar-expanded: 220px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    overflow-y: scroll;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }

/* === СКРОЛЛБАР === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* === ОСНОВНОЙ КОНТЕЙНЕР === */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* === ЛЕВАЯ ПАНЕЛЬ КАТЕГОРИЙ === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition);
    padding-top: 60px;
    scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar:hover {
    width: var(--sidebar-expanded);
}

.sidebar__list {
    list-style: none;
    padding: 4px 0;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 12px 0;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
    position: relative;
}

.sidebar__item:hover {
    background: var(--surface-light);
}

.sidebar__item.active {
    background: rgba(15, 149, 212, 0.15);
}

.sidebar__item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar__icon {
    width: 60px;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.sidebar__icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/* При наведении или активном пункте — иконка становится цветной */
.sidebar__item:hover .sidebar__icon img,
.sidebar__item.active .sidebar__icon img {
    opacity: 1;
}

.sidebar__label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.15s;
    padding-right: 16px;
    overflow: hidden;
}

.sidebar:hover .sidebar__label {
    opacity: 1;
}

.sidebar__item:hover .sidebar__label {
    color: var(--text);
}

.sidebar__item.active .sidebar__label {
    color: var(--primary);
}

/* === КНОПКА БУРГЕР ДЛЯ МОБИЛЬНЫХ === */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    width: 42px;
    height: 42px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 22px;
    color: var(--text);
    align-items: center;
    justify-content: center;
}

/* === ОВЕРЛЕЙ ДЛЯ МОБИЛЬНОГО МЕНЮ === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 999;
}

/* === ОСНОВНОЙ КОНТЕНТ === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 0;
    min-width: 0;
    transition: margin-left var(--transition);
}

/* === ШАПКА === */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header__inner {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    max-width: 1400px;
    margin: 0 auto;
}
.header__logo {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.header__logo span { color: var(--accent); }

.header__search {
    flex: 1;
    max-width: 400px;
    position: relative;
}
.header__search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.header__search input::placeholder { color: var(--text-secondary); }
.header__search input:focus { border-color: var(--primary); }
.header__search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-secondary);
    pointer-events: none;
}

.header__search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0,0,0,0.4);
    z-index: 200;
    display: none;
    max-height: 350px;
    overflow-y: auto;
    margin-top: 6px;
}
.header__search-results.active { display: block; }

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-light); }
.search-item__img {
    width: 52px;
    height: 34px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg);
}
.search-item__title { font-size: 14px; font-weight: 500; flex: 1; }
.search-item__age {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    flex-shrink: 0;
}
.search-item__age.age-0, .search-item__age.age-6 { background: #4CAF50; color: #fff; }
.search-item__age.age-12 { background: #FFC107; color: #1a1a1a; }
.search-item__age.age-16 { background: #FF9800; color: #fff; }
.search-item__age.age-18 { background: #F44336; color: #fff; }

/* === КОНТЕЙНЕР СТРАНИЦ === */
.page-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
}

/* === ЗАГОЛОВКИ СТРАНИЦ === */
.page-title {
    font-size: 24px;
    margin-bottom: 4px;
    color: var(--text);
}
.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 18px;
    font-size: 14px;
}

/* === СЕТКА ИГР === */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
}


/* === КАРТОЧКА ИГРЫ === */
.game-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    border: 1px solid transparent;
}
.game-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.4);
    border-color: var(--primary);
}
.game-card__thumb {
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--bg);
    position: relative;
}
.game-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s, opacity 0.3s;
}

/* Обложка и иконка */
.game-card__cover { display: block; }
.game-card__icon { display: none; }

/* Видео-превью */
.game-card__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
    background: #000;
    pointer-events: none;
}

/* Возрастной бейдж */
.game-card__age {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    z-index: 2;
}

.game-card__rating {
    color: #f1c40f;
    font-size: 12px;
    font-weight: 700;
}
}


.game-card__age.age-0, .game-card__age.age-6 { background: #4CAF50; color: #fff; }
.game-card__age.age-12 { background: #FFC107; color: #1a1a1a; }
.game-card__age.age-16 { background: #FF9800; color: #fff; }
.game-card__age.age-18 { background: #F44336; color: #fff; }

.game-card__info {
    padding: 8px 10px;
    position: relative;
    z-index: 2;
    background: var(--surface);
}
.game-card__title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text);
}
.game-card__plays {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* === ПК: ВИДЕО ПРИ НАВЕДЕНИИ === */
@media (hover: hover) and (pointer: fine) {
    .game-card:hover .game-card__video {
        opacity: 1;
    }
    .game-card:hover .game-card__cover {
        opacity: 0;
    }
}

/* === МОБИЛЬНЫЕ: ИКОНКА ВМЕСТО ОБЛОЖКИ === */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .game-card__cover { display: none; }
    .game-card__icon { display: block; }
    .game-card__video { display: none !important; }
    .game-card__thumb {
        aspect-ratio: 1 / 1;
    }
    .game-card__icon {
        object-fit: contain;
        padding: 8px;
    }
}

/* === МОБИЛЬНЫЕ: ИКОНКА ВМЕСТО ОБЛОЖКИ === */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .game-card__cover { display: none; }
    .game-card__icon { display: block; }
    .game-card__video { display: none !important; }
    .game-card__thumb {
    aspect-ratio: 1 / 1;
}
.game-card__icon {
    object-fit: contain;
    padding: 8px;
}

}

/* === ПАГИНАЦИЯ === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 28px 0;
}
.pagination a, .pagination span {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* === СТРАНИЦА ИГРЫ === */
.game-banner {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    background: #000;
    position: relative;
}
.game-banner iframe {
    width: 100%;
    border: none;
    display: block;
    min-height: 500px;
}

/* === КНОПКА FULLSCREEN === */
.fullscreen-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
    line-height: 1;
}
.fullscreen-btn:hover {
    background: rgba(15, 149, 212, 0.7);
    border-color: var(--primary);
    transform: scale(1.05);
}

/* === ИНФО-БЛОК ИГРЫ === */
.game-info {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}
.game-info h1 { font-size: 26px; margin-bottom: 12px; color: var(--text); }
.game-info__meta {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.game-info__meta-item { font-size: 13px; color: var(--text-secondary); }
.game-info__age {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
}
.game-info__age.age-0, .game-info__age.age-6 { background: #4CAF50; }
.game-info__age.age-12 { background: #FFC107; color: #1a1a1a; }
.game-info__age.age-16 { background: #FF9800; }
.game-info__age.age-18 { background: #F44336; }

.game-info__desc {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.game-info__controls {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.game-info__controls strong { color: var(--text); }

/* === СКРИНШОТЫ === */
.game-screenshots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.game-screenshots img {
    border-radius: var(--radius-sm);
    width: 100%;
    aspect-ratio: auto;
    object-fit: contain;
    background: #000;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}
.game-screenshots img:hover { transform: scale(1.02); }
.game-screenshots img.vertical {
    aspect-ratio: 9/16;
    max-height: 400px;
    width: auto;
    margin: 0 auto;
}

/* === ЗАГОЛОВКИ СЕКЦИЙ === */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text);
}

/* === ФУТЕР === */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 40px;
}

/* === 404 === */
.page-404 { text-align: center; padding: 80px 16px; }
.page-404 h1 { font-size: 80px; color: var(--primary); }
.page-404 p { font-size: 16px; margin: 12px 0 20px; color: var(--text-secondary); }
.page-404 a {
    display: inline-block;
    padding: 10px 24px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s;
}
.page-404 a:hover { background: var(--primary-hover); }


.game-card__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
    background: #000;
    pointer-events: none;
}

/* На ПК — видео при наведении */
@media (hover: hover) and (pointer: fine) {
    .game-card:hover .game-card__video {
        opacity: 1;
    }
    .game-card:hover .game-card__cover {
        opacity: 0;
    }
}

.game-rating {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}

.star {
    font-size: 28px;
    color: #555;
    transition: color 0.15s;
}
.rating-block:hover .star {
    color: #f1c40f;
}
.star:hover ~ .star {
    color: #555;
}
.star.active {
    color: #f1c40f;
}


.rating-value {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 8px;
}


/* === АДАПТИВ === */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }
    .sidebar.open {
        width: var(--sidebar-expanded);
        overflow-y: auto;
    }
    .sidebar.open .sidebar__label {
        opacity: 1;
    }
    .sidebar-toggle {
        display: flex;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .header__inner {
        padding: 10px 16px 10px 60px;
    }
    .page-container {
        padding: 12px 10px;
    }
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .game-info { padding: 16px; }
    .game-info h1 { font-size: 20px; }
    .game-banner iframe { min-height: 300px; }
}

@media (min-width: 769px) {
    .sidebar-toggle { display: none; }
    .sidebar-overlay { display: none; }
}