/* modern.css - Premium Choclate Gaming UI */
:root {
    --bg-base: #1a0f0d;
    --bg-glass: rgba(45, 27, 20, 0.7);
    --bg-glass-hover: rgba(55, 33, 24, 0.85);
    --border-glass: rgba(255, 245, 230, 0.1);

    --text-primary: #fff5e6;
    --text-secondary: #d1a586;

    --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
    --accent-color: #f59e0b;

    --danger-color: #ef4444;
    --success-color: #10b981;

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(251, 191, 36, 0.4);
}

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

body {
    background-color: var(--bg-base);
    background-image:
        radial-gradient(circle at 15% 50%, rgba(217, 119, 6, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(251, 191, 36, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}


/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    border: none;
}

.primary-btn {
    background: var(--accent-gradient);
    color: #fff;
}

.primary-btn:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.outline-btn {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

.outline-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.logout-btn {
    width: 100%;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.full-width {
    width: 100%;
}

/* Main Content Area */


/* Game View Details - Refined */
.game-view-container {
    max-width: 1400px;
    margin: 0 auto;
}

.game-header {
    display: none;
    /* Removed as per user request */
}

.game-title {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
}

.game-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.badge {
    background: var(--accent-gradient);
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}

.date {
    color: var(--text-secondary);
    font-size: 14px;
}

.game-actions {
    display: flex;
    gap: 16px;
}

.fav-btn.active {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
    border-color: rgba(255, 71, 87, 0.3);
}

.iframe-wrapper {
    aspect-ratio: 16 / 9;
    width: 100%;
    margin-bottom: 32px;
    overflow: clip;
    position: relative;
    padding: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #000;
}

@media (min-width: 1101px) {
    .iframe-wrapper.is-premium {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        z-index: 10000;
        aspect-ratio: auto;
        border-radius: 0;
        border: none;
        margin: 0;
        display: grid;
        grid-template-columns: 1fr 15vw;
        grid-template-rows: 1fr auto;
    }

    .iframe-wrapper.is-premium.no-ad {
        grid-template-columns: 1fr;
    }

    .iframe-wrapper.is-premium .pf-controls-overlay {
        display: flex;
        grid-column: 1 / -1;
        grid-row: 2;
        height: 60px;
        background: rgba(0, 0, 0, 0.85);
        backdrop-filter: blur(15px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        align-items: center;
        justify-content: space-between;
        padding: 0 30px;
    }

    .iframe-wrapper.is-premium .pf-side-overlay {
        display: flex;
        grid-column: 2;
        grid-row: 1;
        background: rgba(15, 15, 15, 0.95);
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
    }

    /* When ad is in the fullscreen side panel, override its normal styles */
    .pf-side-overlay .in-canvas-ad-container {
        width: 100% !important;
        min-width: 100% !important;
        height: 100% !important;
        border-left: none !important;
        border-top: none !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
}

.iframe-wrapper.is-premium.no-ad .pf-side-overlay {
    display: none;
}

/* Interaction Bar - Consolidated */
.interaction-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 30px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    border: 1px solid var(--border-glass);
    margin-bottom: 32px;
    box-shadow: var(--shadow-soft);
}

.interaction-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.interaction-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.interaction-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.interaction-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.interaction-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pf-game-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

/* Reusing these for the overlay internal elements */
.pf-controls-overlay,
.pf-side-overlay {
    display: none;
}

.pf-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.pf-side {
    width: 320px;
    background: transparent;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.sticky-ad {
    position: sticky;
    top: 100px;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

.pf-exit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.pf-exit-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger-color);
}

.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.game-description {
    padding: 32px;
}

.game-description h3 {
    margin-bottom: 16px;
    font-size: 20px;
}

.game-description p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 160px);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-card h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.auth-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
}

.form-error {
    color: var(--danger-color);
    font-size: 13px;
    margin-top: 6px;
}

.form-text {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 6px;
}

.auth-form {
    margin-bottom: 24px;
}

.auth-links {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-links a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Tooltip */
.tooltip {
    position: relative;
    display: inline-flex;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: var(--bg-glass);
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}


/* Pagination */
.pagination-section {
    margin-top: 50px;
    display: flex;
    justify-content: center;
    padding-bottom: 20px;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 24px;
    border-radius: 20px;
}

.page-number {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.pagination-btn {
    padding: 8px 16px;
    font-size: 13px;
}

.pagination-btn svg {
    margin: 0;
}

/* Mobile Pagination */
@media (max-width: 600px) {
    .pagination-controls {
        gap: 12px;
        padding: 10px 16px;
    }

    .page-number {
        font-size: 12px;
    }
}


/* Authentication Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.modal-header {
    text-align: center;
    margin-bottom: 30px;
}

.modal-header h2 {
    font-size: 26px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-form .form-group {
    margin-bottom: 20px;
}

.modal-form .form-control {
    width: 100%;
    padding: 14px 16px;
}

.modal-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-secondary);
}

.modal-footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}


@keyframes modal-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px);
    }

    75% {
        transform: translateX(8px);
    }
}

.modal-content.error {
    animation: modal-shake 0.3s ease;
    border-color: var(--danger-color);
}

/* Similar Games Section */
.similar-games-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border-glass);
}


.similar-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

.small-card {
    padding: 12px;
    border-radius: 16px;
}

.small-card .thumb-wrapper {
    margin-bottom: 12px;
}

.small-card h4 {
    font-size: 14px;
    margin-bottom: 4px;
    font-weight: 600;
}



/* --- Mobile Game View Additions --- */
.mobile-game-header {
    display: none;
}

.sheet-drag-handle {
    display: none;
    /* Hide on desktop */
}

@media (max-width: 1100px) {

    /* Hide sidebar and topbar natively by placing game view absolute over everything */
    .game-view-container {
        position: fixed;
        inset: 0;
        z-index: 2100;
        /* above sidebar overlay */
        background: var(--bg-base);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-game-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 16px;
        background: rgba(15, 15, 15, 0.95);
        border-bottom: 1px solid var(--border-glass);
        z-index: 1010;
        backdrop-filter: blur(10px);
        height: 60px;
    }

    .mgh-info {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 12px;
        flex: 1;
        cursor: pointer;
    }

    .mgh-back-btn,
    .mgh-fs-btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.8);
        width: 36px;
        height: 36px;
        padding: 0;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }

    .mgh-back-btn:active,
    .mgh-fs-btn:active {
        background: rgba(255, 255, 255, 0.1);
        transform: scale(0.95);
    }

    .mgh-back-btn svg,
    .mgh-fs-btn svg {
        width: 18px;
        height: 18px;
        stroke-width: 2;
    }

    .mgh-icon-wrapper {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mgh-icon {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .mgh-title {
        font-weight: 600;
        font-size: 16px;
        color: var(--text-primary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    .mgh-chevron {
        transition: transform 0.3s ease;
        opacity: 0.7;
    }

    .mgh-chevron.active {
        transform: rotate(180deg);
        opacity: 1;
    }

    .mgh-fs-btn {
        background: rgba(255, 255, 255, 0.1);
        padding: 8px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Layout Logic for Portrait/Landscape */
    .game-main-layout {
        display: flex !important;
        /* override grid */
        flex-direction: column !important;
        flex: 1;
        width: 100%;
        height: 100%;
        overflow: hidden;
        gap: 0 !important;
    }

    @media (orientation: landscape) {
        .game-main-layout {
            flex-direction: row !important;
        }

        .game-column-right {
            display: none !important; /* Hide sidebar completely in mobile landscape */
        }

        .game-column-left {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .iframe-wrapper {
            flex: 1;
            flex-direction: row !important; /* Game on left, ad on right */
            border-radius: 0 !important;
            margin: 0 !important;
            aspect-ratio: auto !important;
        }

        .iframe-wrapper .in-canvas-ad-container {
            width: 15vw !important; /* Fixed width for right ad */
            min-width: 120px !important;
            max-width: 200px !important;
            height: 100% !important;
            max-height: 100% !important;
            border-left: 1px solid var(--border-glass) !important;
            border-top: none !important;
            flex-shrink: 0;
            display: flex !important;
        }
    }

    @media (orientation: portrait) {
        .game-main-layout {
            flex-direction: column !important;
        }

        .game-column-left {
            flex: 1;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .iframe-wrapper {
            flex: 1;
            flex-direction: column !important;
            border-radius: 0 !important;
            margin: 0 !important;
            aspect-ratio: auto !important;
        }

        .iframe-wrapper .in-canvas-ad-container {
            width: 100% !important;
            min-width: 100% !important;
            max-width: 100% !important;
            height: 15vh !important;
            max-height: 15vh !important;
            min-height: 50px;
            border-left: none !important;
            border-top: 1px solid var(--border-glass);
            flex-shrink: 0;
        }
    }

    /* Bottom Sheet Logic */
    .game-info-wrapper {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(20, 20, 20, 0.95);
        backdrop-filter: blur(15px);
        border-top: 1px solid var(--border-glass);
        border-radius: 20px 20px 0 0;
        transform: translateY(110%);
        transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
        z-index: 1005;
        max-height: 80vh;
        overflow-y: auto;
        padding-top: 20px;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    }

    .game-info-wrapper.active {
        transform: translateY(0);
    }

    .sheet-drag-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: -10px auto 16px auto;
        cursor: pointer;
    }

    .interaction-bar {
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-glass) !important;
        background: transparent !important;
        padding: 16px 20px !important;
    }

    .game-column-right {
        background: rgba(0, 0, 0, 0.5);
        display: flex !important;
        /* Ensure unified ad space is visible */
        justify-content: center;
        align-items: center;
        border-top: 1px solid var(--border-glass);
        width: 100%;
        padding: 10px 0;
    }

    .game-side-ad {
        min-height: 50px !important;
        border: none !important;
        backdrop-filter: none !important;
        background: transparent !important;
        padding: 0 !important;
        box-shadow: none !important;
        width: 100%;
        display: flex;
        justify-content: center;
    }
}

/* --- End Mobile Game View Additions --- */


/* Rating Stars */
.rating-display {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.stars-outer {
    position: relative;
    display: inline-block;
    font-size: 22px;
    line-height: 1;
    height: 1em;
    cursor: default;
    user-select: none;
}

.stars-outer::before {
    content: "\2605 \2605 \2605 \2605 \2605";
    color: rgba(255, 255, 255, 0.15);
}

.stars-inner {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
    line-height: 1;
    transition: width 0.2s ease;
    pointer-events: none;
    /* pass clicks through to stars-outer */
}

.stars-inner::before {
    content: "\2605 \2605 \2605 \2605 \2605";
    color: #f59e0b;
}

.rating-value {
    font-weight: 700;
    color: var(--accent-color);
}

.rating-count {
    font-size: 12px;
    color: var(--text-secondary);
}


/* Game Cover Banner */
.game-cover-banner {
    position: relative;
    width: 100%;
    height: 280px;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 28px;
}

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

.game-cover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 30%, rgba(26, 15, 13, 0.95) 100%);
}


/* =====================================================================
   Portal v2 — shell (sidebar / header / footer) and catalog
   Spacing scale: 4 8 12 16 20 24 32 40.  Radius: 8 12 16 20.
   ===================================================================== */
:root {
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 15px;
    --fs-lg: 18px;
    --fs-xl: clamp(22px, 2.2vw + 12px, 32px);

    --surface: #2a1a14;
    --surface-2: #35221a;
    --text-muted: #b3917a;
    --accent-light: #fbbf24;
    --on-accent: #2a1408;
    --focus-ring: 0 0 0 3px rgba(251, 191, 36, 0.5);

    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
    --transition: all 0.2s cubic-bezier(0.2, 0.7, 0.2, 1);

    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --topbar-h: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    -webkit-text-size-adjust: 100%;
    color-scheme: dark;
    scrollbar-width: thin;
    scrollbar-color: #4a2f22 transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

img {
    max-width: 100%;
}

:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 10002;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: var(--on-accent);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform 0.2s var(--ease);
}

.skip-link:focus {
    transform: none;
}

.accent {
    color: var(--accent-color);
}

h1 .accent,
.logo-text .accent {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Buttons ---------- */
.primary-btn {
    color: var(--on-accent);
}

.btn:focus-visible,
.sort-btn:focus-visible,
.chip:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

.sidebar .btn,
.empty-state .btn,
.modal-form .btn,
.auth-section .btn {
    min-height: 44px;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 0 16px;
    border-radius: 0;
    border: 0;
    border-right: 1px solid var(--border-glass);
    background: rgba(32, 19, 14, 0.94);
    z-index: 100;
    transition: width 0.25s var(--ease);
    overflow: hidden;
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #4a2f22 transparent;
    overscroll-behavior: contain;
}

.sidebar-toggle {
    position: absolute;
    top: 22px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 110;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--accent-gradient);
    border-color: transparent;
    color: var(--on-accent);
}

.sidebar-toggle svg {
    transition: transform 0.25s var(--ease);
}

.sidebar-close {
    display: none;
}

.logo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px;
    text-align: left;
}

.logo a {
    display: flex;
    flex-shrink: 0;
    border-radius: var(--radius-md);
}

.logo-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.3));
    transition: var(--transition);
}

.logo:hover .logo-img {
    transform: scale(1.08) rotate(4deg);
}

.logo-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.nav-section {
    padding: 4px 12px 8px;
}

.nav-title {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 8px;
    padding: 0 12px;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.nav-item > span:not(.genre-count-badge) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.genre-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.genre-icon svg {
    width: 100%;
    height: 100%;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.75;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
    color: var(--accent-light);
    background: rgba(245, 158, 11, 0.14);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-gradient);
}

.nav-item.active svg {
    opacity: 1;
}

.genre-count-badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.nav-item.active .genre-count-badge {
    background: rgba(245, 158, 11, 0.25);
    color: var(--accent-light);
}

.auth-section {
    margin-top: 8px;
    padding: 16px 16px 0;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: var(--on-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
}

.username {
    font-weight: 500;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
}

/* Collapsed sidebar: desktop / tablet only (mobile uses the drawer) */
@media (min-width: 769px) {

    html.sb-collapsed .sidebar,
    .sidebar.collapsed {
        width: var(--sidebar-w-collapsed);
    }

    html.sb-collapsed .sidebar .logo-text,
    html.sb-collapsed .sidebar .nav-title,
    html.sb-collapsed .sidebar .username,
    html.sb-collapsed .sidebar .nav-item > span,
    html.sb-collapsed .sidebar .genre-count-badge,
    html.sb-collapsed .sidebar .logout-btn span,
    html.sb-collapsed .sidebar .auth-section .btn span,
    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-title,
    .sidebar.collapsed .username,
    .sidebar.collapsed .nav-item > span,
    .sidebar.collapsed .genre-count-badge,
    .sidebar.collapsed .logout-btn span,
    .sidebar.collapsed .auth-section .btn span {
        display: none;
    }

    html.sb-collapsed .sidebar .logo,
    .sidebar.collapsed .logo {
        justify-content: center;
        padding: 0 0 56px;
    }

    html.sb-collapsed .sidebar .sidebar-toggle,
    .sidebar.collapsed .sidebar-toggle {
        top: 68px;
        right: auto;
        left: 50%;
        margin-left: -16px;
    }

    html.sb-collapsed .sidebar .sidebar-toggle svg,
    .sidebar.collapsed .sidebar-toggle svg {
        transform: rotate(180deg);
    }

    html.sb-collapsed .sidebar .nav-section,
    .sidebar.collapsed .nav-section {
        padding: 4px 10px 8px;
    }

    html.sb-collapsed .sidebar .nav-item,
    .sidebar.collapsed .nav-item {
        justify-content: center;
        padding: 0;
    }

    html.sb-collapsed .sidebar .auth-section,
    .sidebar.collapsed .auth-section {
        padding: 16px 10px 0;
        align-items: center;
    }

    html.sb-collapsed .sidebar .auth-section .btn,
    .sidebar.collapsed .auth-section .btn {
        width: 44px;
        padding: 0;
    }

    html.sb-collapsed .sidebar .auth-section .btn::before,
    .sidebar.collapsed .auth-section .btn::before {
        content: '\2192';
        font-size: 18px;
    }
}

/* ---------- Content area & top bar ---------- */
.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--topbar-h);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    background: rgba(26, 15, 13, 0.82);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    z-index: 50;
}

.mobile-menu-toggle {
    display: none;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
}

.mobile-menu-toggle:active {
    background: rgba(255, 255, 255, 0.08);
}

.search-form {
    flex: 1;
    min-width: 0;
    max-width: 460px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    min-width: 0;
    height: 44px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    padding: 0 44px 0 44px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 15px;
    transition: var(--transition);
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.09);
    box-shadow: var(--focus-ring);
}

.search-clear {
    position: absolute;
    right: 2px;
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
}

.search-clear:hover {
    color: var(--text-primary);
}

.lang-switch {
    display: flex;
    gap: 2px;
    margin-left: auto;
    padding: 3px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
}

.lang-switch a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 36px;
    padding: 0 10px;
    border-radius: 9px;
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.lang-switch a:hover {
    color: var(--text-primary);
}

.lang-switch a.active {
    background: var(--accent-gradient);
    color: var(--on-accent);
}

.top-bar-logo {
    display: none;
    height: 36px;
    align-items: center;
    justify-content: flex-end;
}

.top-bar-logo img {
    height: 32px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.top-bar-logo a {
    display: flex;
    align-items: center;
}

.page-content {
    flex: 1;
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
    padding: var(--space-8) var(--space-10) var(--space-10);
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding: 20px var(--space-10) calc(20px + var(--safe-bottom));
    border-top: 1px solid var(--border-glass);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--accent-light);
    text-decoration: underline;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(16px + var(--safe-bottom));
    width: 48px;
    height: 48px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(251, 191, 36, 0.4);
    background: rgba(42, 26, 20, 0.94);
    color: var(--accent-light);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    cursor: pointer;
    z-index: 90;
    animation: fadeIn 0.25s var(--ease);
    transition: var(--transition);
}

.back-to-top:hover {
    background: var(--accent-gradient);
    color: var(--on-accent);
}

/* ---------- Page headings ---------- */
.header-section {
    margin-bottom: var(--space-6);
}

.header-section h1 {
    font-size: var(--fs-xl);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 0;
}

.subtitle,
.results-meta {
    margin-top: var(--space-1);
    color: var(--text-secondary);
    font-size: 14px;
}

.results-meta strong,
.subtitle strong {
    color: var(--text-primary);
    font-weight: 600;
}

.header-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--space-4) var(--space-5);
    flex-wrap: wrap;
}

.header-title-block {
    min-width: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-3);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.section-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--accent-gradient);
    border-radius: 2px;
}

/* Sort tabs */
.sort-filters {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
}

.sort-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    font-size: 14px;
    border-radius: 9px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
}

.sort-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.sort-btn.active {
    background: var(--accent-gradient);
    color: var(--on-accent);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Genre chips (phones / small tablets, where the sidebar is hidden) */
.genre-chips {
    display: none;
    gap: 8px;
    margin: var(--space-4) calc(-1 * var(--space-4)) 0;
    padding: 2px var(--space-4) 4px;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.genre-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    scroll-snap-align: start;
    transition: var(--transition);
}

.chip.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: var(--on-accent);
    font-weight: 600;
}

/* ---------- Continue playing ---------- */
.history-section {
    margin-bottom: var(--space-8);
    animation: fadeIn 0.5s var(--ease);
}

.history-grid {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    padding: 4px 2px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-glass) transparent;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
}

.history-grid::-webkit-scrollbar {
    height: 6px;
}

.history-grid::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}

.history-card-link {
    flex: 0 0 auto;
    width: 88px;
    text-decoration: none;
    scroll-snap-align: start;
    border-radius: var(--radius-lg);
}

.history-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s var(--ease);
}

.history-thumb-wrapper {
    width: 88px;
    height: 88px;
    border-radius: 20px;
    overflow: hidden;
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    transition: var(--transition);
}

.history-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s var(--ease);
}

.history-info {
    width: 100%;
    padding-top: 8px;
    text-align: center;
}

.history-game-title {
    display: block;
    font-size: var(--fs-xs);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-card-link:focus-visible .history-thumb-wrapper {
    border-color: var(--accent-light);
    box-shadow: var(--focus-ring);
}

.no-thumb-small {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.2);
}

/* ---------- Game grid & cards ---------- */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-6);
}

.game-grid.similar-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-5);
}

.game-card-wrapper {
    position: relative;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.game-card-link {
    display: block;
    flex: 1;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius-lg);
}

.game-card-link:focus-visible {
    outline: none;
}

.game-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.game-card .thumb-wrapper {
    position: relative;
    margin-bottom: 0;
    border-radius: 0;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #2a1a14 0%, #3a251c 100%);
}

.game-thumbnail {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s var(--ease);
}

.game-thumbnail.is-icon {
    object-fit: contain;
    padding: 8px;
}

.no-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.badge-new {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--accent-gradient);
    color: var(--on-accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.1));
    opacity: 0;
    transition: opacity 0.25s var(--ease);
}

.play-overlay-btn {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 3px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: var(--on-accent);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    transform: scale(0.85);
    transition: transform 0.25s var(--ease);
}

.game-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 14px;
}

.game-info h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-card-meta {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}

.genre-tag {
    display: inline-block;
    min-width: 0;
    max-width: 65%;
    padding: 3px 9px;
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.14);
    color: var(--accent-light);
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.genre-tag:empty {
    display: none;
}

.play-count-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    white-space: nowrap;
}

.card-stats {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.card-stats:empty {
    display: none;
}

.card-stats .play-count-tag {
    margin-left: 0;
}

.rating-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: #fbbf24;
    white-space: nowrap;
}

.rating-tag svg {
    flex-shrink: 0;
}

.play-count-tag svg {
    opacity: 0.7;
}

@media (hover: hover) {
    .game-card-link:hover .game-card {
        transform: translateY(-4px);
        border-color: rgba(251, 191, 36, 0.45);
        box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(251, 191, 36, 0.15);
    }

    .game-card-link:hover .game-thumbnail:not(.is-icon) {
        transform: scale(1.05);
    }

    .game-card-link:hover .play-overlay {
        opacity: 1;
    }

    .game-card-link:hover .play-overlay-btn {
        transform: scale(1);
    }

    .history-card-link:hover .history-card {
        transform: translateY(-3px);
    }

    .history-card-link:hover .history-thumb-wrapper {
        border-color: var(--accent-color);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    }

    .chip:hover,
    .nav-item:hover {
        color: var(--text-primary);
    }
}

.game-card-link:focus-visible .game-card {
    border-color: var(--accent-light);
    box-shadow: var(--focus-ring);
}

.game-card-link:focus-visible .play-overlay {
    opacity: 1;
}

.game-card-link:active .game-card {
    transform: scale(0.985);
}

/* Admin quick actions under a card */
.admin-card-actions {
    display: flex;
    gap: 8px;
    padding: 8px 2px 0;
}

.admin-card-actions .btn {
    flex: 1;
    min-height: 36px;
    padding: 0 8px;
    font-size: var(--fs-xs);
}

.admin-card-actions .btn.danger {
    border-color: rgba(239, 68, 68, 0.35);
    color: #f87171;
}

/* Ads between cards */
.grid-ad-block {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    width: 100%;
    margin: var(--space-3) 0;
}

.grid-ad-slot {
    width: 50%;
}

/* Empty states */
.empty-state {
    grid-column: 1 / -1;
    padding: 56px var(--space-6);
    text-align: center;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
}

.empty-state svg {
    color: var(--text-muted);
    opacity: 0.8;
}

.empty-title {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.empty-hint {
    margin: 0;
    max-width: 420px;
    font-size: 14px;
}

.empty-state .btn {
    margin-top: var(--space-2);
}

/* ---------- Similar games (game page) ---------- */
.similar-games-section {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border-glass);
}

/* ---------- Auth modal ---------- */
.modal-overlay.active {
    animation: overlayIn 0.2s ease;
}

.modal-overlay.active .modal-content {
    animation: modalPop 0.28s var(--ease);
}

@keyframes overlayIn {
    from {
        opacity: 0;
    }
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
}

@keyframes sheetUp {
    from {
        transform: translateY(100%);
    }
}

.modal-close {
    width: 44px;
    height: 44px;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-control:focus {
    box-shadow: var(--focus-ring);
}

/* ---------- Toasts ---------- */
.toast-container {
    position: fixed;
    right: var(--space-6);
    bottom: calc(var(--space-6) + var(--safe-bottom));
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: rgba(42, 26, 20, 0.96);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlide 0.35s var(--ease) forwards;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes toastSlide {
    from {
        transform: translateX(40px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.removing {
    animation: toastFade 0.3s ease forwards;
}

@keyframes toastFade {
    to {
        transform: translateY(-8px);
        opacity: 0;
    }
}

/* ---------- Tablet: sidebar is always compact-by-default (JS), tighter paddings ---------- */
@media (max-width: 1100px) {
    .page-content {
        padding: var(--space-6) var(--space-6) var(--space-8);
    }

    .top-bar {
        padding: 0 var(--space-6);
    }

    .site-footer {
        padding-left: var(--space-6);
        padding-right: var(--space-6);
    }
}

/* ---------- Mobile (<= 768): drawer, sticky compact header, 2-column grid ---------- */
@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(86vw, 320px);
        height: 100vh;
        height: 100dvh;
        padding-top: max(20px, env(safe-area-inset-top));
        border-right: 1px solid var(--border-glass);
        border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
        background: rgba(30, 18, 13, 0.98);
        z-index: 2000;
        transform: translateX(-102%);
        visibility: hidden;
        transition: transform 0.3s var(--ease), visibility 0s linear 0.3s;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        visibility: visible;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
        transition-delay: 0s;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .sidebar-close {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.06);
        border: 0;
        border-radius: 50%;
        color: var(--text-primary);
        cursor: pointer;
        z-index: 110;
    }

    .logo {
        padding-right: 64px;
    }

    .nav-item {
        min-height: 48px;
    }

    .top-bar {
        height: 60px;
        padding: 0 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        gap: 8px;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .search-form {
        max-width: none;
    }

    .search-input-wrapper input {
        font-size: 16px;
        /* 16px prevents iOS from zooming the page on focus */
        padding-left: 40px;
    }

    .search-icon {
        left: 12px;
    }

    .lang-switch a {
        min-width: 38px;
        min-height: 38px;
        padding: 0 8px;
    }

    .top-bar-logo {
        display: none;
    }

    .page-content {
        padding: var(--space-5) var(--space-4) var(--space-8);
    }

    .site-footer {
        padding: 16px var(--space-4) calc(16px + var(--safe-bottom));
        flex-direction: column;
    }

    .header-section {
        margin-bottom: var(--space-4);
    }

    .header-title-row {
        flex-direction: column;
        align-items: stretch;
    }

    .sort-filters {
        width: 100%;
    }

    .sort-btn {
        flex: 1;
        padding: 0 8px;
        font-size: 13px;
    }

    .genre-chips {
        display: flex;
    }

    .history-grid {
        margin: 0 calc(-1 * var(--space-4));
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    .game-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        gap: var(--space-3);
    }

    .game-info {
        padding: 10px 10px 12px;
        gap: 6px;
    }

    .game-info h3 {
        font-size: 13.5px;
    }

    .genre-tag {
        padding: 2px 7px;
        font-size: 11px;
    }

    .play-count-tag {
        font-size: 11px;
    }

    .play-overlay {
        display: none;
    }

    .grid-ad-slot {
        width: 100%;
    }

    .admin-card-actions {
        flex-direction: column;
        gap: 4px;
    }

    .modal-overlay {
        align-items: flex-end;
    }

    .modal-content {
        width: 100% !important;
        max-width: none;
        margin: 0;
        padding: 28px var(--space-5) calc(var(--space-6) + var(--safe-bottom)) !important;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 92dvh;
        overflow-y: auto;
    }

    .modal-overlay.active .modal-content {
        animation: sheetUp 0.3s var(--ease);
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .form-control {
        min-height: 48px;
        font-size: 16px;
    }

    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        bottom: calc(80px + var(--safe-bottom));
        align-items: center;
    }

    .toast {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    @keyframes toastSlide {
        from {
            transform: translateY(16px);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* Phones: strict 2 columns */
@media (max-width: 560px) {

    .game-grid,
    .game-grid.similar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-3);
    }
}

/* Very narrow phones */
@media (max-width: 359px) {
    .logo-text {
        font-size: 10px;
    }

    .lang-switch a {
        min-width: 34px;
        padding: 0 6px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   SEO-контент каталога: вступление жанра/подборки, блок «Подборки», хлебные крошки
   ========================================================================== */
.catalog-intro {
    margin-top: var(--space-4, 16px); max-width: 90ch;
    color: var(--text-secondary); line-height: 1.65; font-size: 15px;
}
.catalog-intro p { margin: 0 0 .75em; }
.catalog-intro p:last-child { margin-bottom: 0; }
.collection-faq { margin: var(--space-5, 24px) 0; max-width: 90ch; display: flex; flex-direction: column; gap: 8px; }
.collection-faq-item { border: 1px solid var(--border-glass); border-radius: 12px; padding: 0 16px; background: var(--bg-glass); }
.collection-faq-item summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--text-primary); }
.collection-faq-item summary:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; border-radius: 6px; }
.collection-faq-answer { padding-bottom: 12px; color: var(--text-secondary); line-height: 1.65; font-size: 15px; }
.collection-faq-answer p { margin: 0 0 .75em; }
.collection-faq-answer p:last-child { margin-bottom: 0; }
.collections-block { margin: var(--space-4, 16px) 0 var(--space-5, 24px); }
.collections-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.collection-chip {
    display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--border-glass); background: var(--bg-glass);
    color: var(--text-primary); text-decoration: none; font-size: 14px; font-weight: 600;
}
.collection-chip:hover, .collection-chip:focus-visible { border-color: var(--accent-color); color: var(--accent-color); }
.collection-chip-count { color: var(--text-secondary); font-weight: 500; font-size: 12.5px; }
/* Главная: подборки одной строкой с прокруткой, затуханием краёв и стрелками. */
.collections-block.is-scroller { margin: 0 0 var(--space-6, 24px); }
.collections-block.is-scroller .section-title { margin-bottom: var(--space-3, 12px); }
.collections-scroller { position: relative; }
.collections-block.is-scroller .collections-list {
    flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; scroll-padding: 0 4px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; padding: 2px 0;
    --fade-l: 0px; --fade-r: 48px;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.collections-block.is-scroller .collections-list::-webkit-scrollbar { display: none; }
.collections-scroller:not(.at-start) .collections-list { --fade-l: 48px; }
.collections-scroller.at-end .collections-list { --fade-r: 0px; }
.collections-block.is-scroller li { flex-shrink: 0; scroll-snap-align: start; }
.collection-chip { white-space: nowrap; }
.collections-arrow {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 1;
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
    border: 1px solid var(--border-glass); background: var(--surface, #2a1a14); color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .45); transition: opacity .2s, border-color .2s;
}
.collections-arrow:hover { border-color: var(--accent-color); color: var(--accent-color); }
.collections-arrow.is-prev { left: -6px; }
.collections-arrow.is-next { right: -6px; }
.collections-scroller.at-start .collections-arrow.is-prev,
.collections-scroller.at-end .collections-arrow.is-next { opacity: 0; pointer-events: none; }
@media (hover: none), (max-width: 768px) {
    .collections-arrow { display: none; }
    .collections-block.is-scroller .collections-list { margin: 0 calc(-1 * var(--space-4, 16px)); padding: 2px var(--space-4, 16px); scroll-padding: 0 var(--space-4, 16px); }
}
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0 0 8px; padding: 0; font-size: 13px; color: var(--text-secondary); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; opacity: .6; }
.breadcrumbs a { color: var(--text-secondary); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent-color); }
