:root {
    --primary: #FF5722;
    --primary-light: #FF8A65;
    --secondary: #FF9800;
    --accent: #4CAF50;
    --danger: #F44336;
    --bg: #FFF8F0;
    --card-bg: #FFFFFF;
    --text: #3E2723;
    --text-light: #6D4C41;
    --white: #FFFFFF;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-lg: 24px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(circle at 20% 80%, rgba(255,152,0,0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,87,34,0.06) 0%, transparent 50%);
    color: var(--text);
    margin: 0;
    padding: 16px;
    min-height: 100vh;
}

header { text-align: center; margin-bottom: 24px; }
header h1 { font-size: 2.2rem; margin: 0 0 4px 0; letter-spacing: -0.5px; }
.subtitle { color: var(--text-light); font-weight: 600; margin: 0; }

.screen {
    display: none;
    max-width: 560px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Кнопки */
.btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--secondary); }
.btn.outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn.outline:hover { background: rgba(255,87,34,0.06); }

.btn-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 16px;
}
.btn-row .btn { flex: 1; min-width: 140px; }

/* Меню */
.menu-grid {
    display: grid;
    gap: 12px;
    margin: 20px 0;
}
.menu-btn {
    width: 100%;
    text-align: left;
    padding: 18px 24px;
    border-radius: var(--radius);
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.btn-icon { font-size: 1.6rem; }
.btn-label { font-size: 1.15rem; font-weight: 700; }
.btn-desc { font-size: 0.85rem; opacity: 0.85; font-weight: 400; }

.vocab-preview {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 20px;
    box-shadow: var(--shadow);
}
.vocab-preview h3 { margin: 0 0 10px 0; font-size: 1rem; }
.vocab-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
    background: rgba(255,87,34,0.1);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Карточки */
.progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 8px;
}
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    height: 260px;
    margin: 12px auto;
    width: 100%;
    max-width: 360px;
    perspective: 1000px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
}
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    padding: 20px;
}
.card-front { background: var(--card-bg); }
.card-back {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--white);
    transform: rotateY(180deg);
}
.card-emoji { font-size: 4rem; }
.card-fr { font-size: 1.8rem; font-weight: 700; margin-bottom: 4px; }
.card-en { font-size: 1rem; opacity: 0.9; }
.card-type {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 10px;
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 10px;
}

/* Квиз */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}
.option-btn {
    background: var(--card-bg);
    border: 2px solid #E0E0E0;
    padding: 14px 12px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.option-btn:active { transform: scale(0.97); }
.option-btn:hover { border-color: var(--primary); }
.option-btn.correct {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    animation: popIn 0.3s ease;
}
.option-btn.wrong {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
    animation: shake 0.4s ease;
}

@keyframes popIn {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.feedback { min-height: 28px; font-weight: 600; font-size: 1rem; }

.results-box {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 30px 20px;
    margin: 20px 0;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.result-big { font-size: 3rem; font-weight: 800; color: var(--primary); }
.result-pct { font-size: 1.5rem; color: var(--text-light); margin-bottom: 20px; }

/* === РЕЦЕПТ-БИЛДЕР === */
.recipe-step {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}
.recipe-step h3 {
    margin: 0 0 16px 0;
    font-size: 1.15rem;
    line-height: 1.4;
}
.recipe-step small { color: var(--text-light); font-weight: 400; }

.choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.choice-btn {
    background: var(--card-bg);
    border: 2px solid #E0E0E0;
    border-radius: var(--radius);
    padding: 14px 10px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
}
.choice-btn:active { transform: scale(0.96); }
.choice-btn:hover { border-color: var(--primary); background: rgba(255,87,34,0.03); }

.choice-emoji { font-size: 2rem; }
.choice-fr { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.choice-en { font-size: 0.8rem; color: var(--text-light); }

.speak-mini {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,87,34,0.1);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.speak-mini:active { background: rgba(255,87,34,0.25); }

.recipe-picks {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pick-tag {
    background: rgba(255,87,34,0.1);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* === РЕЗУЛЬТАТ РЕЦЕПТА: ДИАЛОГ === */
.recipe-result {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.4s ease;
    margin-bottom: 16px;
}

.dish-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px dashed #E0E0E0;
}
.dish-emoji { font-size: 3.5rem; margin-bottom: 8px; }
.dish-fr { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.dish-en { font-size: 1rem; color: var(--text-light); }

/* Диалог */
.dialogue-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.dialogue-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}
.dialogue-row--right {
    flex-direction: row-reverse;
}

.dialogue-avatar {
    font-size: 2rem;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,87,34,0.06);
    border-radius: 50%;
}

.dialogue-cards {
    display: flex;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.dialogue-card {
    flex: 1;
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    min-width: 0;
}
.dialogue-card:active { transform: scale(0.98); }

.dialogue-card--fr {
    background: rgba(255,87,34,0.06);
}
.dialogue-card--fr:hover {
    background: rgba(255,87,34,0.12);
}

.dialogue-card--en {
    background: rgba(0,0,0,0.03);
}

.dialogue-role {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.dialogue-text {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text);
}

.dialogue-card--en .dialogue-text {
    color: var(--text-light);
    font-weight: 400;
}

.speak-icon {
    font-size: 0.8rem;
    opacity: 0.4;
    margin-top: 4px;
    display: block;
}

.final-picks {
    justify-content: center;
    padding-top: 12px;
    border-top: 2px dashed #E0E0E0;
}
.final-tag { font-size: 0.9rem; }

/* Адаптив */
@media (max-width: 480px) {
    header h1 { font-size: 1.7rem; }
    .card { height: 220px; }
    .card-emoji { font-size: 3rem; }
    .card-fr { font-size: 1.4rem; }
    .options-grid { grid-template-columns: 1fr; }
    .choice-grid { grid-template-columns: 1fr; }
    .dialogue-cards { flex-direction: column; gap: 4px; }
    .dialogue-row--right .dialogue-cards { flex-direction: column; }
    .btn { padding: 12px 20px; font-size: 1rem; }
}
