* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 800px;
    width: 100%;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 20px;
    text-align: center;
}

#book-title {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.difficulty {
    font-size: 1rem;
    opacity: 0.9;
}

main {
    padding: 30px;
}

.text-container {
    min-height: 300px;
    display: block;
    margin-bottom: 40px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fafafa;
    text-align: left;
}

.text-content {
    font-size: 1.4rem;
    line-height: 1.8;
    color: #2c3e50;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.choice-btn {
    padding: 15px 25px;
    font-size: 1.1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.choice-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.choice-btn:active {
    transform: translateY(0);
}

.controls {
    margin-top: 30px;
    text-align: center;
}

#restart-btn {
    padding: 12px 30px;
    font-size: 1rem;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#restart-btn:hover {
    background-color: #c0392b;
}

.hidden {
    display: none !important;
}

footer {
    background-color: #ecf0f1;
    padding: 15px;
    text-align: center;
    border-top: 1px solid #ddd;
}

.progress {
    font-size: 1.5rem;
    color: #2c3e50;
}

.copyright {
    margin-top: 20px;
    color: #7f8c8d;
    font-size: 0.9rem;
    text-align: center;
}

#current-node {
    font-weight: bold;
    color: #2c3e50;
}

/* Адаптивность */
@media (max-width: 600px) {
    .text-content {
        font-size: 1.2rem;
    }
    
    .choice-btn {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    main {
        padding: 20px;
    }
    
    .text-container {
        min-height: 250px;
        margin-bottom: 30px;
    }
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

/* Для больших экранов - пытаемся разместить в один ряд */
@media (min-width: 768px) {
    .choices-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 100%;
    }
    
    .choice-btn {
        flex: 1;
        min-width: 200px;
        max-width: 300px;
    }
    
    /* Если кнопка одна - центрируем и даем нормальную ширину */
    .choice-btn:only-child {
        max-width: 300px;
    }
}

/* Автоматическое определение: если текст короткий - в ряд, если длинный - в колонку */
/* Этот вариант работает только для 2 кнопок */
.choices-container.auto-layout {
    flex-direction: column;
}

@media (min-width: 768px) {
    .choices-container.auto-layout {
        flex-direction: row;
        flex-wrap: nowrap;
    }
    
    /* Проверка на длинный текст: если текст занимает больше 3 строк, то оставляем колонку */
    .choice-btn.long-text {
        white-space: normal;
        word-wrap: break-word;
    }
}

/* Еще один вариант: использовать grid для более гибкого управления */
.choices-container.grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 768px) {
    .choices-container.grid-layout {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    /* Если кнопок 2 и обе с коротким текстом */
    .choices-container.grid-layout:has(.choice-btn:nth-child(2):last-child) .choice-btn:not(.long-text) {
        grid-template-columns: 1fr 1fr;
    }
}

/* Адаптивность для очень короткого текста */
@media (min-width: 480px) and (max-width: 767px) {
    .choices-container:has(.choice-btn:nth-child(2):last-child) .choice-btn {
        max-width: 100%;
    }
}

/* Стили для кнопок остаются прежними, но добавляем обработку длинного текста */
.choice-btn {
    padding: 15px 25px;
    font-size: 1.1rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    white-space: normal; /* Разрешаем перенос текста */
    word-wrap: break-word; /* Перенос длинных слов */
    hyphens: auto; /* Автоматические переносы (если поддерживается) */
}

.choice-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.choice-btn:active {
    transform: translateY(0);
}

/* Класс для длинного текста */
.choice-btn.long-text {
    white-space: normal;
}

/* Адаптивность */
@media (max-width: 600px) {
    .text-content {
        font-size: 1.2rem;
    }
    
    .choice-btn {
        padding: 12px 20px;
        font-size: 1rem;
        white-space: normal; /* На мобильных всегда разрешаем перенос */
    }
    
    .choices-container {
        flex-direction: column; /* На мобильных всегда колонка */
    }
}

/* Стили для блока с лексикой */
.vocabulary-container {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin: 20px auto 30px;
    max-width: 800px;
}

.vocabulary-container h3 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

#vocabulary-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

#vocabulary-list li {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 15px;
    font-size: 1.1rem;
    color: #495057;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

#vocabulary-list li:hover {
    background-color: #e9f7fe;
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Скрываем блок, если слов нет */
.vocabulary-container.hidden {
    display: none;
}

/* Адаптивность для лексики */
@media (max-width: 600px) {
    .vocabulary-container {
        padding: 15px;
        margin: 15px auto 20px;
    }
    
    #vocabulary-list li {
        font-size: 1rem;
        padding: 6px 12px;
    }
}

.text-container {
    min-height: 300px;
    display: block; /* Убираем flex центрирование */
    margin-bottom: 40px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fafafa;
    text-align: left; /* Меняем с center на left */
}

.text-content {
    font-size: 1.4rem;
    line-height: 1.8;
    color: #2c3e50;
    text-align: left; /* Убеждаемся, что текст выровнен по левому краю */
}

/* Стили для аудиоплеера */
.audio-player-container {
    margin-bottom: 25px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    text-align: center;
}

#audio-player {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 15px;
    display: block;
}

.audio-info {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-top: 10px;
}

/* Скрытый класс */
.hidden {
    display: none !important;
}

/* Адаптивность для аудиоплеера */
@media (max-width: 600px) {
    .audio-player-container {
        padding: 15px;
        margin-bottom: 20px;
    }
    
    #audio-player {
        max-width: 100%;
    }
}

/* Стили для контейнера с картинкой */
.image-container {
    margin-bottom: 20px;
    text-align: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.node-image {
    max-width: 100%;
    max-height: 400px;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.image-info {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-top: 8px;
}

/* Адаптивность для картинок */
@media (max-width: 600px) {
    .image-container {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .node-image {
        max-height: 250px;
    }
}

/* Стили для аудиоплеера и перевода */
.audio-player-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
}

.audio-wrapper {
    flex: 1;
    max-width: 500px;
}

#audio-player {
    width: 100%;
    margin-bottom: 10px;
}

.translation-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #7f8c8d;
    white-space: nowrap;
    margin-top: 16px;
}

#translation-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.translation-toggle label {
    cursor: pointer;
    user-select: none;
}

/* Адаптивность для аудиоплеера */
@media (max-width: 600px) {
    .audio-player-row {
        flex-direction: column;
        gap: 15px;
        align-items: center;
    }
    
    .audio-wrapper {
        max-width: 100%;
    }
    
    .translation-toggle {
        align-self: flex-end;
        margin-top: 0;
    }
}