:root {
    --bg-base: #0a0a0f;
    --bg-surface: #14141a;
    --bg-elevated: #1e1e26;
    --accent: #00f2ff;
    --accent-glow: rgba(0, 242, 255, 0.3);
    --text-main: #ffffff;
    --text-dim: #8e8e9b;
    --border: #2a2a35;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: 'Inter', system-ui, sans-serif;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* Layout Architecture */
.app-layout { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px; background-color: var(--bg-surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 20px; justify-content: flex-start;
}
.logo { font-size: 1.5rem; font-weight: 800; color: var(--accent); display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.side-nav { display: flex; flex-direction: column; gap: 10px; }
.side-nav a {
    color: var(--text-dim); text-decoration: none; padding: 12px 16px; border-radius: 8px;
    display: flex; align-items: center; gap: 12px; font-weight: 500; transition: var(--transition);
}
.side-nav a:hover, .side-nav a.active { background: var(--bg-elevated); color: var(--text-main); }
.mobile-only-nav { display: none !important; }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; padding: 0 40px 40px 40px; }

/* Topbar */
.topbar {
    display: flex; justify-content: space-between; align-items: center; padding: 20px 0;
    position: sticky; top: 0; background: rgba(10, 10, 15, 0.9); backdrop-filter: blur(10px);
    z-index: 50; border-bottom: 1px solid var(--border); margin-bottom: 30px;
}
.search-bar {
    display: flex; align-items: center; background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 8px 16px; width: 300px;
}
.search-bar i { color: var(--text-dim); }
.search-bar input { background: transparent; border: none; color: white; padding: 5px 10px; outline: none; width: 100%; }
.user-profile { display: flex; align-items: center; gap: 15px; font-weight: 500; }
.avatar { display: flex; align-items: center; justify-content: center; border-radius: 50%; width: 40px; height: 40px; background: var(--accent); color: black; font-weight: bold; }
#user-avatar { cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; }
#user-avatar:hover { transform: scale(1.1); box-shadow: 0 0 15px var(--accent-glow); }
.coin-balance {
    background: rgba(255, 215, 0, 0.1); border: 1px solid rgba(255, 215, 0, 0.5); color: #ffd700;
    padding: 6px 12px; border-radius: 20px; font-weight: 800; display: flex; align-items: center; gap: 6px;
    font-size: 0.95rem; box-shadow: 0 0 10px rgba(255, 215, 0, 0.1); transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.coin-balance:hover { transform: scale(1.05); box-shadow: 0 0 15px rgba(255, 215, 0, 0.3); }
#coin-display { cursor: pointer; }
.mobile-brand { display: none; }

/* Filters */
.category-filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-btn { background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-dim); padding: 8px 16px; border-radius: 20px; cursor: pointer; transition: var(--transition); }
.filter-btn:hover, .filter-btn.active { background: var(--text-main); color: black; border-color: var(--text-main); }

/* Grid & Cards */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.game-card { background: var(--bg-surface); border-radius: 12px; overflow: hidden; cursor: pointer; border: 1px solid var(--border); transition: var(--transition); content-visibility: auto; contain-intrinsic-size: 240px 200px; }
.game-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5); }
.game-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-bottom: 1px solid var(--border); }
.card-meta { padding: 15px; }
.card-tag { font-size: 0.75rem; color: var(--accent); text-transform: uppercase; font-weight: bold; margin-bottom: 5px; }
.card-title { font-weight: 600; font-size: 1.1rem; }
.card-thumb-wrapper { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-bottom: 1px solid var(--border); }
.card-thumb-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--transition); }
.game-card:hover .card-thumb-wrapper img { transform: scale(1.05); }

/* Favorite Button */
.favorite-btn { position: absolute; top: 10px; right: 10px; background: rgba(10, 10, 15, 0.6); border: 1px solid var(--border); color: white; width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; cursor: pointer; backdrop-filter: blur(5px); transition: all 0.2s ease; z-index: 10; }
.favorite-btn:hover { background: rgba(10, 10, 15, 0.9); transform: scale(1.1); }
.favorite-btn.active { color: #ff0055; border-color: #ff0055; background: rgba(255, 0, 85, 0.1); box-shadow: 0 0 10px rgba(255, 0, 85, 0.4); }

/* Buttons */
.btn-primary { background: var(--accent); color: black; border: none; padding: 16px 32px; font-size: 1.1rem; font-weight: 700; border-radius: 12px; cursor: pointer; transition: var(--transition); box-shadow: 0 0 20px var(--accent-glow); display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; }
.btn-primary:hover { transform: scale(1.05); background: #fff; }
.btn-secondary { background: var(--bg-elevated); color: white; border: 1px solid var(--border); padding: 10px 20px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; margin-bottom: 15px; }
.btn-secondary:hover { background: var(--border); }

/* Theater Mode */
.hidden { display: none !important; }
#theater-mode { margin-bottom: 40px; }
.display-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
#game-frame-container { width: 100%; height: 100%; position: absolute; inset: 0; }
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 10, 15, 0.95); z-index: 10; text-align: center; }
.theater-controls { display: flex; gap: 10px; margin-bottom: 15px; }

/* Fullscreen Frame Controls */
#game-frame-container:-webkit-full-screen { width: 100%; height: 100%; }
#game-frame-container:fullscreen { width: 100%; height: 100%; }
#display-container:fullscreen { width: 100vw; height: 100vh; background: #000; display: flex; align-items: center; justify-content: center; }
#display-container:fullscreen #game-frame-container { width: 100%; height: 100%; }
#display-container:fullscreen iframe { width: 100%; height: 100%; border: none; }
.btn-exit-fs { position: absolute; top: 20px; right: 20px; z-index: 2147483647; background: rgba(0, 0, 0, 0.7); color: var(--accent); border: 2px solid var(--accent); width: 45px; height: 45px; border-radius: 50%; display: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 0 15px var(--accent-glow); transition: opacity 0.3s ease; }
.btn-exit-fs:hover { background: var(--accent); color: #000; opacity: 1; }
#game-frame-container:fullscreen #exit-fs-floating { display: flex !important; }
#game-frame-container:-webkit-full-screen #exit-fs-floating { display: flex !important; }
#display-container:fullscreen #exit-fs-floating { display: flex !important; }
#display-container:-webkit-full-screen #exit-fs-floating { display: flex !important; }

/* Hero Carousel */
.hero-carousel-wrapper { position: relative; width: 100%; border-radius: 16px; overflow: hidden; margin-bottom: 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); border: 1px solid var(--border); }
.hero-carousel-track { display: flex; width: 100%; transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1); }
.hero-slide { flex: 0 0 100%; width: 100%; padding: 60px 40px; position: relative; }
.carousel-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(10, 10, 15, 0.6); color: white; border: 1px solid var(--border); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(5px); transition: var(--transition); z-index: 10; }
.carousel-nav:hover { background: var(--accent); color: black; border-color: var(--accent); }
.carousel-nav.prev { left: 15px; }
.carousel-nav.next { right: 15px; }
.carousel-indicators { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; z-index: 10; }
.indicator-dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); cursor: pointer; transition: var(--transition); }
.indicator-dot.active { background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); transform: scale(1.2); }
.hero-content { max-width: 500px; }
.hero-badge { background: var(--accent); color: #000; padding: 4px 10px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; border-radius: 4px; margin-bottom: 15px; display: inline-block; }
.hero-title { font-size: 2.5rem; font-weight: 800; margin-bottom: 50px; line-height: 1.1; }
.hero-desc { color: #c0c0c8; margin-bottom: 25px; font-size: 1rem; line-height: 1.6; }

/* Sidebar Promo Box */
.sidebar-promo { margin-top: auto; background: linear-gradient(135deg, var(--bg-elevated) 0%, #1a1a2e 100%); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; position: relative; overflow: hidden; }
.promo-icon { font-size: 2.5rem; color: #ffd700; margin-bottom: 10px; }
.sidebar-promo h3 { font-size: 1.1rem; margin-bottom: 5px; }
.sidebar-promo p { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 15px; line-height: 1.4; }
.btn-promo { background: transparent; border: 1px solid #ffd700; color: #ffd700; padding: 8px 15px; border-radius: 6px; cursor: pointer; font-weight: bold; width: 100%; transition: var(--transition); }
.btn-promo:hover { background: #ffd700; color: #000; }
.sidebar-promo.refer-promo { background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(0, 255, 136, 0.05) 100%) !important; border-color: rgba(0, 255, 136, 0.2) !important; }
.sidebar-promo.refer-promo .promo-icon, .sidebar-promo.refer-promo h3 { color: #00ff88 !important; }
.sidebar-promo.refer-promo .btn-promo { border-color: #00ff88 !important; color: #00ff88 !important; }
.sidebar-promo.refer-promo .btn-promo:hover { background: #00ff88 !important; color: #000 !important; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(10, 10, 15, 0.85); backdrop-filter: blur(8px); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.5); max-height: 90vh; overflow-y: auto; }
.close-btn { position: absolute; top: 15px; right: 15px; background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; transition: color 0.2s; }
.close-btn:hover { color: #ff0055; }

/* Toasts */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 99999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-main); padding: 14px 20px; border-radius: 12px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); transform: translateX(120%); opacity: 0; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); pointer-events: auto; max-width: 350px; }
.toast.show { transform: translateX(0); opacity: 1; }
.toast-icon { font-size: 1.6rem; }
.toast-success .toast-icon { color: #00ff88; filter: drop-shadow(0 0 8px rgba(0,255,136,0.4)); }
.toast-error .toast-icon { color: #ff0055; filter: drop-shadow(0 0 8px rgba(255,0,85,0.4)); }
.toast-info .toast-icon { color: var(--accent); filter: drop-shadow(0 0 8px var(--accent-glow)); }
.toast-content { font-size: 0.95rem; font-weight: 500; flex: 1; line-height: 1.4; }
.toast-close { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1.2rem; padding: 4px; transition: var(--transition); }
.toast-close:hover { color: var(--text-main); transform: scale(1.1); }

/* Auth Page */
.auth-page { display: flex; height: 100vh; background: var(--bg-base); }
.auth-form-container { width: 450px; padding: 60px; display: flex; flex-direction: column; justify-content: center; z-index: 10; }
.auth-visual { flex: 1; background: url('https://images.unsplash.com/photo-1511512578047-dfb367046420?auto=format&fit=crop&w=1200&q=80') center/cover; position: relative; display: flex; align-items: center; justify-content: center; }
.auth-visual::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to right, var(--bg-base), transparent); }
.auth-header h1 { font-size: 2.5rem; margin-bottom: 10px; color: var(--accent); }
.auth-header p { color: var(--text-dim); margin-bottom: 30px; }
.auth-tabs { display: flex; gap: 20px; margin-bottom: 30px; border-bottom: 1px solid var(--border); }
.auth-tab { background: none; border: none; color: var(--text-dim); padding: 10px 0; cursor: pointer; font-weight: 600; font-size: 1rem; position: relative; }
.auth-tab.active { color: var(--accent); }
.auth-tab.active::after { content: ''; position: absolute; bottom: -1px; left: 0; width: 100%; height: 2px; background: var(--accent); }

/* Specific Targeted Classes */
.text-reward { color: #00ff88 !important; }
.text-locked { color: #ffd700 !important; }
.text-timer { color: #ff0055 !important; }
.quest-card { background: #14141a; border: 1px solid #2a2a35; padding: 20px; border-radius: 16px; }
.btn-quest-claimed { border: 1.5px solid #00ff88 !important; background: rgba(0, 255, 136, 0.05) !important; color: #00ff88 !important; }
.btn-quest-open { background: #1e1e26 !important; color: #8e8e9b !important; border: 1px solid #2a2a35 !important; }
.referral-note { color: #00f2ff; font-size: 0.8rem; font-weight: 700; margin-bottom: 20px; }
.btn-tier-locked { border: 1px solid #ffd700 !important; background: transparent !important; color: #ffd700 !important; font-weight: 700 !important; }
.wheel-pointer-target { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); z-index: 20; color: #00f2ff; filter: drop-shadow(0 0 10px #00f2ff); font-size: 2.5rem; }
.btn-wheel-locked { background: #1e1e26 !important; border: 1px solid #2a2a35 !important; color: #5a5a66 !important; }
.wheel-slice { position: absolute; width: 50%; height: 50%; transform-origin: 100% 100%; left: 0; top: 0; }
.slice-label { position: absolute; left: 60%; top: 30%; transform: rotate(22.5deg); font-weight: 900; font-size: 1.2rem; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); z-index: 5; }
.modern-label { position: absolute; top: 50%; left: 50%; width: 40px; height: 40px; margin-top: -20px; margin-left: -20px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: 'Inter', system-ui, sans-serif; font-weight: 800; font-size: 1.1rem; color: #5a5a66; z-index: 10; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.modern-label.highlight { font-size: 1.3rem; text-shadow: 0 0 12px currentColor; }
.modern-label.jackpot { color: #ffd700; font-size: 1.35rem; text-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
.modern-label.jackpot i { font-size: 1rem; margin-bottom: 2px; }

/* Admin Dashboard Specific */
.admin-grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; padding: 25px; display: flex; align-items: center; gap: 20px; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.stat-icon { font-size: 3rem; background: var(--bg-base); padding: 15px; border-radius: 12px; }
.stat-details h3 { font-size: 0.9rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.stat-details p { font-size: 1.8rem; font-weight: 800; color: var(--text-main); }
.admin-table { width: 100%; border-collapse: collapse; text-align: left; }
.admin-table th { background: var(--bg-base); padding: 15px; font-size: 0.85rem; text-transform: uppercase; color: var(--text-dim); border-bottom: 2px solid var(--border); }
.admin-table td { padding: 15px; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.admin-table tr:hover td { background: rgba(255, 255, 255, 0.02); }


/* =========================================
   PERFECT RESPONSIVE DESIGN (ALL DEVICES)
   ========================================= */

/* --- 1080px: Tablets & Small Laptops --- */
@media (max-width: 1080px) {
    .app-layout { flex-direction: column; }
    body, html { margin: 0; padding: 0; overflow-x: hidden; }
    
    /* Move sidebar to top horizontally */
    .sidebar {
        width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border);
        padding: 10px 20px; flex-direction: row; align-items: center; justify-content: space-between;
        position: sticky; top: 0; z-index: 100;
    }
    .logo { margin-bottom: 0; font-size: 1.2rem; }
    .side-nav { flex-direction: row; gap: 5px; }
    .side-nav a { padding: 8px 12px; font-size: 0.85rem; }
    .side-nav a span { display: none; } /* Hide text, keep icons */
    .sidebar-promo { display: none !important; }
    .mobile-only-nav { display: flex !important; }

    .main-content { padding: 0 20px 40px 20px !important; }

    /* Topbar: Sticky & Flush */
    .topbar {
        position: sticky !important; top: 0 !important; z-index: 99 !important;
        background: rgba(10, 10, 15, 0.95) !important; backdrop-filter: blur(12px) !important;
        margin-top: 0 !important; margin-bottom: 20px !important;
        
        /* Stretch perfectly to edge */
        margin-left: -20px !important; margin-right: -20px !important;
        width: calc(100% + 40px) !important;
        padding: 15px 20px !important; box-sizing: border-box !important;
        border-bottom: 1px solid var(--border) !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.6);
        
        /* Stack Search Bar strictly above buttons */
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
    }
    .search-bar { width: 100% !important; }
    .user-profile { width: 100% !important; justify-content: center !important; gap: 15px !important; }
}

/* --- 850px: Auth Page Resizing --- */
@media (max-width: 850px) {
    .auth-visual { display: none; }
    .auth-form-container { width: 100%; padding: 30px; }
}

/* --- 768px: Large Phones & iPads --- */
@media (max-width: 768px) {
    .hero-slide { padding: 30px 20px; }
    .hero-title { font-size: 1.8rem; }
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 15px; }
    .display-frame { aspect-ratio: 4 / 3; }
    .theater-controls { justify-content: space-between; }
    .btn-primary { padding: 12px 20px; font-size: 1rem; }
    
    .admin-grid-stats { grid-template-columns: 1fr !important; }
    #admin-app .topbar { flex-direction: row !important; }
}

/* --- 600px: Modal Safe-Area Shrinking --- */
@media (max-width: 600px) {
    .modal-content {
        padding: 25px 15px !important; max-height: 85vh; overflow-y: auto; width: 95% !important;
    }
    .modal-content .ph-storefront { font-size: 2.2rem !important; margin-bottom: 5px !important; }
    .modal-content h2 { font-size: 1.5rem !important; }
}

/* --- 480px: Standard Mobile (Bottom Nav Transformation) --- */
@media (max-width: 480px) {
    /* Move navigation to the bottom */
    .sidebar {
        position: fixed; bottom: 0; top: auto;
        border-bottom: none; border-top: 1px solid var(--border);
        justify-content: center; height: 65px; padding: 0 !important;
        z-index: 9999; background: var(--bg-surface);
    }
    .logo { display: none; }
    .side-nav { width: 100%; justify-content: space-around; }
    .side-nav a { flex-direction: column; gap: 4px; padding: 5px; background: transparent !important; justify-content: center; align-items: center; }
    .side-nav a i { font-size: 1.4rem; }
    .side-nav a span { display: block !important; font-size: 0.7rem; text-align: center; }

    .main-content { padding: 0 10px 80px 10px !important; }

    /* Topbar Narrow Stretch */
    .topbar {
        margin-left: -10px !important; margin-right: -10px !important;
        width: calc(100% + 20px) !important;
        padding: 15px 10px !important;
    }

    .category-filters { overflow-x: auto; white-space: nowrap; flex-wrap: nowrap; padding-bottom: 10px; }
    .filter-btn { flex-shrink: 0; }

    #user-name { display: none !important; } /* Hide name to save space */
    .search-bar { padding: 6px 12px !important; margin-bottom: 5px !important; }
    
    .mobile-brand { display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 900; color: var(--accent); width: 100%; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 5px; }
    
    /* Ensure toasts don't get covered by the bottom nav */
    #toast-container { bottom: 85px; right: 15px; left: 15px; align-items: center; }
    .toast { width: 100%; max-width: 100%; transform: translateY(100px); }
    
    /* Admin Bottom Nav Override */
    #admin-app .sidebar { display: flex !important; flex-direction: row !important; padding: 5px 15px !important; height: 65px !important; align-items: center !important; justify-content: space-between !important; background: #0f0f13 !important; }
    #admin-app .admin-nav { font-size: 0 !important; padding: 10px !important; justify-content: center; background: transparent !important; }
    #admin-app .admin-nav i { font-size: 1.5rem !important; margin: 0 !important; }
    #admin-app .sidebar > div:last-child { margin: 0 !important; margin-left: 10px !important; border-left: 1px solid var(--border); padding-left: 10px; }
    #admin-logout-btn { font-size: 0 !important; padding: 10px !important; width: auto !important; background: transparent !important; border: none !important; color: #ff0055 !important; box-shadow: none !important; }
    #admin-logout-btn i { font-size: 1.5rem !important; margin: 0 !important; }
    .admin-table th, .admin-table td { padding: 10px !important; font-size: 0.85rem !important; }
}

/* --- 420px: Modern Phones (iPhone Pro Max, S24 Ultra) UI Cleanup --- */
@media (max-width: 420px) {
    /* 🚨 THE FIX: Added flex-wrap! Extra buttons will now drop to a neat second row */
    .user-profile { gap: 6px !important; justify-content: center !important; flex-wrap: wrap !important; }
    
    /* Prevents the buttons from stacking on top of each other */
    .user-profile button, .topbar .btn-primary, .topbar .btn-secondary {
        padding: 6px 10px !important; font-size: 0.75rem !important; white-space: nowrap !important; flex-shrink: 1 !important;
    }
    
    /* Locks the coins and avatar so they never turn into ovals */
    .coin-balance { padding: 4px 8px !important; font-size: 0.75rem !important; white-space: nowrap !important; flex-shrink: 0 !important; }
    .avatar { width: 32px !important; height: 32px !important; font-size: 0.8rem !important; flex-shrink: 0 !important; }
}

/* --- 380px / 360px: Small & Older Phones --- */
@media (max-width: 380px) {
    /* Magic Grid for Tiny Phones (Fits exactly 2 cards side-by-side) */
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; gap: 10px !important; }
    
    .hero-slide { padding: 20px 15px !important; }
    .hero-title { font-size: 1.5rem !important; margin-bottom: 15px !important; }
    .auth-form-container { padding: 20px 15px !important; }
    .auth-header h1 { font-size: 2rem !important; }
    
    /* Aggressive topbar tightening for 360px */
    .user-profile { gap: 5px !important; flex-wrap: wrap !important; }
    .user-profile button { padding: 5px 8px !important; font-size: 0.7rem !important; }
    .avatar { width: 28px !important; height: 28px !important; font-size: 0.75rem !important; }
}
/* =========================================
   PAGINATION STYLES
   ========================================= */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.page-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    transition: var(--transition);
}

.page-btn:hover {
    border-color: var(--accent);
    color: var(--text-main);
    transform: translateY(-2px);
}

.page-btn.active {
    background: var(--accent);
    color: black;
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   PROFESSIONAL FOOTER STYLES
   ========================================= */
.site-footer {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-bottom {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    padding-top: 20px;
    border-top: 1px dashed #222;
}
/* =========================================
   LEGAL & INFO HUB STYLES
   ========================================= */
.legal-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.tab-header {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 20px;
    margin-bottom: 30px;
    overflow-x: auto; /* Allows scrolling on small screens */
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-elevated);
}

.tab-btn.active {
    color: var(--bg-base);
    background: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Typography for reading */
.tab-pane h3 { font-size: 1.8rem; margin-bottom: 15px; color: var(--text-main); }
.tab-pane h4 { font-size: 1.2rem; margin-top: 30px; margin-bottom: 10px; color: var(--accent); }
.tab-pane p, .tab-pane li { font-size: 1.05rem; color: #c0c0c8; line-height: 1.7; margin-bottom: 15px; }
.tab-pane ul { margin-left: 20px; margin-bottom: 20px; }
.last-updated { font-style: italic; font-size: 0.9rem !important; color: var(--text-dim) !important; margin-bottom: 30px !important; }

/* Support Cards */
.support-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.support-card h4 { margin-top: 0; display: flex; align-items: center; gap: 8px; }

.support-email {
    display: inline-block;
    background: var(--bg-base);
    padding: 10px 20px;
    border-radius: 6px;
    color: var(--accent);
    text-decoration: none;
    font-weight: bold;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.support-email:hover {
    background: var(--accent);
    color: #000;
}

/* Support Form Styling */
.support-form-container {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 25px;
    border-radius: 12px;
    margin-top: 20px;
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--accent); font-weight: bold; font-size: 0.9rem; }
.support-form-container input, .support-form-container textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: white;
    border-radius: 5px;
    font-family: inherit;
    transition: var(--transition);
}
.support-form-container input:focus, .support-form-container textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.1);
}