:root {
    --error-color: #e53935;
    --card-bg: rgba(255, 255, 255, 0.5);
    --read-bg: #fff;
    --border-color: rgba(0, 0, 0, 0.1);
}

.hidden { display: none !important; }

.app-container {
    width: 95%;
    max-width: 1000px;
    min-height: 90vh;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    padding: 30px;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

/* Сетка настроек */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    width: 100%;
    max-width: 800px;
    border: 1px solid var(--border-color);
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.setting-title {
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0.8;
}

.custom-select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color, #fdfbf7);
    color: var(--text-color, #2c302e);
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

.custom-textarea {
    width: 100%;
    height: 100px;
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color, #fdfbf7);
    color: var(--text-color, #2c302e);
    font-size: 0.9rem;
    resize: none;
}

/* Экран чтения */
.read-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.timer {
    font-size: 1.5rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.read-controls { display: flex; gap: 10px; }

.reading-area {
    flex: 1;
    width: 100%;
    background: var(--read-bg);
    border-radius: 15px;
    padding: 30px;
    font-size: 22px;
    line-height: 1.8;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    position: relative;
}

/* Пауза-оверлей */
.pause-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 50;
    border-radius: 20px;
    background: rgba(0,0,0,0.15);
    cursor: pointer;
}
.pause-icon {
    font-size: 4rem;
    color: rgba(0,0,0,0.3);
}

/* ============ АНИМАЦИИ РЕЖИМОВ ============ */

/* Вращающиеся буквы */
.rotating {
    display: inline-block;
    animation: letter-rotate 3s linear infinite;
    transform-origin: center;
}
@keyframes letter-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Зеркальный текст */
.mirrored-letter {
    display: inline-block;
    transform: scaleX(-1);
}

/* Бегущая строка */
.marquee-wrapper {
    overflow: hidden;
    width: 100%;
    padding: 30px 0;
    display: flex;
    align-items: center;
}
.marquee-text {
    display: inline-block;
    white-space: nowrap;
    animation: marquee-scroll linear infinite;
    animation-play-state: running;
    font-size: 1.4rem;
    line-height: 2;
    will-change: transform;
}
@keyframes marquee-scroll {
    from { transform: translateX(100vw); }
    to   { transform: translateX(-100%); }
}

/* Подсказка режима цветных букв */
.color-hint {
    text-align: center;
    margin-bottom: 16px;
    font-size: 0.95rem;
    opacity: 0.85;
}

/* ============ КВИЗ ============ */
.quiz-container {
    width: 100%;
    max-width: 700px;
    margin-top: 20px;
    overflow-y: auto;
    padding-right: 10px;
}
.quiz-question {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.quiz-question h3 { margin-bottom: 15px; font-size: 1.1rem; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
    padding: 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color, #fdfbf7);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 1rem;
    color: var(--text-color, #2c302e);
}
.quiz-option:hover { border-color: var(--primary-color, #467230); }
.quiz-option.selected {
    background: var(--primary-color, #467230);
    color: white;
    border-color: var(--primary-color, #467230);
}

/* ============ РЕЗУЛЬТАТЫ ============ */
.quiz-result-box {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    border: 1px solid var(--border-color);
    width: 100%;
    max-width: 600px;
    margin-top: 20px;
}
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.2rem;
}
.stat-row:last-of-type { border-bottom: none; }

.feedback-msg {
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    background: var(--bg-color, #fdfbf7);
    text-align: center;
    font-weight: 600;
}

/* ============ ИСТОРИЯ ============ */
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.history-table th, .history-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.history-table thead th {
    font-weight: 600;
    opacity: 0.7;
    font-size: 0.8rem;
    text-transform: uppercase;
}

/* ============ АДАПТИВНОСТЬ ============ */
@media (max-width: 600px) {
    .settings-grid { grid-template-columns: 1fr; }
    .reading-area { font-size: 18px; padding: 16px; }
    .app-container { padding: 16px; }
    .marquee-text { font-size: 1.1rem; }
}