/**
 * Multiplayer styles for Typing Race
 */

/* Multiplayer container */
.multiplayer-container {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* Dynamic background */
.multiplayer-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1A2526 0%, #0A0F12 100%);
    z-index: -1;
    border-radius: 15px;
    opacity: 0.8;
}

/* Floating keyboard keys animation */
@keyframes float {
    0% { transform: translateY(0) rotate(0deg); opacity: 0.3; }
    50% { transform: translateY(-15px) rotate(5deg); opacity: 0.7; }
    100% { transform: translateY(0) rotate(0deg); opacity: 0.3; }
}

.multiplayer-container::after {
    content: '⌨';
    position: absolute;
    font-size: 40px;
    color: rgba(255, 255, 255, 0.05);
    top: 20px;
    right: 40px;
    animation: float 6s ease-in-out infinite;
    z-index: -1;
}

/* Server connection indicator */
.server-connection {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    margin-bottom: 20px;
    border-radius: 50px;
    background-color: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.server-connection.connected {
    background-color: rgba(40, 167, 69, 0.2);
}

.server-connection.disconnected {
    background-color: rgba(220, 53, 69, 0.2);
}

.connection-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    background-color: #28a745;
    position: relative;
}

.connection-indicator::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    background-color: rgba(40, 167, 69, 0.4);
    animation: pulse 2s infinite;
    z-index: -1;
}

.connection-indicator.disconnected {
    background-color: #dc3545;
}

.connection-indicator.disconnected::after {
    background-color: rgba(220, 53, 69, 0.4);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.server-connection-text {
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Multiplayer options */
.multiplayer-options {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
}

.multiplayer-options h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: transparent;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 2px 10px rgba(79, 172, 254, 0.3);
    letter-spacing: 1px;
}

.multiplayer-options p {
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: #A3BFFA;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
}

/* Option cards */
.option-cards {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.option-card {
    background-color: rgba(42, 59, 90, 0.7);
    border-radius: 10px;
    padding: 25px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.option-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.option-card h3 {
    font-size: 1.7rem;
    margin-bottom: 15px;
    color: var(--primary-color);
    position: relative;
    display: inline-block;
}

.option-card h3::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), transparent);
    border-radius: 3px;
}

.option-card p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-color);
    line-height: 1.5;
}

.waiting-info {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.waiting-count {
    font-size: 1.4rem;
    color: #FFD166;
    font-weight: bold;
    display: inline-block;
    animation: playerCountPulse 2s infinite;
}

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

.next-race-time {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: var(--text-color);
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    display: inline-block;
}

/* Button styling */
.btn.primary-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn.primary-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.btn.primary-btn:active {
    transform: translateY(1px);
}

.btn.primary-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
    transition: all 0.3s ease;
    z-index: 1;
    opacity: 0;
}

.btn.primary-btn:hover::before {
    opacity: 1;
    animation: shine 1.5s ease;
}

@keyframes shine {
    0% { left: -50%; opacity: 0; }
    50% { opacity: 0.5; }
    100% { left: 150%; opacity: 0; }
}

#joinScheduledBtn::after {
    content: '🏁';
    margin-left: 8px;
    font-size: 1.2rem;
}

#createCustomBtn::after {
    content: '✨';
    margin-left: 8px;
    font-size: 1.2rem;
}

.join-custom {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.join-custom p {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.custom-race-join {
    display: flex;
    gap: 10px;
}

.custom-race-join input {
    flex: 1;
    padding: 12px 15px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    transition: all 0.3s ease;
    box-shadow: 0 0 0 rgba(var(--accent-rgb), 0);
}

.custom-race-join input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3);
    background-color: rgba(255, 255, 255, 0.1);
}

.btn.secondary-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 20px;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.btn.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

#joinCustomBtn::after {
    content: '✓';
    margin-left: 5px;
}

/* Waiting room */
.waiting-room {
    text-align: center;
    background: linear-gradient(135deg, rgba(26, 37, 38, 0.9) 0%, rgba(10, 15, 18, 0.95) 100%);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

/* Floating keyboard animation for waiting room */
.waiting-room::before {
    content: '⌨';
    position: absolute;
    font-size: 120px;
    color: rgba(255, 255, 255, 0.03);
    top: -20px;
    right: -20px;
    z-index: 0;
    animation: float 8s ease-in-out infinite;
    opacity: 0.5;
}

.waiting-room::after {
    content: '⌨';
    position: absolute;
    font-size: 80px;
    color: rgba(255, 255, 255, 0.02);
    bottom: -10px;
    left: -10px;
    z-index: 0;
    animation: float 10s ease-in-out infinite reverse;
    opacity: 0.5;
}

.waiting-room h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: transparent;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    -webkit-background-clip: text;
    background-clip: text;
    text-shadow: 0 2px 10px rgba(79, 172, 254, 0.3);
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

.waiting-info {
    margin-bottom: 30px;
    position: relative;
    z-index: 1;
}

.waiting-info p {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #A3BFFA;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.5px;
}

.waiting-count {
    font-size: 1.6rem;
    color: #FFD166;
    font-weight: bold;
    display: inline-block;
    animation: playerCountPulse 2s infinite;
    text-shadow: 0 0 10px rgba(255, 209, 102, 0.5);
}

#waitingMessage {
    color: #A3BFFA;
    font-size: 1.3rem;
    margin-top: 15px;
    font-style: italic;
}

.next-race-container {
    margin: 2rem auto;
    max-width: 500px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 20px;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.next-race-container p {
    font-size: 1.2rem;
    color: #A3BFFA;
    margin-bottom: 10px;
}

.next-race {
    font-size: 6rem;
    font-weight: bold;
    margin: 0.5rem 0;
    color: #4facfe;
    font-family: 'Montserrat', sans-serif;
    animation: timerPulse 1s infinite;
    text-shadow: 0 0 15px rgba(79, 172, 254, 0.4);
}

@keyframes timerPulse {
    0% { opacity: 0.9; }
    50% { opacity: 1; }
    100% { opacity: 0.9; }
}

#leaveWaitingBtn {
    background-color: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 25px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    margin-top: 20px;
    position: relative;
    z-index: 1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

#leaveWaitingBtn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

#leaveWaitingBtn:active {
    transform: translateY(1px);
}

/* Animation for floating elements */
@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

/* Custom race lobby */
.custom-race-lobby {
    text-align: center;
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.custom-race-lobby h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.race-code-display {
    margin-bottom: 20px;
}

.race-code-display p {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: var(--text-color);
}

.code-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

#raceCodeDisplay {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 10px 20px;
    background-color: var(--bg-color);
    border-radius: 5px;
    border: 1px solid var(--border-color);
    letter-spacing: 2px;
}

.host-controls {
    margin: 20px 0;
}

/* Race container */
.race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.race-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.racers-count {
    font-size: 1.1rem;
    color: var(--text-color);
    font-weight: bold;
}

/* Leaderboard Styles */
.leaderboard {
    background-color: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.leaderboard-loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Updated player row to match single player style */
.leaderboard-entry {
    display: flex;
    align-items: center;
    background-color: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 10px 15px;
    margin-bottom: 10px;
    border-bottom: none;
}

.leaderboard-entry:last-child {
    margin-bottom: 0;
}

.leaderboard-entry.current-player {
    background-color: rgba(var(--accent-rgb), 0.15);
}

/* Updated player position to match single player rank style */
.player-position {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-color);
    color: var(--text-on-accent);
    border-radius: 50%;
    font-weight: bold;
    margin-right: 15px;
    flex-shrink: 0;
}

.player-name {
    flex: 0 0 150px;
    font-weight: bold;
    color: var(--text-primary);
    margin-right: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-stats {
    display: flex;
    gap: 15px;
    margin-right: 15px;
    font-size: 12px;
    color: var(--text-secondary);
}

.player-wpm, .player-accuracy {
    font-size: 0.9rem;
}

.player-progress {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.progress-bar {
    height: 8px;
    background-color: var(--primary-bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    align-self: flex-end;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Results modal */
.multiplayer-position {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: rgba(var(--primary-rgb), 0.1);
    border-radius: 10px;
}

.position-label {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 5px;
}

.position-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

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

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 5px;
    border: none;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: var(--primary-dark);
}

.secondary-btn {
    background-color: var(--secondary-color);
    color: white;
}

.secondary-btn:hover {
    background-color: var(--secondary-dark);
}

.danger-btn {
    background-color: var(--error-color);
    color: white;
}

.danger-btn:hover {
    background-color: #d32f2f;
}

.small-btn {
    padding: 5px 10px;
    font-size: 0.9rem;
}

/* Game controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

/* Countdown overlay */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.countdown-content {
    text-align: center;
    background-color: var(--card-bg);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.3);
    max-width: 400px;
    width: 90%;
}

.countdown-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.countdown-timer {
    font-size: 5rem;
    font-weight: bold;
    color: var(--accent-color);
    margin: 20px 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.countdown-timer.pulse {
    color: var(--error-color);
    animation: pulse 1s infinite;
}

.countdown-content p {
    font-size: 1.2rem;
    color: var(--text-color);
}

/* Connection status */
.connection-status {
    display: none; /* Hide the redundant connection status indicator */
    padding: 5px 10px;
    margin-bottom: 15px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}

.connection-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.connection-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Notification */
.multiplayer-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 300px;
    font-size: 1rem;
    border-left: 4px solid var(--primary-color);
}

.multiplayer-notification.show {
    transform: translateX(0);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Responsive adjustments */
@media (max-width: 768px) {
    .option-cards {
        flex-direction: column;
        align-items: center;
    }
    
    .race-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .race-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .player-progress {
        width: 100px;
    }
    
    .player-stats {
        flex-direction: column;
        gap: 5px;
    }
}
