:root {
    --primary: #FF7A2F;
    --primary-soft: #FFF1E8;
    --navy: #1C2B3A;
    --navy-soft: #8395A9;
    --emerald: #22C55E;
    --emerald-soft: #E7F9EF;
    --red: #EF4444;
    --red-soft: #FEEBEB;
    --sky: #E9F3FF;
    --mint: #E7F9EF;
    --peach: #FFF1E8;
    --canvas: #F4F7FB;
    --surface: #FFFFFF;
    --text: #1C2B3A;
    --text-muted: #8395A9;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-pill: 9999px;
    --shadow: 0 12px 40px rgba(28, 43, 58, 0.10);
    --shadow-sm: 0 4px 16px rgba(28, 43, 58, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Rubik", "Nunito", system-ui, -apple-system, sans-serif;
    background: var(--canvas);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 {
    font-family: "Nunito", "Rubik", sans-serif;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    width: 100%;
    flex: 1;
}

/* ---------- Top nav ---------- */
.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.brand-logo {
    height: 36px;
    width: auto;
    display: block;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-family: "Nunito", sans-serif;
    font-weight: 900;
    font-size: 15px;
    letter-spacing: 0.02em;
}

.brand-name {
    font-family: "Nunito", sans-serif;
    font-weight: 900;
    font-size: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    transition: background 0.2s, color 0.2s;
}

.nav-links a:hover {
    background: var(--peach);
    color: var(--primary);
}

/* ---------- Hero ---------- */
.hero {
    text-align: center;
    padding: 64px 16px 40px;
}

.hero-badge {
    display: inline-block;
    background: var(--peach);
    color: var(--primary);
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    margin-bottom: 20px;
}

.hero-title {
    font-size: clamp(32px, 5vw, 56px);
    color: var(--navy);
    margin-bottom: 16px;
}

.hero-title .accent { color: var(--primary); }

.hero-subtitle {
    max-width: 620px;
    margin: 0 auto 28px;
    color: var(--text-muted);
    font-size: 17px;
}

.hero-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    font-family: inherit;
    font-weight: 800;
    font-size: 15px;
    text-decoration: none;
    text-align: center;
    border: none;
    cursor: pointer;
    padding: 14px 26px;
    border-radius: var(--radius-pill);
    transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}

.btn:hover { transform: translateY(-2px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 24px rgba(255, 122, 47, 0.35);
}

.btn-primary:hover { box-shadow: 0 10px 28px rgba(255, 122, 47, 0.45); }

.btn-ghost {
    background: var(--surface);
    color: var(--navy);
    border: 2px solid #E6EDF5;
}

.btn-grow { align-self: center; }

/* ---------- Sections ---------- */
.section { margin-top: 24px; }

.section-title {
    font-size: 26px;
    color: var(--navy);
    margin-bottom: 6px;
}

.section-subtitle { color: var(--text-muted); margin-bottom: 24px; }

/* ---------- Category grid ---------- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 8px;
}

.category-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.category-icon {
    font-size: 34px;
    background: var(--peach);
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    margin-bottom: 6px;
}

.category-card:nth-child(4n+2) .category-icon { background: var(--mint); }
.category-card:nth-child(4n+3) .category-icon { background: var(--sky); }

.category-name {
    font-family: "Nunito", sans-serif;
    font-weight: 900;
    font-size: 19px;
    color: var(--navy);
}

.category-count {
    display: inline-block;
    align-self: flex-start;
    background: var(--navy);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
}

.category-desc {
    color: var(--text-muted);
    font-size: 14px;
}

.category-cta {
    color: var(--primary);
    font-weight: 700;
    font-size: 14px;
    margin-top: 4px;
}

/* ---------- Quiz progress ---------- */
.quiz-progress { margin-bottom: 18px; }

.progress-text {
    font-weight: 700;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.progress-bar {
    height: 10px;
    background: #E6EDF5;
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #FFB58A);
    border-radius: var(--radius-pill);
    transition: width 0.4s ease;
}

/* ---------- Question card ---------- */
.question-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow);
}

.question-head {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tag {
    background: var(--peach);
    color: var(--primary);
    font-weight: 800;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
}

.tag-muted {
    background: var(--sky);
    color: #3B82F6;
}

.question-text {
    font-size: 17px;
    color: var(--text);
    margin-bottom: 24px;
}

/* Passage / stimulus */
.passage {
    background: var(--sky);
    border-left: 4px solid #3B82F6;
    border-radius: 0 14px 14px 0;
    padding: 16px 20px;
    margin-bottom: 20px;
    font-size: 15px;
    color: var(--text);
}
.passage .md p:last-child { margin-bottom: 0; }

.stimulus {
    margin-bottom: 20px;
    text-align: center;
}
.stimulus-img {
    max-width: 100%;
    height: auto;
    border: 1px solid #E3EAF5;
    border-radius: var(--radius-md);
    background: #fff;
}

.stim-table {
    border-collapse: collapse;
    margin: 0 auto;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.stim-table th, .stim-table td {
    border: 1px solid #E3EAF5;
    padding: 9px 14px;
    text-align: left;
}
.stim-table th {
    background: var(--navy);
    color: #fff;
    font-weight: 700;
}
.stim-table tr:nth-child(even) td { background: #F8FAFE; }

/* Markdown inner styles */
.md { line-height: 1.7; }
.md p { margin-bottom: 12px; }
.md blockquote {
    border-left: 4px solid var(--primary);
    background: var(--peach);
    padding: 12px 18px;
    border-radius: 0 12px 12px 0;
    margin: 14px 0;
    color: var(--text);
}
.md code {
    background: #F0F4FA;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.9em;
}
.md pre {
    background: var(--navy);
    color: #fff;
    padding: 16px 20px;
    border-radius: 14px;
    overflow-x: auto;
    margin: 14px 0;
}
.md ul, .md ol { padding-left: 24px; margin-bottom: 12px; }
.md strong { color: var(--navy); }

/* ---------- Options ---------- */
.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    background: #F7FAFD;
    border: 2px solid #E6EDF5;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.option-btn:hover:not(.locked) {
    border-color: var(--primary);
    background: var(--peach);
    transform: translateX(4px);
}

.option-letter {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: var(--surface);
    border-radius: 50%;
    font-weight: 900;
    color: var(--navy);
    border: 2px solid #E6EDF5;
}

.option-btn.correct {
    border-color: var(--emerald);
    background: var(--emerald-soft);
}

.option-btn.correct .option-letter {
    background: var(--emerald);
    color: #fff;
    border-color: var(--emerald);
}

.option-btn.wrong {
    border-color: var(--red);
    background: var(--red-soft);
}

.option-btn.wrong .option-letter {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.option-btn.locked { cursor: default; }

/* ---------- Feedback ---------- */
.feedback {
    margin-top: 20px;
    padding: 14px 20px;
    border-radius: 14px;
    font-weight: 700;
}

.feedback-correct { background: var(--emerald-soft); color: #15803D; }
.feedback-wrong { background: var(--red-soft); color: #B91C1C; }
.feedback-error { background: var(--peach); color: var(--primary); }

.control-row {
    margin-top: 22px;
    display: flex;
    justify-content: flex-end;
}

/* ---------- Results ---------- */
.results-hero {
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    box-shadow: var(--shadow);
}

.results-hero.pass { background: linear-gradient(180deg, var(--surface), var(--mint)); }
.results-hero.fail { background: linear-gradient(180deg, var(--surface), var(--peach)); }

.results-icon { font-size: 54px; margin-bottom: 12px; }

.results-title {
    font-size: 54px;
    color: var(--navy);
}

.results-percent {
    font-family: "Nunito", sans-serif;
    font-weight: 900;
    font-size: 22px;
    color: var(--primary);
}

.results-status {
    color: var(--text-muted);
    margin: 14px auto 26px;
    max-width: 480px;
}

/* ---------- Review ---------- */
.review-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border-left: 6px solid var(--red);
}

.review-answers {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.answer-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 15px;
}

.badge {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}

.wrong-answer .badge { background: var(--red-soft); color: #B91C1C; }
.correct-answer .badge { background: var(--emerald-soft); color: #15803D; }

.explanation {
    background: var(--sky);
    border-radius: 14px;
    padding: 14px 18px;
    font-size: 14px;
}

.perfect-card {
    text-align: center;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-sm);
}

.perfect-card h2 { color: var(--emerald); margin-bottom: 8px; }
.perfect-card p { color: var(--text-muted); }

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .question-card { padding: 24px; }
    .hero { padding-top: 40px; }
    .container { padding: 16px 14px 40px; }
    .option-btn { padding: 14px 16px; font-size: 14px; }
}