@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Rajdhani:wght@500;700&display=swap');

:root {
    --neon-red: #ff0055;
    --neon-blue: #00ccff;
    --neon-green: #00ff88;
    --neon-yellow: #ffff00;
    --neon-purple: #bc13fe;
    --bg-dark: #050505;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: #fff;
    font-family: 'Rajdhani', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    background-image:
        linear-gradient(rgba(0, 204, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 204, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: scrollGrid 20s linear infinite;
}

@keyframes scrollGrid {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 50px 50px;
    }
}

h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 4rem;
    margin: 40px 0;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: #fff;
    text-shadow:
        0 0 10px var(--neon-blue),
        0 0 20px var(--neon-blue),
        0 0 40px var(--neon-purple);
    animation: glowPulse 2s infinite alternate;
}

@keyframes glowPulse {
    from {
        text-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-blue);
    }

    to {
        text-shadow: 0 0 20px var(--neon-blue), 0 0 40px var(--neon-purple), 0 0 60px var(--neon-purple);
    }
}

/* Fixed: Renamed from .menu-container and enforced 4 columns */
.games-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
    width: 90%;
    max-width: 1600px;
    padding: 20px;
    z-index: 1;
}

/* Responsive: 2 columns on tablet, 1 on mobile */
@media (max-width: 1200px) {
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: 1fr;
    }
}

.game-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    text-decoration: none;
    color: #fff;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.game-card:hover::before {
    transform: translateX(100%);
}

.game-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--neon-blue);
    box-shadow:
        0 0 20px rgba(0, 204, 255, 0.3),
        inset 0 0 20px rgba(0, 204, 255, 0.1);
}

.game-card:nth-child(3n+1):hover {
    border-color: var(--neon-red);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.3);
}

.game-card:nth-child(3n+2):hover {
    border-color: var(--neon-green);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
}

.card-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

.game-card h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #fff;
    text-shadow: 0 0 5px var(--neon-blue);
}

.game-card p {
    color: #aaa;
    font-size: 1rem;
}

.hidden {
    display: none !important;
}

/* Added Overlay Class */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.overlay h1 {
    font-size: 3rem;
    margin: 0 0 20px;
    text-shadow: 0 0 20px var(--neon-blue);
}

.overlay p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    color: #ddd;
}

.neon-btn {
    background: transparent;
    border: 2px solid var(--neon-green);
    color: var(--neon-green);
    padding: 15px 40px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.neon-btn:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 30px rgba(0, 255, 136, 0.6);
    transform: scale(1.05);
}

.neon-btn.small {
    padding: 5px 15px;
    font-size: 1rem;
}

.back-link {
    display: block;
    margin-top: 20px;
    color: #888;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s;
}

.back-link:hover {
    color: #fff;
    text-decoration: underline;
}

.controls-info {
    margin-bottom: 20px;
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 5px;
}

.room-browser-btn-container {
    margin-bottom: 30px;
    z-index: 10;
}

/* Embedded Room List Styles */
.room-list-panel {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ccff;
    box-shadow: 0 0 20px rgba(0, 204, 255, 0.2);
    padding: 20px;
    margin: 20px auto;
    max-width: 800px;
    width: 90%;
    border-radius: 10px;
    text-align: center;
    z-index: 10;
}

.room-list-panel h2 {
    color: #00ccff;
    text-shadow: 0 0 10px rgba(0, 204, 255, 0.5);
    margin-top: 0;
    margin-bottom: 15px;
    font-family: 'Orbitron', sans-serif;
}

#room-list-container {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #333;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    margin-bottom: 5px;
    border: 1px solid #333;
    transition: all 0.2s;
}

.room-item:hover {
    border-color: #00ccff;
    background: rgba(0, 204, 255, 0.1);
}

.room-info {
    text-align: left;
}

.room-game {
    color: #fff;
    font-weight: bold;
    display: block;
}

.room-players {
    color: #888;
    font-size: 0.9em;
}

.join-btn {
    padding: 5px 15px;
    font-size: 0.9em;
    background: transparent;
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
}

.join-btn:hover {
    background: var(--neon-green);
    color: #000;
}

/* Scrollbar styling */
#room-list-container::-webkit-scrollbar {
    width: 8px;
}

#room-list-container::-webkit-scrollbar-track {
    background: #111;
}

#room-list-container::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

#room-list-container::-webkit-scrollbar-thumb:hover {
    background: #00ccff;
}