/* The thinking area shares the farm's cream controls and the existing lesson shell. */
.subject-switch {display:none;position:fixed;z-index:6;top:94px;left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 24px);padding:5px;gap:5px;border:1px solid #bd965f;border-radius:19px;background:#fff5db;box-shadow:0 4px 12px #35532520;}
body:has(.game[data-stage="garden"]) .subject-switch {display:flex;}
.subject-switch button {display:flex;align-items:center;justify-content:center;gap:9px;white-space:normal;min-width:138px;min-height:46px;padding:6px 13px;border:1px solid transparent;border-radius:13px;background:transparent;color:#65472f;font-size:.97rem;font-weight:900;}
.subject-switch button[aria-pressed="true"] {background:#e7f2d0;border-color:#acc583;}
.subject-switch svg {width:28px;height:28px;}.subject-symbol {width:28px;font-size:1.6rem;font-weight:950;color:#54883d;line-height:1;}
.thinking-visual {display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;width:200px;height:170px;flex-shrink:0;}
.thinking-visual>svg {width:100%;height:100%;font-family:inherit;}
.thinking-sprite {width:170px;height:170px;background:url('assets/thinking/objects.webp') 0 0/400% 300% no-repeat;}
.thinking-event {width:190px;height:190px;background:url('assets/thinking/events.webp') 0 0/300% 100% no-repeat;border-radius:14px;}
.farm-world .game .choices:has(>.thinking-choice) {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:100%;max-width:480px;gap:12px;margin-inline:auto;}
.farm-world .game .choices:has(>.thinking-choice:nth-child(2):last-child) {grid-template-columns:repeat(2,minmax(0,1fr));max-width:350px;}
.farm-world .game .thinking-choice {display:flex;width:100%;min-height:140px;aspect-ratio:1;padding:5px;border:2px solid #d6bd8b;border-radius:18px;background:#fffaeb;box-shadow:0 3px 7px #6b532015;}
.farm-world .thinking-choice>.thinking-visual {width:100%;height:100%;aspect-ratio:1;}
.farm-world .game .thinking-choice.guided {border-color:#679a47;background:#edf5d9;}
.thinking-matrix {display:grid;grid-template-columns:repeat(2,1fr);gap:6px;width:230px;height:178px;}
.thinking-cell {display:flex;align-items:center;justify-content:center;min-width:0;border:1px solid #d9c79d;border-radius:12px;background:#fffaf0;}
.thinking-cell>.thinking-visual {width:100%;height:100%;min-width:0;}
.thinking-question-mark {font-size:2rem;font-weight:950;color:#9d6a3f;}
.thinking-sequence {display:flex;gap:6px;width:min(100%,330px);height:80px;}
.thinking-sequence .thinking-cell {flex:1;}.thinking-sequence .thinking-cell>.thinking-visual {width:65px;height:70px;}
.thinking-operation {display:flex;width:100%;height:auto;min-height:120px;gap:9px;justify-content:center;align-items:center;}
.thinking-operation>.thinking-visual {width:100px;height:100px;}
.thinking-op,.thinking-equals {font-size:1.65rem;font-weight:950;color:#76583c;}
.thinking-token-row {display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:4px;max-width:140px;}
.thinking-operation>.thinking-token-row:only-child {max-width:260px;}
.farm-world .game .thinking-count-token {position:relative;display:flex;align-items:center;justify-content:center;width:44px;min-width:44px;height:44px;min-height:44px;padding:0;border:1px solid transparent;border-radius:12px;background:transparent;box-shadow:none;}
.thinking-count-token svg {width:42px;height:42px;}
.thinking-count-token.counted {border-color:#78a64c;background:#e4f2cd;}
.count-badge {position:absolute;right:0;bottom:-2px;min-width:16px;min-height:16px;font-size:.7rem;font-weight:950;color:#325b2e;background:#fff6dc;border-radius:50%;}
.count-badge:empty {display:none;}
.thinking-count-token.removed {opacity:.55;}
.thinking-code {flex-direction:column;width:100%;height:auto;gap:10px;}
.thinking-code-key {display:flex;justify-content:center;gap:12px;}
.thinking-key-item {display:flex;align-items:center;padding:4px 6px;border:1px solid #d4c293;border-radius:12px;background:#fff9e9;}
.thinking-key-item>.thinking-visual {width:48px;height:60px;}
.thinking-key-item .thinking-equals {font-size:1rem;}
.thinking-code-expression {display:flex;align-items:center;justify-content:center;gap:4px;}
.thinking-code-expression>.thinking-visual {width:42px;height:62px;}
.thinking-code-expression .thinking-op {font-size:1.25rem;}
.thinking-code-expression .thinking-question-mark {font-size:1.6rem;}
.farm-world .game[data-subject="math"] .answer-reveal>.thinking-visual {width:160px;height:150px;}
.farm-world .game[data-subject="math"] .thinking-keepsake {width:110px;min-height:115px;padding:3px;}
.thinking-keepsake .thinking-visual {width:100px;height:100px;}
.farm-world .garden-map .thinking-node .plant-sign {font-size:.97rem;min-width:94px;}
.farm-world .garden-map .thinking-node::before {background-position:100% 100%;}
.farm-world .garden-map .thinking-node.is-complete::before {background-position:50% 100%;}
.farm-world .garden-map .thinking-node-picture {position:absolute;top:23px;left:50%;transform:translateX(-50%);width:70px;height:70px;z-index:1;}
@media(max-width:700px){
 .subject-switch {top:80px;max-width:calc(100% - 24px);padding:4px;}
 .subject-switch button {min-width:0;min-height:44px;padding:5px 10px;gap:6px;font-size:.86rem;}
 .subject-switch svg {width:24px;height:24px;}
 .farm-world .game .thinking-choice {min-height:92px;border-radius:14px;}
 .farm-world .game .choices:has(>.thinking-choice) {gap:8px;}
 .thinking-operation {gap:5px;}
 .thinking-token-row {max-width:92px;}
 .thinking-operation>.thinking-token-row:only-child {max-width:240px;}
 .thinking-visual {max-width:100%;}
 .thinking-code-key {gap:5px;}.thinking-key-item {padding:2px 4px;}.thinking-key-item>.thinking-visual {width:43px;height:53px;}
 .thinking-code-expression>.thinking-visual {width:35px;height:54px;}
 .thinking-sequence .thinking-cell>.thinking-visual {width:54px;height:65px;}
 .thinking-keepsake .thinking-visual {width:80px;height:85px;}
 .farm-world .game[data-subject="math"] .thinking-keepsake {width:90px;min-height:95px;}
}
@media(max-height:650px){.farm-world .garden-map .thinking-node-picture{top:12px;width:57px;height:57px;}.subject-switch{top:80px;}}

.farm-world .thinking-node .plant-art {visibility:hidden;}

.farm-world .game .thinking-choice.selected {border-color:#4b9c50;background:#ddf8cf;}
.farm-world .game .thinking-choice.tried:not(.selected):not(.guided) {background:#f4f1e8;border-style:dashed;}

/* A soft preview is distinct from the persistent selected subject. */
.subject-switch button {transition:background-color 160ms ease,border-color 160ms ease,box-shadow 160ms ease;}
@media (hover:hover) and (pointer:fine) {
 .subject-switch button[aria-pressed="false"]:hover {background:#f1f6e5;border-color:#d3dfbd;box-shadow:0 0 0 3px #a6c87a14,0 0 15px 3px #91b95f30;}
}
.subject-switch button:focus-visible {outline:3px solid #54883d;outline-offset:2px;}
.lesson-navigation {display:none;position:fixed;z-index:20;top:94px;left:50%;transform:translateX(-50%);gap:8px;max-width:calc(100% - 24px);}
body:has(.game[data-stage]:not([data-stage="garden"])) .lesson-navigation {display:flex;}
.lesson-home {display:flex;align-items:center;justify-content:center;gap:7px;min-height:44px;padding:8px 12px;border:1px solid #bd965f;border-radius:14px;background:#fff5db;color:#65472f;font-weight:900;box-shadow:0 3px 10px #35532518;white-space:nowrap;}
.lesson-home svg {width:23px;height:23px;flex-shrink:0;}
.lesson-home:not(:disabled):active {transform:translateY(1px);}
@media (hover:hover) and (pointer:fine) {.lesson-home:hover {background:#edf4d9;border-color:#adc586;}}
@media(max-width:700px),(max-height:650px){.lesson-navigation{top:80px;}}
@media(max-width:400px){.lesson-home{font-size:.84rem;padding:8px 9px;gap:5px;}.lesson-navigation{gap:6px;}}
@media(prefers-reduced-motion:reduce){.subject-switch button{transition:none;}}

@media(max-height:500px){.farm-world .garden-map .thinking-node-picture{top:4px;width:48px;height:48px;}.farm-world .garden-map .thinking-node .plant-sign{font-size:.85rem;min-width:78px;}}
@media(max-height:360px){.farm-world .garden-map .thinking-node-picture{top:-2px;width:35px;height:35px;}.farm-world .garden-map .thinking-node .plant-sign{font-size:.72rem;min-width:68px;}}

.farm-world .game[data-stage]:not([data-stage="garden"]) {padding-top:152px;}
@media(max-width:900px){.farm-world .game[data-stage]:not([data-stage="garden"]) {padding-top:140px;}}

.farm-world .game[data-subject="math"] .petals i:nth-child(6){--bloom:var(--rain-orange);}
.farm-world .game[data-subject="math"] .petals i:nth-child(7){--bloom:var(--rain-green);}
@media(max-width:350px){.farm-world .game[data-subject="math"] .trail{gap:4px;}.farm-world .game[data-subject="math"] .trail li{width:17px;height:17px;}}

/* Sudoku has five equally sized choices and full 44px board targets. */
.farm-world .game[data-stage="question"][data-skill="sudoku"] .panel {display:block;}
.sudoku-grid {display:grid;grid-template-columns:repeat(5,44px);gap:4px;padding:5px;border:1px solid #bd965f;border-radius:14px;background:#eadbb6;width:max-content;}
.farm-world .game .sudoku-cell {display:flex;align-items:center;justify-content:center;width:44px;height:44px;min-width:44px;min-height:44px;margin:0;padding:2px;border:1px solid #d6bd8b;border-radius:7px;background:#fffaf0;box-shadow:none;font-size:1.2rem;font-weight:900;color:#76583c;}
.sudoku-cell .thinking-visual {width:34px;height:34px;}
.farm-world .game .sudoku-cell.sudoku-editable {background:#eaf3dc;border-color:#aec58a;}
.farm-world .game .sudoku-cell.sudoku-line {background:#fff0c9;}
.farm-world .game .sudoku-cell.sudoku-current {background:#fff0c9;border:3px solid #54883d;box-shadow:0 0 0 2px #54883d26;}
.farm-world .game[data-skill="sudoku"] .choices:has(>.thinking-choice) {display:grid;grid-template-columns:repeat(5,minmax(44px,1fr));max-width:360px;gap:4px;}
.farm-world .game[data-skill="sudoku"] .thinking-choice {aspect-ratio:auto;min-height:54px;height:58px;padding:3px;border-radius:12px;}
.farm-world .game[data-skill="sudoku"] .thinking-choice>.thinking-visual {width:100%;height:48px;}

.progress-reset {margin:12px 10px;padding:12px;border:1px solid #d9c49a;border-radius:12px;background:#fff9e8;}
.progress-reset h2 {margin:0;font-size:.9rem;color:#65472f;}
.progress-reset p {margin:8px 0;font-size:.8rem;line-height:1.5;}
.progress-reset p:empty {display:none;}
.progress-reset button {min-height:44px;width:100%;padding:8px 10px;border:1px solid #bf9e83;border-radius:10px;background:#fff1dc;color:#794b35;font-size:.82rem;font-weight:850;}
.progress-reset .reset-actions {display:flex;gap:7px;}
.progress-reset #reset-progress-cancel {background:#edf4d9;color:#4f703b;border-color:#adc586;}
.progress-reset #reset-progress-apply {background:#9b5143;color:#fffaf0;border-color:#8a493c;}
.progress-reset #reset-progress-status {color:#4f703b;font-weight:800;}

.sudoku-fill-progress {flex-basis:100%;margin:0;text-align:center;font-size:.85rem;font-weight:850;color:#4f703b;}

.thinking-code-key {flex-wrap:wrap;max-width:100%;}
.thinking-sequence-long {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));width:250px;height:132px;}
.thinking-sequence-long .thinking-cell>.thinking-visual {width:65px;height:60px;}
.thinking-equation {display:flex;flex-direction:column;width:100%;height:auto;gap:8px;}
.thinking-equation-line {display:flex;align-items:center;justify-content:center;gap:3px;max-width:100%;}
.thinking-equation-line>.thinking-visual {width:54px;height:95px;}
.thinking-equation-line .thinking-op {font-size:1.2rem;}
.thinking-equation>.thinking-token-row {max-width:240px;}

.farm-world .game .choices:has(>.thinking-choice:nth-child(4):last-child){grid-template-columns:repeat(2,minmax(0,1fr));max-width:350px;}

/* Larger codebook and expression, with a full-width panel on short landscape screens. */
.farm-world .game[data-skill="symbols"] .panel {display:block;}
.farm-world .game[data-skill="symbols"] .sample {width:100%;}
.thinking-code-key {gap:10px;}
.thinking-key-item {padding:5px 7px;gap:4px;}
.thinking-key-item>.thinking-visual {width:76px;height:78px;}
.thinking-key-item>.thinking-visual>svg,.thinking-code-expression>.thinking-visual>svg {overflow:visible;}
.thinking-code-expression {flex-wrap:wrap;gap:6px;}
.thinking-code-expression>.thinking-visual {width:68px;height:78px;}
.thinking-code-expression .thinking-op {font-size:1.8rem;}
.thinking-code-expression .thinking-question-mark {font-size:2.2rem;}
.sudoku-select-note {flex-basis:100%;margin:2px 0 7px;font-size:.85rem;color:#6d5b40;}
.farm-world .game .sudoku-cell.sudoku-conflict {background:#fff0ce;border-color:#c4964d;}
@media(max-width:700px){
 .thinking-code-key {gap:7px;}.thinking-key-item {padding:4px;gap:3px;}
 .thinking-key-item>.thinking-visual {width:64px;height:72px;}
 .thinking-code-expression {gap:4px;}
 .thinking-code-expression>.thinking-visual {width:55px;height:72px;}
 .thinking-code-expression .thinking-op {font-size:1.5rem;}
 .thinking-equation-line>.thinking-visual {width:62px;height:102px;}
}

/* Multi-step questions show the starting state and instructions, never intermediate answers. */
.farm-world .game[data-skill^="two-step"] .panel {display:block;}
.two-step-visual {width:140px;height:160px;}
.two-step-task {display:flex;flex-direction:column;width:100%;height:auto;gap:10px;}
.two-step-caption {font-size:.85rem;font-weight:900;color:#795c40;}
.two-step-order {display:flex;width:100%;max-width:430px;height:auto;gap:8px;}
.two-step-slot {display:flex;justify-content:center;align-items:center;flex:1;min-width:0;min-height:86px;padding:5px;background:#fff9e8;border:2px solid #d6b982;border-radius:12px;}
.two-step-object {display:inline-flex;width:88px;height:88px;align-items:center;justify-content:center;}
.two-step-object>svg {width:100%;height:100%;}
.two-step-instructions {display:flex;justify-content:center;flex-wrap:wrap;gap:10px;width:100%;}
.two-step-instruction {display:flex;align-items:center;justify-content:center;gap:5px;padding:5px 8px;border:1px solid #d8c496;border-radius:13px;background:#f3eedc;font-size:.8rem;font-weight:850;}
.two-step-instruction>b {display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:#759d5d;color:white;}
.two-step-instruction .two-step-object {width:40px;height:46px;}
.two-step-instruction>svg {width:42px;height:42px;}
.swap-arrow {font-size:1.45rem;color:#7c674b;font-weight:900;}
.farm-world .game[data-skill="two-step-swap"] .choices:has(>.thinking-choice) {grid-template-columns:1fr;max-width:480px;}
.farm-world .game[data-skill="two-step-swap"] .thinking-choice {aspect-ratio:auto;min-height:100px;padding:8px;}
.farm-world .game[data-skill="two-step-swap"] .thinking-choice>.two-step-order {height:82px;aspect-ratio:auto;}
.farm-world .game[data-skill^="two-step"] .sample {width:100%;}
@media(max-width:700px){.two-step-slot{min-height:68px;padding:3px;}.two-step-object{width:65px;height:72px;}.two-step-order{gap:5px;}.two-step-instruction{gap:3px;padding:5px;}.two-step-instructions{gap:6px;}.two-step-instruction .two-step-object{width:32px;height:38px;}}

@media(max-width:700px){
 .farm-world .game[data-skill^="two-step"] .meadow{height:58px;}
 .farm-world .game[data-skill^="two-step"] .rabbit{width:58px;height:65px;}
 .farm-world .game[data-skill^="two-step"] .flower{transform:scale(.29);}
 .farm-world .game[data-skill="two-step-swap"] .thinking-choice{min-height:82px;padding:5px;}
 .farm-world .game[data-skill="two-step-swap"] .thinking-choice>.two-step-order{height:68px;aspect-ratio:auto;}
}

/* Story quantities use pictures, with no computed final state in the question scene. */
.farm-world .game[data-skill="number-story"] .panel{display:block;}
.story-visual{width:100%;height:auto;}
.story-model{display:flex;flex-direction:column;align-items:center;gap:10px;}
.story-caption{font-size:.85rem;font-weight:900;color:#795c40;}
.story-count{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:5px;max-width:100%;width:auto;}
.story-item{display:inline-flex;width:40px;height:38px;align-items:center;justify-content:center;}
.story-item>svg{width:100%;height:100%;}
.story-initial{padding:8px 12px;background:#edf3e1;border:2px solid #b5c799;border-radius:18px;max-width:100%;}
.story-initial[data-item="strawberry"]{border-radius:50%;background:#eef4f5;border-color:#a2b8ce;padding:12px 18px;}
.story-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:9px;width:100%;}
.story-action{display:flex;align-items:center;gap:5px;padding:6px 8px;border:1px solid #d8c496;border-radius:13px;background:#f3eedc;}
.story-step{display:grid;place-items:center;width:21px;height:21px;flex-shrink:0;border-radius:50%;background:#759d5d;color:white;font-size:.8rem;}
.story-sign{font-size:1.5rem;font-weight:950;color:#826548;}.story-action-label{font-size:.8rem;font-weight:850;}
.story-action .story-item{width:30px;height:32px;}
.story-hidden-scene{display:flex;align-items:center;justify-content:center;position:relative;min-height:140px;max-width:100%;width:300px;}
.hidden-balls{padding-bottom:32px;}.hidden-balls>svg{width:260px;height:130px;}.hidden-balls>.story-count{position:absolute;bottom:0;left:0;width:100%;}
.hidden-coins{gap:10px;}.hidden-coins>svg{width:130px;height:130px;flex-shrink:0;}.hidden-coins>.story-count{max-width:135px;}
.farm-world .game[data-skill="number-story"] .choices:has(>.thinking-choice){grid-template-columns:1fr;max-width:480px;gap:9px;}
.farm-world .game[data-skill="number-story"] .thinking-choice{aspect-ratio:auto;min-height:66px;padding:10px;}
.farm-world .game[data-skill="number-story"] .thinking-choice>.story-count{width:100%;height:auto;min-height:38px;aspect-ratio:auto;}
@media(max-width:700px){
 .farm-world .game[data-skill="number-story"] .meadow{height:58px;}.farm-world .game[data-skill="number-story"] .rabbit{width:58px;height:65px;}.farm-world .game[data-skill="number-story"] .flower{transform:scale(.29);}
 .story-item{width:34px;height:34px;}.story-count{gap:3px;}.story-initial{padding:7px;}.story-initial[data-item="strawberry"]{padding:9px 12px;}
 .story-action{padding:5px;gap:4px;}.story-action .story-item{width:26px;height:29px;}.story-actions{gap:6px;}
}

@media(max-width:700px){.hidden-coins>svg{width:110px;height:130px;}.hidden-coins>.story-count{max-width:135px;}}

.farm-world .garden-map .thinking-node-picture.story-count{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0;align-items:center;}
.thinking-node-picture.story-count>.story-item{width:100%;height:auto;aspect-ratio:1;}

/* Five tiers need a positive-width top and rings large enough to compare on a phone. */
.farm-world .game[data-skill="top-view"] .panel{display:block;}
.farm-world .game[data-skill="top-view"] .sample>.thinking-visual{width:240px;height:210px;}
.farm-world .game[data-skill="top-view"] .choices:has(>.thinking-choice){max-width:540px;}
.farm-world .game[data-skill="top-view"] .thinking-choice{padding:7px;}
@media(max-width:700px){
 .farm-world .game[data-skill="top-view"] .meadow{height:58px;}.farm-world .game[data-skill="top-view"] .rabbit{width:58px;height:65px;}.farm-world .game[data-skill="top-view"] .flower{transform:scale(.29);}
 .farm-world .game[data-skill="top-view"] .sample>.thinking-visual{width:220px;height:195px;}
 .farm-world .game[data-skill="top-view"] .thinking-choice{padding:4px;min-height:100px;}
}

.math-sections{position:fixed;z-index:6;top:calc(164px + var(--safe-top));left:calc(50% + (var(--safe-left) - var(--safe-right))/2);transform:translateX(-50%);display:flex;gap:4px;padding:4px;border:1px solid #b8c79c;border-radius:17px;background:#f6f8e7;max-width:calc(100% - 24px - var(--safe-left) - var(--safe-right));box-shadow:0 3px 9px #35532520;}
.math-sections button{display:flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:104px;padding:6px 9px;border:1px solid transparent;border-radius:12px;background:transparent;color:#526e3c;font-size:.85rem;font-weight:900;white-space:nowrap;}
.math-sections button[aria-pressed="true"]{background:#dcebc7;border-color:#a4bd81;}
.math-sections button:focus-visible{outline:3px solid #54883d;outline-offset:2px;}
.math-section-symbol{font-size:.85rem;min-width:20px;}
.farm-world .garden-map .plant-sign[data-section-label]::before{content:attr(data-section-label);display:block;font-size:.56rem;line-height:1.1;font-weight:800;color:#69834d;}
.math-round-size{position:absolute;bottom:-5px;left:50%;transform:translateX(-50%);font-size:.62rem;font-weight:850;color:#4f6e39;background:#f6f6df;border:1px solid #c3cfa7;border-radius:8px;padding:0 6px;white-space:nowrap;}
@media(max-width:700px),(max-height:650px){.math-sections{top:calc(141px + var(--safe-top));}.math-sections button{min-width:0;gap:4px;padding:5px 7px;font-size:.78rem;}}
@media(min-width:500px) and (max-height:500px){
 body[data-subject="math"]:has(.game[data-stage="garden"]) .subject-switch{left:calc(25% + (3 * var(--safe-left) - var(--safe-right))/4);width:calc((100% - var(--safe-left) - var(--safe-right))/2 - 24px);max-width:none;}
 .math-sections{top:calc(80px + var(--safe-top));left:calc(75% + (var(--safe-left) - 3 * var(--safe-right))/4);width:calc((100% - var(--safe-left) - var(--safe-right))/2 - 24px);max-width:none;justify-content:center;}
 .math-sections button{font-size:.72rem;padding-inline:4px;}.math-section-symbol{min-width:13px;}
}
