* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 10px;
}

.lang-switch {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.lang-btn {
    padding: 8px 16px;
    border: 2px solid white;
    background: transparent;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.lang-btn.active {
    background: white;
    color: #667eea;
}

.content {
    padding: 20px;
}

.stats {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #f7fafc;
    border-radius: 12px;
    margin-bottom: 20px;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    font-size: 12px;
    color: #718096;
    margin-top: 5px;
}

.filters {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
}

select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

.question-card {
    background: #f7fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

#description {
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 12px;
    width: 100%;
    text-align: center;
}

.verb-info {
    font-size: 1.8em;
    background: #edf2f7;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
    color: #2d3748;
}

.question-text {
    font-size: 20px;
    line-height: 1.8;
    margin-bottom: 15px;
    color: #2d3748;
}

.answer-input {
    padding: 10px;
    border: 2px solid #cbd5e0;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
    width: auto;
    field-sizing: content; /* Работает только в новейших браузерах! */
    min-width: 80px;
}

.answer-input:focus {
    outline: none;
    border-color: #667eea;
}

.answer-input.correct {
    border-color: #48bb78;
    background: #f0fff4;
}

.answer-input.incorrect {
    border-color: #f56565;
    background: #fff5f5;
}

.translation {
    font-size: 16px;
    color: #718096;
    font-style: italic;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.diacritics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
}

.diacritic-btn {
    padding: 10px 14px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s;
}

.diacritic-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-check {
    background: #667eea;
    color: white;
}

.btn-check:hover {
    background: #5568d3;
}

.btn-skip {
    background: #edf2f7;
    color: #2d3748;
}

.btn-skip:hover {
    background: #e2e8f0;
}

.btn-reset {
    background: #edf2f7;
    color: #2d3748;
    width: 100%;
    margin-top: 10px;
}

.btn-reset:hover {
    background: #f56565;
}

.feedback {
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    font-weight: 600;
    text-align: center;
}

.feedback.correct {
    background: #c6f6d5;
    color: #22543d;
}

.feedback.incorrect {
    background: #fed7d7;
    color: #742a2a;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #718096;
}

.credits {
    text-align: center;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
    color: #718096;
}

.credits a {
    color: #667eea;
    text-decoration: none;
}

@media (max-width: 640px) {
    .header h1 {
        font-size: 20px;
    }

    .question-text {
        font-size: 18px;
    }

    .stat-value {
        font-size: 24px;
    }

    .buttons {
        flex-direction: column;
    }
}

/* --- CRACKTRO MODAL --- */
.cracktro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace; /* Или любой пиксельный шрифт */
}

.cracktro-overlay.hidden {
    display: none;
}

#starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.cracktro-content {
    z-index: 10;
    width: 600px;
    max-width: 90%;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #0f0; /* Классический зеленый */
    box-shadow: 0 0 20px #0f0;
    text-align: center;
    color: #0f0;
    padding: 20px;
}

.cracktro-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    border-bottom: 1px dashed #0f0;
    padding-bottom: 10px;
    text-shadow: 2px 2px 0 #003300;
}

.cracktro-scroller {
    height: 150px;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
    -webkit-mask-image: linear-gradient(to bottom, transparent, black 20%, black 80%, transparent);
}

#scrollText {
    position: absolute;
    width: 100%;
    text-align: center;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1.5;
    /* Анимация будет управляться JS или CSS */
    animation: scrollUp 30s linear infinite;
    color: #fff;
    text-shadow: 0 0 5px #0f0;
}

@keyframes scrollUp {
    0% { transform: translateY(150px); }
    100% { transform: translateY(-100%); }
}

.cracktro-close {
    margin-top: 20px;
    background: #000;
    color: #0f0;
    border: 1px solid #0f0;
    padding: 5px 15px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.2s;
}

.cracktro-close:hover {
    background: #0f0;
    color: #000;
    box-shadow: 0 0 10px #0f0;
}

.blink {
    animation: blinker 1s linear infinite;
}

@keyframes blinker {
    50% { opacity: 0; }
}

/* --- MULTI-SELECT DROPDOWN --- */
.multi-select-container {
    position: relative;
    width: 100%;
    margin-bottom: 15px;
}

.select-box {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.select-box:hover {
    border-color: #667eea;
}

.select-box .selected-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
    color: #2d3748;
}

.select-box .arrow {
    color: #718096;
    font-size: 12px;
    transition: transform 0.3s;
}

.select-box.open .arrow {
    transform: rotate(180deg);
}

.options-container {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 2px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 100;
    display: none;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
}

.options-container.active {
    display: block;
}

.option-item {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.2s;
    border-bottom: 1px solid #edf2f7;
    user-select: none;
}

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

.option-item:hover {
    background: #f7fafc;
}

.option-item input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #667eea;
}

.option-item label {
    cursor: pointer;
    width: 100%;
    margin: 0; /* Сброс глобального margin для label */
    font-weight: normal;
    display: inline-block;
    pointer-events: none;
}

/* --- TELEGRAM MINI APP SPECIFIC STYLES --- */

/* 1. Базовые настройки для body в режиме Telegram */
body.telegram-mode {
    background: var(--tg-theme-bg-color, #ffffff) !important;
    color: var(--tg-theme-text-color, #000000) !important;
    padding: 0;
    margin: 0;
}

/* 2. Контейнер на весь экран без теней */
body.telegram-mode .container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
}

/* 3. Исправление ЗАГОЛОВКОВ (Категория, Время) */
/* Делаем их цвет зависимым от темы (белый в темной теме) */
body.telegram-mode label,
body.telegram-mode #description,
body.telegram-mode .stat-label {
    color: var(--tg-theme-text-color, #000000);
}

/* 4. Исправление КАРТОЧКИ ВОПРОСА */
/* Фон карточки делаем "вторичным цветом фона" (в темной теме это темно-серый),
   а текст внутри - основным цветом текста (белым) */
body.telegram-mode .question-card {
    background: var(--tg-theme-secondary-bg-color, #f0f0f0);
    color: var(--tg-theme-text-color, #000000);
    border: 1px solid var(--tg-theme-hint-color, #ccc); /* легкая рамка */
}

/* Текст перевода (серый) делаем чуть светлее в темной теме, используя hint-color */
body.telegram-mode .question-card div[style*="color: gray"] {
    color: var(--tg-theme-hint-color, #888) !important;
}

/* Текст самого вопроса (где пропуски) */
body.telegram-mode .question-text,
body.telegram-mode .question-card div {
    color: var(--tg-theme-text-color, #000000);
}

/* 5. Исправление ПОЛЕЙ ВВОДА и ВЫПАДАЮЩИХ СПИСКОВ */
body.telegram-mode .answer-input, 
body.telegram-mode .select-box,
body.telegram-mode .options-container {
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
    border-color: var(--tg-theme-hint-color, #ccc);
}

body.telegram-mode .select-box .selected-text {
    color: var(--tg-theme-text-color, #000000);
}

/* Пункты в выпадающем меню */
body.telegram-mode .option-item {
    background: var(--tg-theme-bg-color, #ffffff);
    color: var(--tg-theme-text-color, #000000);
    border-bottom-color: var(--tg-theme-secondary-bg-color, #f0f0f0);
}
body.telegram-mode .option-item:hover {
    background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

/* 6. Кнопки с диакритикой (á, ê...) */
body.telegram-mode .diacritic-btn {
    background: var(--tg-theme-button-color, #667eea);
    color: var(--tg-theme-button-text-color, #ffffff);
    border: none;
}

/* 7. Основные кнопки */
body.telegram-mode .btn-check {
    background: var(--tg-theme-button-color, #667eea);
    color: var(--tg-theme-button-text-color, #ffffff);
}

body.telegram-mode .btn-skip,
body.telegram-mode .btn-reset {
    /* Меняем фон на основной (var(--tg-theme-bg-color)). 
       В светлой теме это будет белый цвет на серой карточке.
       В темной теме — черный/темный на более светлой карточке. */
    background: var(--tg-theme-bg-color, #ffffff) !important;
    
    /* Добавляем явную рамку цвета подсказки (серую), чтобы очертить границы */
    border: 1px solid var(--tg-theme-hint-color, #ccc) !important;
    
    /* Цвет текста берем основной */
    color: var(--tg-theme-text-color, #000000) !important;
}

/* Добавляем эффект нажатия для тактильности */
body.telegram-mode .btn-skip:active,
body.telegram-mode .btn-reset:active {
    opacity: 0.7;
    transform: translateY(1px);
}

/* 1. Блок статистики (Questions / Correct / Accuracy) */
body.telegram-mode .stats {
    /* Используем вторичный фон темы (обычно чуть светлее черного в темной теме) */
    background: var(--tg-theme-secondary-bg-color, #f0f0f0) !important;
    border: 1px solid var(--tg-theme-hint-color, transparent); /* (Опционально) легкая граница */
}

/* Цифры в статистике */
body.telegram-mode .stat-value {
    /* Можно использовать цвет текста или цвет кнопки для акцента */
    color: var(--tg-theme-button-color, #667eea) !important;
}

/* Подписи (Questions, Correct...) */
body.telegram-mode .stat-label {
    /* Цвет подсказки (серый в обеих темах) */
    color: var(--tg-theme-hint-color, #888888) !important;
}


/* 2. Блок с глаголом (на скриншоте "pedir") */
body.telegram-mode .verb-info {
    /* Тоже вторичный фон, чтобы не был белым пятном */
    background: var(--tg-theme-secondary-bg-color, #f0f0f0) !important;
    /* Цвет текста - основной цвет темы (белый в темной, черный в светлой) */
    color: var(--tg-theme-text-color, #000000) !important;
    border: 1px solid var(--tg-theme-hint-color, transparent);
}