/**
 * Lightweight, Mobile-First CSS Stylesheet
 * Optimized for Core Web Vitals, Speed, and Google AdX Placements
 * Color Scheme: Clean White / Light Gray / Neutral Slate / Accent Blue
 */

/* ==========================================================================
   1. CSS Reset & Base Variables
   ========================================================================== */
:root {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --rating-color: #f59e0b;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-base);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
}

/* ==========================================================================
   2. Layout & Containers
   ========================================================================== */
.main-content {
    flex: 1;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 12px 14px 40px;
}

@media (min-width: 768px) {
    .main-content {
        padding: 18px 20px 60px;
    }
}

/* ==========================================================================
   3. Header Navigation
   ========================================================================== */
.site-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.logo-icon {
    color: var(--accent-color);
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.logo-accent {
    color: var(--accent-color);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--accent-color);
    background-color: var(--accent-light);
}

/* ==========================================================================
   4. Section Headers & Typography
   ========================================================================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 0 12px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title svg {
    color: var(--accent-color);
}

.section-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface-alt);
    padding: 2px 8px;
    border-radius: 12px;
}

/* ==========================================================================
   5. Game Cards & Responsive Grid (1:1 Aspect Ratio)
   ========================================================================== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (min-width: 480px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

@media (min-width: 768px) {
    .game-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
}

@media (min-width: 1024px) {
    .game-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 14px;
    }
}

.game-card {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.game-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.game-card:active {
    transform: scale(0.98);
}

.game-thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--bg-surface-alt);
    overflow: hidden;
}

.game-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    aspect-ratio: 1 / 1;
    transition: opacity 0.2s ease;
}

.game-card-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.game-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.game-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.game-card-rating {
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    color: var(--rating-color);
}

.game-card-plays {
    color: var(--text-muted);
}

/* ==========================================================================
   6. Video Section & Cards (16:9 Landscape Aspect Ratio)
   ========================================================================== */
.video-section {
    margin: 24px 0;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 12px;
}

@media (min-width: 480px) {
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
}

@media (min-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .video-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.video-card {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.video-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.video-thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-surface-alt);
    overflow: hidden;
}

.video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    aspect-ratio: 16 / 9;
}

.video-play-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.video-card:hover .video-play-badge {
    background-color: #ef4444;
    transform: translate(-50%, -50%) scale(1.1);
}

.video-card-info {
    padding: 10px 12px;
}

.video-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
    min-height: 2.3em;
}

.video-card-meta {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ==========================================================================
   7. Play Game Page
   ========================================================================== */
.play-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.play-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.play-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.25;
}

.play-meta-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.play-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--rating-color);
    font-weight: 700;
}

/* Game Player Stage */
.game-stage-wrapper {
    position: relative;
    width: 100%;
    background-color: #000000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    aspect-ratio: 16 / 9;
    max-height: 75vh;
}

.game-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Game Action Controls Bar */
.game-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.btn-fullscreen {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.9rem;
    font-weight: 700;
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-fullscreen:hover {
    background-color: var(--accent-hover);
}

.btn-fullscreen:active {
    transform: scale(0.97);
}

.game-details-box {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.details-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.game-description-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.controls-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.control-key {
    background-color: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.8rem;
    min-width: 90px;
    text-align: center;
}

.control-action {
    color: var(--text-secondary);
}

/* ==========================================================================
   8. Watch Video Page
   ========================================================================== */
.watch-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.video-player-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.video-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ==========================================================================
   9. AdX / Google Ad Manager Sizing & Layout Stability
   ========================================================================== */
.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 16px 0;
    width: 100%;
    overflow: hidden;
}

.ad-slot {
    width: 100%;
    background-color: #f1f5f9;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    text-align: center;
}

.ad-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 2px 6px;
}

/* Leaderboard Ad */
.ad-top {
    min-height: 50px;
    max-width: 320px;
}

@media (min-width: 768px) {
    .ad-top {
        min-height: 90px;
        max-width: 728px;
    }
}

/* In-Feed Ad */
.ad-feed {
    min-height: 90px;
    max-width: 728px;
}

@media (max-width: 480px) {
    .ad-feed {
        min-height: 60px;
        max-width: 320px;
    }
}

/* Play & Watch Ads */
.ad-game-top, .ad-game-bottom, .ad-watch {
    min-height: 90px;
    max-width: 728px;
}

@media (max-width: 480px) {
    .ad-game-top, .ad-game-bottom, .ad-watch {
        min-height: 50px;
        max-width: 320px;
    }
}

/* Sticky Footer Anchor Ad */
.ad-sticky-footer {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 4px 0;
    z-index: 99;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .ad-sticky-footer {
        display: flex;
        justify-content: center;
    }
    .ad-sticky-footer .ad-anchor {
        min-height: 50px;
        max-width: 320px;
        border: none;
        background: transparent;
    }
}

/* ==========================================================================
   10. Infinite Scroll Loader
   ========================================================================== */
.infinite-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
    margin-top: 12px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.loader-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 8px;
}

.end-of-content {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 16px 0;
    text-align: center;
}

/* ==========================================================================
   11. Footer
   ========================================================================== */
.site-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    padding: 24px 14px;
}

.footer-container {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    text-align: center;
}

.footer-logo {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.footer-logo span {
    color: var(--accent-color);
}

.footer-tagline {
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-width: 500px;
}

.footer-copy {
    font-size: 0.75rem;
    color: var(--text-muted);
}
