/* ===== CSS Variables ===== */
:root {
    --font-display: 'Orbitron', sans-serif;
    --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2236;
    --bg-card-hover: #222d44;
    --bg-elevated: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-2: #ec4899;
    --accent-3: #06b6d4;
    --gradient: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
    --gradient-2: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.4);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-h: 70px;
    --max-width: 1280px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-h);
    -webkit-text-size-adjust: 100%;
}

/* Screen-reader-only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus-visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
}

/* Smooth image rendering */
img {
    image-rendering: -webkit-optimize-contrast;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

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

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input {
    font-family: inherit;
}

/* ===== Container ===== */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    transition: var(--transition);
}

.header.scrolled {
    background: rgba(10, 14, 26, 0.95);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 1.4rem;
    white-space: nowrap;
}

.logo-icon {
    font-size: 1.5rem;
}

.logo-text {
    letter-spacing: -0.5px;
}

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

.nav {
    display: flex;
    gap: 28px;
    margin-left: auto;
}

.nav-link {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: color var(--transition);
    position: relative;
    padding: 4px 0;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient);
    transition: width var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

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

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 9px 16px 9px 40px;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 200px;
    transition: var(--transition);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    border-color: var(--accent);
    width: 260px;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-btn {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Hero ===== */
.hero {
    position: relative;
    padding: calc(var(--header-h) + 60px) 0 50px;
    text-align: center;
    overflow: hidden;
}

.hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(236, 72, 153, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 100%, rgba(6, 182, 212, 0.1) 0%, transparent 60%);
    z-index: -1;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 6vw, 3.8rem);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-num {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== Categories ===== */
.categories-section {
    padding: 20px 0;
}

.category-pills {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.category-pills::-webkit-scrollbar {
    height: 4px;
}

.category-pills::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.category-pill {
    padding: 8px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
}

.category-pill:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.category-pill.active {
    background: var(--gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

/* ===== Games Section ===== */
.games-section {
    padding: 30px 0;
}

.games-section.alt-bg {
    background: var(--bg-secondary);
}

.section-header {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* ===== Game Card ===== */
.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

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

.game-card-thumb {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--bg-elevated);
}

.game-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.game-card:hover .game-card-thumb img {
    transform: scale(1.08);
}

.game-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

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

.play-icon {
    width: 52px;
    height: 52px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
}

.game-card-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--gradient);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-card-body {
    padding: 12px 14px;
}

.game-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.btn-large {
    padding: 14px 32px;
    font-size: 1.05rem;
}

.load-more-wrap {
    text-align: center;
    margin-top: 32px;
}

/* ===== Loading Spinner ===== */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-elevated);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}

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

/* ===== No Results ===== */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.no-results h3 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

.footer-container {
    display: grid;
    grid-template-columns: 1.5fr 2fr;
    gap: 40px;
    padding: 48px 20px 32px;
}

.footer-brand .logo {
    margin-bottom: 16px;
}

.footer-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 360px;
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

.footer-col h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.footer-col a {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 4px 0;
    transition: color var(--transition);
}

.footer-col a:hover {
    color: var(--accent-light);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding: 18px 0;
    text-align: center;
}

.footer-bottom p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footer-bottom a {
    color: var(--accent-light);
}

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    background: var(--gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    z-index: 999;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: translateY(-3px);
}

/* ===== Game Page ===== */
.game-page {
    padding-top: calc(var(--header-h) + 20px);
    min-height: 100vh;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--accent-light);
    transition: color var(--transition);
}

.breadcrumb a:hover {
    color: var(--text-primary);
}

.breadcrumb span {
    color: var(--text-muted);
}

.game-container {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
    aspect-ratio: 16 / 10;
}

.game-frame-wrap {
    position: relative;
    width: 100%;
    height: 100%;
}

.game-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.game-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
    z-index: 1;
}

.game-loading.hidden {
    display: none;
}

.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: opacity 0.4s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.game-overlay-inner {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.game-overlay-inner img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.game-overlay-inner h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
}

.game-info {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
}

.game-info-main {
    min-width: 0;
}

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.game-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.game-category {
    background: var(--gradient);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.game-tag {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 100px;
}

.game-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.game-description,
.game-instructions {
    margin-bottom: 20px;
}

.game-description h3,
.game-instructions h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.game-description p,
.game-instructions p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
}

.game-sidebar h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.sidebar-games {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-game {
    display: flex;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    transition: var(--transition);
    cursor: pointer;
}

.sidebar-game:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.sidebar-game img {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.sidebar-game-info {
    min-width: 0;
}

.sidebar-game-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.sidebar-game-category {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ===== Fullscreen Game ===== */
.game-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    border-radius: 0;
    aspect-ratio: auto;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .game-info {
        grid-template-columns: 1fr;
    }

    .footer-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 16px 20px;
        gap: 0;
        transform: translateY(-100%);
        opacity: 0;
        pointer-events: none;
        transition: var(--transition);
    }

    .nav.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .nav-link {
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
        width: 100%;
    }

    .nav-link:last-child {
        border-bottom: none;
    }

    .menu-toggle {
        display: flex;
    }

    .search-box input {
        width: 140px;
    }

    .search-box input:focus {
        width: 180px;
    }

    .hero-stats {
        gap: 24px;
    }

    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }

    .game-card-body {
        padding: 10px;
    }

    .game-card-title {
        font-size: 0.82rem;
    }
}

@media (max-width: 480px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .hero-title {
        font-size: 2rem;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .stat-num {
        font-size: 1.5rem;
    }

    .search-box input {
        width: 120px;
    }

    .footer-links {
        grid-template-columns: 1fr;
    }

    .section-title {
        font-size: 1.3rem;
    }
}

/* ===== SEO Content Section ===== */
.seo-content {
    padding: 40px 0 60px;
}

.seo-content .section-title {
    margin-bottom: 16px;
}

.seo-text {
    max-width: 800px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

.seo-text p {
    margin-bottom: 14px;
}

.seo-text strong {
    color: var(--text-primary);
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-card {
    animation: fadeInUp 0.4s ease backwards;
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
