/* --- Theme and Basic Setup --- */
:root {
    --primary-color: rgb(58, 41, 111);
    --background-color: #ffffff;
    --card-background: #ffffff;
    --text-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

#app-container {
    max-width: 360px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

html {
    /* --- FLUID TYPOGRAPHY SETUP --- */
    /* This sets the base font size to scale smoothly between 12px and 14px. */
    /* clamp(MINIMUM, PREFERRED, MAXIMUM) */
    /* MIN: 0.75rem is 12px (if browser default is 16px) */
    /* PREFERRED: 1vw + 0.5rem is a calculation that grows with the viewport width */
    /* MAX: 0.875rem is 14px */
    font-size: clamp(0.75rem, 1vw + 0.5rem, 0.875rem);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
}

h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.top-banner {
    height: 5rem;
    /* 80px, translated from h-20 */
    background-color: var(--primary-color);
    /* Translated from bg-[#3A296F] */
}

.site-header {
    box-shadow: 1px 0 6px #000000bf;
    border-radius: 20px;
    margin-bottom: 20px;
    -webkit-border-radius: 20px;
    -moz-border-radius: 20px;
    -ms-border-radius: 20px;
    -o-border-radius: 20px;
    border: 3px solid var(--primary-color);
    background-color: rgb(252 252 252 / var(--tw-bg-opacity, 1));
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 30px;
}

.content-container {
    flex: 1;
    width: 100%;
    margin: auto;
    padding-left: 1rem;
    padding-right: 1rem;
    margin-bottom: 1rem;
    margin-top: -3rem;
}

.logo {
    display: flex;
    justify-content: center;
}

.logo img {
    width: 11rem;
    height: auto;
}

.nav-toggle-btn {
    font-size: 1.5rem;
    /* text-2xl */
    padding: 0.5rem;
    /* p-2 */
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-color);
}

.nav-wrapper {
    width: 100%;
    /* w-full */
    /* This is the core of the mobile animation */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

/* This class will be toggled by JavaScript */
.nav-wrapper.is-open {
    max-height: 20rem;
    /* A value large enough to show all items */
    margin-top: 1rem;
    /* mt-4, provides space below logo on mobile */
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    /* Mobile: vertical list */
    gap: 0.5rem;
    /* space-y-2 */
}

.nav-item {
    display: block;
    padding: 0.5rem 0;
    /* py-2 */
    font-weight: 800;
    /* font-extrabold */
    text-decoration: none;
    color: var(--text-color);

    /* THE BORDER TRICK: Start with a transparent border */
    border-top: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s ease-in-out;
}

.nav-item:hover {
    /* On hover, only change the border color. No layout shift! */
    border-color: var(--primary-color);
}

/* --- Game Grid --- */
.game-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Game Card (Now an <a> tag) --- */
.game-card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    overflow: hidden;
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    max-width: 160px; /* Limit card width */
    margin: 0 auto; /* Center the card */
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(58, 41, 111, 0.2);
}

/* --- Square Image Placeholder --- */
.game-image-container {
    aspect-ratio: 1 / 1;
    width: 100%;
    background-color: #f0f2f5;
    overflow: hidden;
}

.game-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-in-out;
}

/* --- The Information and Action Area --- */
.game-info {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    text-align: center;
}

.game-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1a202c;
    margin-bottom: auto;
    padding-bottom: 0.5rem;
}

.play-button {
    font-family: inherit;
    font-size: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    width: 100%;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.play-button:hover {
    background-color: rgb(78, 55, 151);
    /* Add a subtle shadow to the button itself on hover for a 3D press effect */
    box-shadow: 0 4px 12px rgba(58, 41, 111, 0.3);
    transform: translateY(-2px);
}

/* --- Load More Button --- */
.load-more-container {
    text-align: center;
    padding: 20px 0 40px 0;
}

#load-more-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#load-more-btn:hover {
    background-color: rgb(78, 55, 151);
}

/* --- Utility Class --- */
.hidden {
    display: none;
}

/* --- Game Introduction Section --- */
.game-intro {
    text-align: center;
    padding: 2rem 1rem;
    margin: 2rem auto 2rem;
    background: linear-gradient(135deg, #f6f8ff 0%, #ffffff 100%);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(58, 41, 111, 0.1);
}

.fun-title {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(58, 41, 111, 0.1);
}

.fun-description {
    font-size: 1rem;
    color: #4a5568;
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.fun-features {
    display: flex;
    justify-content: center;
    gap: 1rem;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
    flex-wrap: wrap;
}

.feature {
    background: white;
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(58, 41, 111, 0.05);
    transition: all 0.3s ease;
    text-align: center;
    flex: 1;
    min-width: 100px;
    max-width: 150px;
}

.feature:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(58, 41, 111, 0.15);
}

.feature .emoji {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.25rem;
}

.feature h3 {
    color: var(--primary-color);
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 1px;
    margin: 0;
    white-space: nowrap;
}

.feature p {
    color: #4a5568;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* =================================================== */
/*   MEDIA QUERY FOR DESKTOP (sm: breakpoint ~640px)   */
/* =================================================== */
@media (min-width: 640px) {
    .logo img {
        width: 13rem;
        /* sm:w-52 */
    }

    .nav-toggle-btn {
        display: none;
        /* sm:hidden */
    }

    .nav-wrapper {
        display: block;
        /* sm:block */
        width: auto;
        /* sm:w-auto */
        max-height: none;
        /* sm:max-h-full */
        overflow: visible;
        margin-top: 0;
        /* sm:mt-0 */
        transition: none;
        /* sm:transition-none */
    }

    .nav-menu {
        flex-direction: row;
        /* sm:flex-row */
        gap: 1rem;
        /* sm:space-x-4 */
    }

    .nav-item {
        padding: 0;
        /* sm:py-0 */
        font-size: 1.125rem;
        /* sm:text-lg */
    }
}


@media (min-width: 640px) {
    .content-container {
        max-width: 640px;
        /* From 'sm:mb-10': Overrides the mobile bottom margin on larger screens */
        margin-bottom: 2.5rem;
        /* 40px */
    }
}



@media (min-width: 768px) {
    .content-container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .content-container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .content-container {
        max-width: 1280px;
    }
}

@media (min-width: 1536px) {
    .content-container {
        max-width: 1536px;
    }
}

/* --- Ad Containers --- */
.ad-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.ad-wrapper {
    width: 100%;
    min-height: 250px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.ad-wrapper.vertical {
    width: 100%;
    min-height: 600px;
}

.top-ad {
    margin-top: 2rem;
}

.bottom-ad {
    margin: 2rem 0;
}


.ad-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000; /* Ensure it's on top of everything */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent overlay */
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* We'll use this class to hide it initially and when closed */
.ad-dialog.hidden {
    opacity: 0;
    pointer-events: none; /* Can't be clicked when hidden */
}

#ad-dialog-box {
    background-color: var(--card-background);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 400px; /* Increased max-width to accommodate larger ads */
    position: relative;
    transform: scale(1);
    transition: transform 0.3s ease-in-out;
}

.ad-dialog.hidden #ad-dialog-box {
    transform: scale(0.9);
}

#close-dialog-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 2rem;
    font-weight: 300;
    color: var(--text-color-light);
    cursor: pointer;
    line-height: 1;
}

.dialog-title {
    text-align: center;
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

#dialog-ad-container {
    width: 100%;
    min-height: 250px;
    background-color: #f0f2f5; /* Placeholder color before ad loads */
    border: 1px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Important for AdSense */
}

.dialog-notice {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-color-light);
    margin-top: 1rem;
}