/* Общие стили */
:root {
    --primary: #6c5ce7;
    --secondary: #a29bfe;
    --accent: #fd79a8;
    --light: #f8f9fa;
    --dark: #343a40;
    --success: #00b894;
    --danger: #d63031;
    --warning: #fdcb6e;
    --info: #0984e3;
    --easy: #00b894;
    --medium: #fdcb6e;
    --hard: #d63031;
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
}

* {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

body {
    user-select: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    color: var(--light);
}

/* Стили модального окна */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    max-width: 90%;
    width: 650px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 24px;
}

.modal-content p {
    color: var(--dark);
    margin-bottom: 25px;
    font-size: 18px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-cancel {
    background: linear-gradient(to right, var(--danger), #ff7675) !important;
}

/* Добавляем стили для новой модалки (если нужно) */
#restore-modal .modal-content {
    background-color: #f8f9fa;
    border: 2px solid var(--primary);
}

#restore-modal h3 {
    color: var(--info);
}

#leaderboard-screen {
    width: 100%;
    height: 100%;
    padding: 10px;
}

.leaderboard-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

#back-from-leaderboard-btn {
    margin-top: 20px;
    align-self: center;
    width: auto;
    padding: 10px 30px;
}

.leaderboard-panel h2 {
    color: var(--primary);
    margin-bottom: 20px;
    text-align: center;
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    margin: 15px 0;
}

.leaderboard-entry {
    display: flex;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    font-size: 18px;
    transition: all 0.3s;
}

.leaderboard-entry .rank {
    width: 40px;
    font-weight: bold;
    color: var(--info);
    margin-right: 10px;
}

.leaderboard-entry .name {
    flex: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    color: var(--info);
}

.leaderboard-entry .score {
    font-weight: bold;
    color: var(--info);
}

.loading, .error {
    text-align: center;
    padding: 20px;
    font-size: 18px;
}

.loading {
    color: var(--info);
}

.error {
    color: var(--danger);
}

.game-container {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 650px;
    overflow: hidden;
    color: var(--dark);
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.game-header {
    background: linear-gradient(to right, var(--primary), var(--info));
    color: white;
    padding: 10px;
    text-align: center;
    position: relative;
}

.game-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}

.game-body {
    padding: 5px;
}

.settings-panel {
    background-color: var(--light);
    border-radius: 15px;
    padding: 5px 10px 20px 10px;
    margin-bottom: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.settings-title {
    font-size: 18px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.leaderboard-entry.header {
    font-weight: bold;
    background-color: #f1f2f6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.leaderboard-entry.header .rank,
.leaderboard-entry.header .name,
.leaderboard-entry.header .score {
    color: var(--primary);
}

.settings-title svg {
    margin-right: 10px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

button {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    transition: all 0.2s;
}

.btn {
    background: linear-gradient(to right, var(--primary), var(--info));
    color: white;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(108, 92, 231, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(108, 92, 231, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-start {
    background: linear-gradient(to right, var(--success), #55efc4);
}

.game-display {
    position: relative;
    text-align: center;
    margin-bottom: 25px;
}

.freeze-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.freeze-timer {
    font-size: 48px;
    color: white;
    font-weight: bold;
}

.freeze-message {
    color: white;
    font-size: 18px;
    margin-top: 20px;
    text-align: center;
}

.game-header-info {
    margin: 5px;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.timer {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    background-color: var(--light);
    padding: 10px;
    border-radius: 10px;
    display: inline-block;
    min-width: 100px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.problem {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    background-color: var(--light);
    padding: 10px;
    border-radius: 15px;
    display: inline-block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.option {
    user-select: none;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px 5px 10px 5px;
}

.option {
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    font-size: 24px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.05);
    border: 3px solid transparent;
}

.option:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    border-color: var(--secondary);
}

.option:active {
    transform: translateY(0);
}

.score-display {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
    background-color: var(--light);
    padding: 12px;
    border-radius: 10px;
    margin-top: 15px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.correct {
    background-color: var(--success);
    color: white;
    transform: scale(1.05);
}

.incorrect {
    background-color: var(--danger);
    color: white;
}

.pulse {
    animation: pulse 0.5s;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.game-over {
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.5s;
}

.game-over h2 {
    color: var(--primary);
    margin-bottom: 15px;
}

.final-score {
    font-size: 24px;
    font-weight: 700;
    color: var(--info);
    margin-bottom: 20px;
}

.difficulty-levels {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.difficulty-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.difficulty-btn.active {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.difficulty-btn.easy {
    background-color: var(--easy);
    color: white;
}

.difficulty-btn.medium {
    background-color: var(--medium);
    color: var(--dark);
}

.difficulty-btn.hard {
    background-color: var(--hard);
    color: white;
}

.difficulty-info {
    font-size: 14px;
    color: var(--dark);
    margin-bottom: 15px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.language-switcher {
    display: flex;          /* Включаем flex-контейнер */
    align-items: center;    /* Выравниваем элементы по вертикали */
    justify-content: space-between; /* Распределяем пространство между элементами */
    gap: 10px;
    margin-bottom: 20px;
}

.buttons-container {
    display: flex;          /* Делаем контейнер для кнопок flex */
    gap: 10px;              /* Расстояние между кнопками */
    margin-left: auto;      /* Прижимаем кнопки к правому краю */
}

.lang-btn {
    background: rgba(78, 79, 80, 0.2);
    border: 2px solid white;
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    padding: 8px 15px;
}

.lang-btn.active {
    background: rgb(118, 237, 241);
    color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
    color: white;
}

/* Эффекты комбо */
.combo-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
    z-index: 100;
    animation: comboAnimation 1s forwards;
    pointer-events: none;
}

@keyframes comboAnimation {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -100%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1.5);
    }
}

/* Стили для таблицы лидеров */
.leaderboard-entry.gold {
    background-color: rgba(255, 215, 0, 0.15);
    border-left: 4px solid var(--gold);
}

.leaderboard-entry.gold .rank {
    color: var(--gold);
    font-weight: 900;
}

.leaderboard-entry.silver {
    background-color: rgba(192, 192, 192, 0.15);
    border-left: 4px solid var(--silver);
}

.leaderboard-entry.silver .rank {
    color: var(--silver);
    font-weight: 900;
}

.leaderboard-entry.bronze {
    background-color: rgba(205, 127, 50, 0.15);
    border-left: 4px solid var(--bronze);
}

.leaderboard-entry .player-marker {
    color: #777;
    font-size: 14px;
    font-style: italic;
    margin-left: 5px;
}

.leaderboard-entry.bronze .rank {
    color: var(--bronze);
    font-weight: 900;
}

.leaderboard-separator {
    text-align: center;
    padding: 15px;
    font-weight: bold;
    color: var(--primary);
    background-color: #f8f9fa;
    margin-top: 10px;
}

/* Кнопки на экране окончания игры */
.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Адаптивные стили */
@media (max-width: 500px) {
    .leaderboard-panel {
        padding: 15px;
    }

    .problem {
        font-size: 22px;
        padding: 10px 20px;
    }
    
    .option {
        padding: 15px;
        font-size: 20px;
    }
    
    .difficulty-levels {
        flex-direction: column;
    }

    .game-container {
        border-radius: 15px;
        max-width: 95%;
    }
    
    .game-header {
        padding: 15px;
    }
    
    .game-body {
        padding: 15px;
    }
    
    .settings-panel {
        padding: 15px;
    }
    
    .option {
        min-height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .timer {
        font-size: 20px;
        padding: 8px 12px;
    }
    
    .score-display {
        font-size: 18px;
    }
    
    .lang-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
}

@media (max-width: 400px) {
    .problem {
        font-size: 18px;
        padding: 8px 16px;
    }
    
    .option {
        padding: 12px;
        font-size: 18px;
        min-height: 55px;
    }
    
    .game-title {
        font-size: 24px;
    }
    
    .settings-title {
        font-size: 16px;
    }
    
    button {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .timer {
        font-size: 18px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .problem {
        font-size: 32px;
        margin: 10px 0;
    }
    
    .options-grid {
        gap: 10px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .game-container {
        transform: scale(0.9);
        transform-origin: center;
    }
    
    .problem {
        font-size: 22px;
        margin: 10px 0;
    }
}

.time-bonus {
    animation: timeBonus 0.5s;
    color: var(--success) !important;
}

@keyframes timeBonus {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}