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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 10px;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.5rem;
    color: #232D4B;
    flex: 1;
    min-width: 200px;
}

.back-link {
    color: #E57200;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 8px 12px;
    border: 1px solid #E57200;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.back-link:hover {
    background-color: #E57200;
    color: white;
}


.exercise-container {
    width: 100%;
}

.info-box,
.teaching-box,
.warning-box {
    padding: 14px 16px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.info-box {
    background-color: #e3f2fd;
    border-left: 4px solid #2196F3;
}

.teaching-box {
    background-color: #f8f9fa;
    border-left: 4px solid #232D4B;
}

.warning-box {
    background-color: #fff3e0;
    border-left: 4px solid #E57200;
}

.info-box p,
.teaching-box p,
.warning-box p {
    margin: 0 0 8px;
}

.info-box p:last-child,
.teaching-box p:last-child,
.warning-box p:last-child {
    margin-bottom: 0;
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    min-height: 44px;
    min-width: 120px;
    flex: 1;
    max-width: 220px;
}

.btn-primary {
    background-color: #E57200;
    color: white;
}

.btn-primary:hover {
    background-color: #d16500;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

.hidden {
    display: none;
}

.result-callout {
    border: 2px solid #E57200;
    border-radius: 8px;
    padding: 16px;
    margin: 15px 0;
    background: #fff8f0;
}

.result-callout h2 {
    color: #232D4B;
    margin-bottom: 8px;
}

.feedback-correct {
    background-color: #e8f5e9;
    border-left: 4px solid #66bb6a;
    color: #2e7d32;
}

.feedback-incorrect {
    background-color: #fce4ec;
    border-left: 4px solid #ef5350;
    color: #c62828;
}

.quiz-error {
    color: #c62828;
    text-align: center;
    font-weight: 500;
    margin-top: 10px;
}

a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

/* ---- Step indicator ---- */
.step-indicator {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 0 0 18px;
    flex-wrap: wrap;
}

.step-dot {
    width: 30px;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
}

.step-dot.active { background: #E57200; }
.step-dot.done { background: #232D4B; }

.section-title {
    color: #232D4B;
    font-size: 1.15rem;
    margin: 22px 0 10px;
}


.pick-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #f8f9fa;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    color: #444;
    cursor: pointer;
}

.pick-toggle:hover:not(:disabled) { border-color: #E57200; }
.pick-toggle:disabled { cursor: default; }

.pick-box {
    width: 18px;
    height: 18px;
    border: 2px solid #999;
    border-radius: 4px;
    background: white;
    position: relative;
    flex: none;
}

.pick-toggle[aria-pressed="true"] {
    background: #fff3e0;
    border-color: #E57200;
    color: #b35900;
}

.pick-toggle[aria-pressed="true"] .pick-box {
    background: #E57200;
    border-color: #E57200;
}

.pick-toggle[aria-pressed="true"] .pick-box::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.rule-list {
    margin: 6px 0 0 1.3em;
}

.rule-list li { margin-bottom: 4px; }

.btn:disabled,
.btn:disabled:hover {
    opacity: 0.55;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.pitfalls ul {
    margin: 4px 0 0 1.2em;
}

/* ---- Page 6: the dealt sentence and answer buttons ---- */
.deal-card {
    border: 2px solid #232D4B;
    border-radius: 10px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 12px;
}

.deal-card.dealt { animation: deal-in 0.3s ease-out; }

@keyframes deal-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.build-progress {
    font-size: 0.85rem;
    font-weight: 600;
    color: #E57200;
    margin-bottom: 6px;
}

.current-sentence {
    font-size: 1.05rem;
    line-height: 1.6;
}

.choice-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.choice-btn {
    max-width: none;
    min-width: 0;
    background: white;
    color: var(--sec);
    border: 2px solid var(--sec);
    font-weight: 700;
}

.choice-btn:hover:not(:disabled) {
    background: var(--sec);
    color: white;
}

.choice-btn.wrong { animation: shake 0.35s; }

@keyframes shake {
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.build-feedback {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.build-score {
    font-size: 0.85rem;
    color: #666;
    text-align: right;
    min-height: 1.3em;
    margin-bottom: 8px;
}

/* ---- Part colors (one per job of the introduction) ---- */
.part-problem   { --sec: #1E88E5; --sec-soft: #e3f2fd; }
.part-known     { --sec: #232D4B; --sec-soft: #e8eaf1; }
.part-gap       { --sec: #E57200; --sec-soft: #fff3e0; }
.part-objective { --sec: #2e7d32; --sec-soft: #e8f5e9; }

/* ---- Page 1: the funnel ---- */
.funnel {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin: 6px auto 14px;
}

.funnel-bands path {
    fill: var(--sec);
    stroke: #fff;
    stroke-width: 4;
    stroke-linejoin: round;
}

.funnel-shade path { pointer-events: none; }

.funnel-mouth { fill: #1565C0; stroke: #fff; stroke-width: 4; }
.funnel-mouth-inner { fill: #0b3b75; }
.funnel-tip { fill: #1b5e20; }

.funnel-text text {
    fill: #fff;
    font-size: 30px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
}

.funnel-text text.small { font-size: 21px; }

.funnel-key {
    list-style: none;
    display: grid;
    gap: 8px;
    max-width: 640px;
    margin: 0 auto 18px;
}

.funnel-key li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.45;
}

.funnel-key strong { color: var(--sec); }

.key-num {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--sec);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Single-best-answer question (page 2) ---- */
.pick-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.pick-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: 2px solid #d5d9e0;
    border-radius: 8px;
    background: white;
    font: inherit;
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.pick-option:hover:not(:disabled) { border-color: #E57200; }
.pick-option:disabled { cursor: default; }

.pick-letter {
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #232D4B;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.pick-text { flex: 1; }

/* The reader's own picks carry a check or an X; options they never tapped stay unmarked. */
.pick-mark {
    flex: none;
    width: 28px;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
    text-align: center;
}

.pick-row.right .pick-option { border-color: #2e7d32; background: #f3faf3; }
.pick-row.right .pick-letter { background: #2e7d32; }
.pick-row.right .pick-mark { color: #2e7d32; }
.pick-row.wrong .pick-option { border-color: #c62828; background: #fff7f7; }
.pick-row.wrong .pick-letter { background: #c62828; }
.pick-row.wrong .pick-mark { color: #c62828; }
.pick-row.revealed .pick-option { color: #666; background: #fafafa; }
.pick-row.revealed .pick-letter { background: #9aa1ab; }

.pick-why {
    margin: 6px 4px 0 44px;
    font-size: 0.93rem;
}

.pick-row.right .pick-why { color: #1b5e20; }
.pick-row.wrong .pick-why { color: #8e1c1c; }
.pick-row.revealed .pick-why { color: #555; }

.outcome-card {
    border: 1px solid #ddd;
    border-left: 5px solid #232D4B;
    border-radius: 8px;
    padding: 10px 14px;
    background: #fafafa;
    margin-bottom: 12px;
    font-size: 0.97rem;
}

/* ---- Pages 3 and 5: pick the right cards ---- */
.fact-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 14px 0;
}

.fact-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 14px;
    background: white;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fact-card.picked {
    border-color: #E57200;
    box-shadow: 0 0 0 3px rgba(229, 114, 0, 0.15);
}

.fact-card.graded-right {
    border-color: #2e7d32;
    background: #f7fcf7;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.18);
}

.fact-card.graded-wrong {
    border-color: #c62828;
    background: #fff7f7;
    box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.18);
}

.fact-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.fact-text { line-height: 1.5; }

/* After checking, each right card shows its place in the finished paragraph. */
.fact-num {
    flex: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #232D4B;
    color: white;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fact-num.hidden { display: none; }

.fact-card .pick-toggle { align-self: flex-start; }

.fact-why {
    font-size: 0.92rem;
    border-top: 1px dashed #ddd;
    padding-top: 8px;
}

.graded-right .fact-why { color: #1b5e20; }
.graded-wrong .fact-why { color: #8e1c1c; }

/* ---- Page 4: gap types ---- */
.gap-type-list { margin-top: 8px; }

.gap-type-list li { line-height: 1.45; margin-bottom: 6px; }

.gap-cards {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 14px 0 6px;
}

.gap-card {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 14px;
    background: white;
}

.gap-card.solved { border-color: #2e7d32; background: #fbfefb; }

.gap-source {
    font-size: 0.82rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.gap-text {
    font-size: 1rem;
    line-height: 1.55;
    margin-bottom: 10px;
}

.gap-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.gap-choice {
    min-height: 44px;
    padding: 8px 10px;
    border: 2px solid #E57200;
    border-radius: 6px;
    background: white;
    color: #b35900;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.gap-choice:hover:not(:disabled) { background: #E57200; color: white; }
.gap-choice:disabled { cursor: default; opacity: 0.45; }
.gap-choice.wrong { animation: shake 0.35s; }

.gap-choice.right,
.gap-choice.right:disabled {
    opacity: 1;
    background: #2e7d32;
    border-color: #2e7d32;
    color: white;
}

.gap-feedback {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.93rem;
}

.select-count {
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    margin-top: 4px;
}

/* ---- Page 6: the introduction as it builds ---- */
.choice-buttons .choice-btn { padding: 12px 10px; }

.built-intro {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 14px 16px;
    background: #fcfcfc;
}

.built-intro-title {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
    margin-bottom: 10px;
}

.built-section {
    border-left: 4px solid var(--sec);
    padding: 2px 0 2px 10px;
    margin-bottom: 12px;
}

.built-section:last-child { margin-bottom: 0; }

.built-heading {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sec);
    margin-bottom: 2px;
}

.built-body {
    font-size: 0.93rem;
    line-height: 1.6;
    min-height: 1.6em;
}

.built-body:empty::before {
    content: "6";
    color: #bbb;
}

.placed {
    transition: background-color 1.4s;
    border-radius: 3px;
}

.placed.just-placed { background: var(--sec-soft); }

/* ---- Wider screens ---- */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }

    .container {
        max-width: 900px;
        padding: 30px;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .gap-choices,
    .choice-buttons {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media print {
    body {
        background-color: white;
    }

    .buttons {
        display: none;
    }
}
