* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 500px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.error-message {
    background: #ef4444;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    animation: slideDown 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.error-message.hidden {
    display: none;
}

.disconnect-message {
    background: #f59e0b;
    color: white;
    padding: 12px 20px;
    border-radius: 12px;
    margin: 20px 0;
    text-align: center;
    font-weight: 600;
    animation: pulse 2s infinite;
}

.disconnect-message.hidden {
    display: none;
}

/* Matchmaking Styles */
.matchmaking-loader {
    text-align: center;
    padding: 30px;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.matchmaking-info {
    color: #666;
    margin: 20px 0;
    font-size: 0.95rem;
}

#matchmaking-section .card {
    text-align: center;
}

/* Call Controls */
.call-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 15px;
}

.call-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #10b981;
    font-weight: 600;
    padding: 8px 16px;
    background: #d1fae5;
    border-radius: 20px;
    font-size: 0.9rem;
}

.call-indicator.hidden {
    display: none;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

.btn-call {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-call:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.call-actions {
    display: flex;
    gap: 10px;
}

.btn-mute {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 1.2rem;
}

.btn-mute:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.call-actions.hidden {
    display: none;
}

/* Typing Indicator */
.typing-indicator {
    padding: 8px 16px;
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 8px 0;
}

.typing-indicator.hidden {
    display: none;
}

/* Divider */
.divider {
    text-align: center;
    margin: 20px 0;
    color: #999;
    font-size: 0.9rem;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #e0e0e0;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.screen {
    animation: fadeIn 0.3s ease-in;
}

.screen.hidden {
    display: none;
}

.card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1.1rem;
    margin-bottom: 15px;
    text-align: center;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.9rem;
    width: auto;
}

/* Post-Game Action Buttons (Small, Side) */
.post-game-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 15px;
    animation: fadeIn 0.3s ease-out;
}

.post-game-actions .btn-small {
    padding: 8px 16px;
    font-size: 1.2rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.post-game-actions .btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.post-game-actions .btn-small:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

#join-input {
    margin-top: 15px;
    animation: slideDown 0.3s ease-out;
}

.game-code {
    background: #667eea;
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 1.3rem;
    letter-spacing: 2px;
}

.loader {
    margin: 30px 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f0f0f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Game Screen */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.player span:first-child {
    font-weight: bold;
    color: #333;
}

.symbol {
    background: #667eea;
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 1.2rem;
}

.vs {
    font-size: 1.5rem;
    font-weight: bold;
    color: #999;
}

.turn-indicator {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #333;
}

.highlight {
    color: #667eea;
    font-weight: bold;
    font-size: 1.5rem;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

.cell {
    aspect-ratio: 1;
    background: #f8f9fa;
    border: 3px solid #e0e0e0;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.cell:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.cell.x {
    color: #667eea;
}

.cell.o {
    color: #764ba2;
}

.cell.winner {
    background: #10b981;
    color: white;
    animation: pulse 0.5s ease-in-out;
}

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

.result {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: bold;
    animation: slideDown 0.3s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.result-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.result-emoji {
    font-size: 2rem;
}

.result-text {
    font-size: 1.2rem;
    font-weight: bold;
}

.result.win {
    background: #10b981;
    color: white;
}

.result.draw {
    background: #f59e0b;
    color: white;
}

.result.lose {
    background: #ef4444;
    color: white;
}

/* Chat */
.chat-container {
    background: white;
    border-radius: 15px;
    padding: 15px;
    margin-top: 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.chat-messages {
    height: 150px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 8px;
    padding: 8px;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
}

.chat-message .player-name {
    font-weight: bold;
    color: #667eea;
}

.chat-input {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    margin-bottom: 0;
}

/* Voice Message Button */
.btn-voice {
    background: #8b5cf6;
    color: white;
    font-size: 1.3rem;
    padding: 10px 14px;
    transition: all 0.2s;
}

.btn-voice:hover {
    background: #7c3aed;
    transform: scale(1.05);
}

.btn-voice.recording {
    background: #ef4444;
    animation: pulse 1s infinite;
}

/* Voice Recording UI */
.voice-recording-ui {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.3s ease-out;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 1.1rem;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

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

/* Voice Message in Chat */
.voice-message {
    background: #f3f4f6;
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
}

.voice-message audio {
    height: 40px;
    max-width: 200px;
}

.voice-message .play-btn {
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.voice-message .play-btn:hover {
    background: #7c3aed;
}

.voice-message .duration {
    font-size: 0.85rem;
    color: #6b7280;
    white-space: nowrap;
}

.voice-message.sent {
    background: #dbeafe;
}

.voice-message.received {
    background: #f3f4f6;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    animation: slideDown 0.3s ease-out;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #333;
}

.emoji {
    font-size: 5rem;
    margin-bottom: 30px;
    display: block;
}

/* Responsive */
@media (max-width: 480px) {
    header h1 {
        font-size: 2rem;
    }
    
    .card {
        padding: 20px;
    }
    
    .cell {
        font-size: 2.5rem;
    }
    
    .player span:first-child {
        font-size: 0.9rem;
    }
}

/* ============ NEW FEATURES STYLES ============ */

/* Timer Display */
.timer-display {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 15px 0;
    text-align: center;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    animation: pulse 1s infinite;
}

.timer-display.urgent {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    animation: pulse 0.5s infinite;
}

.timer-display.my-turn {
    border: 3px solid #10b981;
}

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

/* Feature Buttons */
.feature-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 15px 0;
}

.btn-feature {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-feature:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.player-count {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #6366f1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #6b7280;
}

/* Leaderboard Table */
.leaderboard-content {
    max-width: 600px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.9rem;
}

.leaderboard-table th {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 12px 8px;
    text-align: center;
}

.leaderboard-table td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.leaderboard-table tr.current-player {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    font-weight: bold;
}

.leaderboard-table tr:hover {
    background: #f9fafb;
}

/* ELO Change in Game Over */
.elo-change {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 15px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Modal Scrollable */
.modal-content {
    max-height: 80vh;
    overflow-y: auto;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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