:root {
    --games-bg: rgba(20, 0, 40, 0.45);
    --games-border: rgba(170, 204, 255, 0.18);
    --games-glow: rgba(114, 9, 183, 0.35);
}

.games-hero {
    position: relative;
    z-index: 1;
    padding: 6rem 1.5rem 3rem;
    text-align: center;
    scroll-margin-top: calc(90px + env(safe-area-inset-top, 0px));
}

#games {
    scroll-margin-top: calc(90px + env(safe-area-inset-top, 0px));
}

.games-hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 0.75rem;
    background: linear-gradient(115deg, #ffffff, #d6e9ff 55%, #c77dff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.5px;
}

.games-hero p {
    color: var(--text-secondary);
    font-size: 1.15rem;
    font-weight: 300;
    max-width: 520px;
    margin: 0 auto 2rem;
    opacity: 0.85;
    line-height: 1.6;
}

.games-search-wrapper {
    max-width: 480px;
    margin: 0 auto 2rem;
    position: relative;
}

.games-search {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem;
    background: var(--games-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--games-border);
    border-radius: 14px;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.games-search:focus {
    border-color: rgba(199, 125, 255, 0.5);
    box-shadow: 0 0 20px rgba(114, 9, 183, 0.25), 0 0 0 3px rgba(199, 125, 255, 0.15);
}

.games-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    opacity: 0.6;
    pointer-events: none;
}

.games-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    max-width: 800px;
    margin: 0 auto 3rem;
    padding: 0 1rem;
}

.games-filter-btn {
    padding: 0.55rem 1.2rem;
    background: var(--games-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--games-border);
    border-radius: 50px;
    color: var(--text-secondary);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.games-filter-btn:hover {
    background: rgba(114, 9, 183, 0.25);
    border-color: rgba(199, 125, 255, 0.4);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(114, 9, 183, 0.2);
}

.games-filter-btn.active {
    background: linear-gradient(135deg, rgba(114, 9, 183, 0.5), rgba(58, 12, 163, 0.5));
    border-color: rgba(199, 125, 255, 0.5);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(114, 9, 183, 0.35), 0 0 0 1px rgba(199, 125, 255, 0.2);
}

.games-featured {
    max-width: 1100px;
    margin: 0 auto 4rem;
    padding: 0 1.5rem;
}

.games-featured-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text);
    opacity: 0.9;
}

.games-featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.games-grid-section {
    max-width: 1100px;
    margin: 0 auto 4rem;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.game-card {
    position: relative;
    background: linear-gradient(165deg, rgba(36, 16, 62, 0.85), rgba(18, 8, 36, 0.75));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--games-border);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: rgba(199, 125, 255, 0.45);
    box-shadow: 0 25px 60px rgba(114, 9, 183, 0.45), 0 0 80px rgba(170, 204, 255, 0.12), inset 0 0 40px rgba(199, 125, 255, 0.05);
}

.game-card-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(114,9,183,0.35), rgba(58,12,163,0.35));
    transition: background-image 0.6s ease;
}

.game-card-thumb.loaded {
    animation: thumbReveal 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes thumbReveal {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

.game-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    position: relative;
    z-index: 1;
}

.game-card:hover .game-card-thumb img {
    transform: scale(1.08);
}

.game-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 40%, rgba(7, 6, 17, 0.9) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
}

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

.game-card-play {
    padding: 0.7rem 1.8rem;
    background: linear-gradient(135deg, #7209b7, #3a0ca3);
    border: 1px solid rgba(199, 125, 255, 0.4);
    border-radius: 50px;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: 'Poppins', sans-serif;
    box-shadow: 0 4px 15px rgba(114, 9, 183, 0.4);
    transform: translateY(10px);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.game-card:hover .game-card-play {
    transform: translateY(0);
}

.game-card-info {
    padding: 1.1rem 1.2rem 1.3rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.game-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    margin: 0;
}

.game-card-genre {
    font-size: 0.75rem;
    color: var(--accent-hot);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.game-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    opacity: 0.8;
}

.game-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.game-card-tag {
    padding: 0.2rem 0.6rem;
    background: rgba(114, 9, 183, 0.2);
    border: 1px solid rgba(170, 204, 255, 0.15);
    border-radius: 6px;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 500;
}

.games-no-results {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.games-no-results i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.game-page-player {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--games-border);
    box-shadow: 0 18px 50px rgba(8, 4, 20, 0.45);
}

.game-page-player iframe {
    display: block;
    width: 100%;
    height: auto;
    border: none;
    background: #000;
}

.game-page-player.portrait iframe {
    max-height: 70vh;
    margin: 0 auto;
}

.game-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    gap: 1rem;
    color: var(--text-secondary);
}

.game-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(170, 204, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.game-page-info {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    text-align: center;
}

.game-page-title {
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(115deg, #ffffff, #d6e9ff 55%, #c77dff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.game-page-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.game-page-tag {
    padding: 0.3rem 0.9rem;
    background: rgba(114, 9, 183, 0.25);
    border: 1px solid rgba(170, 204, 255, 0.2);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 500;
}

.game-page-desc {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0.85;
    font-weight: 300;
}

.game-modal {
    z-index: 2100 !important;
    display: none !important;
}
.game-modal.visible {
    display: flex !important;
}
.game-modal .modal-content {
    max-width: 1100px;
    width: 94vw;
    max-height: 92vh;
    background: linear-gradient(160deg, rgba(34,14,60,0.95), rgba(18,8,36,0.95));
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border-radius: 24px;
    padding: 1.5rem;
    border: 1px solid rgba(170,204,255,0.18);
    box-shadow: 0 18px 50px rgba(8,4,20,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}
.game-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(20, 8, 35, 0.8) !important;
    border: 1px solid rgba(170,204,255,0.2) !important;
    color: #fff !important;
    font-size: 1.2rem !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.game-modal-close:hover {
    background: rgba(114, 9, 183, 0.5) !important;
    border-color: rgba(199,125,255,0.5) !important;
    transform: scale(1.05);
}
.game-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.game-modal-title {
    font-size: 1.3rem;
    font-weight: 600;
    background: linear-gradient(115deg, #ffffff, #d6e9ff 55%, #c77dff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
}
.game-modal-body {
    position: relative;
    width: 100%;
    aspect-ratio: var(--game-aspect, 16/9);
    max-height: 80vh;
    overflow: hidden;
    background: rgba(0,0,0,0.4);
    border-radius: 16px;
    border: 1px solid var(--games-border);
    box-shadow: 0 18px 50px rgba(8,4,20,0.45);
}
.game-modal-body iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
}
.game-modal-body.portrait iframe {
    max-height: 70vh;
    margin: 0 auto;
}
.game-modal-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.show-more-btn {
    display: none;
    margin: 2rem auto 0;
    padding: 0.75rem 2.5rem;
    width: fit-content;
    min-width: 220px;
    max-width: 90%;
    background: linear-gradient(135deg, rgba(114, 9, 183, 0.4), rgba(58, 12, 163, 0.4));
    border: 1px solid rgba(199, 125, 255, 0.35);
    border-radius: 50px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    align-self: center;
}
.show-more-btn:hover {
    background: linear-gradient(135deg, rgba(114, 9, 183, 0.6), rgba(58, 12, 163, 0.6));
    border-color: rgba(199, 125, 255, 0.6);
    box-shadow: 0 4px 20px rgba(114, 9, 183, 0.35);
    transform: translateY(-2px);
}
@media (max-width: 768px) {
    .game-modal .modal-content {
        padding: 1rem;
        border-radius: 18px;
    }
    .game-modal-title {
        font-size: 1.1rem;
    }
}
@media (max-width: 480px) {
    .game-modal .modal-content {
        padding: 0.75rem;
        border-radius: 16px;
    }
    .game-modal-close {
        top: 0.5rem;
        right: 0.5rem;
        width: 34px;
        height: 34px;
        font-size: 1rem !important;
    }
}
.game-fullscreen-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0.7rem 1.5rem;
    background: linear-gradient(135deg, rgba(114, 9, 183, 0.4), rgba(58, 12, 163, 0.4));
    border: 1px solid rgba(199, 125, 255, 0.35);
    border-radius: 10px;
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-fullscreen-btn:hover {
    background: linear-gradient(135deg, rgba(114, 9, 183, 0.6), rgba(58, 12, 163, 0.6));
    border-color: rgba(199, 125, 255, 0.6);
    box-shadow: 0 4px 20px rgba(114, 9, 183, 0.35);
    transform: translateY(-2px);
}

.games-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0.6rem 1.2rem;
    background: rgba(20, 8, 35, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(170, 204, 255, 0.15);
    border-radius: 10px;
    color: var(--text-secondary);
    font-family: 'Poppins', sans-serif;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.games-back:hover {
    background: rgba(114, 9, 183, 0.3);
    border-color: rgba(199, 125, 255, 0.4);
    color: #fff;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .games-hero {
        padding: 5rem 1rem 2rem;
    }

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

    .games-featured-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .game-page-player {
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .games-hero h1 {
        font-size: 1.6rem;
    }

    .games-hero p {
        font-size: 1rem;
    }

    .games-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .games-filter-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .game-card-info {
        padding: 0.9rem 1rem 1.1rem;
    }
}
