/* Outside the game container so legacy game sizing remains independent. */
#about .ec-activity-copy {
    box-sizing: border-box;
    width: calc(100% - 32px);
    max-width: 1040px;
    margin: 20px auto;
    padding: 20px 24px;
    color: #245777;
    background: #f0fcfc;
    border: 1px solid #b9dfea;
    border-radius: 14px;
    box-shadow: inset 0 1px 0 #fff;
    text-align: start;
    overflow-wrap: break-word;
    font-family: Arial, Helvetica, sans-serif;
}
#about .ec-activity-copy--top {
    border-top: 4px solid #4b9fc2;
    background: linear-gradient(180deg, #f0fcfc 0%, #ecf9ff 100%);
    text-align: center;
}
#about .ec-activity-copy--bottom {
    border-inline-start: 4px solid #6ab1ca;
    background: #f3fbfe;
}
#about .ec-activity-copy h1 {
    margin: 0;
    color: #176d98;
    font-family: inherit;
    font-size: clamp(18px, 2.2vw, 24px);
    font-weight: 700;
    line-height: 1.5;
}
#about .ec-activity-copy p {
    margin: 0 0 0.7em;
    color: inherit;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.8;
}
#about .ec-activity-copy p:last-child { margin-bottom: 0; }
@media (max-width: 600px) {
    #about .ec-activity-copy {
        width: calc(100% - 24px);
        margin: 12px auto;
        padding: 14px 16px;
        border-radius: 12px;
    }
}

/* Align the copy to the visible game columns, including their gap. */
:is(.page-template-slideshow, .page-template-spelling, .page-template-matching, .ec-cts-copy-layout, .page-template-readingcomp, .page-template-pairs) #jsContent > .ec-activity-copy {
    width: var(--ec-slideshow-copy-width, 100%);
    max-width: none;
    margin-left: var(--ec-slideshow-copy-left, 0px);
    margin-right: auto;
}

/* Keep the header gap outside the zoomable activity frame. */
#about .box-container:has(#jsContent > .ec-activity-copy--top) {
    margin-block-start: 0;
    padding-block-start: 10px;
}

#about #contentHook:has(#jsContent > .ec-activity-copy--top) > div > .categoryMenu {
    display: none;
}

/* Reserve room for two lines and leave clearance for the game label. */
#about #jsContent > .ec-activity-copy--top {
    display: flex;
    flex-direction: column;
    justify-content: center;
    block-size: 82px;
    margin-block: 0 50px;
    padding-block: 8px;
}

#about #jsContent > .ec-activity-copy--top h1 {
    min-block-size: 0;
    overflow: auto;
    scrollbar-width: thin;
    line-height: 1.25;
}

/* Let the heading set the gap instead of the game's legacy top margin. */
#jsContent > .ec-activity-copy--top + :is(#spellingSlideShow, #matchSlideShow, #clozy, #comprehension, #pairs) {
    margin-block-start: 0;
}

/* The reading columns can pull the whole game up through a collapsed margin. */
#jsContent > .ec-activity-copy--top + #comprehension > .game-columns-wrapper {
    margin-block-start: 0;
}

@media (max-width: 600px) {
    #about #jsContent > .ec-activity-copy--top {
        margin-block-end: 46px;
    }
}

@media (max-width: 768px) and (orientation: portrait) {
    /* Reading comprehension keeps the game label and progress in flow here. */
    .page-template-readingcomp #about #jsContent > .ec-activity-copy--top {
        margin-block-end: 10px;
    }
}

@media (max-width: 768px) {
    #about #jsContent > .ec-activity-copy--top {
        block-size: 96px;
    }

    /* The slideshow's mobile rules add a top margin to each wrapper. */
    #about .box-container:has(#jsContent > .ec-activity-copy--top),
    #about #contentHook:has(#jsContent > .ec-activity-copy--top),
    #about #jsContent:has(> .ec-activity-copy--top) {
        margin-block-start: 0 !important;
    }

    #about .box-container:has(#jsContent > .ec-activity-copy--top) {
        padding-block-start: 10px !important;
    }

    /* The mobile box-container summary rule is for excerpts, not lesson copy. */
    :is(.page-template-slideshow, .page-template-spelling, .page-template-matching, .ec-cts-copy-layout, .page-template-readingcomp, .page-template-pairs) #jsContent > .ec-activity-copy--bottom p {
        display: block;
        -webkit-line-clamp: unset;
        overflow: visible;
    }
}

@media (min-width: 769px) {
    /* Keep the frame inside its parent: 180px of padding minus the 145px shift. */
    .page-template-slideshow #about .content.practiceType #jsContent {
        min-width: min(850px, calc(100% + 35px));
    }

    /* Reserve the legacy 145px shift so the game and its copy fit the page. */
    .page-template-spelling #about .content.practiceType #jsContent {
        width: calc(100% - 145px);
    }
}

@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
    #about .box-container.ec-activity-viewport-layout {
        max-width: none;
    }

    #about .ec-activity-viewport-layout #contentHook {
        padding-inline: 0;
    }

    #about .ec-activity-viewport-layout #contentHook #jsContent {
        width: min(1137px, 100%);
        min-width: 0;
        max-width: none;
        margin-inline: auto;
        transform: none;
        zoom: var(--ec-activity-scale, 1);
    }

    .ec-activity-viewport-layout #jsContent > :is(#simpleSlideShow, #spellingSlideShow, #matchSlideShow, #clozy, #comprehension, #pairs) {
        min-height: var(--ec-activity-game-min-height, 0px);
    }

    .ec-activity-viewport-layout #jsContent > #clozy {
        max-width: none;
    }

    .ec-activity-viewport-layout #jsContent > :is(#clozy, #comprehension) .secondColom {
        width: 21%;
        flex-basis: 21%;
    }

    .ec-activity-viewport-layout #jsContent > :is(#simpleSlideShow, #spellingSlideShow, #matchSlideShow, #clozy, #comprehension, #pairs) :is(.pairColom, .secondColom) {
        min-height: max(520px, calc(var(--ec-activity-game-min-height, 0px) - var(--ec-activity-panel-bottom-space, 0px)));
    }

    /* These control rows extend below the columns. Leave room inside the first screen. */
    #simpleSlideShow > .pairColom {
        --ec-activity-panel-bottom-space: var(--ec-slideshow-control-reserve, 50px);
    }

    #matchSlideShow > .pairColom {
        --ec-activity-panel-bottom-space: 40px;
    }

    #clozy {
        --ec-activity-panel-bottom-space: 36px;
    }

    #comprehension {
        --ec-activity-panel-bottom-space: 54px;
    }

    #pairs {
        --ec-activity-panel-bottom-space: 24px;
    }
}

@media (min-width: 933px) {
    #about .ec-activity-viewport-layout #jsContent {
        --ec-slideshow-control-reserve: 50px;
        --ec-slideshow-control-extension: 44.4px;
        --ec-slideshow-board-height: calc(
            max(520px, var(--ec-activity-game-min-height, 0px) - var(--ec-slideshow-control-reserve))
            + var(--ec-slideshow-control-extension)
        );
    }

    #about .ec-activity-viewport-layout #simpleSlideShow > .pairColom {
        margin-block-end: var(--ec-slideshow-control-extension);
    }

    #about #jsContent > .ec-activity-copy--top + :is(#matchSlideShow, #spellingSlideShow, #clozy, #comprehension) :is(.pairColom, .secondColom) {
        min-height: var(--ec-slideshow-board-height, 520px);
    }

    /* Matching's floating controls should meet the panel's bottom edge. */
    #about #jsContent > .ec-activity-copy--top + #matchSlideShow > .controllBar {
        margin-block-start: -57px;
    }

    /* Overlap the columns without leaving the controls' original space below them. */
    #about #jsContent > .ec-activity-copy--top + :is(#clozy, #comprehension) > .controllBar {
        top: 0;
        margin-block-start: -36px;
    }

    #about #jsContent > .ec-activity-copy--top + :is(#clozy, #comprehension) > .controllBar.isGameOverWidth {
        margin-block-start: -57px;
    }

    #about #jsContent > .ec-activity-copy--top + #comprehension > .wrapCarousel {
        display: none;
    }

    /* The navigation bar is part of the left panel's visible height. */
    #about #jsContent.ec-activity-aligned-sidebar > :is(#simpleSlideShow, #matchSlideShow) > .secondColom {
        height: var(--ec-activity-sidebar-height);
        min-height: var(--ec-activity-sidebar-height);
    }
}

.ec-activity-size-controls {
    position: fixed;
    z-index: 999;
    inset-block-end: 16px;
    inset-inline-end: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    align-items: center;
    box-sizing: border-box;
    width: min(252px, calc(100vw - 32px));
    padding: 10px 12px;
    color: #245777;
    background: #f3fbfe;
    border: 1px solid #b9dfea;
    border-radius: 12px;
    box-shadow: 0 3px 14px rgba(36, 87, 119, 0.18);
    font: 14px/1.4 Arial, Helvetica, sans-serif;
}

.ec-activity-size-controls[hidden] {
    display: none;
}

.ec-activity-size-controls label {
    font-weight: 700;
}

.ec-activity-size-controls output {
    direction: ltr;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.ec-activity-size-controls input {
    width: 100%;
    min-width: 0;
    margin: 0;
    accent-color: #176d98;
}

.ec-activity-size-controls button {
    padding: 2px 8px;
    color: #176d98;
    background: #fff;
    border: 1px solid #b9dfea;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}
