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

body {
    font-family: 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    transition: all 0.3s ease;
}

.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.stars::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 2px;
    background: white;
    box-shadow: 100px 200px white, 300px 100px white, 500px 300px white, 700px 150px white;
    animation: twinkle 3s infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* Leaderboard */
.leaderboard {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 280px;
    z-index: 1000;
}

.leaderboard h3 {
    color: #667eea;
    margin: 0 0 15px 0;
    font-size: 1.2rem;
    text-align: center;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    margin: 5px 0;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    font-size: 0.9rem;
}

.leaderboard-item .rank {
    font-weight: bold;
    color: #667eea;
    margin-right: 8px;
}

.leaderboard-item .name {
    flex: 1;
    color: #333;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-item .plays {
    color: #667eea;
    font-weight: bold;
    margin-left: 8px;
}

.leaderboard-item:nth-child(1) .rank { color: #ffd700; }
.leaderboard-item:nth-child(2) .rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .rank { color: #cd7f32; }

@media (max-width: 768px) {
    .leaderboard {
        position: relative;
        top: 0;
        right: 0;
        margin: 20px auto;
        max-width: 90%;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

.title {
    font-size: 3rem;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
}

.game-counter {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.player-counter {
    font-size: 1.1rem;
    color: rgba(255, 215, 0, 0.95);
    font-weight: 700;
    margin-top: 5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.date {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    margin-top: 8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.clock {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    margin-top: 5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    letter-spacing: 2px;
}

.header-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.theme-toggle, .favorites-toggle, .eject-button {
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 25px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover, .favorites-toggle:hover, .eject-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.eject-button {
    background: rgba(255, 69, 0, 0.3);
    border-color: rgba(255, 69, 0, 0.8);
}

.theme-dropdown-container {
    position: relative;
}

.cloak-dropdown-container {
    position: relative;
}

.cloak-toggle {
    padding: 12px 25px;
    background: rgba(138, 43, 226, 0.2);
    border: 2px solid rgba(138, 43, 226, 0.5);
    border-radius: 25px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cloak-toggle:hover {
    background: rgba(138, 43, 226, 0.3);
    transform: scale(1.05);
}

.cloak-toggle.active {
    background: rgba(138, 43, 226, 0.4);
    border-color: rgba(138, 43, 226, 0.8);
}

.cloak-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10000;
    min-width: 180px;
}

.cloak-dropdown.active {
    display: block;
}

.cloak-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: linear-gradient(135deg, #8a2be2 0%, #9370db 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cloak-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(138, 43, 226, 0.4);
}

.cloak-btn.active {
    box-shadow: 0 0 0 3px #ffdd57 inset;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 10000;
    min-width: 200px;
}

.theme-dropdown.active {
    display: block;
}

.theme-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.theme-btn.active {
    box-shadow: 0 0 0 3px #ffdd57 inset;
}

.search-container {
    max-width: 600px;
    margin: 0 auto 30px;
}

.search-bar {
    width: 100%;
    padding: 15px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.game-button {
    padding: 30px 20px;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #667eea;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    font-family: inherit;
}

.game-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
}

.no-results {
    text-align: center;
    color: white;
    font-size: 1.2rem;
    padding: 40px;
}

/* Game Sidebar */
.game-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    transition: right 0.4s ease;
    overflow-y: auto;
}

.game-sidebar.active {
    right: 0;
}

.close-sidebar {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
}

.sidebar-content {
    padding: 80px 30px 30px;
}

.sidebar-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.stats {
    background: rgba(102, 126, 234, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.stats p {
    color: #333;
    margin: 8px 0;
    font-weight: 600;
}

.action-btn, .play-btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.action-btn:hover {
    transform: translateY(-2px);
    border-color: #667eea;
}

.action-btn.active {
    background: rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.play-btn {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    border: none;
    color: white;
    font-size: 1.2rem;
    margin-top: 20px;
}

.play-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(76, 175, 80, 0.4);
}

/* Themes - Enhanced with Cool Animations */

    background: var(--custom-bg);
    font-family: var(--custom-font) !important;
}

body.theme-custom * {
    font-family: inherit !important;
}

@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .games-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .game-sidebar {
        width: 100%;
        right: -100%;
    }
}

/* Auth Modal */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
}

.auth-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.auth-container h2 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.auth-form h3 {
    color: white;
    margin-bottom: 20px;
    text-align: center;
}

.auth-input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
}

.auth-button {
    width: 100%;
    padding: 15px;
    margin: 15px 0;
    border: none;
    border-radius: 10px;
    background: white;
    color: #667eea;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.auth-link {
    color: white;
    text-align: center;
    margin-top: 15px;
}

.auth-link span {
    text-decoration: underline;
    cursor: pointer;
    font-weight: bold;
}

.auth-link span:hover {
    color: #ffdd57;
}

/* User Bar */
.user-bar {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1000;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

#currentUsername {
    font-weight: bold;
    color: #667eea;
}

.user-status {
    font-size: 0.85rem;
    color: #4caf50;
    padding: 3px 8px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 5px;
}

.user-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

.badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ff4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}

/* Side Panels */
.side-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    transition: right 0.4s ease;
    overflow-y: auto;
}

.side-panel.active {
    right: 0;
}

.panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    margin: 0;
}

.close-panel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
}

.panel-content {
    padding: 20px;
}

.friend-search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.friend-search input {
    flex: 1;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.friend-search button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.friend-item, .notification-item {
    background: rgba(102, 126, 234, 0.1);
    padding: 15px;
    margin: 10px 0;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.friend-name {
    font-weight: bold;
    color: #333;
}

.friend-status {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.friend-actions button, .notification-item button {
    padding: 8px 15px;
    margin-left: 5px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.accept-btn {
    background: #4caf50;
    color: white;
}

.reject-btn, .unfriend-btn {
    background: #ff4444;
    color: white;
}

/* Leaderboard Updates */
.leaderboard h3 {
    cursor: pointer;
    user-select: none;
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.leaderboard-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.leaderboard-content.expanded {
    max-height: 800px;
}

@media (max-width: 768px) {
    .user-bar {
        left: 10px;
        right: 10px;
        padding: 10px;
    }
    
    .side-panel {
        width: 100%;
        right: -100%;
    }
}

/* Enhanced Themes with Cool Animations */

/* Rainbow theme - Enhanced */
body.theme-rainbow {
    background: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
    background-size: 400% 400%;
    animation: rainbowShift 10s ease infinite;
    font-family: 'Rubik', sans-serif !important;
    overflow-y: auto;
}

body.theme-rainbow::before {
    content: '🌈 ✨ 🌟 ⭐ 💫';
    position: fixed;
    font-size: 3rem;
    width: 200%;
    animation: rainbowScroll 20s linear infinite;
    opacity: 0.2;
    pointer-events: none;
    z-index: 0;
}

@keyframes rainbowScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Galaxy theme - Enhanced with nebula */
body.theme-galaxy {
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    font-family: 'Orbitron', sans-serif !important;
    overflow-y: auto;
}

body.theme-galaxy::before {
    content: '✦';
    position: fixed;
    font-size: 2rem;
    color: white;
    text-shadow: 0 0 10px white;
    animation: galaxyStars 5s ease-in-out infinite;
    top: 20%;
    left: 30%;
    pointer-events: none;
    z-index: 0;
}

@keyframes galaxyStars {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.5); }
}

/* Dark Mode - Enhanced with subtle grid */
body.theme-dark-mode {
    background: #000000;
    font-family: 'Inter', sans-serif !important;
    overflow-y: auto;
    position: relative;
}

body.theme-dark-mode::before {
    content: '';
    position: fixed;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* Neon Cyberpunk - Enhanced with scan lines */
body.theme-neon-cyberpunk {
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0a2e 50%, #16213e 100%);
    font-family: 'Audiowide', cursive !important;
    overflow-y: auto;
}

body.theme-neon-cyberpunk::before {
    content: '';
    position: fixed;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 255, 255, 0.03),
        rgba(0, 255, 255, 0.03) 1px,
        transparent 1px,
        transparent 2px
    );
    animation: scanlines 8s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes scanlines {
    0% { transform: translateY(0); }
    100% { transform: translateY(50px); }
}

/* Retro Arcade - Enhanced with moving pixels */
body.theme-retro-arcade {
    background: #1a1a2e;
    font-family: 'Press Start 2P', cursive !important;
    overflow-y: auto;
}

body.theme-retro-arcade::before {
    content: '';
    position: fixed;
    width: 200%;
    height: 200%;
    background-image: 
        linear-gradient(45deg, #ff0080 25%, transparent 25%),
        linear-gradient(-45deg, #ff0080 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #00ffff 75%),
        linear-gradient(-45deg, transparent 75%, #00ffff 75%);
    background-size: 40px 40px;
    opacity: 0.3;
    animation: pixelMove 10s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes pixelMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, 40px); }
}

/* Forest Fantasy - Enhanced with floating leaves */
body.theme-forest-fantasy {
    background: linear-gradient(135deg, #1e4620 0%, #2d5016 50%, #1a3d1a 100%);
    font-family: 'Cinzel', serif !important;
    overflow-y: auto;
}

body.theme-forest-fantasy::before {
    content: '🍃 🍂 🌿';
    position: fixed;
    font-size: 2rem;
    width: 200%;
    animation: leavesfall 15s linear infinite;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

@keyframes leavesfall {
    0% { transform: translateY(-100px) rotate(0deg); }
    100% { transform: translateY(100vh) rotate(360deg); }
}

/* Fire & Lava - Enhanced with flame particles */
body.theme-fire-lava {
    background: linear-gradient(135deg, #ff0000 0%, #ff4500 25%, #ff6347 50%, #ff7f00 75%, #ff0000 100%);
    background-size: 400% 400%;
    animation: fireFlow 5s ease infinite;
    font-family: 'Russo One', sans-serif !important;
    overflow-y: auto;
}

body.theme-fire-lava::before {
    content: '🔥';
    position: fixed;
    font-size: 4rem;
    bottom: 0;
    left: 50%;
    animation: fireRise 3s ease-in-out infinite;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

@keyframes fireRise {
    0% { transform: translateY(0) scale(1); opacity: 0.5; }
    100% { transform: translateY(-100vh) scale(2); opacity: 0; }
}

/* Ice Kingdom - Enhanced with snowflakes */
body.theme-ice-kingdom {
    background: linear-gradient(135deg, #00bfff 0%, #1e90ff 50%, #87ceeb 100%);
    font-family: 'Rajdhani', sans-serif !important;
    overflow-y: auto;
}

body.theme-ice-kingdom::before {
    content: '❄️ ❄ ❅ ❆';
    position: fixed;
    font-size: 2rem;
    width: 200%;
    animation: snowFall 12s linear infinite;
    opacity: 0.6;
    pointer-events: none;
    z-index: 0;
}

@keyframes snowFall {
    0% { transform: translateY(-100px); }
    100% { transform: translateY(100vh); }
}

/* Ocean Depths - Enhanced with waves */
body.theme-ocean-depths {
    background: linear-gradient(135deg, #001f3f 0%, #003d5c 50%, #005a7a 100%);
    font-family: 'Exo 2', sans-serif !important;
    overflow-y: auto;
}

body.theme-ocean-depths::before {
    content: '';
    position: fixed;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        rgba(0, 255, 255, 0.05) 50px,
        transparent 100px
    );
    animation: waves 8s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes waves {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(50px); }
}

/* Desert Storm - Enhanced with sand */
body.theme-desert-storm {
    background: linear-gradient(135deg, #daa520 0%, #d2691e 50%, #cd853f 100%);
    font-family: 'Teko', sans-serif !important;
    overflow-y: auto;
}

body.theme-desert-storm::before {
    content: '';
    position: fixed;
    width: 200%;
    height: 100%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(139, 69, 19, 0.1) 10px,
        rgba(139, 69, 19, 0.1) 20px
    );
    animation: sandStorm 15s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes sandStorm {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Synthwave - Enhanced with grid */
body.theme-synthwave {
    background: linear-gradient(180deg, #ff00ff 0%, #ff1493 25%, #ff69b4 50%, #4b0082 75%, #000080 100%);
    font-family: 'Bungee', cursive !important;
    overflow-y: auto;
}

body.theme-synthwave::before {
    content: '';
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 50%;
    background: 
        linear-gradient(rgba(255, 0, 255, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 0, 255, 0.3) 1px, transparent 1px);
    background-size: 50px 50px;
    transform: perspective(500px) rotateX(60deg);
    pointer-events: none;
    z-index: 0;
}

/* Blood Moon - Enhanced with dripping effect */
body.theme-blood-moon {
    background: linear-gradient(135deg, #1a0000 0%, #330000 50%, #4d0000 100%);
    font-family: 'Creepster', cursive !important;
    overflow-y: auto;
}

body.theme-blood-moon::before {
    content: '🌙';
    position: fixed;
    font-size: 8rem;
    top: 10%;
    right: 10%;
    filter: brightness(0.5) sepia(1) hue-rotate(-50deg) saturate(5);
    animation: bloodPulse 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes bloodPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

/* Minimal White - Enhanced with subtle pattern */
body.theme-minimal-white {
    background: #ffffff;
    font-family: 'Montserrat', sans-serif !important;
    overflow-y: auto;
}

body.theme-minimal-white::before {
    content: '';
    position: fixed;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, #00000005 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: 0;
}

/* Galaxy Rainbow - Enhanced */
body.theme-galaxy-rainbow {
    background: radial-gradient(ellipse at center, #ff0080 0%, #ff8c00 20%, #ffd700 40%, #00ff00 60%, #00bfff 80%, #8a2be2 100%);
    background-size: 200% 200%;
    animation: galaxyRainbow 10s ease infinite;
    font-family: 'Oxanium', cursive !important;
    overflow-y: auto;
}

body.theme-galaxy-rainbow::before {
    content: '⭐ 🌟 ✨ 💫';
    position: fixed;
    font-size: 3rem;
    width: 200%;
    animation: starTwinkle 8s linear infinite;
    opacity: 0.4;
    pointer-events: none;
    z-index: 0;
}

@keyframes starTwinkle {
    0% { transform: translateX(0) rotate(0deg); }
    100% { transform: translateX(-50%) rotate(360deg); }
}

/* Steampunk - Enhanced with gears */
body.theme-steampunk {
    background: linear-gradient(135deg, #3e2723 0%, #5d4037 50%, #6d4c41 100%);
    font-family: 'MedievalSharp', cursive !important;
    overflow-y: auto;
}

body.theme-steampunk::before {
    content: '⚙️';
    position: fixed;
    font-size: 6rem;
    top: 20%;
    left: 10%;
    animation: gearSpin 10s linear infinite;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

@keyframes gearSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cartoon Pop - Enhanced with bouncing */
body.theme-cartoon-pop {
    background: linear-gradient(45deg, #ff6b6b 0%, #4ecdc4 25%, #ffe66d 50%, #a8e6cf 75%, #ff6b6b 100%);
    font-family: 'Luckiest Guy', cursive !important;
    overflow-y: auto;
}

body.theme-cartoon-pop::before {
    content: '🎈 🎪 🎨';
    position: fixed;
    font-size: 3rem;
    animation: bounce 2s ease-in-out infinite;
    left: 20%;
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-50px); }
}

/* Shadow Realm - Enhanced with dark particles */
body.theme-shadow-realm {
    background: linear-gradient(135deg, #1a0033 0%, #2d004d 50%, #4b0082 100%);
    font-family: 'Chakra Petch', sans-serif !important;
    overflow-y: auto;
}

body.theme-shadow-realm::before {
    content: '';
    position: fixed;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle, rgba(138, 43, 226, 0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    animation: shadowPulse 4s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes shadowPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Snowy Night - Enhanced with snow */
body.theme-snowy-night {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 50%, #3a7ca5 100%);
    font-family: 'Silkscreen', cursive !important;
    overflow-y: auto;
}

body.theme-snowy-night::before {
    content: '❄️';
    position: fixed;
    font-size: 2rem;
    animation: snowDrift 10s linear infinite;
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
}

@keyframes snowDrift {
    0% { transform: translate(-100px, -100px); }
    100% { transform: translate(100vw, 100vh); }
}


/* Matrix Code - Enhanced with falling code */
body.theme-matrix {
    background: #000000;
    font-family: 'Share Tech Mono', monospace !important;
    overflow-y: auto;
}

body.theme-matrix::before {
    content: '0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0';
    position: fixed;
    top: -100%;
    left: 0;
    width: 100%;
    height: 200%;
    color: #00ff00;
    font-size: 1.2rem;
    line-height: 1.5;
    word-wrap: break-word;
    opacity: 0.3;
    z-index: 0;
    pointer-events: none;
    animation: matrixFall 20s linear infinite;
}

body.theme-matrix::after {
    content: '1 0 1 0 0 1 0 1 1 0 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 0';
    position: fixed;
    top: -150%;
    left: 20%;
    width: 100%;
    height: 200%;
    color: #00ff00;
    font-size: 1.2rem;
    line-height: 1.5;
    word-wrap: break-word;
    opacity: 0.2;
    z-index: 0;
    pointer-events: none;
    animation: matrixFall 25s linear infinite 5s;
}

@keyframes matrixFall {
    0% { top: -100%; }
    100% { top: 100%; }
}

body.theme-matrix .game-button {
    background: rgba(0, 0, 0, 0.8);
    color: #00ff00;
    border: 1px solid #00ff00;
}


/* ===== STATS ROW ===== */
.stats-row {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 8px 0 4px;
}
.stats-row span {
    background: rgba(0,0,0,0.2);
    color: rgba(255,255,255,0.95);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: .95rem;
    font-weight: 700;
    backdrop-filter: blur(4px);
}

/* ===== RANDOM BUTTON ===== */
.random-btn {
    padding: 12px 25px;
    background: rgba(255, 200, 0, 0.25);
    border: 2px solid rgba(255, 200, 0, 0.6);
    border-radius: 25px;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}
.random-btn:hover {
    background: rgba(255, 200, 0, 0.45);
    transform: scale(1.05);
}

/* ===== RECENT DROPDOWN ===== */
.recent-dropdown-container {
    position: relative;
}
.recent-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.98);
    padding: 12px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: none;
    z-index: 10000;
    min-width: 220px;
}
.recent-dropdown.active { display: block; }

/* ===== LEADERBOARD ===== */
.leaderboard {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    max-width: 270px;
    z-index: 1000;
    overflow: hidden;
}
.leaderboard h3 {
    color: #667eea;
    margin: 0;
    padding: 14px 18px;
    font-size: 1.1rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(102,126,234,0.07);
}
.dropdown-arrow { font-size: .85rem; transition: transform .3s; }
.leaderboard-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.leaderboard-content.expanded { max-height: 640px; overflow-y: auto; }
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: .88rem;
}
.leaderboard-item .rank { font-weight: 800; color: #667eea; min-width: 26px; }
.leaderboard-item .name { flex: 1; color: #333; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leaderboard-item .plays { color: #999; font-size: .8rem; }
.leaderboard-item:nth-child(1) .rank { color: #ffd700; }
.leaderboard-item:nth-child(2) .rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .rank { color: #cd7f32; }


/* ===== GAME VIEWER ===== */
/* The viewer wrapper just controls show/hide */
.game-viewer {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 9000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.game-viewer.active {
    opacity: 1;
    pointer-events: all;
}

/* Toolbar is FIXED at very top — iframes CANNOT steal these clicks */
.game-toolbar {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(10,10,10,0.97);
    border-bottom: 2px solid rgba(255,255,255,0.1);
    z-index: 99999;
    pointer-events: all;
    box-shadow: 0 2px 20px rgba(0,0,0,0.6);
    gap: 12px;
}
.viewer-title {
    color: white;
    font-weight: 800;
    font-size: 1rem;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.toolbar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.toolbar-btn {
    padding: 6px 13px;
    background: rgba(255,255,255,0.1);
    border: 1.5px solid rgba(255,255,255,0.18);
    border-radius: 7px;
    color: white;
    font-size: .84rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    pointer-events: all;
}
.toolbar-btn:hover { background: rgba(255,255,255,0.22); }
.exit-toolbar-btn {
    background: rgba(200,30,30,0.5);
    border-color: rgba(255,70,70,0.6);
    font-size: .88rem;
    padding: 6px 16px;
}
.exit-toolbar-btn:hover { background: rgba(220,30,30,0.85); }

/* Frame sits directly below toolbar */
.game-frame-container {
    position: fixed;
    top: 52px; left: 0;
    width: 100%;
    height: calc(100% - 52px);
    background: #000;
    z-index: 9001;
}
.game-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}


/* Date / Clock */
.date {
    font-size: 1rem;
    color: rgba(255,255,255,.9);
    font-weight: 600;
    margin-top: 6px;
}
.clock {
    font-size: 1.2rem;
    color: rgba(255,255,255,.95);
    font-weight: 700;
    margin-top: 4px;
    letter-spacing: 2px;
}

@media (max-width: 768px) {
    .leaderboard { right: 8px; top: 8px; max-width: 200px; }
    .toolbar-controls { gap: 8px; }
    .viewer-title { max-width: 120px; }
}
