:root {
    --bg: #f1ecff;
    --surface: #ffffff;
    --ink: #2b2350;
    --muted: #6d6594;
    --pink: #ff6fa5;
    --yellow: #ffd23f;
    --mint: #5ee0b0;
    --sky: #6ec6ff;
    --coral: #ff6b6b;
    --mint-soft: #d9f8ec;
    --coral-soft: #ffe1e1;
    --sky-soft: #def2ff;
    --border: 3px solid var(--ink);
    --shadow: 5px 5px 0 var(--ink);
    --shadow-small: 3px 3px 0 var(--ink);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Nunito", "Segoe UI", Arial, sans-serif;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.5;
    background-color: var(--bg);
    background-image: radial-gradient(#d3c8f7 2px, transparent 2px);
    background-size: 26px 26px;
}

.app {
    max-width: 780px;
    margin: 0 auto;
    padding: 36px 20px 64px;
}

.hidden {
    display: none !important;
}

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.course {
    display: inline-block;
    margin: 0 0 10px;
    padding: 4px 14px;
    background: var(--yellow);
    border: var(--border);
    border-radius: 99px;
    box-shadow: var(--shadow-small);
    font-size: 0.85rem;
    font-weight: 800;
    transform: rotate(-2deg);
}

h1 {
    margin: 0;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-shadow: 3px 3px 0 var(--pink);
}

h2 {
    margin: 0 0 12px;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 1.3rem;
    font-weight: 600;
}

.score-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 110px;
    padding: 10px 20px;
    background: var(--sky);
    border: var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-small);
    transform: rotate(3deg);
}

.score-label {
    font-size: 0.8rem;
    font-weight: 800;
}

.score-value {
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
}

/* ---------- Card ---------- */
.card {
    padding: 30px;
    background: var(--surface);
    border: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ---------- Progress ---------- */
.progress {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.progress-step {
    flex: 1;
    height: 16px;
    background: #fff;
    border: 2.5px solid var(--ink);
    border-radius: 99px;
    transition: background 0.3s;
}

.progress-step.current {
    background: var(--yellow);
}

.progress-step.done-correct {
    background: var(--mint);
}

.progress-step.done-wrong {
    background: var(--coral);
}

.level-text {
    display: inline-block;
    margin: 0 0 16px;
    padding: 3px 14px;
    background: var(--pink);
    border: 2.5px solid var(--ink);
    border-radius: 99px;
    font-size: 0.9rem;
    font-weight: 800;
    color: #fff;
}

.instruction {
    margin: 0 0 26px;
    font-size: 1.1rem;
    font-weight: 700;
}

/* ---------- Reference ---------- */
.reference {
    margin-bottom: 30px;
}

.reference-frame {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 270px;
    padding: 14px;
    background: var(--sky-soft);
    background-image: radial-gradient(#b9e2fb 2px, transparent 2px);
    background-size: 18px 18px;
    border: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-small);
}

.reference-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #fff;
    border: 3px solid var(--ink);
    border-radius: 14px;
    transform: rotate(-1.5deg);
}

/* ---------- Choices ---------- */
.choices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 14px;
    background: var(--surface);
    border: var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-small);
    font: inherit;
    color: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}

.choice img {
    width: 100%;
    height: 140px;
    object-fit: contain;
    background: #fff;
    border: 2.5px solid var(--ink);
    border-radius: 12px;
}

.choice-label {
    padding: 2px 16px;
    background: var(--yellow);
    border: 2.5px solid var(--ink);
    border-radius: 99px;
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
}

.choice:nth-child(1):hover:not(:disabled) { transform: translate(-2px, -5px) rotate(-2deg); }
.choice:nth-child(2):hover:not(:disabled) { transform: translate(-2px, -5px) rotate(1.5deg); }
.choice:nth-child(3):hover:not(:disabled) { transform: translate(-2px, -5px) rotate(-1deg); }

.choice:hover:not(:disabled) {
    box-shadow: 6px 8px 0 var(--ink);
    background: #fff8d6;
}

.choice:active:not(:disabled) {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 var(--ink);
}

.choice:focus-visible,
.btn:focus-visible {
    outline: 4px solid var(--pink);
    outline-offset: 3px;
}

.choice:disabled {
    cursor: default;
}

.choice.correct {
    background: var(--mint-soft);
    box-shadow: 5px 5px 0 #0f9b6a;
    border-color: #0f9b6a;
    animation: pop 0.4s ease;
}

.choice.correct .choice-label {
    background: var(--mint);
}

.choice.wrong {
    background: var(--coral-soft);
    box-shadow: 5px 5px 0 #c73c3c;
    border-color: #c73c3c;
    animation: shake 0.4s ease;
}

.choice.wrong .choice-label {
    background: var(--coral);
    color: #fff;
}

.choice.faded {
    opacity: 0.5;
    box-shadow: none;
}

@keyframes pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.07); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-7px); }
    75%      { transform: translateX(7px); }
}

/* ---------- Feedback ---------- */
.feedback {
    padding: 14px 18px;
    background: var(--bg);
    border: 2.5px dashed var(--muted);
    border-radius: 16px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--muted);
    text-align: center;
}

.feedback.good {
    background: var(--mint-soft);
    border: 2.5px solid #0f9b6a;
    color: #0b7a54;
}

.feedback.bad {
    background: var(--coral-soft);
    border: 2.5px solid #c73c3c;
    color: #b02f2f;
}

/* ---------- Buttons ---------- */
.actions {
    display: flex;
    justify-content: flex-end;
    gap: 14px;
    margin-top: 24px;
}

.actions-center {
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 13px 30px;
    border: var(--border);
    border-radius: 99px;
    box-shadow: var(--shadow-small);
    font-family: "Fredoka", "Nunito", sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
}

.btn:hover:not(:disabled) {
    transform: translate(-2px, -3px);
    box-shadow: 5px 6px 0 var(--ink);
}

.btn:active:not(:disabled) {
    transform: translate(3px, 3px);
    box-shadow: 0 0 0 var(--ink);
}

.btn-primary {
    background: var(--pink);
    color: #fff;
    text-shadow: 1px 1px 0 var(--ink);
}

.btn-primary:disabled {
    background: #e4def5;
    color: #9a93bd;
    border-color: #b9b1dc;
    box-shadow: none;
    text-shadow: none;
    cursor: not-allowed;
}

.btn-ghost {
    background: var(--yellow);
    color: var(--ink);
}

/* ---------- Result ---------- */
.result {
    padding: 48px 28px;
    text-align: center;
}

.result-label {
    display: inline-block;
    margin: 0;
    padding: 4px 18px;
    background: var(--mint);
    border: var(--border);
    border-radius: 99px;
    box-shadow: var(--shadow-small);
    font-weight: 800;
    transform: rotate(-2deg);
}

.result-score {
    margin: 18px 0 14px;
    font-size: 5.5rem;
    line-height: 1;
    color: var(--pink);
    -webkit-text-stroke: 3px var(--ink);
    text-shadow: 5px 5px 0 var(--ink);
    animation: pop 0.6s ease;
}

.result-message {
    max-width: 440px;
    margin: 0 auto 10px;
    font-size: 1.15rem;
    font-weight: 700;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .app {
        padding: 24px 14px 48px;
    }

    .card {
        padding: 20px;
    }

    h1 {
        font-size: 2.2rem;
    }

    .reference-frame {
        height: 210px;
    }

    .choices {
        grid-template-columns: 1fr;
    }

    .choice {
        flex-direction: row;
        gap: 14px;
    }

    .choice img {
        width: 50%;
        height: 100px;
    }

    .actions {
        justify-content: stretch;
    }

    .actions .btn {
        width: 100%;
        text-align: center;
    }

    .result-score {
        font-size: 4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
