/* ============ ОСНОВНЫЕ ПЕРЕМЕННЫЕ ============ */
:root {
    /* Основные цвета */
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --secondary: #14B8A6;
    --secondary-light: #5EEAD4;
    --secondary-dark: #0F766E;
    --accent: #F59E0B;
    --accent-light: #FCD34D;
    --accent-dark: #B45309;
    --success: #10B981;
    --success-light: #6EE7B7;
    --success-dark: #047857;
    --error: #EF4444;
    --error-light: #FCA5A5;
    --error-dark: #B91C1C;
    
    /* Фоновые цвета */
    --dark: #0B1120;
    --darker: #050A14;
    --card-bg: #1E293B;
    --card-bg-light: #334155;
    --surface: #F9FAFB;
    
    /* Текст */
    --text-light: #F1F5F9;
    --text-dark: #0F172A;
    --text-muted: #94A3B8;
    
    /* Границы */
    --border-light: #E2E8F0;
    --border-dark: #334155;
    
    /* Тени и свечения */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    --glow-primary: 0 0 20px rgba(79, 70, 229, 0.5);
    --glow-secondary: 0 0 20px rgba(20, 184, 166, 0.5);
    --glow-accent: 0 0 20px rgba(245, 158, 11, 0.5);
    --glow-success: 0 0 20px rgba(16, 185, 129, 0.5);
}

/* ============ БАЗОВЫЕ СТИЛИ ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* ГЛОБАЛЬНО ОТКЛЮЧАЕМ ВСЕ ФИЛЬТРЫ И BLUR */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: radial-gradient(circle at top left, var(--dark), var(--darker));
    color: var(--text-light);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100vh;
    background: radial-gradient(circle at 50% 0%, rgba(79, 70, 229, 0.15), transparent 70%);
    pointer-events: none;
    /* Убеждаемся, что псевдоэлементы не влияют на текст */
    filter: none;
    backdrop-filter: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: -20px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* ============ ЭКРАНЫ ============ */
.screen {
    width: 100%;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.screen.hidden {
    display: none;
}

.screen.active {
    display: block;
}

/* ============ ЛОББИ / КАРТОЧКА ВХОДА ============ */
.lobby-card {
    max-width: 500px;
    width: 100%;
    margin: 20px auto;
    background: var(--card-bg);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 32px;
    padding: 48px 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
}

.lobby-card h1 {
    font-size: 42px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.02em;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 16px;
}

/* ============ ПОЛЯ ВВОДА ============ */
.input-group {
    margin-bottom: 24px;
}

.input-field {
    width: 100%;
    height: 60px;
    background: rgba(10, 10, 20, 0.9);
    border: 2px solid var(--border-dark);
    border-radius: 20px;
    padding: 0 24px;
    color: var(--text-light);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
}

.input-field:hover {
    border-color: var(--primary-light);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
    background: rgba(20, 20, 30, 0.95);
}

.input-field::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* ============ КНОПКИ ============ */
.button {
    height: 60px;
    padding: 0 32px;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

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

.button:hover::after {
    width: 300px;
    height: 300px;
}

.button:active {
    transform: scale(0.98);
}

.button span, .button i {
    position: relative;
    z-index: 1;
}

/* Primary Button */
.button.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 100%;
}

.button.primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px -8px var(--primary);
}

.button.primary:active:not(:disabled) {
    transform: translateY(0);
}

.button.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Secondary Button */
.button.secondary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary-light);
}

.button.secondary:hover {
    background: rgba(79, 70, 229, 0.1);
    transform: translateY(-2px);
}

/* Rematch Button */
.rematch-btn {
    min-width: 220px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    border: none;
    border-radius: 40px;
    padding: 0 32px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 8px 16px -6px var(--accent-dark);
    position: relative;
    overflow: hidden;
}

.rematch-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: 0;
}

.rematch-btn:hover::after {
    width: 300px;
    height: 300px;
}

.rematch-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 16px 32px -10px var(--accent);
}

.rematch-btn:active:not(:disabled) {
    transform: translateY(0);
}

.rematch-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rematch-btn.pulse {
    animation: buttonPulse 1.5s infinite;
}

@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 var(--accent);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px 15px var(--accent);
    }
}

/* ============ КОМНАТА ИНФО ============ */
.room-info {
    margin-top: 32px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(20, 184, 166, 0.1));
    border-radius: 24px;
    text-align: center;
    border: 1px solid rgba(79, 70, 229, 0.3);
}

.room-info p {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.room-code {
    font-size: 56px;
    font-weight: 800;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    color: var(--accent);
    letter-spacing: 8px;
    text-shadow: 0 0 20px var(--accent);
    display: block;
    margin: 16px 0;
}

/* ============ ТАБЛО ============ */
.scoreboard-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto 30px auto;
    padding: 24px;
    background: linear-gradient(145deg, rgba(79, 70, 229, 0.15), rgba(20, 184, 166, 0.15));
    border: 2px solid rgba(79, 70, 229, 0.3);
    border-radius: 32px;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

.scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.score-item {
    flex: 1;
    text-align: center;
    padding: 28px 20px;
    background: rgba(10, 10, 20, 0.9);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    transition: all 0.3s ease;
}

.score-item.player1 {
    border-color: var(--primary);
}

.score-item.player2 {
    border-color: var(--secondary);
}

.score-item.winner {
    border-color: var(--accent);
    background: linear-gradient(145deg, rgba(10, 10, 20, 0.9), rgba(245, 158, 11, 0.15));
}

.score-item.tie {
    border-color: var(--accent);
    background: linear-gradient(145deg, rgba(10, 10, 20, 0.9), rgba(245, 158, 11, 0.1));
}

.score-avatar {
    width: 90px;
    height: 90px;
    margin: 0 auto 15px auto;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 0 30px var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
}

.score-name {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 56px;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    line-height: 1.2;
    transition: all 0.2s ease;
}

.score-value.changed {
    animation: scorePop 0.3s ease-out;
}

@keyframes scorePop {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.4); color: var(--accent-light); }
}

.score-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.score-vs {
    font-size: 40px;
    font-weight: 800;
    color: var(--text-light);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 30px var(--primary);
    font-family: 'Inter', sans-serif;
}

/* ============ ИГРОВОЙ ЭКРАН - ИСПРАВЛЕНО (БЕЗ BLUR) ============ */
#gameScreen {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    width: 100%;
}

.timer-container {
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
}

.timer {
    font-size: 56px;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 30px var(--primary);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    line-height: 1.2;
}

.timer.warning {
    color: var(--accent);
    text-shadow: 0 0 30px var(--accent);
    animation: blink 0.8s infinite;
}

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

.timer-label {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 8px;
}

/* ============ МАТЕМАТИЧЕСКИЙ ПРИМЕР - ПОЛНОСТЬЮ ИСПРАВЛЕНО ============ */
.math-problem-container {
    width: 100%;
    max-width: 700px;
    margin: 30px auto;
    text-align: center;
}

.problem-label {
    font-size: 16px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 16px;
}

.math-problem {
    font-size: 96px;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background: rgba(10, 10, 20, 0.9);
    padding: 40px 30px;
    border-radius: 32px;
    border: 2px solid var(--accent);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    /* ПОЛНОСТЬЮ УБИРАЕМ BLUR */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    filter: none;
    /* Четкий текст */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* ============ ПОЛЕ ВВОДА ОТВЕТА ============ */
.answer-input-container {
    width: 100%;
    max-width: 550px;
    margin: 30px auto;
}

.problem-input {
    height: 70px;
    font-size: 28px;
    text-align: center;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background: rgba(10, 10, 20, 0.9);
    border: 2px solid var(--border-dark);
    border-radius: 40px;
    color: var(--text-light);
    width: 100%;
    padding: 0 30px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    -moz-appearance: textfield; /* Firefox */
    appearance: textfield;
}

.problem-input::-webkit-outer-spin-button,
.problem-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.problem-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.submit-btn {
    width: 100%;
    height: 70px;
    margin-top: 20px;
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    border: none;
    border-radius: 40px;
    color: white;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 12px 24px -10px var(--success-dark);
    position: relative;
    overflow: hidden;
}

.submit-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    z-index: 0;
}

.submit-btn:hover::after {
    width: 300px;
    height: 300px;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 30px -12px var(--success);
}

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

.submit-btn span, .submit-btn i {
    position: relative;
    z-index: 1;
}

.feedback {
    text-align: center;
    font-size: 20px;
    margin-top: 20px;
    min-height: 40px;
    font-weight: 600;
}

.feedback .correct {
    color: var(--success);
    text-shadow: 0 0 10px var(--success);
}

.feedback .wrong {
    color: var(--error);
    text-shadow: 0 0 10px var(--error);
}

/* ============ ЧАТ / ЛЕНТА СОБЫТИЙ ============ */
.game-chat {
    width: 100%;
    max-width: 550px;
    margin: 30px auto;
    background: rgba(10, 10, 20, 0.9);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 28px;
    padding: 20px 24px;
    box-shadow: var(--shadow-lg);
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(79, 70, 229, 0.3);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-messages {
    max-height: 130px;
    overflow-y: auto;
    font-size: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--darker);
    padding-right: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--darker);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.message {
    padding: 8px 12px;
    margin: 6px 0;
    border-radius: 16px;
}

.message.system {
    color: var(--text-muted);
    font-style: italic;
}

.message.player {
    color: var(--primary-light);
}

.message.opponent {
    color: var(--secondary-light);
}

.message.correct {
    color: var(--success);
}

/* ============ РЕЗУЛЬТАТЫ ============ */
#resultsScreen {
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
}

.results-header {
    text-align: center;
    margin-bottom: 30px;
}

.results-header h1 {
    font-size: 42px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.game-arena {
    background: var(--card-bg);
    border: 1px solid rgba(79, 70, 229, 0.3);
    border-radius: 40px;
    padding: 40px;
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5);
}

.final-scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.final-scoreboard .score-item {
    padding: 28px 20px;
}

.final-scoreboard .score-item h3 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--text-light);
}

.final-scoreboard .final-score {
    font-size: 42px;
    font-weight: 800;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
    text-shadow: 0 0 20px var(--accent);
}

.tie-message {
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 30px var(--accent);
    margin: 20px 0 30px;
    padding: 15px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 50px;
    border: 1px solid var(--accent);
}

.rematch-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.rematch-hint {
    text-align: center;
    margin-top: 20px;
    color: var(--accent);
    font-size: 18px;
    font-weight: 600;
    animation: hintPulse 1.5s infinite;
    padding: 16px;
    background: rgba(245, 158, 11, 0.15);
    border-radius: 40px;
    border: 1px solid var(--accent);
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; background: rgba(245, 158, 11, 0.25); }
}

/* ============ РАЗДЕЛИТЕЛЬ ============ */
.divider {
    position: relative;
    margin: 30px 0;
    text-align: center;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    transform: translateY(-50%);
}

.divider-text {
    position: relative;
    background: var(--card-bg);
    padding: 0 15px;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 1;
}

/* ============ УВЕДОМЛЕНИЯ ============ */
.notification {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 18px 28px;
    background: var(--card-bg);
    border-left: 5px solid var(--primary);
    border-radius: 20px;
    color: var(--text-light);
    box-shadow: 0 20px 35px -10px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: notificationSlide 0.3s ease;
    max-width: 380px;
    font-weight: 500;
    font-size: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.notification.success {
    border-left-color: var(--success);
}

.notification.error {
    border-left-color: var(--error);
}

.notification.warning {
    border-left-color: var(--accent);
}

.notification.info {
    border-left-color: var(--primary);
}

.notification.hidden {
    display: none;
}

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

/* ============ ХИНТЫ ============ */
.hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(79, 70, 229, 0.2);
}

/* ============ АДАПТАЦИЯ ============ */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .lobby-card {
        padding: 32px 24px;
    }
    
    .lobby-card h1 {
        font-size: 32px;
    }
    
    .room-code {
        font-size: 42px;
        letter-spacing: 4px;
    }
    
    .scoreboard {
        flex-direction: column;
        gap: 20px;
    }
    
    .score-item {
        width: 100%;
    }
    
    .score-avatar {
        width: 70px;
        height: 70px;
        font-size: 28px;
    }
    
    .score-name {
        font-size: 22px;
    }
    
    .score-value {
        font-size: 42px;
    }
    
    .score-vs {
        order: -1;
        margin: 10px 0;
    }
    
    .math-problem {
        font-size: 56px;
        padding: 30px 20px;
    }
    
    .problem-input {
        font-size: 22px;
    }
    
    .submit-btn {
        font-size: 20px;
    }
    
    .timer {
        font-size: 42px;
    }
    
    .rematch-actions {
        flex-direction: column;
    }
    
    .rematch-btn, .button.secondary {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .math-problem {
        font-size: 42px;
        padding: 20px 15px;
    }
    
    .score-avatar {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .score-name {
        font-size: 20px;
    }
    
    .score-value {
        font-size: 36px;
    }
}

/* ============ УТИЛИТЫ ============ */
.hidden {
    display: none !important;
}

/* Добавьте в конец файла style.css */

/* ============ QR-КОД ============ */
.qrcode-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
    padding: 15px;
    background: white;
    border-radius: 20px;
    width: fit-content;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
}

.qrcode-container img {
    display: block;
    width: 180px;
    height: 180px;
    image-rendering: pixelated;
}

/* Адаптация для мобильных */
@media (max-width: 480px) {
    .qrcode-container img {
        width: 150px;
        height: 150px;
    }
}


