#allaround:has(#wordsearch) {
    background-color: #0b9795 !important;
    background-image: var(--ct-master-background-image) !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
}

.centre-column:has(#wordsearch) > .page_title {
    box-sizing: border-box;
    height: 10%;
    padding-inline-start: 0;
}

.centre-column:has(#wordsearch) > .shared_body {
    height: 90%;
    padding-bottom: 0;
}

.wordsearch-main-panel,
#wordsearch {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
}

#wordsearch {
    padding: clamp(8px, 1.3vh, 15px) clamp(10px, 1.3vw, 20px) clamp(10px, 1.5vh, 18px);
}

.wordsearch-activity-card {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: clamp(14px, 1.8vh, 22px) clamp(15px, 1.7vw, 25px);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 128, 125, .16);
    border-radius: var(--ct-radius-panel);
    background: linear-gradient(145deg, var(--ct-surface) 0%, #fffdf8 100%);
    box-shadow: var(--ct-shadow-panel);
}

.wordsearch-summary {
    display: flex;
    flex: 0 0 auto;
    gap: clamp(18px, 3vw, 44px);
    align-items: flex-start;
    justify-content: space-between;
    padding: 0 clamp(2px, .5vw, 8px) clamp(10px, 1.4vh, 16px);
}

.wordsearch-heading-row,
.wordsearch-words-heading-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.wordsearch-instruction-block h1,
.wordsearch-words-panel h2 {
    margin: 0;
    color: #007f7c;
    font-size: clamp(24px, 2.5vw, 34px);
    font-weight: 780;
    line-height: 1.08;
}

.wordsearch-instruction-block p {
    margin: clamp(4px, .55vh, 7px) 0 0;
    color: var(--ct-muted);
    font-size: clamp(17px, 1.65vw, 23px);
    font-weight: 560;
}

.wordsearch-audio-button {
    display: grid;
    width: var(--ct-audio-prompt-size);
    min-width: var(--ct-audio-prompt-size);
    height: var(--ct-audio-prompt-size);
    padding: 0;
    place-items: center;
    border: 1px solid rgba(231, 51, 82, .24);
    border-radius: 50%;
    background: #fff3f4;
    cursor: pointer;
    transition: transform var(--ct-transition-quick), box-shadow var(--ct-transition-quick);
}

.wordsearch-audio-button img {
    width: var(--ct-audio-inline-size);
    height: var(--ct-audio-inline-size);
    pointer-events: none;
}

.wordsearch-audio-button:hover,
.wordsearch-audio-button.is-playing {
    box-shadow: 0 4px 10px rgba(32, 53, 72, .16);
    transform: translateY(-2px);
}

.wordsearch-progress {
    width: min(30%, 280px);
    min-width: 210px;
    padding-top: 2px;
}

.wordsearch-progress > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    color: var(--ct-ink);
    font-size: clamp(16px, 1.45vw, 20px);
    font-weight: 650;
}

.wordsearch-progress strong {
    color: #007f7c;
    font-size: clamp(18px, 1.75vw, 24px);
}

.wordsearch-progress-track {
    display: block;
    height: 10px;
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #dfe4e3;
}

.wordsearch-progress-track i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--ct-brand-teal);
    transition: width 320ms ease;
}

.wordsearch-case-selector {
    display: flex;
    margin: clamp(8px, 1vh, 12px) 0 0;
    padding: 0;
    align-items: center;
    justify-content: space-between;
    border: 0;
}

.wordsearch-case-selector legend {
    float: left;
    padding: 0;
    color: var(--ct-muted);
    font-size: clamp(14px, 1.25vw, 17px);
    font-weight: 650;
}

.wordsearch-case-selector > div {
    display: inline-flex;
    padding: 3px;
    border: 1px solid rgba(0, 128, 125, .2);
    border-radius: 999px;
    background: #e8eeee;
}

.wordsearch-case-selector button {
    min-width: 54px;
    min-height: 36px;
    padding: 4px 11px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ct-muted);
    cursor: pointer;
    font-size: clamp(16px, 1.4vw, 19px);
    font-weight: 760;
    line-height: 1;
    transition: background-color var(--ct-transition-quick), color var(--ct-transition-quick), box-shadow var(--ct-transition-quick);
}

.wordsearch-case-selector button.is-selected {
    background: var(--ct-brand-teal);
    box-shadow: 0 2px 6px rgba(0, 94, 91, .22);
    color: #fff;
}

.wordsearch-case-selector button:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid rgba(0, 134, 205, .38);
    outline-offset: 2px;
}

.wordsearch-content {
    display: grid;
    min-height: 0;
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1.85fr) minmax(250px, 1fr);
    gap: clamp(14px, 1.8vw, 26px);
}

.wordsearch-grid-panel,
.wordsearch-words-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid rgba(0, 128, 125, .16);
    border-radius: var(--ct-radius-card);
    background: rgba(255, 255, 255, .82);
    box-shadow: var(--ct-shadow-card);
}

.wordsearch-grid-panel {
    display: grid;
    padding: clamp(9px, 1.25vh, 15px);
    place-items: center;
}

.wordsearch {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}

.wordsearch table {
    max-width: 100%;
    max-height: 100%;
    margin: auto;
    border: 0;
    border-collapse: separate;
    border-spacing: clamp(2px, .28vmin, 4px);
    table-layout: fixed;
}

.wordsearch td {
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid rgba(32, 53, 72, .09);
    border-radius: clamp(5px, .6vmin, 9px);
    background: #fbfcfb;
    color: var(--ct-ink-strong);
    font-weight: 730;
    text-align: center;
    vertical-align: middle;
    user-select: none;
    transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

/* Long curriculum vocabulary can generate 18–20-cell grids. Reduce framing
   before reducing the puzzle, and use tighter spacing so every row remains visible. */
#wordsearch.wordsearch-large-grid .wordsearch-activity-card {
    padding-block: clamp(8px, 1vh, 11px);
}

#wordsearch.wordsearch-large-grid .wordsearch-summary {
    padding-bottom: clamp(5px, .65vh, 8px);
}

#wordsearch.wordsearch-large-grid .wordsearch-instruction-block h1 {
    font-size: clamp(22px, 3vh, 29px);
}

#wordsearch.wordsearch-large-grid .wordsearch-instruction-block p {
    margin-top: 2px;
    font-size: clamp(14px, 1.9vh, 18px);
}

#wordsearch.wordsearch-large-grid .wordsearch-grid-panel {
    padding: clamp(4px, .6vh, 7px);
}

#wordsearch.wordsearch-large-grid .wordsearch table {
    border-spacing: 1px;
}

#wordsearch.wordsearch-uppercase .wordsearch td,
#wordsearch.wordsearch-uppercase .wordsearch-word-text {
    text-transform: uppercase;
}

#wordsearch.wordsearch-lowercase .wordsearch td,
#wordsearch.wordsearch-lowercase .wordsearch-word-text {
    text-transform: lowercase;
}

.wordsearch td.highlighted {
    border-color: rgba(0, 177, 173, .45);
    background: rgba(0, 177, 173, .24);
    box-shadow: inset 0 0 0 1px rgba(0, 177, 173, .28);
}

.wordsearch td.correct {
    border-color: rgba(0, 177, 173, .3);
    background: rgba(0, 177, 173, .16);
    box-shadow: inset 0 0 0 1px rgba(0, 177, 173, .18);
}

.wordsearch td.hinted {
    border-color: #d69d00;
    background: rgba(253, 198, 82, .42);
    box-shadow: 0 0 0 4px rgba(253, 198, 82, .22);
    animation: wordsearch-hint-pulse 850ms ease-in-out 2;
}

.wordsearch-words-panel {
    display: flex;
    padding: clamp(14px, 1.6vh, 20px) clamp(15px, 1.5vw, 22px);
    flex-direction: column;
}

.wordsearch-words-panel h2 {
    flex: 1 1 auto;
    font-size: clamp(22px, 2.1vw, 30px);
}

#words {
    min-height: 0;
    margin: clamp(7px, 1vh, 12px) 0;
    padding: 0;
    flex: 1 1 auto;
    overflow: auto;
    list-style: none;
}

#words li {
    display: grid;
    min-height: var(--ct-touch-target);
    margin: 0;
    padding: 3px 7px 3px 2px;
    align-items: center;
    grid-template-columns: var(--ct-touch-target) minmax(0, 1fr) 24px;
    border-bottom: 1px solid rgba(32, 53, 72, .1);
    border-radius: 9px;
    color: var(--ct-ink-strong);
    font-size: clamp(16px, 1.48vw, 21px);
    font-weight: 650;
    transition: background-color 220ms ease;
}

.wordsearch-word-audio {
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 177, 173, .11);
    cursor: pointer;
}

.wordsearch-word-audio img {
    width: 25px;
    height: 25px;
    pointer-events: none;
}

.wordsearch-word-status {
    color: transparent;
    font-size: 18px;
    font-weight: 800;
    text-align: center;
}

#words li.is-found {
    background: rgba(0, 177, 173, .1);
}

#words li.is-found .wordsearch-word-text {
    color: #557477;
    text-decoration: line-through;
    text-decoration-color: rgba(0, 127, 124, .55);
}

#words li.is-found .wordsearch-word-status {
    color: #008f8b;
}

#words li.just-found {
    animation: wordsearch-found-pulse 620ms ease-out;
}

.wordsearch-hint-button {
    min-height: 50px;
    padding: 9px 18px;
    flex: 0 0 auto;
    border: 0;
    border-radius: 999px;
    background: var(--ct-brand-yellow);
    box-shadow: 0 5px 12px rgba(99, 78, 9, .18);
    color: #145955;
    cursor: pointer;
    font-size: clamp(17px, 1.55vw, 22px);
    font-weight: 760;
    transition: transform var(--ct-transition-quick), box-shadow var(--ct-transition-quick);
}

.wordsearch-hint-button:hover {
    box-shadow: 0 8px 16px rgba(99, 78, 9, .23);
    transform: translateY(-2px);
}

.wordsearch-audio-button:focus-visible,
.wordsearch-word-audio:focus-visible,
.wordsearch-hint-button:focus-visible {
    outline: 4px solid rgba(0, 134, 205, .36);
    outline-offset: 2px;
}

#wordsearch_marker {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
}

#wordsearch_marker i {
    position: absolute;
    left: var(--sparkle-left);
    top: var(--sparkle-top);
    color: var(--ct-brand-yellow);
    font-size: clamp(17px, 2vw, 26px);
    opacity: 0;
    animation: wordsearch-sparkle 700ms ease-out forwards;
}

@keyframes wordsearch-hint-pulse {
    50% { transform: scale(1.08); }
}

@keyframes wordsearch-found-pulse {
    45% { background: rgba(0, 177, 173, .22); }
}

@keyframes wordsearch-sparkle {
    18%, 64% { opacity: 1; transform: translateY(-5px) scale(1.1) rotate(12deg); }
    100% { opacity: 0; transform: translateY(-18px) scale(.55) rotate(34deg); }
}

@media (max-width: 850px) {
    .wordsearch-content { grid-template-columns: minmax(0, 1.55fr) minmax(220px, 1fr); gap: 10px; }
    .wordsearch-activity-card { padding-inline: 10px; }
    .wordsearch-progress { min-width: 170px; }
    .wordsearch-case-selector { align-items: flex-start; flex-direction: column; gap: 4px; }
}

@media (max-width: 700px) and (orientation: portrait) {
    .wordsearch-summary { gap: 8px; }
    .wordsearch-content { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.55fr) minmax(210px, .8fr); }
    .wordsearch-words-panel { padding: 10px 14px; }
    #words { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
}

@media (max-height: 650px) {
    .wordsearch-activity-card { padding-block: 9px; }
    .wordsearch-summary { padding-bottom: 7px; }
    .wordsearch-instruction-block p { margin-top: 2px; }
    #words li { min-height: 38px; }
    .wordsearch-word-audio { width: 32px; height: 32px; }
    .wordsearch-case-selector { margin-top: 5px; }
    .wordsearch-case-selector button { min-height: 31px; }
}

@media (max-height: 900px) and (min-width: 701px) {
    .wordsearch-activity-card { padding-block: clamp(9px, 1.2vh, 13px); }
    .wordsearch-summary { padding-bottom: clamp(7px, 1vh, 10px); }
    .wordsearch-instruction-block h1 { font-size: clamp(23px, 3.25vh, 30px); }
    .wordsearch-instruction-block p { font-size: clamp(16px, 2.25vh, 20px); }
    .wordsearch-grid-panel { padding: clamp(6px, .85vh, 10px); }
}

@media (prefers-reduced-motion: reduce) {
    .wordsearch td.hinted,
    #words li.just-found,
    #wordsearch_marker i { animation-duration: 1ms; animation-iteration-count: 1; }
}
