/* ============================================================
   graph_make_exercises.css — Styles for Graph Construction exercises
   ============================================================
   Load AFTER style.css so these rules win ties without !important:

     <link rel="stylesheet" href="style.css">
     <link rel="stylesheet" href="graph_make_exercises.css">

   Uses CSS variables defined in style.css's :root.

   Three layouts, all driven from the same markup:
     1. Desktop / tablet   (default)                     canvas left, description right
     2. Phone, portrait    (max-width: 520px)            conditions, canvas, tools, feedback, sticky buttons
     3. Phone, landscape   (landscape + max-height 500)  tool rail | canvas | panel, fills the screen, no page scroll

   On the two phone layouts the canvas keeps its full logical size
   (480 x 360 CSS px inside the border = 16 x 12 squares) and graph_make_exercises.js scales it
   to fit, so grading sees the same canvas on every device.
   ============================================================ */

/* ==========================================
   SKETCH PAD & CANVAS CONTAINER
   ========================================== */

.sketch-pad-container {
    max-width: 700px;
    margin: 24px auto;
    background: var(--bg-card);
    border: 3px solid var(--border-accent);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-soft);
    text-align: center;
}

.sketch-instructions {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sketch-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.gm-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Only shown on a portrait phone */
.gm-page .notes-content .gm-rotate-tip { display: none; }

/* The stage is the positioned parent of the canvas AND the coordinate tooltip. */
.canvas-stage {
    position: relative;
    flex: 1;
    min-width: 0;
}

/* Two stacked canvases: grid layer underneath (#gridCanvas), drawing layer on top (#graphCanvas) */
.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #14171d;
    border: 2px solid var(--border-main);
    border-radius: 10px;
    overflow: hidden;
    touch-action: none; /* Prevents page scrolling while drawing on mobile */
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.canvas-wrapper canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.canvas-wrapper #gridCanvas {
    pointer-events: none; /* All drawing input passes to the top canvas */
}

/* ==========================================
   BUTTON BASICS
   ========================================== */

.tool-toggle {
    background: var(--bg-header);
    color: var(--text-primary);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    padding: 10px 16px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;           /* no double-tap-zoom delay on buttons */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.tool-toggle.active {
    background: rgba(61, 214, 140, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.check-step-btn {
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 24px;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.check-step-btn:hover { background: #ffbb2e; }
.check-step-btn:active { transform: scale(0.98); }

.check-step-btn.new-exercise-btn {
    background: var(--accent-green);
    border-color: #2aa76d;
}
.check-step-btn.new-exercise-btn:hover { background: #55e6a1; }

.check-step-btn.clear-btn {
    background: var(--bg-header);
    color: var(--text-primary);
    border-color: var(--border-main);
}
.check-step-btn.clear-btn:hover { background: #2a3144; }
.check-step-btn.clear-btn.armed,
.check-step-btn.new-exercise-btn.armed {
    background: #e53935;
    border-color: #b71c1c;
    color: #fff;
}

/* ==========================================
   SIDE TOOLBAR (desktop: one column of text buttons)
   ========================================== */

.canvas-with-sidebar {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.canvas-side-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
    flex: none;
}

.side-tool {
    min-width: 42px;
    height: 42px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    flex: none;
    white-space: nowrap;
}

.side-tool .ico { display: none; }   /* icons only on the phone layouts */

.side-sep {
    height: 2px;
    background: var(--border-main);
    border-radius: 1px;
    margin: 2px 4px;
}

/* ==========================================
   COORDINATE TOOLTIP (hover / hold-tap inspect)
   ========================================== */

.coord-tooltip {
    position: absolute;
    z-index: 10;
    pointer-events: none; /* never blocks drawing */
    background: rgba(20, 23, 29, 0.95);
    border: 1px solid var(--border-accent);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transform: translateY(-100%);
}

/* ==========================================
   SPLIT LAYOUT (GRAPH LEFT / DESC RIGHT)
   ========================================== */

.exercise-split-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-top: 20px;
}

.exercise-graph-pane {
    flex: 1.5; /* Takes the majority of the left space on PC */
    min-width: 0;
}

.exercise-graph-pane .sketch-pad-container {
    max-width: 100%; /* Fills the pane cleanly */
    margin: 0;
}

.exercise-desc-pane {
    flex: 1; /* Right column */
    min-width: 280px;
}

.desc-card {
    background: var(--bg-card);
    border: 3px solid var(--border-main);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.desc-scroll { display: flex; flex-direction: column; gap: 12px; }
.desc-top { display: flex; flex-direction: column; gap: 20px; }

.desc-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 2px solid var(--border-main);
    padding-bottom: 10px;
}

.desc-card h3 {
    margin: 0;
    text-align: center;
    color: var(--accent-green);
}

.gm-home-mini, .gm-fs-btn, .gm-unit-note { display: none; }

.notes-content .desc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.notes-content .desc-list li {
    font-size: 1.05rem;
    margin: 0;
    color: var(--text-primary);
    line-height: 1.5;
}

#graphFeedback {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    text-align: left;
}

#graphFeedback .gc-row { margin: 0 0 4px; }
#graphFeedback .gc-row.ok { color: #3dd68c; }
#graphFeedback .gc-row.bad { color: #e53935; }
#graphFeedback .gc-all { color: #3dd68c; margin-top: 6px; }

/* Little "i" next to a message: hover shows a tooltip (title), tap/Enter toggles the note */
.gc-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4em;
    height: 1.4em;
    margin-left: 4px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 0.8em;
    font-style: normal;
    cursor: pointer;
    vertical-align: middle;
    position: relative;
}
/* Invisible extra hit area so a fingertip can actually land on it */
.gc-hint::after {
    content: "";
    position: absolute;
    inset: -10px;
}

.gc-hint-note {
    display: none;
    margin: 4px 0 2px 1.4em;
    padding: 6px 8px;
    border-left: 3px solid currentColor;
    color: #ccc;
    font-size: 0.9rem;
    font-weight: 500;
}
.gc-hint-note.open { display: block; }

.gm-json-btn {
    align-self: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 6px 8px;
    touch-action: manipulation;
}

.check-btn-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.check-btn-container .check-step-btn {
    width: 100%;
    text-align: center;
}

/* ==========================================
   TABLET / SMALL WINDOW: stack the two panes
   ========================================== */

@media (max-width: 900px) {
    .exercise-split-layout {
        flex-direction: column;
    }
    .exercise-graph-pane,
    .exercise-desc-pane {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .sketch-pad-container {
        padding: 12px 8px;
        border-width: 2px;
    }
}

/* ==========================================
   PHONE CANVAS: fixed logical size, scaled to fit the stage
   ========================================== */
/* Same condition as SCALED_MQ in graph_make_exercises.js — keep the two in sync. */

@media (max-width: 520px), (orientation: landscape) and (max-height: 500px) {
    .canvas-wrapper {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 484px;               /* 480 x 360 inside the 2px border = 16 x 12 squares: room for points at y = +-5 */
        height: 364px;
        aspect-ratio: auto;
        transform: translate(-50%, -50%);   /* JS adds scale(...) to this */
        transform-origin: center center;
    }
}

/* ==========================================
   PHONE, PORTRAIT / NARROW
   ========================================== */

@media (max-width: 520px) {
    .gm-page { padding: 8px 4px calc(0px + env(safe-area-inset-bottom)); }
    .gm-page .container {
        width: 100%;
        padding: 12px 8px 0;
        border-radius: 8px;
    }
    .gm-page #home-btn { margin: 0 0 10px; }
    .gm-page .notes-content { margin-top: 0; }
    .gm-page .notes-content h1 { font-size: 1.45rem; padding-bottom: 8px; margin-bottom: 10px; }
    .gm-page .gm-subtitle { font-size: 0.9rem; margin-bottom: 8px; line-height: 1.4; }
    .gm-page .notes-content .gm-rotate-tip {
        display: block;
        text-align: center;
        font-size: 0.8rem;
        color: var(--accent-amber);
        margin: 0 0 6px;
        line-height: 1.3;
    }

    /* Let the pieces of the description card become direct children of the layout,
       so they can be ordered: conditions, canvas + tools, feedback, buttons. */
    .gm-page .exercise-split-layout {
        gap: 10px;
        margin-top: 6px;
        align-items: stretch;
    }
    .gm-page .exercise-desc-pane,
    .gm-page .desc-card,
    .gm-page .desc-scroll { display: contents; }

    .gm-page .desc-top {
        order: 1;
        background: var(--bg-card);
        border: 2px solid var(--border-main);
        border-radius: 12px;
        padding: 10px 12px;
        gap: 8px;
    }
    .gm-page .desc-head { padding-bottom: 6px; }
    .gm-page .desc-card h3 { font-size: 1rem; }
    .gm-page .notes-content .desc-list { gap: 8px; }
    .gm-page .notes-content .desc-list li { font-size: 1rem; line-height: 1.4; }
    .gm-page .gm-unit-note { display: block; font-size: 0.75rem; color: var(--text-secondary); }

    .gm-page .exercise-graph-pane { order: 2; }
    .gm-page .exercise-graph-pane .sketch-pad-container {
        padding: 8px;
        border-radius: 12px;
    }
    .gm-page .sketch-instructions,
    .gm-page .sketch-hint { display: none; }

    .gm-page .canvas-with-sidebar { flex-direction: column; gap: 8px; }
    .gm-page .canvas-stage {
        flex: none;
        width: 100%;
        aspect-ratio: 484 / 364;
    }

    /* Tools: a wrapping grid below the canvas */
    .gm-page .canvas-side-toolbar {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        padding: 0;
    }
    .gm-page .side-sep { display: none; }

    #graphFeedback {
        order: 3;
        background: var(--bg-card);
        border: 2px solid var(--border-main);
        border-radius: 12px;
        padding: 10px 12px;
        scroll-margin-bottom: 70px;   /* keep it clear of the sticky buttons */
    }
    .gm-page .gm-json-btn { order: 4; }

    /* Buttons stay on screen while the page scrolls */
    .gm-page .check-btn-container {
        order: 5;
        position: sticky;
        bottom: 0;
        z-index: 20;
        display: grid;
        grid-template-columns: 2fr 1fr 1fr;   /* one slim row so it never hides much of the canvas */
        gap: 6px;
        margin: 0 -8px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: var(--bg-container);
        border-top: 2px solid var(--border-main);
    }
    .gm-page .check-btn-container .check-step-btn {
        font-size: 0.8rem;
        min-height: 46px;
        padding: 4px 6px;
        line-height: 1.1;
    }
    .gm-page .check-btn-container #checkGraphBtn {
        font-size: 1.05rem;
    }
}

/* ==========================================
   PHONE, LANDSCAPE: tool rail | canvas | panel
   ========================================== */
/* Everything fits the screen with no page scrolling; only the right panel
   scrolls (when there are many conditions or feedback lines). Written after
   the portrait block so it wins when both match (a very small phone). */

@media (orientation: landscape) and (max-height: 500px) {
    html { scroll-behavior: auto; }

    .gm-page {
        padding: 0;
        min-height: 0;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }
    .gm-page .container {
        width: 100%;
        height: 100%;
        min-height: 0;
        max-width: none;
        margin: 0;
        padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
        border: none;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }
    .gm-page #home-btn,
    .gm-page .notes-content > h1,
    .gm-page .gm-subtitle,
    .gm-page .notes-content .gm-rotate-tip { display: none; }

    .gm-page .notes-content {
        margin: 0;
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .gm-page .exercise-split-layout {
        flex: 1;
        min-height: 0;
        margin: 0;
        gap: 8px;
        flex-direction: row;
        align-items: stretch;
    }

    /* — left: rail + canvas — */
    .gm-page .exercise-graph-pane {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        display: flex;
    }
    .gm-page .exercise-graph-pane .sketch-pad-container {
        flex: 1;
        min-width: 0;
        min-height: 0;
        margin: 0;
        padding: 6px;
        border-width: 2px;
        border-radius: 12px;
        display: flex;
        flex-direction: column;
    }
    .gm-page .sketch-instructions,
    .gm-page .sketch-hint { display: none; }

    .gm-page .canvas-with-sidebar {
        flex: 1;
        min-height: 0;
        flex-direction: row;
        gap: 8px;
    }
    .gm-page .canvas-stage { min-height: 0; }

    .gm-page .canvas-side-toolbar {
        order: -1;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: minmax(44px, 1fr);
        gap: 6px;
        width: 112px;
        padding: 0;
        overflow-y: auto;
    }
    .gm-page .side-sep { display: none; }

    /* — right: description panel — */
    .gm-page .exercise-desc-pane {
        flex: 0 0 clamp(190px, 29vw, 270px);
        width: auto;
        min-width: 0;
        display: flex;
    }
    .gm-page .desc-card {
        flex: 1;
        min-height: 0;
        padding: 8px 10px;
        border-width: 2px;
        border-radius: 12px;
        gap: 6px;
        display: flex;
        flex-direction: column;
    }
    .gm-page .desc-scroll {
        display: flex;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
    }
    .gm-page .desc-top { gap: 6px; flex: none; }
    .gm-page .desc-scroll > * { flex: none; }
    .gm-page .desc-head {
        justify-content: space-between;
        padding-bottom: 4px;
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 2;
    }
    .gm-page .desc-card h3 { font-size: 0.9rem; flex: 1; }
    .gm-home-mini, .gm-fs-btn:not([hidden]) {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        flex: none;
        border: 2px solid var(--border-main);
        border-radius: 8px;
        background: var(--bg-header);
        color: var(--accent-blue);
        font-size: 1.1rem;
        text-decoration: none;
        cursor: pointer;
        touch-action: manipulation;
    }
    .gm-fs-btn { font-family: inherit; }
    .gm-page .notes-content .desc-list { gap: 6px; }
    .gm-page .notes-content .desc-list li { font-size: 0.95rem; line-height: 1.35; }
    .gm-page .gm-unit-note { display: block; font-size: 0.7rem; color: var(--text-secondary); }
    #graphFeedback { font-size: 0.85rem; scroll-margin-bottom: 8px; }
    .gc-hint-note { font-size: 0.8rem; }
    .gm-page .gm-json-btn { font-size: 0.7rem; }

    .gm-page .check-btn-container {
        margin: 0;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        flex: none;
    }
    .gm-page .check-btn-container .check-step-btn {
        font-size: 0.85rem;
        padding: 6px 4px;
        min-height: 44px;
        line-height: 1.15;
    }
    .gm-page .check-btn-container #checkGraphBtn {
        grid-column: 1 / -1;
        font-size: 1.05rem;
        min-height: 48px;
    }
}

/* ==========================================
   PHONE TOOL BUTTONS (icon over a short label) — portrait and landscape
   ========================================== */

@media (max-width: 520px), (orientation: landscape) and (max-height: 500px) {
    .gm-page .side-tool {
        min-width: 0;
        height: auto;
        min-height: 48px;
        padding: 4px 2px;
        flex-direction: column;
        gap: 3px;
        font-size: 0.62rem;
        font-weight: 600;
        line-height: 1.05;
        white-space: normal;
        text-align: center;
    }
    .gm-page .side-tool .ico {
        display: block;
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
        stroke-linejoin: round;
    }
    .gm-page .t-dashv .lbl, .gm-page .t-dashh .lbl { font-size: 0; }
    .gm-page .t-dashv .lbl::after, .gm-page .t-dashh .lbl::after { content: attr(data-short); font-size: 0.62rem; }
    /* While curve dots are waiting, Done / Cancel take the place of the dot tools (same two slots) */
    .gm-page .curve-pending .t-closed, .gm-page .curve-pending .t-open { display: none; }
    .gm-page .side-tool:active { transform: scale(0.96); }
    .gm-page .side-tool:disabled { opacity: 0.4; }
}


/* ==========================================
   CURVE MAKER buttons (all layouts)
   ========================================== */

.side-tool[hidden] { display: none !important; }

.side-tool.t-done {
    background: var(--accent-green);
    border-color: #2aa76d;
    color: #111;
}
.side-tool.t-done:disabled { opacity: 0.45; }
.side-tool.t-cancel {
    border-color: #e53935;
    color: #ff7b78;
}

/* ==========================================
   CURVE PLACEMENT PAD
   While the curve tool is active, JS adds .gm-curve-placing to <body>:
   the description header (title + back + full-screen) and the action
   buttons step aside so the conditions move up and the pad takes the
   button slot. Tap the canvas to move the ring; arrows nudge it;
   Place drops a dot.
   ========================================== */

.curve-pad { display: none; }

.gm-curve-placing .desc-head { display: none; }              /* conditions move up */
.gm-curve-placing .check-btn-container { display: none; }    /* action buttons step aside */
.gm-curve-placing .curve-pad { display: block; }

.curve-pad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.curve-pad-btn {
    min-height: 48px;
    border: 2px solid var(--border-main);
    border-radius: 8px;
    background: var(--bg-header);
    color: var(--text-primary);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
.curve-pad-btn:active { transform: scale(0.96); background: #2a3144; }

.curve-pad-place {
    background: var(--accent-green);
    border-color: #2aa76d;
    color: #111;
    font-size: 0.85rem;
    line-height: 1.15;
}

/* Portrait phone: pin the pad where the sticky action buttons sit */
@media (max-width: 520px) {
    .gm-curve-placing .curve-pad {
        order: 5;
        position: sticky;
        bottom: 0;
        z-index: 20;
        margin: 0 -8px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: var(--bg-container);
        border-top: 2px solid var(--border-main);
    }
}



/* ==========================================
   INTRO POPUP (shown each time the page opens)
   ========================================== */
/* Three illustrated steps: read the description, sketch your graph, check
   your answer. Built by showGraphIntro() in graph_make_exercises.js. The popup
   lives on <body>, outside .notes-content, so it sets its own text sizes. */

body.intro-open {
    overflow: hidden;   /* stop the page scrolling behind the popup */
}

.intro-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 20px;
    opacity: 0;
    animation: introFadeIn 0.2s forwards;
}

.intro-modal-content {
    position: relative;
    background: var(--bg-card);
    border: 3px solid black;
    border-radius: 16px;
    max-width: 760px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 30px 32px 26px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    transform: scale(0.9);
    animation: introScaleUp 0.2s forwards;
}

.intro-modal-close {
    position: absolute;
    top: 12px;
    right: 18px;
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

.intro-modal-close:hover {
    color: var(--text-primary);
}

.intro-modal-close:focus-visible,
.intro-modal-start:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 3px;
}

.intro-modal-title {
    margin: 0 0 6px 0;
    padding-right: 36px;      /* keeps the title clear of the × button */
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--accent-amber);
}

.intro-modal-sub {
    margin: 0 0 20px 0;
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ---- the three steps ---- */
.intro-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

.intro-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 210px;
    align-items: center;
    gap: 18px;
    margin: 0;
    padding: 16px 18px;
    background: var(--bg-header);
    border: 2px solid var(--border-main);
    border-radius: 14px;
}

.intro-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-amber);
    color: #111;
    font-size: 1.15rem;
    font-weight: 700;
}

.intro-step-title {
    margin: 0 0 4px 0;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-heading);
}

.intro-step-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.intro-step-art {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- illustrations (miniatures of the real page) ---- */
.intro-art {
    width: 100%;
    max-width: 210px;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 2px solid var(--text-primary);
    border-radius: 14px;
    padding: 10px 12px;
}

/* 1. the description card */
.intro-mini-cond {
    margin-bottom: 7px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-heading);
}

.intro-mini-cond:last-child {
    margin-bottom: 0;
}

/* 2. a tiny graph with a curve, an open dot, a closed dot and a dashed asymptote */
.intro-art.intro-art-plain {
    background: none;
    border: none;
    padding: 0;
}

.intro-graph {
    display: block;
    width: 100%;
    height: auto;
    border: 2px solid var(--border-main);
    border-radius: 10px;
}

.intro-graph .ig-bg    { fill: #14171d; }
.intro-graph .ig-grid  { stroke: #232936; stroke-width: 1; fill: none; }
.intro-graph .ig-axis  { stroke: #4a5568; stroke-width: 2; fill: none; }
.intro-graph .ig-dash  { stroke: #f5a623; stroke-width: 2; stroke-dasharray: 6 4; fill: none; }
.intro-graph .ig-curve { stroke: #3dd68c; stroke-width: 3; stroke-linecap: round; fill: none; }
.intro-graph .ig-open  { fill: #14171d; stroke: #3dd68c; stroke-width: 2.5; }
.intro-graph .ig-closed { fill: #3dd68c; }

/* 3. Check Answer button and two feedback rows */
.intro-mini-btn {
    margin-bottom: 8px;
    padding: 7px 10px;
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
}

.intro-mini-fb {
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
}

.intro-mini-fb:last-child {
    margin-bottom: 0;
}

.intro-mini-fb.ok  { color: #3dd68c; }
.intro-mini-fb.bad { color: #e53935; }

/* ---- start button ---- */
.intro-modal-start {
    display: block;
    margin: 22px 0 0 auto;
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 26px;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
    touch-action: manipulation;
}

.intro-modal-start:hover {
    background: #ffbb2e;
}

.intro-modal-start:active {
    transform: scale(0.98);
}

@keyframes introFadeIn {
    to { opacity: 1; }
}

@keyframes introScaleUp {
    to { transform: scale(1); }
}

/* Phones, portrait: ultra-compact to avoid scrolling. */
@media (max-width: 600px) {
    .intro-modal-overlay {
        padding: 6px;
    }
    .intro-modal-content {
        padding: 12px 10px 10px;
        border-width: 2px;
        border-radius: 12px;
    }
    .intro-modal-close {
        top: 2px;
        right: 8px;
        font-size: 1.6rem;
    }
    .intro-modal-title {
        font-size: 1.25rem;
        margin-bottom: 0;
    }
    /* Hide the subtitle on mobile to save space */
    .intro-modal-sub {
        display: none;
    }
    .intro-steps {
        gap: 8px;
    }
    .intro-step {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 4px 8px;
        padding: 8px 10px;
        border-radius: 8px;
    }
    .intro-step-num {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    .intro-step-title {
        font-size: 1rem;
        margin-bottom: 0;
    }
    .intro-step-text {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    .intro-step-art {
        grid-column: 1 / -1;
        justify-content: center;
        margin-top: 2px;
    }
    /* Shrink the illustrations so they don't dominate the screen */
    .intro-art {
        padding: 4px 8px;
    }
    .intro-mini-cond {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }
    .intro-graph {
        max-height: 60px; /* Shrink the SVG graph */
        width: auto;
    }
    .intro-mini-btn {
        padding: 4px 8px;
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    .intro-mini-fb {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }
    .intro-modal-start {
        width: 100%;
        margin-top: 8px;
        padding: 6px 12px;
        font-size: 1rem;
    }
}

/* Phones, landscape: very little height, so tighten everything. */
@media (orientation: landscape) and (max-height: 500px) {
    .intro-modal-overlay {
        padding: 4px;
    }
    .intro-modal-content {
        padding: 10px 14px;
    }
    .intro-modal-title {
        font-size: 1.15rem;
    }
    .intro-modal-sub {
        display: none;
    }
    .intro-steps {
        gap: 6px;
    }
    .intro-step {
        grid-template-columns: auto minmax(0, 1fr) 140px;
        gap: 8px;
        padding: 6px 10px;
    }
    .intro-step-art {
        grid-column: auto;
        justify-content: center;
    }
    .intro-step-num {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    .intro-step-title {
        font-size: 1rem;
    }
    .intro-step-text {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    /* Constrain the graph and text elements for landscape */
    .intro-graph {
        max-height: 50px;
        width: auto;
    }
    .intro-mini-cond {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }
    .intro-mini-btn {
        font-size: 0.8rem;
        padding: 4px 6px;
        margin-bottom: 2px;
    }
    .intro-mini-fb {
        font-size: 0.75rem;
        margin-bottom: 2px;
    }
    .intro-modal-start {
        width: auto;
        margin-top: 8px;
        padding: 6px 20px;
        font-size: 1rem;
    }
}

/* ==========================================
   ERASER OPTIONS MENU
   ========================================== */
.eraser-options-menu {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    padding: 8px 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}
.eraser-options-menu[hidden] {
    display: none !important;
}
.eraser-options-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: 4px;
}
.eraser-opt-btn {
    background: var(--bg-header);
    color: var(--text-primary);
    border: 2px solid var(--border-main);
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
}
.eraser-opt-btn:hover {
    background: #2a3144;
}
.eraser-opt-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 8px rgba(91, 156, 246, 0.4);
}

@media (max-width: 520px) {
    .eraser-options-menu {
        top: 8px;
        padding: 6px 12px;
    }
    .eraser-opt-btn {
        padding: 4px 12px;
        font-size: 0.8rem;
    }
}