* {
    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%);
    color: white;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
}

.screen {
    display: none;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

.title {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    opacity: 0.9;
}

.menu-section {
    margin: 2rem 0;
}

.menu-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 2rem 0;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
}

.btn-primary {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

input[type="text"] {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 1rem;
    display: block;
}

input[type="text"]:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.3);
}

.hidden {
    display: none !important;
}

/* Lobby Styles */
#game-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin: 2rem 0;
    font-size: 1.1rem;
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.player-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.player-card.ready {
    border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.2);
}

.player-card.current-player {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.2);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.4);
}

.host-badge {
    display: inline-block;
    background: #ff6b6b;
    color: white;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-weight: 600;
}

.lobby-actions {
    margin-top: 2rem;
}

/* Game Screen Styles */
#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.timer {
    font-size: 2rem;
    font-weight: bold;
    color: #ff6b6b;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.timer.warning {
    animation: pulse 1s infinite;
}

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

#prompt-section {
    margin: 3rem 0;
}

#game-prompt {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 12px;
    border-left: 4px solid #ff6b6b;
}

#answer-section {
    margin: 2rem 0;
}

#answer-input {
    font-size: 1.2rem;
    padding: 16px;
    max-width: 400px;
    margin-bottom: 1rem;
}

.loading-dots {
    display: inline-block;
    margin-left: 10px;
}

.loading-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    margin: 0 2px;
    animation: loading 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Results Styles */
.results-grid {
    display: grid;
    gap: 1rem;
    margin: 2rem 0;
}

.result-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item.matched {
    border-left: 4px solid #2ecc71;
    background: rgba(46, 204, 113, 0.2);
}

.result-answer {
    font-weight: 600;
}

.result-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2ecc71;
}

.leaderboard {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    margin: 1rem 0;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-item.gold {
    background: linear-gradient(45deg, #f39c12, #e67e22);
}

.leaderboard-item.silver {
    background: linear-gradient(45deg, #95a5a6, #7f8c8d);
}

.leaderboard-item.bronze {
    background: linear-gradient(45deg, #e74c3c, #c0392b);
}

.leaderboard-item.current-player {
    border-left: 4px solid #ff6b6b;
    padding-left: calc(1rem - 4px);
}

.player-rank {
    font-weight: bold;
    font-size: 1.1rem;
}

.player-score {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Final Results */
.final {
    font-size: 1.2rem;
}

.final .leaderboard-item {
    padding: 1.5rem;
}

.final-actions {
    margin-top: 3rem;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #e74c3c;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: #2ecc71;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .menu-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    #game-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    #game-prompt {
        font-size: 1.5rem;
        padding: 1.5rem;
    }
    
    .players-grid {
        grid-template-columns: 1fr;
    }
    
    .result-item {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* Additional robust multiplayer styles */
.answer {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.players {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.matches {
    font-size: 0.85rem;
    opacity: 0.8;
}

.points {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2ecc71;
}

.points:not(:contains('+')) {
    color: #95a5a6;
}

#waiting-message {
    margin-top: 2rem;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Prevent text selection during game */
.screen.active#game-screen * {
    user-select: none;
}

/* Focus styles for accessibility */
button:focus,
input:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Error states */
input.error {
    border: 2px solid #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}