@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800;900&display=swap');

:root {
    --primary: #2c7ffc;
    --background: #1b1b1b;
    --card-bg: #222222;
    --text-color: #ffffff;
    --search-bg: #222222;
    --nav-height: 70px;
}

.dark {
    --background: #1e1e24;
    --card-bg: #252530;
    --text-color: #ffffff;
    --search-bg: #252530;
}

body {
    background-color: var(--background);
    font-family: 'Montserrat', sans-serif;
    color: var(--text-color);
    margin: 0;
    padding: 0;
}

nav {
    position: fixed;
    top: 0;
    left: 0;
    backdrop-filter: blur(10px) saturate(200%) brightness(70%);
    color: var(--text-color);
    display: flex;
    height: var(--nav-height);
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 2%;
    z-index: 5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.nav-left {
    display: flex;
    align-items: center;
}

nav img {
    height: 50px;
    width: auto;
    margin-right: 15px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

nav h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
}

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    margin-top: var(--nav-height);
}

.categories {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    width: 100%;
    max-width: 800px;
}

.category-btn {
    background-color: var(--card-bg);
    border: none;
    border-radius: 8px;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
}

.category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.category-btn.active {
    background-color: var(--primary);
}

.search-container {
    display: flex;
    width: 100%;
    max-width: 500px;
    margin: 20px 0;
}

.search-container input {
    background-color: var(--search-bg);
    border: 2px solid transparent;
    border-radius: 10px 0 0 10px;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 600;
    padding: 12px 20px;
    font-family: 'Montserrat', sans-serif;
    flex-grow: 1;
    outline: none;
    transition: border-color 0.3s;
}

.search-container input:focus {
    border-color: var(--primary);
}

.search-container input::placeholder {
    color: var(--text-color);
    opacity: 0.7;
    font-weight: 600;
}

.search-container button {
    background-color: var(--primary);
    border: none;
    border-radius: 0 10px 10px 0;
    color: white;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 20px;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    transition: .3s all ease;
}

.search-container button:hover {
    background-color: #1a6cd9;
}

#games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    padding: 20px 0;
}

.game {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
    display: block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    aspect-ratio: 1/1;
}

.game:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

.game a {
    text-decoration: none;
    color: var(--text-color);
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    display: block;
}

.game img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    transition: transform 0.3s;
    position: absolute;
    top: 0;
    left: 0;
}

.game:hover img {
    transform: scale(1.05);
}

.game p {
    position: absolute;
    bottom: 6px; 
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5); 
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 14px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    max-width: 90%;
}

.game a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%; 
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%); 
    border-radius: 0 0 8px 8px;
    transition: opacity 0.3s ease;
    opacity: 0;
    z-index: 1; 
}

.game a:hover::before {
    opacity: 1; 
}

.game a:hover p {
    opacity: 1;
}

/* Game modal */
.game-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-modal-content {
    position: relative;
    width: 90%;
    max-width: 1200px;
    height: 70vh;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

.game-modal iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: all 0.2s;
}

.close-modal:hover {
    background-color: rgba(255, 0, 0, 0.8);
    transform: scale(1.1);
}

.featured {
    width: 100%;
    max-width: 1200px;
    margin-top: 6vw;
    margin-bottom: 2vw;
}

.featured h2 {
    font-size: 3.5vw;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-color);
}

#featured-games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
    width: 100%;
}

.featured-game {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s, border-color 0.3s;
    animation: fadeIn 0.5s ease forwards;
    opacity: 0;
    display: block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    aspect-ratio: 1/1;
}

.featured-game:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--primary);
}

.featured-game a {
    text-decoration: none;
    color: var(--text-color);
    width: 100%;
    height: 100%;
    position: relative;
    cursor: pointer;
    display: block;
}

.featured-game img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    transition: transform 0.3s;
    position: absolute;
    top: 0;
    left: 0;
}

.featured-game:hover img {
    transform: scale(1.05);
}

.featured-game p {
    position: absolute;
    bottom: 10px; 
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5); 
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 16px; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    max-width: 90%;
}

.featured-game a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%; 
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0) 100%); 
    border-radius: 0 0 8px 8px;
    transition: opacity 0.3s ease;
    opacity: 0;
    z-index: 1; 
}

.featured-game a:hover::before {
    opacity: 1; 
}

.featured-game a:hover p {
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    width: 100%;
}

.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid var(--primary);
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    nav h1 {
        font-size: 24px;
    }

    .featured {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto repeat(2, 1fr);
    }

    .featured-game:nth-child(2),
    .featured-game:nth-child(3),
    .featured-game:nth-child(4) {
        grid-column: auto;
        grid-row: auto;
    }

    #games-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .category-btn {
        font-size: 14px;
        padding: 6px 12px;
    }
}

@media (max-width: 480px) {
    nav {
        height: 60px;
    }

    nav img {
        height: 40px;
    }

    nav h1 {
        font-size: 20px;
    }

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

    #games-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 15px;
    }

    .search-container input,
    .search-container button {
        font-size: 16px;
        padding: 10px 15px;
    }
}