:root {
    --primary: #0a0f1e;
    --secondary: #111827;
    --card: #1a2235;
    --accent: #2563eb;
    --accent-light: #60a5fa;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #1e2d45;
    --ad-bg: #0d1526;
    --ad-border: #1e3a5f;
}

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

html, body {
    background: var(--primary);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===================== NAVBAR ===================== */
.navbar {
    background: var(--secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.nav-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.nav-controls {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-bar {
    background: var(--primary);
    border: 1px solid var(--border);
    color: #f1f5f9;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    flex: 1;
    min-width: 180px;
    max-width: 380px;
    transition: all 0.2s;
    -webkit-text-fill-color: #f1f5f9;
    caret-color: #f1f5f9;
}

.search-bar::placeholder {
    color: #94a3b8;
    -webkit-text-fill-color: #94a3b8;
    opacity: 1;
}

.search-bar:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
    color: #f1f5f9;
    -webkit-text-fill-color: #f1f5f9;
}

.search-bar:-webkit-autofill,
.search-bar:-webkit-autofill:hover,
.search-bar:-webkit-autofill:focus {
    -webkit-text-fill-color: #f1f5f9;
    -webkit-box-shadow: 0 0 0px 1000px var(--primary) inset;
    caret-color: #f1f5f9;
}

.filter-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.pill:hover { border-color: var(--accent); color: var(--accent-light); }
.pill.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ===================== PAGES ===================== */
.page { display: none; }
.page.active { display: block; }

/* ===================== HOME LAYOUT ===================== */
.home-layout {
    display: flex;
    gap: 1rem;
    padding: 0 1rem 1rem;
    align-items: flex-start;
    justify-content: center;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}

.section-header h2 {
    font-size: 1.3rem;
    color: var(--text);
}

.game-count {
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-weight: 600;
}

/* ===================== GAME GRID ===================== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.75rem;
}

/* ===================== GAME CARDS ===================== */
.game-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(37,99,235,0.25);
}

.game-thumbnail {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

.thumb-emoji {
    font-size: 2rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    pointer-events: none;
    user-select: none;
}

.game-card .game-info {
    padding: 0.4rem 0.5rem;
}

.game-card .game-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.1rem;
}

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

/* ===================== PLAYER PAGE ===================== */
.player-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1rem;
    padding: 1rem;
    align-items: start;
}

.game-player-area {
    display: flex;
    flex-direction: column;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.player-header h3 {
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.back-btn, .fullscreen-btn {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.back-btn:hover, .fullscreen-btn:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

.game-window {
    background: #000;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.game-window > * {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.loading {
    color: var(--text-muted);
    font-size: 1rem;
}

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    top: 75px;
    max-height: calc(100vh - 90px);
}

.sidebar-search .search-bar {
    width: 100%;
    max-width: 100%;
}

.game-list {
    overflow-y: auto;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    max-height: calc(100vh - 280px);
}

.game-list-item {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.game-list-item:hover { background: var(--card); color: var(--text); }
.game-list-item.active { background: var(--accent); color: white; }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1100px) {
    
}

@media (max-width: 900px) {
    .player-layout { grid-template-columns: 1fr; height: auto; }
    .game-sidebar { max-height: 250px; }
    .game-window { min-height: 350px; }
}

@media (max-width: 600px) {
    .navbar { flex-wrap: wrap; gap: 0.75rem; }
    .nav-controls { flex-direction: column; align-items: stretch; }
    .search-bar { max-width: 100%; }
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.75rem; }
    .home-layout { padding: 0 0.5rem 0.5rem; }
    
}

/* ===================== POPULAR SECTION ===================== */
#popularSection {
    margin-bottom: 2rem;
}

#popularSection .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

#popularSection h2 {
    font-size: 1.3rem;
    color: var(--text);
}

.see-all-btn {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent-light);
    padding: 0.35rem 1rem;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.see-all-btn:hover {
    background: var(--accent);
    color: white;
}

/* ===================== LAZY LOADING ===================== */
.lazy-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    display: none;
}

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

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

#allGamesSection .section-header h2 {
    font-size: 1.3rem;
}

/* ===================== FAVORITES BUTTON ===================== */
.fav-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.4);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 2;
    line-height: 1;
    padding: 0;
}

.game-card:hover .fav-btn {
    opacity: 1;
}

.fav-btn.active {
    opacity: 1;
    background: rgba(0,0,0,0.5);
}

.fav-btn:hover {
    transform: scale(1.2);
}

/* ===================== PERSONAL SECTIONS ===================== */
#recentSection,
#favoritesSection {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

#recentSection h2,
#favoritesSection h2 {
    font-size: 1.3rem;
}

/* ===================== INLINE AD SLOTS ===================== */
.grid-ad-slot {
    background: #0a0f1e;
    border-top: 1px solid #1e2d45;
    border-bottom: 1px solid #1e2d45;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    width: 100%;
}

.grid-ad-slot ins {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
}

.sidebar-ad {
    width: 100%;
    min-height: 250px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 8px;
}
