:root {
    color-scheme: dark;
    --bg: #090f1f;
    --panel: rgba(16, 25, 47, .94);
    --panel-soft: rgba(30, 41, 59, .74);
    --line: rgba(148, 163, 184, .24);
    --text: #f8fafc;
    --muted: #cbd5e1;
    --accent: #7c3aed;
    --accent-2: #9333ea;
    --good: #22c55e;
    --bad: #ef4444;
    --warn: #f59e0b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(124, 58, 237, .24), transparent 34%),
        radial-gradient(circle at top right, rgba(14, 165, 233, .17), transparent 31%),
        var(--bg);
}

button,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.container {
    width: min(1120px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 54px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.back-link {
    color: #e9d5ff;
    text-decoration: none;
    font-weight: 800;
}

.language-select {
    min-width: 170px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    background: #111827;
}

.hero,
.voice-guide,
.lesson-panel,
.result-panel {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: 0 18px 46px rgba(0, 0, 0, .26);
}

.hero {
    padding: 26px;
}

.hero h1 {
    margin: 0 0 10px;
    font-size: clamp(29px, 5vw, 48px);
}

.hero p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.notice {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #fde68a;
    background: rgba(245, 158, 11, .12);
}

.voice-guide {
    margin-top: 18px;
    padding: 20px;
    background:
        linear-gradient(145deg, rgba(76, 29, 149, .78), rgba(30, 27, 75, .96));
}

.voice-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.voice-avatar {
    display: grid;
    place-items: center;
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: #f8fafc;
    font-size: 32px;
}

.voice-kicker {
    margin: 0 0 4px;
    color: #ddd6fe;
    font-size: 14px;
    font-weight: 900;
}

.voice-guide h2 {
    margin: 0;
    font-size: clamp(21px, 3vw, 27px);
}

.voice-text {
    margin: 14px 0 16px;
    color: #ede9fe;
    line-height: 1.65;
}

.primary,
.secondary,
.answer-button,
.audio-button {
    border: 0;
    border-radius: 13px;
    font-weight: 900;
}

.primary {
    width: 100%;
    padding: 14px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.voice-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.secondary {
    min-height: 45px;
    padding: 10px;
    color: #111827;
    background: #f8fafc;
}

.secondary:disabled {
    cursor: default;
    opacity: .55;
}

.options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 12px;
    color: #ede9fe;
}

.options label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.options input {
    width: 19px;
    height: 19px;
}

.status {
    margin: 10px 0 0;
    color: #ddd6fe;
    font-size: 14px;
}

.section-title {
    margin: 26px 0 12px;
    font-size: 25px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.card {
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-soft);
}

.card h3 {
    margin: 0 0 8px;
    font-size: 20px;
}

.card .native {
    color: #ddd6fe;
    font-weight: 800;
}

.card .range {
    margin: 7px 0;
    color: var(--muted);
    font-size: 14px;
}

.card .example {
    min-height: 44px;
    color: #f8fafc;
    line-height: 1.45;
}

.audio-button {
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    color: #111827;
    background: #f8fafc;
}

.setup {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    margin-top: 22px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel-soft);
}

.setup label {
    display: grid;
    gap: 7px;
    font-weight: 800;
}

.setup select {
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    background: #111827;
}

.start-button {
    min-width: 210px;
}

.lesson-panel,
.result-panel {
    margin-top: 20px;
    padding: 22px;
}

.progress-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-weight: 800;
}

.progress-track {
    height: 10px;
    margin: 10px 0 22px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, .18);
}

.progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #7c3aed, #22d3ee);
}

.question-type {
    margin: 0 0 8px;
    color: #c4b5fd;
    font-weight: 900;
}

.prompt {
    margin: 0;
    font-size: clamp(25px, 5vw, 46px);
    line-height: 1.2;
}

.hint {
    margin: 10px 0 0;
    color: var(--muted);
}

.answers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.answer-button {
    min-height: 58px;
    padding: 13px;
    color: var(--text);
    background: #1f2937;
    border: 1px solid rgba(148, 163, 184, .28);
}

.answer-button:hover {
    transform: translateY(-1px);
}

.answer-button.correct {
    border-color: var(--good);
    background: rgba(34, 197, 94, .18);
}

.answer-button.wrong {
    border-color: var(--bad);
    background: rgba(239, 68, 68, .16);
}

.answer-button:disabled {
    cursor: default;
}

.feedback {
    min-height: 48px;
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(15, 23, 42, .72);
    line-height: 1.5;
}

.lesson-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.lesson-actions button {
    flex: 1 1 190px;
}

.result-panel {
    text-align: center;
}

.result-score {
    margin: 12px 0;
    font-size: 42px;
    font-weight: 950;
}

[hidden] {
    display: none !important;
}

html[dir="rtl"] body {
    direction: rtl;
}

html[dir="rtl"] .voice-header {
    flex-direction: row-reverse;
}

@media (max-width: 900px) {
    .cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .topbar,
    .setup,
    .progress-row {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .cards,
    .answers,
    .voice-controls {
        grid-template-columns: 1fr;
    }

    .start-button {
        min-width: 0;
    }
}
