/* ============================
   GLOBAL RESET & VARIABLES
   ============================ */

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

:root {
    --bg-dark: #0a0e27;
    --bg-card: #1a1f3a;
    --bg-hover: #252d48;
    --accent: #667eea;
    --accent2: #764ba2;
    --text-main: #ffffff;
    --text-muted: #b0b8d4;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    --radius: 16px;
}

/* ============================
   BODY
   ============================ */

body {
    background: linear-gradient(135deg, var(--bg-dark), #0f1428, var(--bg-dark));
    color: var(--text-main);
    font-family: 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/* ============================
   NAVBAR
   ============================ */

nav {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(10, 14, 39, 0.85);
    backdrop-filter: blur(20px);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

nav h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#search {
    width: 320px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transition: 0.3s;
}

#search:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.12);
}

/* ============================
   HERO SECTION
   ============================ */

.hero {
    text-align: center;
    padding: 80px 20px;
}

.hero h2 {
    font-size: 52px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-muted);
    font-size: 18px;
    margin-top: 12px;
}

/* ============================
   SECTION TITLES
   ============================ */

.sectionTitle {
    width: 95%;
    margin: 40px auto 20px;
    font-size: 30px;
    font-weight: 700;
}

/* ============================
   GAME GRID
   ============================ */

#games,
#favorites {
    width: 95%;
    margin: 0 auto 60px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

/* ============================
   GAME CARD
   ============================ */

.game {
    position: relative;
    height: 260px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.game:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow);
    border-color: rgba(255, 255, 255, 0.18);
}

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

/* ============================
   GAME TITLE OVERLAY
   ============================ */

.game h3 {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 50px 12px 16px;
    text-align: center;
    font-size: 18px;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.7));
}

/* ============================
   FAVORITE BUTTON
   ============================ */

.favoriteBtn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: 0.25s;
}

.favoriteBtn:hover {
    transform: scale(1.15);
}

.favoriteBtn.inactive {
    color: rgba(255,255,255,0.5);
}

.favoriteBtn:not(.inactive) {
    color: gold;
    text-shadow: 0 0 10px gold;
}

/* ============================
   GAME PLAYER OVERLAY
   ============================ */

#player {
    display: none;
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
}

ruffle-player,
iframe {
    width: 100% !important;
    height: 100% !important;
}

/* ============================
   CLOSE BUTTON
   ============================ */

#closeGameBtn {
    display: none;
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 8px 24px rgba(245, 87, 108, 0.3);
    transition: 0.3s;
}

#closeGameBtn:hover {
    transform: translateY(-2px);
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 768px) {
    nav {
        flex-direction: column;
        gap: 12px;
    }

    #search {
        width: 100%;
    }

    .hero h2 {
        font-size: 40px;
    }

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

    .game {
        height: 200px;
    }
}

@media (max-width: 480px) {
    .hero h2 {
        font-size: 32px;
    }

    #games,
    #favorites {
        grid-template-columns: 1fr;
    }

    .game {
        height: 180px;
    }
}
