/* CSS for Typing Game */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3a0ca3;
    --accent-color: #f72585;
    --success-color: #4cc9f0;
    --warning-color: #f8961e;
    --danger-color: #f94144;
    --dark-color: #212529;
    --light-color: #f8f9fa;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark-color);
}

.typing-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.game-header {
    background: white;
    padding: 20px 30px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--box-shadow);
}

.game-header h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-header h1 i {
    color: var(--accent-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.guest-badge {
    background: var(--warning-color);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Button Styles */
.btn-action {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    text-decoration: none;
    color: white;
}

.btn-primary {
    background: var(--primary-color);
}

.btn-secondary {
    background: var(--secondary-color);
}

.btn-info {
    background: var(--success-color);
}

.btn-warning {
    background: var(--warning-color);
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Lobby Actions */
.lobby-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

/* Join Room Form */
.join-room-form {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}

.join-room-form h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.join-room-form form {
    display: flex;
    gap: 10px;
}

.join-room-form input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.join-room-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-join {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.btn-join:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.game-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.game-card-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-card-header h3 {
    font-size: 1.2rem;
    margin: 0;
}

.room-code {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.game-card-body {
    padding: 20px;
}

.game-card-body p {
    margin: 8px 0;
    color: #666;
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-card-footer {
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    gap: 10px;
}

.btn-join-game {
    flex: 1;
    background: var(--success-color);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-join-game:hover {
    background: #36b9e0;
}

.btn-spectate {
    flex: 1;
    background: var(--warning-color);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

/* Game Room Layout */
.game-room {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 20px;
    min-height: 700px;
}

.players-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
}

.players-list {
    margin-top: 20px;
}

.player-card {
    background: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
}

.player-card.ready {
    border-left: 4px solid var(--success-color);
}

.player-card.playing {
    border-left: 4px solid var(--primary-color);
}

.player-card.empty {
    opacity: 0.6;
    background: #e9ecef;
}

.player-avatar {
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.player-info h4 {
    margin: 0;
    font-size: 1rem;
}

.player-status {
    font-size: 0.8rem;
    color: #666;
    display: block;
    margin-top: 5px;
}

.player-wpm {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    margin-top: 5px;
}

/* Typing Area */
.typing-area {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--box-shadow);
    display: none;
}

.text-display {
    background: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 20px 0;
    font-size: 1.2rem;
    line-height: 1.8;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #e9ecef;
}

.typing-input textarea {
    width: 100%;
    height: 120px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
    resize: none;
    transition: var(--transition);
}

.typing-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Game Timer */
.game-timer {
    text-align: center;
    margin-bottom: 20px;
}

.game-timer span {
    display: inline-block;
    background: var(--dark-color);
    color: white;
    padding: 10px 30px;
    border-radius: 30px;
    font-size: 2rem;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

/* Progress Bar */
.typing-progress {
    margin: 20px 0;
}

.progress-bar {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    width: 0%;
    transition: width 0.3s ease;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    color: #666;
    font-size: 0.9rem;
}

/* Live Stats */
.live-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-box {
    background: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    border: 2px solid #e9ecef;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Power-ups */
.powerups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.powerup-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.powerup-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.powerup-card i {
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 10px;
}

.powerup-card span {
    display: block;
    font-weight: 600;
    color: var(--dark-color);
}

.active-powerups {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-top: 20px;
}

.active-powerup {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    margin: 5px;
    font-size: 0.9rem;
}

/* Chat Section */
.chat-section {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    height: 700px;
}

.chat-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.chat-input {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
}

.chat-input button {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 45px;
    border-radius: var(--border-radius);
    cursor: pointer;
}

/* Voice Chat */
.voice-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

.voice-header {
    background: var(--dark-color);
    color: white;
    padding: 15px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.voice-controls button {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    margin-left: 5px;
}

/* Tournament Cards */
.tournaments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.tournament-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius);
}

.tournament-card h3 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.prize-pool {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
    margin: 10px 0;
    font-size: 0.9rem;
}

.btn-enter-tournament {
    background: white;
    color: var(--accent-color);
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    width: 100%;
    justify-content: center;
}

/* Leaderboard */
.leaderboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-link {
    flex: 1;
    padding: 10px;
    background: #e9ecef;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.tab-link.active {
    background: var(--primary-color);
    color: white;
}

.tab-content {
    display: none;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
}

.tab-content.active {
    display: block;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-room {
        grid-template-columns: 1fr;
    }
    
    .chat-section {
        grid-row: 3;
        height: 400px;
    }
}

@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .lobby-actions {
        grid-template-columns: 1fr;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .live-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .voice-chat {
        width: calc(100% - 40px);
    }
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.collapsed {
    width: 50px !important;
    overflow: hidden;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.alert {
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 10px 0;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* Text difficulty badges */
.text-difficulty {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.text-difficulty.easy {
    background: #d4edda;
    color: #155724;
}

.text-difficulty.medium {
    background: #fff3cd;
    color: #856404;
}

.text-difficulty.hard {
    background: #f8d7da;
    color: #721c24;
}

/* Custom Text Form */
.create-game-form {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.btn-create {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 20px;
    transition: var(--transition);
}

.btn-create:hover {
    background: #e11570;
    transform: translateY(-2px);
}

.text-stats {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
}

.custom-texts-list {
    margin-top: 40px;
}

.texts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.text-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
}

.text-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
}

.text-card h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.text-card p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
}