/* =========================================================
   Long Division Practice Tool
   /interactive-learning-tools/long-division/long-division.css
   ========================================================= */


/* =========================================================
   Page Variables
   ========================================================= */

.long-division-page
{
    --ld-teal: #0f766e;
    --ld-teal-dark: #115e59;
    --ld-teal-light: #ccfbf1;
    --ld-teal-pale: #f0fdfa;

    --ld-blue: #2563eb;
    --ld-blue-light: #dbeafe;

    --ld-green: #15803d;
    --ld-green-light: #dcfce7;

    --ld-red: #b91c1c;
    --ld-red-light: #fee2e2;

    --ld-orange: #c2410c;
    --ld-orange-light: #ffedd5;

    --ld-purple: #7e22ce;
    --ld-purple-light: #f3e8ff;

    --ld-text: #172033;
    --ld-text-muted: #64748b;
    --ld-border: #dbe3ec;
    --ld-border-dark: #b8c4d2;

    --ld-background: #f6f8fb;
    --ld-card: #ffffff;

    --ld-shadow:
        0 18px 45px rgba(15, 23, 42, 0.10);

    --ld-shadow-small:
        0 8px 24px rgba(15, 23, 42, 0.08);

    --ld-radius-large: 24px;
    --ld-radius-medium: 16px;
    --ld-radius-small: 10px;

    color: var(--ld-text);
    font-family: "Inter", sans-serif;
}


/* =========================================================
   General Tool Section
   ========================================================= */

.ld-section
{
    padding: 5rem 1.5rem;
    background:
        radial-gradient(
            circle at top left,
            rgba(15, 118, 110, 0.08),
            transparent 30rem
        ),
        var(--ld-background);
}

.ld-app
{
    width: min(100%, 1040px);
    margin: 0 auto;
}

.ld-intro
{
    max-width: 760px;
    margin: 0 auto 2rem;
    text-align: center;
}

.ld-eyebrow
{
    margin: 0 0 0.65rem;
    color: var(--ld-teal);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.ld-intro h2,
.ld-method-heading h2
{
    margin: 0 0 0.9rem;
    color: var(--ld-text);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    line-height: 1.15;
}

.ld-intro p:not(.ld-eyebrow),
.ld-method-heading p:not(.ld-eyebrow)
{
    margin: 0;
    color: var(--ld-text-muted);
    font-size: 1.05rem;
    line-height: 1.75;
}


/* =========================================================
   Practice Controls
   ========================================================= */

.ld-controls
{
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-medium);
    box-shadow: var(--ld-shadow-small);
}

.ld-control-group
{
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.45rem;
    max-width: 480px;
}

.ld-control-group label
{
    color: var(--ld-text);
    font-size: 0.9rem;
    font-weight: 700;
}

.ld-select
{
    width: 100%;
    min-height: 48px;
    padding: 0.75rem 2.75rem 0.75rem 0.95rem;
    color: var(--ld-text);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    background-color: #ffffff;
    border: 1px solid var(--ld-border-dark);
    border-radius: var(--ld-radius-small);
    cursor: pointer;
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.ld-select:focus
{
    border-color: var(--ld-teal);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.ld-secondary-button
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-height: 48px;
    padding: 0.75rem 1.15rem;
    color: var(--ld-teal-dark);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    background: var(--ld-teal-pale);
    border: 1px solid rgba(15, 118, 110, 0.35);
    border-radius: var(--ld-radius-small);
    cursor: pointer;
    white-space: nowrap;
    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
}

.ld-secondary-button:hover
{
    background: var(--ld-teal-light);
    border-color: var(--ld-teal);
    transform: translateY(-1px);
}

.ld-secondary-button:active
{
    transform: translateY(0);
}

.ld-secondary-button svg
{
    width: 17px;
    height: 17px;
}


/* =========================================================
   Progress
   ========================================================= */

.ld-progress-area
{
    margin-bottom: 1.25rem;
    padding: 1.15rem 1.25rem;
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-medium);
    box-shadow: var(--ld-shadow-small);
}

.ld-progress-text
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.65rem;
    color: var(--ld-text-muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.ld-progress-track
{
    width: 100%;
    height: 11px;
    overflow: hidden;
    background: #e7edf3;
    border-radius: 999px;
}

.ld-progress-bar
{
    width: 10%;
    height: 100%;
    background:
        linear-gradient(
            90deg,
            var(--ld-teal),
            #14b8a6
        );
    border-radius: inherit;
    transition: width 0.4s ease;
}


/* =========================================================
   Main Practice Card
   ========================================================= */

.ld-card
{
    position: relative;
    overflow: hidden;
    padding: clamp(1.25rem, 4vw, 2.25rem);
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-large);
    box-shadow: var(--ld-shadow);
}

.ld-card::before
{
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 5px;
    background:
        linear-gradient(
            90deg,
            var(--ld-teal),
            #2dd4bf,
            var(--ld-blue)
        );
    content: "";
}

.ld-card-header
{
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.ld-card-label
{
    margin: 0 0 0.35rem;
    color: var(--ld-teal);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ld-problem-description
{
    margin: 0;
    color: var(--ld-text);
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 700;
}

.ld-step-badge
{
    flex-shrink: 0;
    padding: 0.5rem 0.8rem;
    color: var(--ld-teal-dark);
    font-size: 0.78rem;
    font-weight: 800;
    background: var(--ld-teal-light);
    border-radius: 999px;
}


/* =========================================================
   Long Division Workspace
   ========================================================= */

.ld-workspace
{
    display: flex;
    justify-content: center;
    min-height: 275px;
    margin-bottom: 1.5rem;
    padding: clamp(1.4rem, 5vw, 2.25rem);
    overflow-x: auto;
    background:
        linear-gradient(
            rgba(37, 99, 235, 0.045) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(37, 99, 235, 0.045) 1px,
            transparent 1px
        ),
        #fbfdff;
    background-size: 28px 28px;
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-medium);
}

.ld-problem-display
{
    display: inline-flex;
    min-width: max-content;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0.5rem;
    color: var(--ld-text);
    font-family:
        "Courier New",
        Courier,
        monospace;
    font-size: clamp(1.8rem, 7vw, 3.4rem);
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.ld-quotient-row
{
    min-height: 1.2em;
    margin-left: 1.65em;
    padding: 0 0.25em 0.1em;
    letter-spacing: 0.16em;
    white-space: pre;
}

.ld-placeholder-digit
{
    visibility: hidden;
}

.ld-division-expression
{
    display: flex;
    align-items: flex-start;
}

.ld-divisor
{
    min-width: 1.4em;
    padding-top: 0.14em;
    padding-right: 0.22em;
    text-align: right;
}

.ld-dividend
{
    min-width: 3em;
    padding: 0.12em 0.25em 0.08em 0.32em;
    letter-spacing: 0.16em;
    border-top: 0.09em solid currentColor;
    border-left: 0.09em solid currentColor;
    border-top-left-radius: 0.22em;
    white-space: pre;
}

.ld-work-rows
{
    width: calc(100% - 1.65em);
    margin-left: 1.65em;
    padding-right: 0.25em;
    letter-spacing: 0.16em;
}

.ld-work-row
{
    display: flex;
    justify-content: flex-end;
    min-height: 1.15em;
    white-space: pre;
}

.ld-work-row-product
{
    position: relative;
    padding-bottom: 0.08em;
}

.ld-work-row-product::after
{
    position: absolute;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 0.07em;
    background: currentColor;
    content: "";
}



.ld-work-row-remainder
{
    color: var(--ld-purple);
}

.ld-work-digit-current
{
    color: var(--ld-blue);
}

.ld-work-digit-correct
{
    color: var(--ld-green);
}

.ld-work-digit-new
{
    display: inline-block;
    animation: ld-digit-enter 0.3s ease;
}

@keyframes ld-digit-enter
{
    from
    {
        opacity: 0;
        transform: translateY(-8px);
    }

    to
    {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================================================
   Current Step Panel
   ========================================================= */

.ld-step-panel
{
    margin-bottom: 1.25rem;
    padding: 1.3rem 1.4rem;
    background:
        linear-gradient(
            135deg,
            var(--ld-teal-pale),
            #f8fafc
        );
    border: 1px solid rgba(15, 118, 110, 0.2);
    border-radius: var(--ld-radius-medium);
}

.ld-step-type
{
    display: inline-flex;
    margin: 0 0 0.55rem;
    padding: 0.35rem 0.65rem;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--ld-teal);
    border-radius: 999px;
}

.ld-step-prompt
{
    margin: 0;
    color: var(--ld-text);
    font-size: clamp(1.15rem, 3vw, 1.55rem);
    font-weight: 800;
    line-height: 1.35;
}

.ld-step-hint
{
    margin: 0.7rem 0 0;
    color: var(--ld-text-muted);
    font-size: 0.92rem;
    line-height: 1.65;
}

.ld-step-hint[hidden]
{
    display: none;
}


/* =========================================================
   Answer Form
   ========================================================= */

.ld-answer-form
{
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1rem;
}

.ld-answer-input
{
    flex: 1;
    min-width: 0;
    min-height: 54px;
    padding: 0.85rem 1rem;
    color: var(--ld-text);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    background: #ffffff;
    border: 2px solid var(--ld-border-dark);
    border-radius: var(--ld-radius-small);
    outline: none;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease;
}

.ld-answer-input::placeholder
{
    color: #94a3b8;
    font-weight: 500;
}

.ld-answer-input:focus
{
    border-color: var(--ld-teal);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

.ld-answer-input.is-correct
{
    background: var(--ld-green-light);
    border-color: var(--ld-green);
}

.ld-answer-input.is-incorrect
{
    background: var(--ld-red-light);
    border-color: var(--ld-red);
    animation: ld-shake 0.28s ease;
}

@keyframes ld-shake
{
    0%,
    100%
    {
        transform: translateX(0);
    }

    25%
    {
        transform: translateX(-5px);
    }

    75%
    {
        transform: translateX(5px);
    }
}

.ld-submit-button
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0.85rem 1.35rem;
    color: #ffffff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 800;
    background:
        linear-gradient(
            135deg,
            var(--ld-teal),
            var(--ld-teal-dark)
        );
    border: 0;
    border-radius: var(--ld-radius-small);
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
    cursor: pointer;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        filter 0.2s ease;
}

.ld-submit-button:hover
{
    box-shadow: 0 11px 24px rgba(15, 118, 110, 0.27);
    filter: brightness(1.04);
    transform: translateY(-1px);
}

.ld-submit-button:active
{
    box-shadow: 0 6px 14px rgba(15, 118, 110, 0.2);
    transform: translateY(0);
}

.ld-submit-button:disabled,
.ld-secondary-button:disabled
{
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}


/* =========================================================
   Feedback
   ========================================================= */

.ld-feedback
{
    min-height: 50px;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    color: var(--ld-text-muted);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.55;
    background: #f8fafc;
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-small);
}

.ld-feedback.is-correct
{
    color: #166534;
    background: var(--ld-green-light);
    border-color: #86efac;
}

.ld-feedback.is-incorrect
{
    color: #991b1b;
    background: var(--ld-red-light);
    border-color: #fca5a5;
}

.ld-feedback.is-hint
{
    color: #9a3412;
    background: var(--ld-orange-light);
    border-color: #fdba74;
}

.ld-feedback.is-revealed
{
    color: #6b21a8;
    background: var(--ld-purple-light);
    border-color: #d8b4fe;
}


/* =========================================================
   Attempts and Help Actions
   ========================================================= */

.ld-card-actions
{
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.ld-attempts
{
    margin-right: auto;
    color: var(--ld-text-muted);
    font-size: 0.86rem;
}

.ld-attempts strong
{
    color: var(--ld-text);
}

.ld-text-button
{
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0;
    color: var(--ld-teal);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 750;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}

.ld-text-button:hover
{
    color: var(--ld-teal-dark);
    text-decoration: underline;
}

.ld-text-button:disabled
{
    color: #94a3b8;
    cursor: not-allowed;
    text-decoration: none;
}

.ld-text-button svg
{
    width: 16px;
    height: 16px;
}


/* =========================================================
   Problem Completion
   ========================================================= */

.ld-problem-complete
{
    margin-top: 1.5rem;
    padding: 1.5rem;
    text-align: center;
    background:
        linear-gradient(
            135deg,
            var(--ld-green-light),
            #f0fdf4
        );
    border: 1px solid #86efac;
    border-radius: var(--ld-radius-medium);
}

.ld-problem-complete[hidden]
{
    display: none;
}

.ld-complete-label
{
    margin: 0 0 0.45rem;
    color: var(--ld-green);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.ld-problem-complete h3
{
    margin: 0;
    color: #14532d;
    font-size: clamp(1.35rem, 4vw, 1.9rem);
    font-weight: 800;
}

.ld-problem-complete p:not(.ld-complete-label)
{
    margin: 0.65rem 0 1.15rem;
    color: #3f6212;
}


/* =========================================================
   Statistics
   ========================================================= */

.ld-stats
{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.ld-stat
{
    padding: 1.15rem;
    text-align: center;
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-medium);
    box-shadow: var(--ld-shadow-small);
}

.ld-stat span
{
    display: block;
    min-height: 2.5em;
    margin-bottom: 0.4rem;
    color: var(--ld-text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
}

.ld-stat strong
{
    display: block;
    color: var(--ld-teal-dark);
    font-size: 1.75rem;
    font-weight: 800;
}


/* =========================================================
   Results
   ========================================================= */

.ld-results
{
    margin-top: 1.25rem;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    text-align: center;
    background: var(--ld-card);
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-large);
    box-shadow: var(--ld-shadow);
}

.ld-results[hidden]
{
    display: none;
}

.ld-results-label
{
    margin: 0 0 0.45rem;
    color: var(--ld-teal);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.ld-results h2
{
    margin: 0;
    color: var(--ld-text);
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 800;
}

.ld-results-message
{
    margin: 0.7rem 0 1.5rem;
    color: var(--ld-text-muted);
}

.ld-results-grid
{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.ld-result-item
{
    padding: 1.15rem;
    background: #f8fafc;
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-medium);
}

.ld-result-item span
{
    display: block;
    min-height: 2.5em;
    margin-bottom: 0.4rem;
    color: var(--ld-text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.ld-result-item strong
{
    display: block;
    color: var(--ld-text);
    font-size: 1.7rem;
    font-weight: 800;
}

.ld-result-accuracy
{
    background: var(--ld-teal-pale);
    border-color: rgba(15, 118, 110, 0.25);
}

.ld-result-accuracy strong
{
    color: var(--ld-teal-dark);
}


/* =========================================================
   Information Cards
   ========================================================= */

.ld-info
{
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
    padding-top: 5rem;
    padding-bottom: 5rem;
}

.ld-info article
{
    padding: 1.65rem;
    background: #ffffff;
    border: 1px solid var(--ld-border);
    border-radius: var(--ld-radius-medium);
    box-shadow: var(--ld-shadow-small);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

.ld-info article:hover
{
    border-color: rgba(15, 118, 110, 0.35);
    box-shadow: var(--ld-shadow);
    transform: translateY(-4px);
}

.ld-info-icon
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin-bottom: 1rem;
    color: var(--ld-teal);
    background: var(--ld-teal-light);
    border-radius: 13px;
}

.ld-info-icon svg
{
    width: 22px;
    height: 22px;
}

.ld-info h2
{
    margin: 0 0 0.7rem;
    color: var(--ld-text);
    font-size: 1.15rem;
    font-weight: 800;
}

.ld-info p
{
    margin: 0;
    color: var(--ld-text-muted);
    font-size: 0.94rem;
    line-height: 1.7;
}


/* =========================================================
   Long Division Method Section
   ========================================================= */

.ld-method-section
{
    padding: 5rem 0;
    background:
        linear-gradient(
            135deg,
            #f0fdfa,
            #eff6ff
        );
}

.ld-method-content
{
    max-width: 1050px;
    margin: 0 auto;
}

.ld-method-heading
{
    max-width: 750px;
    margin: 0 auto 2.25rem;
    text-align: center;
}

.ld-method-grid
{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.ld-method-step
{
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.4rem;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(15, 118, 110, 0.15);
    border-radius: var(--ld-radius-medium);
    box-shadow: var(--ld-shadow-small);
}

.ld-method-number
{
    display: inline-flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    background:
        linear-gradient(
            135deg,
            var(--ld-teal),
            #14b8a6
        );
    border-radius: 50%;
}

.ld-method-step h3
{
    margin: 0 0 0.4rem;
    color: var(--ld-text);
    font-size: 1.05rem;
    font-weight: 800;
}

.ld-method-step p
{
    margin: 0;
    color: var(--ld-text-muted);
    font-size: 0.9rem;
    line-height: 1.65;
}


/* =========================================================
   SEO Section
   ========================================================= */

.ld-seo-section
{
    padding: 5rem 0;
    background: #ffffff;
}

.ld-seo-content
{
    max-width: 900px;
    margin: 0 auto;
}

.ld-seo-content h2
{
    margin: 0 0 1rem;
    color: var(--ld-text);
    font-size: clamp(1.7rem, 4vw, 2.35rem);
    font-weight: 800;
    line-height: 1.2;
}

.ld-seo-content h3
{
    margin: 2rem 0 0.7rem;
    color: var(--ld-text);
    font-size: 1.25rem;
    font-weight: 800;
}

.ld-seo-content p
{
    margin: 0 0 1rem;
    color: var(--ld-text-muted);
    font-size: 1rem;
    line-height: 1.8;
}

.ld-seo-links
{
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.ld-resource-link
{
    color: var(--ld-teal);
    font-weight: 700;
    text-decoration: none;
}

.ld-resource-link:hover
{
    color: var(--ld-teal-dark);
    text-decoration: underline;
}


/* =========================================================
   Utility and State Classes
   ========================================================= */

.ld-card.is-complete .ld-step-panel,
.ld-card.is-complete .ld-answer-form,
.ld-card.is-complete .ld-feedback,
.ld-card.is-complete .ld-card-actions
{
    display: none;
}

.ld-card.is-loading
{
    pointer-events: none;
}

.ld-card.is-loading::after
{
    position: absolute;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    color: var(--ld-teal);
    font-weight: 800;
    background: rgba(255, 255, 255, 0.82);
    content: "Loading problem…";
}

.ld-screen-reader-text
{
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* =========================================================
   Tablet Layout
   ========================================================= */

@media (max-width: 900px)
{
    .ld-stats,
    .ld-results-grid
    {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ld-info
    {
        grid-template-columns: 1fr;
    }

    .ld-info article
    {
        max-width: 720px;
        width: 100%;
        margin: 0 auto;
    }
}


/* =========================================================
   Mobile Layout
   ========================================================= */

@media (max-width: 700px)
{
    .ld-section
    {
        padding: 3.5rem 1rem;
    }

    .ld-controls
    {
        align-items: stretch;
        flex-direction: column;
    }

    .ld-control-group
    {
        max-width: none;
    }

    .ld-secondary-button
    {
        width: 100%;
    }

    .ld-card
    {
        padding: 1.25rem;
        border-radius: 18px;
    }

    .ld-card-header
    {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .ld-step-badge
    {
        align-self: flex-start;
    }

    .ld-workspace
    {
        min-height: 230px;
        justify-content: flex-start;
        padding: 1.5rem 1rem;
    }

    .ld-problem-display
    {
        margin: 0 auto;
    }

    .ld-answer-form
    {
        flex-direction: column;
    }

    .ld-submit-button
    {
        width: 100%;
    }

    .ld-card-actions
    {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.75rem;
    }

    .ld-attempts
    {
        margin-right: 0;
    }

    .ld-method-grid
    {
        grid-template-columns: 1fr;
    }

    .ld-method-section,
    .ld-seo-section
    {
        padding: 3.75rem 0;
    }

    .ld-info
    {
        padding-top: 3.75rem;
        padding-bottom: 3.75rem;
    }
}


/* =========================================================
   Small Mobile Layout
   ========================================================= */

@media (max-width: 480px)
{
    .ld-section
    {
        padding-right: 0.75rem;
        padding-left: 0.75rem;
    }

    .ld-progress-area,
    .ld-controls
    {
        padding: 1rem;
    }

    .ld-card
    {
        padding: 1rem;
    }

    .ld-workspace
    {
        min-height: 205px;
        padding: 1.25rem 0.65rem;
    }

    .ld-problem-display
    {
        font-size: clamp(1.65rem, 9vw, 2.4rem);
    }

    .ld-step-panel
    {
        padding: 1.1rem;
    }

    .ld-stats,
    .ld-results-grid
    {
        grid-template-columns: 1fr 1fr;
        gap: 0.7rem;
    }

    .ld-stat,
    .ld-result-item
    {
        padding: 0.9rem 0.65rem;
    }

    .ld-stat span,
    .ld-result-item span
    {
        min-height: 3em;
        font-size: 0.7rem;
    }

    .ld-stat strong,
    .ld-result-item strong
    {
        font-size: 1.45rem;
    }

    .ld-method-step
    {
        padding: 1.15rem;
    }

    .ld-method-number
    {
        flex-basis: 38px;
        width: 38px;
        height: 38px;
    }
}


/* =========================================================
   Reduced Motion
   ========================================================= */

@media (prefers-reduced-motion: reduce)
{
    .long-division-page *,
    .long-division-page *::before,
    .long-division-page *::after
    {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================
   Long Division Calculation Rows
   ========================================================= */

.ld-work-rows
{
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch;
    width: calc(100% - 1.65em);
    margin-left: 1.65em;
    padding-right: 0.25em;
    letter-spacing: 0.16em;
}

.ld-work-row
{
    display: block !important;
    width: 100%;
    min-height: 1.15em;
    margin: 0;
    padding: 0;
    text-align: left;
    white-space: pre;
}

.ld-work-row-product
{
    position: relative;
    padding-bottom: 0.12em;
}

.ld-work-row-product::before
{
    content: "−";
    position: absolute;
    left: -0.65em;
}

.ld-work-row-product::after
{
    position: absolute;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 0.07em;
    background: currentColor;
    content: "";
}

.ld-work-row-remainder
{
    color: var(--ld-purple);
}

.ld-work-row-bring-down
{
    color: var(--ld-blue);
}

.ld-work-digit-current
{
    color: var(--ld-blue);
}

.ld-work-digit-correct
{
    color: var(--ld-green);
}

.ld-work-digit-new
{
    animation: ld-digit-enter 0.3s ease;
}

/* =========================================================
   Fixed-Column Long Division Layout
   ========================================================= */

.ld-problem-display
{
    --ld-digit-width: 1.18em;
    --ld-divisor-width: 1.45em;
    --ld-column-count: 4;

    display: inline-flex;
    min-width: max-content;
    flex-direction: column;
    align-items: flex-start;
    padding-top: 0.5rem;
    color: var(--ld-text);
    font-family:
        "Courier New",
        Courier,
        monospace;
    font-size: clamp(1.8rem, 7vw, 3.4rem);
    font-weight: 700;
    line-height: 1.08;
    font-variant-numeric: tabular-nums;
}


/* =========================================================
   Quotient
   ========================================================= */

.ld-quotient-row
{
    display: grid;
    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        );
    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        );
    min-height: 1.1em;
    margin-left: var(--ld-divisor-width);
    padding-bottom: 0.08em;
}

.ld-quotient-digit
{
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ld-digit-width);
    min-width: var(--ld-digit-width);
}


/* =========================================================
   Divisor and Dividend
   ========================================================= */

.ld-division-expression
{
    display: flex;
    align-items: stretch;
}

.ld-divisor
{
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: var(--ld-divisor-width);
    min-width: var(--ld-divisor-width);
    padding-right: 0.18em;
}

.ld-dividend
{
    display: grid;
    position: relative;
    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        );
    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        );
    padding-top: 0.1em;
    border-top: 0.08em solid currentColor;
    border-left: 0.08em solid currentColor;
    border-top-left-radius: 0.2em;
}

.ld-dividend-digit
{
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ld-digit-width);
    min-width: var(--ld-digit-width);
}


/* =========================================================
   Work Rows
   ========================================================= */

.ld-work-rows
{
    display: flex;
    flex-direction: column;
    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        );
    margin-left: var(--ld-divisor-width);
    padding: 0;
}

.ld-work-row
{
    display: grid;
    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        );
    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        );
    min-height: 1.12em;
    margin: 0;
    padding: 0;
}

.ld-number-segment
{
    display: grid;
    position: relative;
    grid-template-columns:
        repeat(
            var(--ld-segment-columns, 1),
            var(--ld-digit-width)
        );
    width: max-content;
}

.ld-work-digit
{
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ld-digit-width);
    min-width: var(--ld-digit-width);
}


/* =========================================================
   Product and Subtraction Line
   ========================================================= */

.ld-product-segment
{
    padding-bottom: 0.12em;
}

.ld-product-segment::before
{
    position: absolute;
    top: 0;
    right: 100%;
    margin-right: 0.02em;
    content: "−";
}

.ld-product-segment::after
{
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 0.065em;
    background: currentColor;
    content: "";
}


/* =========================================================
   Remainders and Brought-Down Numbers
   ========================================================= */

.ld-remainder-segment,
.ld-final-remainder-segment
{
    color: var(--ld-purple);
}

.ld-partial-segment
{
    color: var(--ld-purple);
}

.ld-partial-segment .ld-brought-down-digit
{
    color: var(--ld-blue);
}


/* =========================================================
   Row Animation
   ========================================================= */

.ld-work-row-new
{
    animation: ld-digit-enter 0.3s ease;
}

/* =========================================================
   FINAL LONG-DIVISION ALIGNMENT OVERRIDES
   Keep this block at the end of long-division.css
   ========================================================= */


/*
 * Every work row uses the same fixed digit columns
 * as the dividend.
 */
.ld-work-rows
{
    display: flex !important;
    flex-direction: column !important;

    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        ) !important;

    margin-left: var(--ld-divisor-width) !important;
    padding: 0 !important;
    letter-spacing: 0 !important;
}


.ld-work-row
{
    display: grid !important;

    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        ) !important;

    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        ) !important;

    min-height: 1.12em;
    margin: 0 !important;
    padding: 0 !important;

    text-align: initial !important;
}


/*
 * Remove all older row-level minus signs and bars.
 */
.ld-work-row-product::before,
.ld-work-row-product::after
{
    display: none !important;
    content: none !important;
}


/*
 * The number segment is positioned in the exact dividend
 * columns assigned by JavaScript.
 */
.ld-number-segment
{
    position: relative;

    display: grid !important;

    grid-template-columns:
        repeat(
            var(--ld-segment-columns),
            var(--ld-digit-width)
        ) !important;

    width:
        calc(
            var(--ld-segment-columns) *
            var(--ld-digit-width)
        ) !important;

    margin: 0 !important;
    padding: 0 !important;

    letter-spacing: 0 !important;
}


/*
 * Each digit occupies exactly one fixed-width column.
 */
.ld-work-digit
{
    display: flex;
    align-items: center;
    justify-content: center;

    width: var(--ld-digit-width) !important;
    min-width: var(--ld-digit-width) !important;

    margin: 0 !important;
    padding: 0 !important;
}


/*
 * Attach the minus sign directly to the product segment.
 *
 * For 1164 ÷ 4, the 8 will occupy dividend column 2,
 * directly beneath the second 1.
 */
.ld-product-segment::before
{
    position: absolute !important;
    top: 0;
    right: 100%;
    left: auto !important;

    display: block !important;

    margin-right: 0.04em;

    content: "−" !important;
}


/*
 * Draw the subtraction bar only across the product itself.
 *
 * A one-digit product such as 8 gets a one-digit bar.
 * A two-digit product such as 32 gets a two-digit bar.
 */
.ld-product-segment::after
{
    position: absolute !important;
    right: 0 !important;
    bottom: 0;
    left: 0 !important;

    display: block !important;

    width: auto !important;
    height: 0.065em;

    background: currentColor;

    content: "" !important;
}


.ld-product-segment
{
    position: relative;
    padding: 0 0 0.13em !important;
}

/* =========================================================
   Product Rows
   ========================================================= */

.ld-product-segment
{
    position: relative;

    display: grid;

    grid-template-columns:
        repeat(
            var(--ld-segment-columns),
            var(--ld-digit-width)
        );

    width:
        calc(
            var(--ld-segment-columns) *
            var(--ld-digit-width)
        );

    padding-bottom: 0.13em;
}


/*
 * The minus sign begins immediately to the left of the
 * entire subtraction segment, not merely beside the
 * first visible product digit.
 */
.ld-product-segment::before
{
    position: absolute;
    top: 0;
    right: 100%;

    margin-right: 0.04em;

    content: "−";
}


/*
 * The line spans the complete partial-dividend width.
 *
 * For 14 − 9, it spans two columns.
 * For 57 − 54, it spans two columns.
 * For 8 − 8, it spans one column.
 */
.ld-product-segment::after
{
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;

    height: 0.065em;

    background: currentColor;

    content: "";
}

/* =========================================================
   LONG DIVISION COLUMN ALIGNMENT
   Keep this at the very end of long-division.css
   ========================================================= */

.ld-problem-display
{
    /*
     * One shared width for every invisible digit column.
     */
    --ld-digit-width: 1.18em;
    --ld-divisor-width: 1.45em;

    letter-spacing: 0 !important;
}


/* =========================================================
   Quotient Columns
   ========================================================= */

.ld-quotient-row
{
    display: grid !important;

    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        ) !important;

    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        ) !important;

    margin-left: var(--ld-divisor-width) !important;
    padding: 0 0 0.08em !important;

    letter-spacing: 0 !important;
}

.ld-quotient-digit
{
    display: flex !important;
    align-items: center;
    justify-content: center;

    width: var(--ld-digit-width) !important;
    min-width: var(--ld-digit-width) !important;
    max-width: var(--ld-digit-width) !important;

    margin: 0 !important;
    padding: 0 !important;

    letter-spacing: 0 !important;
}


/* =========================================================
   Divisor and Dividend Columns
   ========================================================= */

.ld-division-expression
{
    display: flex !important;
    align-items: stretch;
}

.ld-divisor
{
    display: flex !important;
    align-items: center;
    justify-content: flex-end;

    width: var(--ld-divisor-width) !important;
    min-width: var(--ld-divisor-width) !important;
    max-width: var(--ld-divisor-width) !important;

    margin: 0 !important;
    padding: 0 0.18em 0 0 !important;

    letter-spacing: 0 !important;
}

.ld-dividend
{
    display: grid !important;

    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        ) !important;

    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        ) !important;

    margin: 0 !important;
    padding: 0.1em 0 0 0 !important;

    letter-spacing: 0 !important;
}

.ld-dividend-digit
{
    display: flex !important;
    align-items: center;
    justify-content: center;

    width: var(--ld-digit-width) !important;
    min-width: var(--ld-digit-width) !important;
    max-width: var(--ld-digit-width) !important;

    margin: 0 !important;
    padding: 0 !important;

    letter-spacing: 0 !important;
}


/* =========================================================
   Work-Row Columns
   ========================================================= */

.ld-work-rows
{
    display: flex !important;
    flex-direction: column !important;

    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        ) !important;

    margin-left: var(--ld-divisor-width) !important;
    padding: 0 !important;

    letter-spacing: 0 !important;
}

.ld-work-row
{
    display: grid !important;

    grid-template-columns:
        repeat(
            var(--ld-column-count),
            var(--ld-digit-width)
        ) !important;

    width:
        calc(
            var(--ld-column-count) *
            var(--ld-digit-width)
        ) !important;

    min-height: 1.12em;

    margin: 0 !important;
    padding: 0 !important;

    letter-spacing: 0 !important;
}


/* =========================================================
   Number Segments
   ========================================================= */

.ld-number-segment
{
    display: grid !important;
    position: relative;

    grid-template-columns:
        repeat(
            var(--ld-segment-columns),
            var(--ld-digit-width)
        ) !important;

    width:
        calc(
            var(--ld-segment-columns) *
            var(--ld-digit-width)
        ) !important;

    margin: 0 !important;
    padding-right: 0 !important;
    padding-left: 0 !important;

    letter-spacing: 0 !important;
}

.ld-work-digit
{
    display: flex !important;
    align-items: center;
    justify-content: center;

    width: var(--ld-digit-width) !important;
    min-width: var(--ld-digit-width) !important;
    max-width: var(--ld-digit-width) !important;

    margin: 0 !important;
    padding: 0 !important;

    letter-spacing: 0 !important;
}


/* =========================================================
   Product Decoration
   ========================================================= */

.ld-product-segment
{
    padding-bottom: 0.13em !important;
}

.ld-product-segment::before
{
    top: 0 !important;
    right: 100% !important;
    left: auto !important;

    margin-right: 0.04em !important;
}

.ld-product-segment::after
{
    right: 0 !important;
    left: 0 !important;

    width: auto !important;
}


/* =========================================================
   Remove Old Row-Level Decorations
   ========================================================= */

.ld-work-row-product::before,
.ld-work-row-product::after
{
    display: none !important;
    content: none !important;
}

.ld-zero-remainder-digit
{
    color: var(--ld-purple);
}

.ld-brought-down-digit
{
    color: var(--ld-blue);
}

/* =========================================================
   Bring-Down Arrow Animation
   ========================================================= */

.ld-brought-down-digit
{
    position: relative;
    color: var(--ld-blue);
    overflow: visible;
}


/*
 * The arrow appears directly above the digit that was
 * brought down, moves downward slightly, and fades away.
 */



@keyframes ld-bring-down-arrow
{
    0%
    {
        opacity: 0;
        transform: translate(-50%, -1em);
    }

    18%
    {
        opacity: 1;
    }

    65%
    {
        opacity: 1;
        transform: translate(-50%, -0.2em);
    }

    100%
    {
        opacity: 0;
        transform: translate(-50%, 0.05em);
    }
}


/*
 * Ensure the arrow is not clipped by the digit rows.
 */
.ld-work-row,
.ld-number-segment,
.ld-work-digit
{
    overflow: visible;
}

.ld-brought-down-digit
{
    position: relative;
    color: var(--ld-blue);
}

.ld-brought-down-digit::before
{
    content: "↓";

    position: absolute;
    left: 50%;
    bottom: 72%;

    transform: translateX(-50%);

    color: var(--ld-blue);
    font-size: 2em;
    font-weight: 800;
    line-height: 1;

    pointer-events: none;
}

@media (max-width: 767px)
{
    .ld-brought-down-digit::before
    {
        top: -34px;
        font-size: 32px;
    }
}