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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    overflow: hidden;
    background: #0a0e27;
    position: relative;
}

/* Animated gradient background */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        #ff006e,
        #8338ec,
        #3a86ff,
        #06ffa5,
        #ffbe0b,
        #ff006e
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    opacity: 0.15;
    z-index: 0;
}

@keyframes gradientShift {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(10%, 10%) rotate(120deg); }
    66% { transform: translate(-10%, 10%) rotate(240deg); }
}

/* Animated particles */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 80% 10%, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(1px 1px at 90% 60%, rgba(255, 255, 255, 0.3), transparent);
    background-size: 200% 200%;
    animation: particlesMove 20s linear infinite;
    z-index: 0;
    pointer-events: none;
}

@keyframes particlesMove {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

.screen {
    display: none;
    width: 100%;
    position: relative;
    z-index: 1;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.container {
    background: rgba(15, 20, 45, 0.7);
    backdrop-filter: blur(20px);
    padding: 50px;
    border-radius: 25px;
    box-shadow:
        0 8px 32px 0 rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 0 20px rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

h1 {
    font-size: 3.5rem;
    margin-bottom: 30px;
    text-shadow:
        0 0 10px rgba(131, 56, 236, 0.8),
        0 0 20px rgba(131, 56, 236, 0.6),
        0 0 30px rgba(131, 56, 236, 0.4),
        2px 2px 4px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, #ff006e, #8338ec, #3a86ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titlePulse 2s ease-in-out infinite;
    font-weight: bold;
    letter-spacing: 2px;
}

@keyframes titlePulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.02); filter: brightness(1.2); }
}

h2 {
    font-size: 2.2rem;
    margin-bottom: 20px;
    text-shadow: 0 0 10px rgba(58, 134, 255, 0.8);
    color: #3a86ff;
}

input[type="text"] {
    width: 100%;
    padding: 18px;
    font-size: 1.3rem;
    border: 2px solid rgba(131, 56, 236, 0.5);
    border-radius: 15px;
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.95);
    color: #0a0e27;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(131, 56, 236, 0.2);
}

input[type="text"]:focus {
    outline: none;
    border-color: #8338ec;
    box-shadow:
        0 0 0 3px rgba(131, 56, 236, 0.2),
        0 0 20px rgba(131, 56, 236, 0.4);
    transform: translateY(-2px);
}

button {
    padding: 18px 45px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #8338ec, #3a86ff);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow:
        0 4px 15px rgba(131, 56, 236, 0.4),
        0 0 20px rgba(131, 56, 236, 0.2);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

button:hover {
    transform: translateY(-3px);
    box-shadow:
        0 6px 25px rgba(131, 56, 236, 0.6),
        0 0 30px rgba(131, 56, 236, 0.4);
}

button:active {
    transform: translateY(-1px);
}

.spinner {
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid #3a86ff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 25px auto;
    box-shadow: 0 0 20px rgba(58, 134, 255, 0.5);
}

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

#game-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 800px;
    padding: 25px;
    background: rgba(15, 20, 45, 0.8);
    backdrop-filter: blur(20px);
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(131, 56, 236, 0.2);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.4rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.player-info.right {
    flex-direction: row-reverse;
}

.score {
    font-size: 2.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, #8338ec, #3a86ff);
    padding: 15px 25px;
    border-radius: 15px;
    min-width: 70px;
    text-align: center;
    box-shadow:
        0 4px 15px rgba(131, 56, 236, 0.4),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
    animation: scorePulse 0.5s ease;
}

@keyframes scorePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

#game-canvas {
    border: 3px solid rgba(131, 56, 236, 0.5);
    border-radius: 15px;
    background: #0a0e27;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.7),
        0 0 30px rgba(131, 56, 236, 0.3),
        inset 0 0 50px rgba(0, 0, 0, 0.5);
}

.controls-info {
    background: rgba(15, 20, 45, 0.8);
    backdrop-filter: blur(20px);
    padding: 18px 35px;
    border-radius: 15px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

kbd {
    background: linear-gradient(135deg, #8338ec, #3a86ff);
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow:
        0 2px 8px rgba(131, 56, 236, 0.4),
        inset 0 1px 3px rgba(255, 255, 255, 0.3);
    margin: 0 3px;
    display: inline-block;
}

#waiting-info {
    margin-top: 15px;
    font-size: 1.2rem;
    opacity: 0.9;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================================================
   LOBBY SYSTEM STYLES
   ============================================================================ */

/* Larger container for lobby screens */
.container.large {
    max-width: 900px;
    width: 90%;
    padding: 40px;
}

/* Mode selection buttons */
.mode-buttons {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-btn {
    flex: 1;
    min-width: 200px;
    padding: 30px 40px;
    background: linear-gradient(135deg, #ff006e, #8338ec);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow:
        0 10px 40px rgba(255, 0, 110, 0.5),
        0 0 40px rgba(131, 56, 236, 0.5);
}

.mode-btn h3 {
    margin: 0 0 10px 0;
    font-size: 1.8rem;
    color: #fff;
}

.mode-btn p {
    margin: 0;
    font-size: 1rem;
    opacity: 0.9;
    color: #fff;
}

/* Lobby actions */
.lobby-actions {
    display: flex;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.primary-btn {
    background: linear-gradient(135deg, #06ffa5, #3a86ff);
}

.primary-btn:hover {
    box-shadow:
        0 6px 25px rgba(6, 255, 165, 0.6),
        0 0 30px rgba(6, 255, 165, 0.4);
}

.secondary-btn {
    background: linear-gradient(135deg, #555, #777);
    padding: 15px 30px;
    font-size: 1.1rem;
}

.secondary-btn:hover {
    box-shadow:
        0 6px 25px rgba(255, 255, 255, 0.3),
        0 0 30px rgba(255, 255, 255, 0.2);
}

/* Lobbies list */
.lobbies-list {
    margin-top: 30px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.lobbies-list::-webkit-scrollbar {
    width: 8px;
}

.lobbies-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.lobbies-list::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #8338ec, #3a86ff);
    border-radius: 10px;
}

.no-lobbies {
    text-align: center;
    padding: 40px;
    opacity: 0.7;
    font-size: 1.2rem;
}

.lobby-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.lobby-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(131, 56, 236, 0.5);
    transform: translateX(5px);
}

.lobby-info h4 {
    margin: 0 0 8px 0;
    font-size: 1.4rem;
    color: #06ffa5;
    text-shadow: 0 0 10px rgba(6, 255, 165, 0.5);
}

.lobby-info p {
    margin: 5px 0;
    opacity: 0.8;
    font-size: 1rem;
}

.lobby-player-count {
    color: #3a86ff;
    font-weight: bold;
}

.join-lobby-btn {
    padding: 12px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #8338ec, #ff006e);
}

/* Pre-game lobby */
.lobby-mode {
    text-align: center;
    color: #06ffa5;
    font-size: 1.2rem;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(6, 255, 165, 0.5);
}

.lobby-players, .lobby-teams {
    margin: 30px 0;
}

.lobby-players h3, .team-column h3 {
    color: #3a86ff;
    text-shadow: 0 0 10px rgba(58, 134, 255, 0.5);
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.players-list, .team-list {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 15px;
    min-height: 80px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.player-nickname {
    font-size: 1.2rem;
    color: #fff;
    font-weight: 500;
}

.ready-badge {
    color: #06ffa5;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(6, 255, 165, 0.8);
    font-size: 1.1rem;
}

.not-ready-badge {
    color: #ff006e;
    opacity: 0.6;
    font-size: 0.9rem;
}

/* 2v2 Teams */
.lobby-teams {
    display: flex;
    gap: 30px;
    justify-content: space-between;
}

.team-column {
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 15px;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.team-btn {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    font-size: 1rem;
}

.no-players {
    text-align: center;
    opacity: 0.5;
    padding: 20px;
    font-style: italic;
}

/* Lobby status */
.lobby-status {
    text-align: center;
    padding: 15px;
    margin: 20px 0;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 500;
}

.lobby-status.waiting {
    background: rgba(255, 190, 11, 0.1);
    color: #ffbe0b;
    border: 2px solid rgba(255, 190, 11, 0.3);
}

.lobby-status.ready {
    background: rgba(6, 255, 165, 0.1);
    color: #06ffa5;
    border: 2px solid rgba(6, 255, 165, 0.3);
    animation: pulse 1s ease-in-out infinite;
}

/* Ready button state */
#ready-btn.ready {
    background: linear-gradient(135deg, #ff006e, #ff4d00);
}

/* Responsive design */
@media (max-width: 900px) {
    .game-info {
        width: 90%;
    }

    #game-canvas {
        width: 90%;
        height: auto;
    }

    h1 {
        font-size: 2.5rem;
    }

    .mode-buttons {
        flex-direction: column;
    }

    .lobby-teams {
        flex-direction: column;
        gap: 20px;
    }

    .container.large {
        padding: 30px 20px;
    }
}
