:root {
    --bg: #f3f6f8;
    --bg-soft: #eaf4ef;
    --ink: #15202b;
    --muted: #5f6c7b;
    --panel: #ffffff;
    --line: #d9e1e8;
    --primary: #116c67;
    --primary-dark: #0a4e4a;
    --accent: #f0b84f;
    --coral: #e66f51;
    --sky: #3978bf;
    --good: #238b45;
    --bad: #c2410c;
    --shadow: 0 20px 55px rgba(21, 32, 43, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    background:
        linear-gradient(120deg, rgba(17, 108, 103, 0.08), transparent 42%),
        linear-gradient(180deg, #f9fbfc 0%, var(--bg) 100%);
}

button,
input {
    font: inherit;
}

button {
    min-height: 48px;
    border: 0;
    border-radius: 8px;
    padding: 0 18px;
    color: #fff;
    background: var(--primary);
    cursor: pointer;
    font-weight: 800;
    box-shadow: 0 5px 0 var(--primary-dark);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

button:hover,
button:focus-visible {
    background: #16837d;
    outline: 3px solid rgba(17, 108, 103, 0.2);
    outline-offset: 2px;
}

button:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 var(--primary-dark);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

img {
    display: block;
    max-width: 100%;
}

.secondary-button {
    color: var(--primary-dark);
    background: #dff1ec;
    box-shadow: 0 5px 0 #b5d5cd;
}

.secondary-button:hover,
.secondary-button:focus-visible {
    background: #d1ebe4;
}

.is-hidden {
    display: none !important;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0;
}

.start-screen,
.training-screen,
.finish-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.start-screen {
    display: grid;
    gap: 28px;
    padding: clamp(22px, 4.5vw, 48px);
}

.brand-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 18px;
}

.brand-mark {
    display: grid;
    width: 84px;
    height: 84px;
    place-items: center;
    border-radius: 18px;
    color: #063c39;
    background: linear-gradient(135deg, #f7d36b, #f0b84f);
    font-size: 22px;
    font-weight: 900;
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.08);
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: clamp(34px, 5vw, 60px);
    line-height: 1;
    color: #0d423f;
}

.brand-row p,
.finish-card p {
    margin-top: 10px;
    color: var(--muted);
    font-size: 18px;
    line-height: 1.45;
}

.start-form {
    display: grid;
    gap: 10px;
    max-width: 720px;
}

.start-form label {
    font-size: 17px;
    font-weight: 800;
}

.name-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
}

.name-row input {
    width: 100%;
    min-height: 54px;
    border: 2px solid var(--line);
    border-radius: 8px;
    padding: 0 16px;
    background: #fff;
    color: var(--ink);
    font-size: 18px;
    font-weight: 700;
}

.name-row input:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(17, 108, 103, 0.18);
}

.topic-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topic-strip span {
    border: 1px solid #d8e3e8;
    border-radius: 999px;
    padding: 10px 14px;
    background: #f6fafb;
    color: #31515d;
    font-weight: 800;
}

.course-note {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    border: 1px solid #c9dff4;
    border-radius: 8px;
    padding: 12px 14px;
    background: #eff7ff;
    color: #12345a;
}

.course-note strong {
    font-size: 14px;
    text-transform: uppercase;
}

.course-note span {
    color: #31515d;
    font-weight: 800;
}

.recent-results {
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.recent-results summary {
    cursor: pointer;
    color: var(--primary-dark);
    font-weight: 900;
}

.recent-results ol {
    display: grid;
    gap: 8px;
    margin: 14px 0 0;
    padding-left: 24px;
}

.recent-results li {
    color: var(--muted);
}

.recent-results span {
    margin-left: 8px;
    color: var(--ink);
    font-weight: 900;
}

.training-screen {
    display: grid;
    gap: 18px;
    padding: clamp(16px, 2.5vw, 28px);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.student-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border-radius: 999px;
    padding: 0 12px;
    color: #073f3b;
    background: #dbf0ed;
    font-size: 14px;
    font-weight: 900;
}

.topbar h2 {
    margin-top: 6px;
    font-size: clamp(24px, 3vw, 36px);
    line-height: 1.1;
}

.score-pill {
    display: grid;
    gap: 4px;
    min-width: 138px;
    border: 1px solid #ead296;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff7df;
    text-align: center;
    font-weight: 900;
}

.score-pill span:last-child {
    color: var(--muted);
    font-size: 14px;
}

.progress-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #dde5eb;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--coral));
    transition: width 260ms ease;
}

.exercise-card {
    min-height: 460px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(16px, 2.5vw, 26px);
    background: #fff;
}

.instruction {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.45;
}

.big-word {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 86px;
    border: 1px solid #cde1de;
    border-radius: 8px;
    background: var(--bg-soft);
    color: #0d514d;
    font-size: clamp(34px, 7vw, 66px);
    font-weight: 900;
    text-transform: lowercase;
}

.speak-button {
    display: inline-grid;
    width: 46px;
    min-height: 46px;
    place-items: center;
    flex: 0 0 auto;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    background: var(--sky);
    box-shadow: 0 4px 0 #24578e;
    font-size: 18px;
}

.speak-button:hover,
.speak-button:focus-visible {
    background: #2f6fab;
}

.picture-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.picture-option,
.letter-option,
.word-option,
.match-card {
    border: 3px solid transparent;
    border-radius: 8px;
    background: #f8fafc;
    color: var(--ink);
    box-shadow: inset 0 -5px 0 rgba(21, 32, 43, 0.08);
}

.picture-option {
    display: grid;
    grid-template-rows: 132px auto auto 46px;
    gap: 8px;
    min-height: 240px;
    place-items: center;
    padding: 12px;
}

.visual {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 116px;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid #d8e3e8;
    background: #edf3f6;
}

.image-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.color-visual {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(0, 0, 0, 0.08)),
        var(--item-color);
}

.color-visual span {
    width: 52%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--item-color);
    border: 5px solid rgba(255, 255, 255, 0.82);
    box-shadow: 0 10px 22px rgba(21, 32, 43, 0.18);
}

.large-visual {
    width: min(360px, 100%);
    min-height: 210px;
}

.match-visual {
    width: 92px;
    min-height: 62px;
}

.image-visual.is-broken {
    color: #31515d;
    background: #edf3f6;
    font-size: 18px;
    font-weight: 900;
    text-transform: lowercase;
}

.picture-option strong,
.figure-card strong {
    font-size: 18px;
    text-transform: lowercase;
}

.picture-option small {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.picture-option.selected,
.letter-option.selected,
.word-option.selected,
.match-card.selected {
    border-color: var(--accent);
    background: #fff8e6;
}

.picture-option.correct,
.letter-option.correct,
.word-option.correct,
.match-card.correct {
    border-color: var(--good);
    background: #edf9f1;
}

.picture-option.wrong,
.letter-option.wrong,
.word-option.wrong,
.match-card.wrong {
    border-color: var(--bad);
    background: #fff2ea;
}

.figure-card {
    display: grid;
    place-items: center;
    gap: 12px;
    max-width: 390px;
    margin: 0 auto 20px;
    border: 1px solid #cde1de;
    border-radius: 8px;
    padding: 18px;
    background: #f5fbf8;
}

.masked-word {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    border-radius: 8px;
    background: #fff4d4;
    color: #5b3c00;
    font-size: clamp(34px, 7vw, 58px);
    font-weight: 900;
    letter-spacing: 0;
}

.letter-grid,
.word-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.letter-option,
.word-option {
    min-height: 62px;
    color: var(--ink);
    font-size: 24px;
    font-weight: 900;
}

.sentence-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    border: 1px solid #c9dff4;
    border-radius: 8px;
    padding: 18px;
    background: #eff7ff;
}

.sentence-icon {
    display: grid;
    width: 76px;
    height: 76px;
    place-items: center;
    border-radius: 18px;
    color: #12345a;
    background: #dceeff;
    font-size: 28px;
    font-weight: 900;
}

.sentence-card p {
    color: #12345a;
    font-size: clamp(28px, 5vw, 46px);
    font-weight: 900;
    line-height: 1.1;
}

.match-board {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: clamp(18px, 6vw, 80px);
    margin-top: 18px;
}

.match-lines {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.match-column {
    z-index: 1;
    display: grid;
    gap: 12px;
}

.match-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 86px;
    padding: 10px;
    color: var(--ink);
    font-size: 24px;
    font-weight: 900;
}

.match-card .speak-button {
    margin-left: 8px;
}

.feedback {
    min-height: 34px;
    margin-top: 16px;
    color: var(--primary-dark);
    font-size: 20px;
    font-weight: 900;
    text-align: center;
}

.feedback.bad {
    color: var(--bad);
}

.action-row {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.finish-screen {
    display: grid;
    min-height: calc(100vh - 64px);
    place-items: center;
}

.finish-card {
    display: grid;
    gap: 12px;
    width: min(620px, 100%);
    padding: clamp(24px, 5vw, 42px);
    text-align: center;
}

.stars {
    color: var(--accent);
    font-size: clamp(42px, 8vw, 70px);
    letter-spacing: 0;
}

.finish-card h2 {
    font-size: clamp(28px, 5vw, 48px);
}

.finish-card button {
    justify-self: center;
    margin-top: 8px;
}

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

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
        padding: 10px 0;
    }

    .brand-row,
    .topbar,
    .sentence-card {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .name-row,
    .letter-grid,
    .word-grid {
        grid-template-columns: 1fr 1fr;
    }

    .name-row button {
        grid-column: 1 / -1;
    }

    .score-pill {
        width: 100%;
    }

    .exercise-card {
        min-height: 520px;
    }

    .match-board {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .match-card {
        min-height: 76px;
        font-size: 18px;
    }

    .match-visual {
        width: 72px;
        min-height: 56px;
    }

    .action-row {
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .picture-grid,
    .letter-grid,
    .word-grid {
        grid-template-columns: 1fr;
    }

    .picture-option {
        grid-template-rows: 160px auto auto 46px;
    }

    .brand-mark {
        width: 70px;
        height: 70px;
        border-radius: 16px;
    }
}
