/* main.css */
:root {
    --primary-color: #6C5CE7;
    --primary-dark: #5649C0;
    --secondary-color: #00CEFF;
    --accent-color: #FF7675;
    --text-color: #2D3436;
    --light-text: #FFFFFF;
    --bg-color: #F5F6FA;
    --card-bg: #FFFFFF;
    --border-radius: 16px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

html,
body {
    width: 100%;
    height: 100%;
    -webkit-text-size-adjust: 100%;
    overflow: hidden;
    position: fixed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-user-select: none;
    user-select: none;
    padding: var(--safe-area-inset-top) var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left);
    overscroll-behavior: none;
}

.container {
    width: 100%;
    height: 100%;
    max-width: 800px;
    min-width: 320px;
    margin: 0 auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--light-text);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
    min-height: 100px;
}

.header-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 12px;
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.text-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: var(--light-text);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
    flex-shrink: 0;
    box-sizing: border-box;
}

.progress-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.progress-card {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 8px;
    backdrop-filter: blur(4px);
    min-width: 0;
}

.progress-title {
    font-size: 11px;
    opacity: 0.8;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    min-width: 0;
}

.progress-stat {
    text-align: center;
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    display: block;
    line-height: 1;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-label {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quiz-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    height: calc(100% - 120px);
    min-height: 300px;
}

.question-scrollable {
    flex: 1;
    overflow: hidden;
    padding: 12px;
    min-height: 0;
}

.navigation-sticky {
    padding: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    padding-bottom: calc(8px + var(--safe-area-inset-bottom));
}

.btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 500;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(108, 92, 231, 0.3);
    width: 100%;
    max-width: 280px;
    min-width: 120px;
}

.btn:active {
    transform: scale(0.98);
}

.hidden {
    display: none !important;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .header {
        padding: 4px 4px !important;
        min-height: 80px !important;
    }

    .header-top {
        margin-bottom: 6px !important;
    }

    .text-btn {
        padding: 4px 8px !important;
        font-size: 12px !important;
        min-width: 50px !important;
        max-width: 100px !important;
    }

    .progress-cards {
        gap: 4px !important;
    }

    .progress-card {
        padding: 2px !important;
    }

    .progress-title {
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }

    .stat-value {
        font-size: 12px !important;
    }

    .stat-label {
        font-size: 9px !important;
    }

    .quiz-container {
        height: calc(100% - 150px) !important;
    }
}

/* Альбомная ориентация */
@media (orientation: landscape) {
    .header {
        padding: 2px 4px !important;
        min-height: 60px !important;
    }

    .quiz-container {
        height: calc(100% - 40px) !important;
    }

    @media (max-height: 500px) {
        .header {
            padding: 1px 2px !important;
            min-height: 40px !important;
        }

        .text-btn {
            padding: 0 2px !important;
            font-size: 8px !important;
            min-width: 40px !important;
        }

        /* УБИРАЕМ СКРЫТИЕ ПРОГРЕССА В ЛАНДШАФТНОМ РЕЖИМЕ */
        .progress-cards {
            display: grid !important;
        }

        .quiz-container {
            height: calc(100% - 30px) !important;
        }
    }
}

/* PC адаптация при изменении масштаба */
@media (min-width: 769px) {
    .container {
        min-height: 600px;
    }

    .header {
        min-height: 120px;
    }

    .quiz-container {
        min-height: 400px;
    }

    @media (max-height: 700px) {
        .header {
            min-height: 90px;
        }

        .quiz-container {
            min-height: 300px;
        }
    }

    @media (max-height: 600px) {
        .header {
            min-height: 70px;
        }

        .text-btn {
            padding: 4px 8px;
            font-size: 12px;
        }

        .progress-title {
            font-size: 10px;
        }

        .stat-value {
            font-size: 14px;
        }

        .quiz-container {
            min-height: 250px;
        }
    }
}

/* Минимальный размер окна */
@media (max-width: 400px) and (max-height: 500px) {
    .header {
        min-height: 50px !important;
        margin-bottom: 6px !important;
    }

    .quiz-container {
        min-height: 200px !important;
    }

    .btn {
        padding: 8px 16px !important;
        font-size: 14px !important;
    }

    .text-btn {
        padding: 3px 6px !important;
        font-size: 11px !important;
        min-width: 45px !important;
        max-width: 80px !important;
    }
}

/* Адаптация для планшетов */
@media (max-width: 992px) {
    .text-btn {
        padding: 7px 14px;
        font-size: 14px;
        min-width: 75px;
    }
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .text-btn {
        padding: 6px 12px;
        font-size: 13px;
        min-width: 70px;
    }
}

/* Для маленьких мобильных */
@media (max-width: 480px) {
    .text-btn {
        padding: 5px 10px;
        font-size: 12px;
        min-width: 65px;
    }
}

/* Минимальные размеры - дальше не уменьшаем */
@media (max-width: 360px) {
    .text-btn {
        padding: 5px 8px !important;
        font-size: 12px !important;
        min-width: 60px !important;
    }
}

/* Ландшафтная ориентация */
@media (orientation: landscape) {
    .text-btn {
        padding: 5px 10px !important;
        min-width: 65px !important;
    }
    
    @media (max-height: 500px) {
        .text-btn {
            padding: 4px 8px !important;
            font-size: 12px !important;
            min-width: 60px !important;
        }
    }
}

/* Добавьте этот код в конец файла main.css */

.language-switcher {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 4px;
    margin-left: 8px;
}

.lang-btn {
    background: transparent;
    border: none;
    color: var(--light-text);
    padding: 4px 8px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    font-weight: 500;
    min-width: 36px;
    text-align: center;
}

.lang-btn:hover, .lang-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.lang-btn.active {
    background: var(--light-text);
    color: var(--primary-color);
    font-weight: 600;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .language-switcher {
        gap: 2px;
        padding: 2px;
        margin-left: 4px;
    }
    
    .lang-btn {
        padding: 2px 6px;
        font-size: 11px;
        min-width: 30px;
        border-radius: 14px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 360px) {
    .language-switcher {
        gap: 1px;
    }
    
    .lang-btn {
        padding: 1px 4px;
        font-size: 10px;
        min-width: 28px;
    }
}

/* Ландшафтная ориентация */
@media (orientation: landscape) and (max-height: 500px) {
    .language-switcher {
        padding: 1px;
    }
    
    .lang-btn {
        padding: 0 3px;
        font-size: 10px;
        min-width: 25px;
    }
}