/* --- LAYOUT & SHELL STYLES --- */
html {
    box-sizing: border-box;
}

*,
*:before,
*:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex-grow: 1;
}

/* Header Styles */
.main-header {
    background-color: #ffffff;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    text-decoration: none;
}

/* Navigation Styles */
.main-nav ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: center;
}

.main-nav li {
    position: relative;
}

.main-nav a {
    display: block;
    padding: 20px 15px;
    text-decoration: none;
    color: #555;
    font-weight: bold;
    transition: color 0.3s, background-color 0.3s;
}

.main-nav a:hover,
.main-nav a.active {
    color: #007bff;
    background-color: #f8f9fa;
}

/* Dropdown Menu */
.dropdown-content {
    display: none; /* Default for desktop, overridden by hover */
    position: absolute;
    background-color: #ffffff;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    border-radius: 4px;
    overflow: hidden;
    border-top: 2px solid #007bff;
}

.dropdown-content a {
    padding: 12px 16px;
    /* On mobile, this will be overridden */
}

/* Desktop-only hover effect */
@media (min-width: 993px) {
    .dropdown:hover .dropdown-content {
        display: block;
    }
}

/* Hamburger Menu for Mobile */
.menu-toggle {
    display: none;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 28px;
}

/* Footer & Content Styles */
.main-footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 20px;
    flex-shrink: 0;
}

.main-footer a {
    color: #aedffc;
    text-decoration: none;
}

.main-footer a:hover {
    text-decoration: underline;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.footer-links {
    font-size: 12px;
    text-align: right;
}

.footer-links a {
    margin: 0 5px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Category Page Header specific styling */
.category-header {
    background-color: #fff; /* Similar to text-content but can be distinct */
    margin-bottom: 30px;
    padding: 25px 40px; /* Slightly more padding */
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.category-header h1 {
    margin-top: 0;
    font-size: 2.2rem;
    color: #333;
}
.category-header p {
    font-size: 1.1rem;
    color: #555;
    line-height: 1.6;
}
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
    /* New rules to cap at 3 columns and center the grid */
    max-width: 1000px; /* Calculated for up to 3 cards, each around 320px wide */
    margin-left: auto;  /* Center the grid within its parent if parent is wider */
    margin-right: auto; /* Center the grid within its parent if parent is wider */
}

/*begin*/

.game-card {
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    position: relative; /* Needed for absolute positioning of play button */
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    background-color: grey;
}

/* Play button overlay */
.game-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5); /* Semi-transparent overlay */
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Play button SVG */
.game-card::before {
    content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff' width='48px' height='48px'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
}

.game-card:hover::before {
    opacity: 0.8;
}
/*end*/
.game-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.game-info {
    padding: 15px;
    flex-grow: 1; /* Allows info to take remaining space if card height varies */
}

.game-title {
    text-align: center;
    margin: 0;
    font-size: 16px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-category {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 22px;
    color: #666;
    font-weight: bold;
    grid-column: 1 / -1; /* Make it span all columns */
}

.error {
    color: #d32f2f;
    text-align: center;
    padding: 50px;
    font-size: 18px;
    font-weight: bold;
    grid-column: 1 / -1; /* Make it span all columns */
}

.text-content {
    background-color: #fff;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    line-height: 1.6;
}

.text-content h2 {
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-top: 0;
}

.text-content h3 {
    margin-top: 30px;
}

/* Introduction content on homepage */
.introduction-content {
    margin-bottom: 30px; /* Space below introduction */
}
.introduction-content p {
    margin-bottom: 1em; 
}
.introduction-content strong {
    color: #333; 
}
.introduction-content a {
    color: #007bff;
    text-decoration: underline;
}
.introduction-content a:hover {
    color: #0056b3;
}


.hero-section {
    text-align: center;
    padding: 40px 20px;
    background-color: #fff; /* Add a background to hero if desired */
    border-radius: 8px;
    margin-bottom: 30px; /* Space below hero */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.hero-section h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #333;
}

.hero-section .subtitle {
    font-size: 1.2rem;
    color: #666;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    margin-top: 40px;
    margin-bottom: 20px; /* Space below title */
    color: #333;
}

/* --- GAME PAGE STYLES --- */
#game-page-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game-play-area-container {
    width: 100%;
    max-width: 1350px; /* Accommodate 960px game + 2*160px ads + padding/margins */
    margin: 20px auto;
    padding: 0 20px; /* Side padding for the container itself */
    box-sizing: border-box;
}

.game-play-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-play-header h1 {
    font-size: 2.2rem;
    color: #333;
    margin-top: 0;
    margin-bottom: 10px;
}

.game-display-wrapper {
    background-color: #000; /* Black background for the game area */
    padding: 15px; /* Padding around the ad/game content flex area */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.game-ad-top {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    /* Ad placeholder is already styled inline, this is for positioning */
}

.game-content-flex {
    display: flex;
    justify-content: center; /* Center game if ads are hidden */
    align-items: flex-start; /* Align ads and game to the top */
    gap: 15px; /* Space between ads and game frame */
}

.game-iframe-onpage {
    width: 960px;   /* Default width for desktop */
    height: 540px;  /* Default height (16:9 for 960px width) */
    border: none;
    background-color: #111; /* Darker placeholder if game is slow to load */
    display: block; /* Remove extra space below iframe */
}

.game-ad-left,
.game-ad-right {
    width: 160px;
    /* Ad placeholder is already styled inline, this is for positioning */
    /* display: flex; align-items: center; justify-content: center; */ /* Useful if ad unit itself needs centering */
}

/* Button style (example, you might already have this or similar) */
.btn-primary {
    display: inline-block;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.2s;
}
.btn-primary:hover {
    background-color: #0056b3;
    color: white;
}


/* --- INTERSTITIAL AD STYLES --- */
.interstitial-ad-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); 
    z-index: 3000; 
    display: none; 
    align-items: center;
    justify-content: center;
    flex-direction: column; 
}

.interstitial-ad-overlay.active { /* Use .active or directly set display:flex in JS */
    display: flex; 
}

.interstitial-ad-content {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 380px; 
    width: 90%;
}

.interstitial-ad-unit {
    width: 300px; 
    height: 250px; 
    background-color: #e9e9e9; 
    margin: 0 auto 20px auto; 
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
}

.interstitial-timer {
    font-size: 16px;
    color: #333;
    margin-bottom: 15px;
    font-weight: 500;
}

.interstitial-skip-btn {
    padding: 10px 20px;
    background-color: #28a745; 
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
    /*to cnetre button*/
    display: block;
    margin: 0 auto; /* Centers block-level elements */
}

.interstitial-skip-btn:hover {
    background-color: #218838;
}


/* Layout for pages with sidebars (Homepage, Category) */
.main-with-sidebars {
    display: flex;
    justify-content: center; 
    gap: 20px; 
    width: 100%;
    max-width: 1600px; /* Max container width for 3 columns: 160+20+1200+20+160 = 1560. 1600 is fine. */
    margin: 20px auto; /* Add some top/bottom margin for these pages */
    padding: 0 15px; 
    box-sizing: border-box;
}

.main-content-area.container { /* Targets the main content block on home/category */
    flex-grow: 1; 
    max-width: 1000px; 
    padding:0; /* Original container padding: 20px will be applied by its own class if still nested, or not needed if this IS the padded container */
}

.sidebar-ad-container { /* Common class for sidebar ad slots on home/category */
    width: 160px; 
    flex-shrink: 0; 
    
    /* --- STICKY ADS --- */
    position: -webkit-sticky; /* For Safari compatibility */
    position: sticky;
    /* top: Value needs to account for sticky header and any top margin of the ad's container */
    /* Header height is 60px. The parent '.main-with-sidebars' has 'margin: 20px auto;' */
    /* So the ads should stick 20px below the 60px header. */
    top: 80px; /* 60px (header) + 20px (top margin of .main-with-sidebars) */
    
    /* Ensure the sticky element aligns correctly if its container is a flexbox */
    align-self: flex-start; 

    /* It's good for sticky elements to have a defined height or for their content to define a height.
       Your ad placeholders are 160x600. So we can set height on the container too. */
    height: 600px; /* Or max-height if ad content height can vary and you want it scrollable within itself */
}


/* --- RESPONSIVE STYLES --- */

/* Responsive adjustments for sidebars on home/category pages */
/* Hide LEFT sidebar first on medium screens */
@media (max-width: 1100px) { 
    #ad-home-sidebar-left,
    #ad-category-sidebar-left {
        display: none !important;
    }
    .main-with-sidebars {
        justify-content: center;
    }
     .main-content-area.container {
        margin-left: 0;
    }
}

/* Hide RIGHT sidebar on smaller "tablet" or "large phone landscape" screens (mobile breakpoint) */
@media (max-width: 991px) { 
    #ad-home-sidebar-right,
    #ad-category-sidebar-right {
         display: none !important;
    }
    .main-with-sidebars {
        flex-direction: column;
        align-items: center;
        margin-top: 20px;
    }
    .main-content-area.container {
        width: 100%;
        max-width: 1000px;
        margin: 0;
    }

    /* General Mobile Nav Adjustments */
    .main-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: #ffffff;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    .main-nav.active {
        display: block;
    }
    .main-nav ul {
        flex-direction: column;
        width: 100%;
    }
    .main-nav li {
        width: 100%;
        text-align: center; 
        border-bottom: 1px solid #f0f0f0;
    }
    .main-nav li:last-child { 
        border-bottom: none;
    }
    .dropdown-content {
        display: block; 
        position: static;
        background-color: #f8f9fa; 
        box-shadow: none;
        border-radius: 0;
        border-top: none; 
        max-height: 0; 
        overflow: hidden;
        transition: max-height 0.3s ease-out, padding-top 0.3s ease-out, padding-bottom 0.3s ease-out;
        width: 100%; 
        min-width: auto; 
        padding-top: 0; 
        padding-bottom: 0;
    }
    .dropdown-content.submenu-active {
        max-height: 500px; 
        transition: max-height 0.4s ease-in, padding-top 0.4s ease-in, padding-bottom 0.4s ease-in;
        padding-top: 10px; 
        padding-bottom: 10px;
        border-top: 1px solid #e0e0e0; 
    }
    .dropdown-content a {
        padding: 10px 15px 10px 30px; 
        text-align: left; 
        color: #333; 
        display: block; 
        border-bottom: 1px solid #eee; 
    }
    .dropdown-content a:last-child {
        border-bottom: none; 
    }
    .dropdown-content a.active { 
        background-color: #e9ecef; 
        color: #0056b3;
    }
    .menu-toggle {
        display: block;
    }
}


/* Game Page Responsive Ads */
@media (max-width: 1350px) { 
    .page-game .game-ad-left,
    .page-game .game-ad-right {
         display: none; 
    }
    #game-play-area-container {
        padding: 0 10px; 
    }
}


@media (max-width: 991px) {
    .game-iframe-onpage {
        width: 100%; 
        height: auto;  
        aspect-ratio: 16 / 9; 
    }
     .game-ad-top > div { 
        max-width: 100%; 
        width: auto; 
        min-width: 250px; 
        height: auto; 
    }
}

@media (max-width: 767px) { /* True Mobile Styles */
    .text-content, .category-header {
        padding: 20px; 
    }
    .hero-section h1, .category-header h1, .game-play-header h1 {
        font-size: 1.8rem; 
    }
    .hero-section .subtitle, .category-header p {
        font-size: 1rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
    }
    .footer-links {
        text-align: center;
    }

    /* Game Page Responsive on mobile */
    .game-display-wrapper {
        padding: 10px; 
    }
    #game-play-area-container {
        margin: 10px auto; 
        padding: 0 5px; 
    }

    .interstitial-ad-content {
        padding: 15px; 
        max-width: 95%;
    }
     .interstitial-ad-unit {
        max-width: 100%;
    }
    #ad-game-sidebar-left,
    #ad-game-sidebar-right {
        display: none !important;
    }
}

/* --- FEATURED GAMEPLAY SECTION STYLES --- */
.featured-gameplay-section {
    background-color: #f9f9f9;
    padding: 30px 20px;
    margin: 40px auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    text-align: center;
    max-width: 900px;
    border: 1px solid #e0e0e0;
}

.featured-game-info h2 {
    font-size: 2.2rem;
    color: #2c3e50;
    margin-bottom: 10px;
    font-weight: 600;
}

.featured-game-info p {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 25px;
    line-height: 1.6;
}

.featured-game-logo {
    width: 230px; 
    height: 230px; 
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 4px solid #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.btn-play-featured {
    background-color: #2ecc71;
    color: white;
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-out, transform 0.2s ease-out;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-play-featured:hover {
    background-color: #27ae60;
    transform: scale(1.03);
}

/* Pulsing Animation for the button */
.animated-pulse {
    animation: pulseFeaturedButton 2s infinite ease-in-out;
}

@keyframes pulseFeaturedButton {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 6px 12px rgba(46, 204, 113, 0.4);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
}

#featured-game-iframe-container {
    width: 100%;
    margin: 20px auto 0;
}

#featured-game-iframe-container iframe {
    display: block;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 800px;
    height: 600px;
}


/* --- POPOVER AD MODAL STYLES --- */
.popover-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 5000;
    display: flex; 
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
}

.popover-content {
    background-color: #ffffff;
    padding: 25px 30px;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
    width: 100%;
    max-width: 420px;
    position: relative;
}

.progress-bar-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 25px;
    margin: 20px 0;
    height: 22px; 
    overflow: hidden; 
    border: 1px solid #ced4da;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #28a745;
    border-radius: 25px;
    transition: width 0.3s ease-in-out;
    text-align: center;
    color: white;
    font-size: 0.8em;
    line-height: 22px;
}

#popover-message {
    font-size: 1rem;
    color: #343a40;
    margin-bottom: 25px;
    font-weight: 500;
}

.btn-begin-game {
    background-color: #007bff; 
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-out, transform 0.2s ease-out;
    display: inline-block;
}

.btn-begin-game:hover {
    background-color: #0056b3; 
    transform: translateY(-2px);
}

@media (max-width: 820px) {
    #featured-game-iframe-container iframe {
    }
}
@media (max-width: 480px) {
    .featured-game-info h2 {
        font-size: 1.8rem;
    }
    .btn-play-featured {
        font-size: 2rem;
        padding: 12px 25px;
    }
    .featured-game-logo {
        width: 200px;
        height: 200px;
    }
    .popover-content {
        padding: 20px;
    }
    #popover-message {
        font-size: 0.9rem;
    }
    .btn-begin-game {
        font-size: 1rem;
        padding: 10px 20px;
    }
}

/* --- GAME PAGE DETAILS SECTION --- */
.game-details-container {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    margin-top: 40px;
    padding-bottom: 40px;
}

.game-details-main {
    flex: 2;
    min-width: 300px;
}

.game-details-sidebar {
    flex: 1;
    min-width: 250px;
}

.details-section {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

.details-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.6rem;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.details-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3rem;
    color: #444;
}

.details-section p {
    line-height: 1.7;
    color: #555;
    margin: 0;
}

/* --- TAGS LIST STYLING --- */
.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-item {
    background-color: #e9ecef;
    color: #495057;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.tag-item:hover {
    background-color: #007bff;
    color: #ffffff;
}

/* --- RESPONSIVE ADJUSTMENTS FOR GAME DETAILS --- */
@media (max-width: 767px) {
    .game-details-container {
        flex-direction: column;
        gap: 20px;
        margin-top: 20px;
    }
    
    .details-section {
        padding: 20px;
    }

    .details-section h2 {
        font-size: 1.4rem;
    }
}

/* --- DESKTOP AD CONTAINER --- */
.desktop-ad-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* --- MOBILE AD PLACEMENTS --- */
.mobile-ad-container {
    /* CORRECTED: Only display: none by default */
    display: none;
    width: 100%;
    margin: 15px 0;
    padding: 0 10px;
    box-sizing: border-box;
}

/* Special container for in-feed ads on category page grid */
.games-grid .game-card-ad {
    display: none; /* Hidden on desktop */
}


/* --- MOBILE-ONLY VISIBILITY --- */
@media (max-width: 767px) {
    /* Hide desktop-only ad containers */
    .desktop-ad-container {
        display: none !important;
    }

    /* Show the generic mobile ad containers */
    .mobile-ad-container {
        /* CORRECTED: display is now set to flex only on mobile */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Make the in-feed ad a visible grid item on mobile */
    .games-grid .game-card-ad {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px;
        background-color: #f8f9fa;
        border-radius: 8px;
        min-height: 250px; /* Ensure it has space for a 300x250 ad */
        grid-column: 1 / -1; /* Make the ad span the full width of the grid */
    }
}