* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  height: 100dvh;
  background: #fff7e8;
  color: #44372e;
  font-family:
    system-ui,
    -apple-system,
    'PingFang SC',
    sans-serif;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border: 0;
  border-radius: 18px;
  min-height: 48px;
  color: inherit;
  background: #fff1ce;
}
button:active {
  transform: scale(0.97);
}
button:focus-visible {
  outline: 3px solid #298d53;
  outline-offset: 2px;
}
button:disabled {
  cursor: default;
  opacity: 0.85;
}
main {
  height: 100%;
  max-width: 760px;
  margin: auto;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 7px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
}
.brand {
  font-weight: 800;
  font-size: 19px;
}
header button {
  font-size: 15px;
  background: white;
  padding: 6px 14px;
  min-height: 44px;
}
#stars {
  font-weight: 700;
  font-size: 18px;
}
.progress {
  height: 8px;
  border-radius: 20px;
  overflow: hidden;
  background: #eddfc9;
  flex-shrink: 0;
}
#bar {
  display: block;
  height: 100%;
  width: 0;
  background: #52c486;
  transition: width 0.2s;
}
#step {
  font-size: 15px;
  margin: 0;
  text-align: center;
  flex-shrink: 0;
}
#scene {
  flex: 1;
  min-height: 0;
  border-radius: 25px;
  background: white;
  box-shadow: 0 6px 24px #dbb98524;
  padding: clamp(10px, 2vh, 18px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  overflow: hidden;
  position: relative;
}
h1,
h2,
p {
  margin: 0;
}
h2 {
  text-align: center;
  font-size: clamp(20px, 3vh, 25px);
  line-height: 1.3;
  flex-shrink: 0;
}
.prompt {
  font-size: clamp(17px, 2.4vh, 21px);
  line-height: 1.5;
  text-align: center;
  flex-shrink: 0;
}
.visual {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}
.visual:empty {
  display: none;
}
.visual > svg {
  width: 100%;
  height: 100%;
  max-height: 260px;
  min-height: 0;
}
.objects {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 450px;
  margin: 0 auto;
}
.objects img {
  width: clamp(32px, 5vh, 43px);
  height: clamp(32px, 5vh, 43px);
  object-fit: contain;
}
img {
  object-fit: contain;
  max-width: 100%;
  user-select: none;
}
.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  flex-shrink: 0;
}
.choice {
  min-height: 70px;
  padding: 10px 6px;
  font-size: 32px;
  font-weight: 750;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 3px solid transparent;
  line-height: 1.25;
  background: #fff4d9;
}
.choice > img {
  height: clamp(48px, 11vh, 100px);
  width: 100%;
  max-height: 100px;
}
.choice svg {
  width: 100%;
  height: 60px;
}
.choice .objects {
  gap: 2px;
}
.choice .objects img {
  width: 26px;
  height: 26px;
}
.choices.wide {
  grid-template-columns: 1fr;
}
.choices.wide .choice {
  min-height: 58px;
  font-size: 24px;
}
.choice.correct {
  border-color: #40b875;
  background: #dcf5e5;
}
.choice.wrong {
  border-color: #edb5a7;
}
.primary {
  min-height: 62px;
  background: #45bd75;
  color: white;
  font-weight: 800;
  font-size: 23px;
  padding: 14px 24px;
  box-shadow: 0 5px 0 #319c5d;
}
#feedback {
  min-height: 26px;
  height: 26px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: #25844a;
  flex-shrink: 0;
}
footer {
  font-size: 12px;
  text-align: center;
  color: #887a66;
  flex-shrink: 0;
}
.intro {
  justify-content: center !important;
  align-items: center !important;
  gap: 20px !important;
  text-align: center;
}
.intro .hero {
  font-size: 65px;
}
.intro p {
  font-size: 18px;
  line-height: 1.5;
}
.intro .primary {
  width: min(100%, 340px);
}
.intro .strands {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 16px;
}
.strands span {
  background: #f1f8ed;
  border-radius: 14px;
  padding: 10px 12px;
}
.home {
  background: transparent;
  text-decoration: underline;
  font-size: 15px;
  min-height: 44px;
}
.bins {
  display: flex;
  gap: 12px;
  width: 100%;
  align-items: stretch;
  justify-content: center;
}
.bins > div {
  flex: 1;
  min-width: 0;
  border: 2px dashed #add3b4;
  border-radius: 18px;
  padding: 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  font-size: 20px;
  min-height: 90px;
}
.bins strong {
  font-size: 40px;
}
.bins .objects img {
  width: 32px;
  height: 32px;
}
.count-label {
  font-size: 23px;
  font-weight: 750;
}
.formula {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  font-size: 32px;
  font-weight: 800;
  vertical-align: middle;
}
.operator {
  width: 38px;
  height: 38px;
  object-fit: contain;
}
.formula-row {
  text-align: center;
}
.formula-row.big .formula {
  font-size: 48px;
  gap: 15px;
}
.formula-row.big .operator {
  width: 54px;
  height: 54px;
}
.picture-equation {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.picture-equation .objects {
  flex: 1;
}
.picture-equation .operator {
  flex-shrink: 0;
}
.compare-row {
  display: flex;
  gap: 14px;
  align-items: center;
  width: 100%;
  background: #fff;
  border-radius: 16px;
  padding: 10px;
}
.compare-row > img {
  height: 64px;
  width: 64px;
  flex-shrink: 0;
}
.compare-row .objects {
  flex: 1;
}
.panda-model {
  height: 100%;
  max-height: 170px;
  width: 130px;
  min-height: 0;
  display: flex;
  justify-content: center;
  border-right: 2px dashed #a6c3ad;
  padding-right: 2px;
}
.panda-model img {
  height: 100%;
  width: auto;
  object-fit: contain;
}
.branch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 220px;
  max-width: 100%;
  text-align: center;
  font-size: 35px;
  font-weight: 800;
}
.branch > b {
  grid-column: span 2;
}
.branch svg {
  grid-column: span 2;
  width: 100%;
  height: 35px;
}
.branch > span {
  background: #edf8e9;
  border-radius: 16px;
  padding: 6px;
}
.chain {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.chain .branch {
  width: 200px;
  font-size: 28px;
}
.chain .branch svg {
  height: 24px;
}
.chain .branch > span {
  padding: 2px 8px;
}
.picture-branch {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.picture-branch > svg {
  height: 32px;
  width: 100%;
}
.picture-branch .bins > div {
  font-size: 35px;
  min-height: 65px;
  padding: 8px;
}
.receivers {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  width: 100%;
  height: 75px;
  flex-shrink: 0;
}
.receivers img {
  width: 65px;
  height: 75px;
}
.cookies {
  max-width: 340px;
}
.cookies > span {
  position: relative;
  display: flex;
}
.crossed {
  opacity: 0.45;
}
.crossed:after {
  content: '';
  position: absolute;
  left: 5%;
  top: 48%;
  width: 90%;
  height: 3px;
  background: #c63b46;
  transform: rotate(-45deg);
}
.measurement {
  width: min(100%, 400px);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-left: 2px solid #665e55;
  border-right: 2px solid #665e55;
}
.train {
  width: 100%;
  height: 65px;
}
.train img {
  object-fit: fill;
  width: 100%;
  height: 100%;
}
.cars {
  display: grid;
  grid-template-columns: repeat(var(--units), 1fr);
  width: 100%;
}
.cars img {
  width: 100%;
  height: 42px;
}
.bead-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  flex-wrap: wrap;
}
.bead-sequence img {
  width: 11%;
  max-width: 55px;
  aspect-ratio: 1;
}
.bead-sequence strong {
  font-size: 34px;
}
.cloth-model {
  height: 100%;
  max-height: 240px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cloth-model img {
  height: 100%;
  width: 100%;
  object-fit: contain;
}
.number-order {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 42px;
  font-weight: 800;
}
.number-order span {
  background: #edf8e9;
  border-radius: 16px;
  padding: 14px;
}
.path-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 35px;
  gap: 8px;
  flex-shrink: 0;
}
.path-legend img {
  width: 30px;
  height: 30px;
}
.path-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  width: min(100%, 300px);
  height: min(100%, 300px);
  aspect-ratio: 1;
  min-height: 230px;
}
.path-cell {
  min-height: 0;
  min-width: 0;
  padding: 4px;
  background: #f5faed;
  border-radius: 9px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid transparent;
  aspect-ratio: 1;
}
.path-cell img {
  width: 100%;
  height: 100%;
  max-height: 48px;
}
.path-cell.active {
  background: #cbefda;
  border-color: #63b987;
}
.path-cell.current {
  border-color: #2b9d62;
}
.choice-grid .choice {
  min-height: 64px;
}
.choice-grid .choice svg {
  height: 46px;
}
.summary-stars {
  font-size: 40px;
  color: #d9a326;
}
@media (max-width: 400px) {
  main {
    gap: 6px;
  }
  #scene {
    gap: 8px;
    padding: 12px;
  }
  .prompt {
    font-size: 17px;
  }
  .choice {
    min-height: 64px;
  }
  .choices.wide .choice {
    min-height: 54px;
    font-size: 22px;
  }
  .formula {
    gap: 8px;
    font-size: 28px;
  }
  .operator {
    width: 32px;
    height: 32px;
  }
  .objects {
    gap: 4px;
  }
  .bins {
    gap: 8px;
  }
  .bins > div {
    padding: 8px;
    font-size: 18px;
  }
  .intro .strands {
    font-size: 14px;
    gap: 6px;
  }
  .strands span {
    padding: 9px;
  }
  .choice .objects img {
    width: 24px;
    height: 24px;
  }
}
@media (max-height: 650px) {
  main {
    gap: 5px;
  }
  #scene {
    gap: 7px;
    padding: 10px;
  }
  header {
    height: 40px;
  }
  header button {
    min-height: 40px;
  }
  footer {
    display: none;
  }
  .prompt {
    font-size: 16px;
  }
  .choices {
    gap: 7px;
  }
  .choice {
    min-height: 56px;
    font-size: 29px;
  }
  .choices.wide .choice {
    min-height: 49px;
    font-size: 22px;
  }
  .choice > img {
    height: 65px;
  }
  .objects img {
    width: 32px;
    height: 32px;
  }
  .receivers {
    height: 50px;
  }
  .receivers img {
    height: 50px;
    width: 45px;
  }
  .branch {
    font-size: 30px;
  }
  .branch svg {
    height: 24px;
  }
  .branch > span {
    padding: 3px;
  }
  .path-grid {
    width: 235px;
    min-height: 220px;
  }
  .path-legend {
    height: 28px;
  }
  .panda-model {
    max-height: 125px;
  }
  .intro {
    gap: 16px !important;
  }
  .intro .hero {
    font-size: 48px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  main {
    max-width: 1000px;
    padding: 6px 12px;
    gap: 4px;
  }
  header {
    height: 35px;
  }
  header button {
    min-height: 35px;
  }
  .brand {
    font-size: 17px;
  }
  .progress {
    height: 5px;
  }
  #step {
    font-size: 13px;
  }
  #feedback {
    height: 22px;
    min-height: 22px;
    font-size: 16px;
  }
  #scene.question-scene {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 0.85fr);
    grid-template-rows: auto 1fr;
    gap: 8px 20px;
  }
  h2 {
    font-size: 20px;
  }
  .question-scene h2 {
    display: none;
  }
  .question-scene .prompt {
    grid-column: 1;
    grid-row: 1;
    font-size: 16px;
    line-height: 1.35;
  }
  .question-scene .visual {
    grid-column: 1;
    grid-row: 2;
  }
  .question-scene .choices {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-content: center;
  }
  .question-scene .choices.wide {
    gap: 8px;
  }
  .choice {
    min-height: 60px;
  }
  .choice > img {
    height: 70px;
  }
  .path-scene .prompt {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }
  .path-scene .visual {
    grid-row: 1 / span 2;
    grid-column: 1;
    flex-direction: row;
    gap: 10px;
  }
  .path-legend {
    flex-direction: column;
    height: 100%;
    font-size: 0;
  }
  .path-legend img {
    width: 30px;
    height: 30px;
  }
  .path-grid {
    height: 210px;
    width: 210px;
    min-height: 210px;
    gap: 2px;
  }
  .path-cell {
    padding: 2px;
  }
  .intro {
    gap: 10px !important;
  }
  .intro .hero {
    display: none;
  }
  .intro p {
    font-size: 16px;
  }
  .intro .primary {
    min-height: 54px;
  }
  .intro .strands {
    font-size: 14px;
  }
  .strands span {
    padding: 6px 10px;
  }
  .branch {
    font-size: 26px;
  }
  .branch svg {
    height: 20px;
  }
  .chain {
    flex-direction: row;
    gap: 10px;
  }
  .chain .branch {
    font-size: 23px;
  }
  .chain .branch svg {
    height: 24px;
  }
  .chain .branch > span {
    padding: 3px;
  }
  .compare-row > img {
    width: 40px;
    height: 40px;
  }
  .compare-row {
    padding: 2px;
  }
  .objects img {
    width: 28px;
    height: 28px;
  }
  .visual {
    gap: 5px;
  }
  .receivers {
    height: 40px;
  }
  .receivers img {
    height: 40px;
  }
  .measurement {
    padding: 0;
    gap: 4px;
  }
  .train {
    height: 48px;
  }
  .cars img {
    height: 30px;
  }
  .panda-model {
    max-height: 125px;
  }
  .choice-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
  }
  .choice-grid .choice {
    min-height: 56px;
  }
  .choice-grid .choice svg {
    height: 38px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
  button:active {
    transform: none;
  }
}
img,
svg image {
  mix-blend-mode: multiply;
}
@media (max-height: 650px) and (orientation: portrait) {
  .compare-row {
    padding: 3px;
    gap: 8px;
  }
  .compare-row > img {
    height: 42px;
    width: 42px;
  }
  .path-grid {
    width: 240px;
    min-height: 240px;
    height: 240px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .path-grid {
    height: 228px;
    width: 228px;
    min-height: 228px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .bins > div {
    min-height: 65px;
    padding: 5px;
    font-size: 17px;
    gap: 3px;
  }
  .bins .objects img {
    width: 26px;
    height: 26px;
  }
  .count-label {
    font-size: 20px;
  }
  .formula {
    font-size: 28px;
    gap: 8px;
  }
  .operator {
    width: 32px;
    height: 32px;
  }
  .picture-branch {
    gap: 3px;
  }
  .picture-branch > svg {
    height: 20px;
  }
}
/* Space goes to the task and touch targets; the progress line already names the task. */
.question-scene > h2 {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}
.chain {
  flex-direction: row;
  gap: 14px;
  width: 100%;
  justify-content: center;
}
.chain .branch {
  flex: 1;
  max-width: 190px;
  font-size: 29px;
}
.chain .branch svg {
  height: 30px;
}
.chain .branch > span {
  padding: 6px;
}
@media (max-height: 700px) {
  footer {
    display: none;
  }
  .intro .intro-note {
    display: none;
  }
}
@media (max-height: 540px) and (orientation: portrait) {
  main {
    gap: 4px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  header {
    height: 44px;
  }
  .brand {
    font-size: 16px;
  }
  header button {
    min-height: 44px;
    font-size: 14px;
    padding: 5px 9px;
  }
  #stars {
    font-size: 16px;
  }
  .progress {
    height: 5px;
  }
  #step {
    font-size: 14px;
  }
  #scene {
    padding: 10px;
    gap: 8px;
    border-radius: 20px;
  }
  .prompt {
    font-size: 16px;
    line-height: 1.4;
  }
  .visual {
    gap: 6px;
  }
  .choices {
    gap: 6px;
  }
  .choice {
    min-height: 56px;
    padding: 8px 5px;
    font-size: 28px;
  }
  .choices.wide .choice {
    min-height: 48px;
    padding: 7px 6px;
    font-size: 22px;
  }
  .choice > img {
    height: 60px;
  }
  .choice-grid .choice {
    min-height: 58px;
  }
  .choice-grid .choice svg {
    height: 38px;
  }
  .objects img {
    width: 28px;
    height: 28px;
  }
  .objects {
    gap: 4px;
  }
  .compare-row {
    padding: 2px;
    gap: 8px;
  }
  .compare-row > img {
    width: 36px;
    height: 36px;
  }
  .bins > div {
    min-height: 72px;
    padding: 6px;
    font-size: 17px;
  }
  .bins .objects img {
    width: 28px;
    height: 28px;
  }
  .count-label {
    font-size: 20px;
  }
  .operator {
    width: 30px;
    height: 30px;
  }
  .formula {
    font-size: 28px;
    gap: 7px;
  }
  .receivers {
    height: 44px;
  }
  .receivers img {
    height: 44px;
    width: 40px;
  }
  .chain .branch {
    font-size: 27px;
  }
  .chain .branch svg {
    height: 25px;
  }
  .chain .branch > span {
    padding: 4px;
  }
  .panda-model {
    max-height: 130px;
  }
  .path-legend {
    height: 24px;
  }
  .path-legend img {
    height: 24px;
    width: 24px;
  }
  .path-grid {
    width: 240px;
    height: 240px;
    min-height: 240px;
  }
  .path-cell img {
    max-height: 38px;
  }
  .intro {
    gap: 16px !important;
  }
  .intro .hero {
    font-size: 42px;
  }
  .intro h2 {
    font-size: 22px;
  }
  .intro p {
    font-size: 17px;
  }
  .intro .strands {
    font-size: 14px;
    gap: 6px;
  }
  .strands span {
    padding: 7px 9px;
  }
  .intro .primary {
    min-height: 58px;
    font-size: 23px;
  }
  #feedback {
    font-size: 16px;
    min-height: 20px;
    height: 20px;
  }
  .summary-stars {
    font-size: 34px;
  }
}
.compare-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}
.compare-answer .animal {
  width: 50px;
  height: 50px;
}
.compare-answer .operator {
  width: 25px;
  height: 25px;
  opacity: 0.8;
}
.compare-answer b {
  font-size: 42px;
  line-height: 1;
}
.choice-row {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 7px;
  align-items: center;
  min-width: 0;
}
.option-listen {
  width: 44px;
  height: 44px;
  min-height: 44px;
  font-size: 20px;
  background: #f0f7e9;
  border-radius: 14px;
}
.help-toggle {
  position: absolute;
  right: 8px;
  top: 5px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  font-size: 23px;
  background: #f1f8ed;
}
.has-help .prompt {
  padding-right: 42px;
}
.pairing {
  width: 100%;
  max-width: 430px;
}
.pair-row {
  display: grid;
  grid-template-columns: 32px repeat(9, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
  margin: 16px 0;
}
.pair-row > img {
  width: 30px;
  height: 35px;
}
.pair-row > span {
  height: 30px;
  padding: 1px;
  border-radius: 5px;
}
.pair-row > span img {
  width: 100%;
  height: 100%;
}
.pair-row .unpaired {
  border: 2px dashed #7eb592;
  background: #e9f7eb;
}
.hands-frame {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  border: 0;
  z-index: 10;
  background: #fff9ee;
}
body.hands-active main > header,
body.hands-active #step,
body.hands-active .progress,
body.hands-active main > #feedback,
body.hands-active footer {
  visibility: hidden;
}
@media (max-height: 540px) and (orientation: portrait) {
  .compare-answer {
    gap: 15px;
  }
  .compare-answer .animal {
    width: 36px;
    height: 36px;
  }
  .compare-answer b {
    font-size: 36px;
  }
  .compare-answer .operator {
    width: 22px;
    height: 22px;
  }
  .choice-row .choice {
    min-height: 54px;
    padding: 5px;
  }
  .help-toggle {
    width: 44px;
    height: 44px;
    top: 3px;
    right: 5px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .has-help .help-toggle {
    left: calc(54% - 40px);
    right: auto;
    top: 3px;
  }
}

#practice {
  width: min(100%, 340px);
}
#practice:not([hidden]) {
  display: flex;
  gap: 8px;
}
#practice select {
  flex: 1;
  min-width: 0;
  border: 2px solid #b7d9bf;
  border-radius: 14px;
  font: inherit;
  padding: 10px;
  background: white;
  min-height: 48px;
}
#practice-go {
  min-width: 56px;
}

@media (max-height: 540px) and (orientation: portrait) {
  [data-type='compare'] .compare-row .objects {
    gap: 3px;
  }
  [data-type='compare'] .compare-row .objects img {
    width: 26px;
    height: 26px;
  }
}
/* Keep the shared top control touch target at 44px on 650px-high phones too. */
header {
  height: 44px;
}
header button {
  height: 44px;
  min-height: 44px;
}

/* v11: readable quantities, consistent original bead colors and external route guides. */
[data-type='rolling'] svg image,
[data-type='rolling'] .choice img {
  mix-blend-mode: normal;
}
.chain-linked {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 100%;
  gap: 3px;
}
.chain-linked .branch {
  width: 190px;
  font-size: 30px;
}
.chain-linked .branch svg {
  height: 26px;
}
.same-star {
  font-style: normal;
  color: #955600;
  background: #fff0b8;
  border: 2px solid #eebc53;
  border-radius: 12px;
  padding: 0 9px;
}
.chain-transfer {
  color: #b08028;
  font-size: 30px;
  line-height: 1;
}
.chain-sum .formula {
  font-size: 32px;
}
.chain-sum .operator {
  width: 30px;
  height: 30px;
}
.path-outside {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 300px);
  height: 32px;
  flex-shrink: 0;
  gap: 5px;
}
.path-outside span {
  display: flex;
  justify-content: center;
}
.path-outside img {
  height: 32px;
  width: 32px;
}
.path-scene .visual {
  gap: 3px;
}
.path-grid {
  min-height: 0;
  flex-shrink: 1;
}
@media (max-height: 650px) and (orientation: portrait) {
  .path-grid {
    width: 220px;
    height: 220px;
    min-height: 0;
  }
  .path-outside {
    width: 220px;
    height: 27px;
  }
  .path-outside img {
    width: 27px;
    height: 27px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .path-scene .visual {
    flex-direction: column;
    gap: 1px;
  }
  .path-grid {
    width: 170px;
    height: 170px;
    min-height: 0;
  }
  .path-outside {
    width: 170px;
    height: 23px;
  }
  .path-outside img {
    height: 23px;
    width: 23px;
  }
  .path-legend {
    flex-direction: row;
    height: 22px;
    font-size: 15px;
  }
  .path-legend img {
    width: 22px;
    height: 22px;
  }
  .chain-linked {
    flex-direction: row;
    gap: 10px;
  }
  .chain-transfer {
    transform: rotate(-90deg);
  }
  .chain-linked .branch {
    width: 120px;
    font-size: 26px;
  }
  .chain-sum .formula {
    font-size: 26px;
    gap: 5px;
  }
}

/* v12: a quantity comparison is not an addition expression. */
.compare-answer {
  gap: 12px;
}
.compare-answer .animal {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}
.extra-objects {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  border: 2px dashed #cfad6a;
  border-radius: 12px;
  padding: 4px 8px;
  max-width: 240px;
  flex: 1;
}
.extra-caption {
  font-size: 12px;
  grid-column: 1;
  text-align: left;
  line-height: 1;
}
.extra-pictures {
  grid-column: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: flex-start;
}
.extra-pictures img {
  width: 23px;
  height: 23px;
}
.compare-answer .extra-objects b {
  grid-column: 2;
  grid-row: 1/3;
  font-size: 30px;
}
.choice-row .choice {
  min-height: 64px;
}
.compare-answer .extra-pictures img {
  mix-blend-mode: normal;
}
@media (max-width: 350px) {
  .compare-answer {
    gap: 7px;
  }
  .compare-answer .animal {
    width: 34px;
    height: 34px;
  }
  .extra-objects {
    padding: 3px 5px;
    gap: 2px 4px;
  }
  .extra-pictures img {
    width: 19px;
    height: 19px;
  }
  .compare-answer .extra-objects b {
    font-size: 26px;
  }
  .choice-row {
    gap: 4px;
  }
  .choices.wide {
    gap: 6px;
  }
}
@media (max-height: 550px) {
  [data-type='compare'] .visual {
    gap: 2px;
  }
  [data-type='compare'] .compare-row {
    padding: 1px;
  }
  [data-type='compare'] .compare-row .objects img {
    width: 22px;
    height: 22px;
  }
  [data-type='compare'] .prompt {
    font-size: 15px;
    line-height: 1.3;
  }
  [data-type='compare'] .choice-row .choice {
    min-height: 54px;
    padding: 3px 4px;
  }
  [data-type='compare'] .extra-pictures img {
    width: 18px;
    height: 18px;
  }
  [data-type='compare'] .compare-answer .animal {
    width: 33px;
    height: 33px;
  }
}

/* v14: familiar one-step representations, with room for ten objects. */
.picture-join {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  max-width: 450px;
}
.join-pile {
  flex: 1;
  min-width: 0;
  background: #f4f8ed;
  border: 2px solid #d6e8c4;
  border-radius: 18px;
  padding: 12px 7px;
}
.picture-join > .operator {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
}
.join-pile .objects {
  gap: 4px;
}
.join-pile .objects img {
  width: 32px;
  height: 32px;
}
.join-question {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 45px;
}
.missing-part .branch {
  width: 240px;
  font-size: 42px;
}
.gap-sequence {
  flex-wrap: nowrap;
}
.gap-sequence img {
  width: 14%;
  max-width: 50px;
}
.gap-sequence strong {
  width: 14%;
  text-align: center;
}
@media (max-width: 350px), (max-height: 550px) {
  .join-pile {
    padding: 7px 4px;
  }
  .join-pile .objects img {
    width: 25px;
    height: 25px;
  }
  .picture-join {
    gap: 6px;
  }
  .picture-join > .operator {
    width: 24px;
    height: 24px;
  }
  .join-question {
    font-size: 34px;
  }
  .missing-part .branch {
    font-size: 34px;
    width: 190px;
  }
}

/* v15 consistent content alignment; speech and arithmetic unchanged. */
main {
  max-width: 620px;
  gap: 8px;
}
#scene {
  padding: 16px;
  gap: 12px;
}
.question-scene .prompt {
  max-width: 480px;
  align-self: center;
  width: 100%;
  line-height: 1.4;
}
.question-scene .visual {
  width: 100%;
  gap: 12px;
}
.choices {
  width: 100%;
  gap: 10px;
}
.choice {
  border-radius: 16px;
  min-height: 64px;
}
.formula {
  line-height: 1;
  align-items: center;
}
.formula .operator {
  flex: none;
  vertical-align: middle;
}
.branch {
  column-gap: 10px;
  row-gap: 0;
}
.branch > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}
.branch svg {
  overflow: visible;
}
.chain-linked {
  width: min(100%, 260px);
  gap: 0;
}
.chain-first {
  width: 100%;
}
.chain-linked .branch {
  width: 100%;
  font-size: 36px;
}
.chain-linked .branch svg {
  height: 32px;
}
.chain-transfer {
  width: 100%;
  height: 32px;
  flex: none;
}
.chain-transfer svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chain-sum {
  width: 100%;
}
.chain-sum .formula {
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  font-size: 34px;
}
.same-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 44px;
  padding: 0 6px;
}
.chain-sum .operator {
  width: 32px;
  height: 32px;
}
.compare-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
}
.compare-row > img {
  width: 48px;
  height: 48px;
}
.compare-row .objects {
  margin: 0;
  justify-content: flex-start;
  align-content: center;
  min-height: 64px;
}
.picture-join {
  align-items: stretch;
}
.picture-join > .operator {
  align-self: center;
}
.join-pile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
}
.bead-sequence {
  align-items: center;
}
.gap-sequence img,
.gap-sequence strong {
  flex: 0 1 14%;
  height: 46px;
  object-fit: contain;
  display: grid;
  place-items: center;
}
.number-order {
  justify-content: center;
  gap: 10px;
}
.number-order span {
  min-width: 48px;
  text-align: center;
}
.choice-row .choice {
  justify-content: stretch;
}
.compare-answer {
  align-items: center;
}
.extra-objects {
  min-height: 46px;
}
.choice-row {
  grid-template-columns: minmax(0, 1fr) 44px;
}
.has-help .prompt {
  padding-right: 42px;
}
.path-grid {
  align-self: center;
}
.path-outside {
  align-self: center;
}
@media (min-height: 700px) {
  .question-scene .visual {
    max-height: 430px;
    margin: auto 0;
  }
  .question-scene .choices {
    margin-top: auto;
  }
  .question-scene .prompt {
    font-size: 19px;
  }
  .question-scene .visual > svg {
    max-height: 310px;
  }
}
@media (max-height: 550px) {
  main {
    gap: 4px;
  }
  #scene {
    padding: 10px;
    gap: 8px;
  }
  .question-scene .prompt {
    font-size: 16px;
    line-height: 1.3;
  }
  .question-scene .visual {
    gap: 6px;
  }
  .choice {
    min-height: 54px;
  }
  .chain-linked {
    width: 210px;
  }
  .chain-linked .branch {
    font-size: 28px;
  }
  .chain-linked .branch svg {
    height: 22px;
  }
  .chain-linked .branch > span {
    min-height: 38px;
    padding: 2px;
  }
  .same-star {
    min-width: 36px;
    height: 34px;
  }
  .chain-transfer {
    height: 22px;
  }
  .chain-sum .formula {
    font-size: 28px;
    gap: 5px;
  }
  .chain-sum .operator {
    width: 28px;
    height: 28px;
  }
  .compare-row {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 6px;
  }
  .compare-row > img {
    width: 32px;
    height: 32px;
  }
  .compare-row .objects {
    min-height: 32px;
  }
  .join-pile {
    min-height: 76px;
  }
  .gap-sequence img,
  .gap-sequence strong {
    height: 34px;
  }
  .number-order {
    gap: 6px;
  }
  .number-order span {
    font-size: 30px;
    min-width: 40px;
    padding: 8px;
  }
  .path-scene .visual {
    gap: 2px;
  }
}

[data-type='pattern-gap'] .visual img,
[data-type='pattern-gap'] .choice img,
[data-type='pattern'] .visual img,
[data-type='pattern'] .choice img {
  mix-blend-mode: normal;
}

/* v16: keep the illustration and answers together rather than pinned apart. */
@media (min-height: 650px) {
  .question-scene .visual {
    flex: 0 1 auto;
    min-height: 120px;
    max-height: 48dvh;
    margin: auto 0 8px;
  }
  .question-scene .choices {
    margin-top: 0;
    margin-bottom: auto;
  }
  [data-type='chain'] .chain-linked {
    width: min(100%, 300px);
  }
  [data-type='chain'] .chain-linked .branch {
    font-size: 42px;
  }
  [data-type='chain'] .chain-sum .formula {
    font-size: 40px;
  }
  [data-type='chain'] .same-star {
    height: 50px;
    min-width: 50px;
  }
  [data-type='chain'] .chain-transfer {
    height: 40px;
  }
  .choices.wide .choice {
    min-height: 64px;
  }
  .compare-row .objects img {
    width: 40px;
    height: 40px;
  }
}

/* v18: clear five-column counting rows, up to 15 objects. */
[data-type='count'] .count-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 16px);
  width: min(100%, 360px);
}
[data-type='count'] .count-grid img {
  width: 100%;
  height: clamp(36px, 7dvh, 64px);
}
@media (max-height: 550px) {
  [data-type='count'] .count-grid {
    width: min(100%, 250px);
    gap: 6px;
  }
  [data-type='count'] .count-grid img {
    height: 32px;
  }
}

/* v19: children build the unit row, then answer; equal units touch edge to edge. */
.interactive-measure .measure-track {
  display: flex;
  width: 100%;
  min-height: 54px;
  border-bottom: 2px solid #bbd8ca;
  align-items: flex-end;
  overflow: hidden;
}
.interactive-measure .measure-unit {
  flex: 0 0 calc(100% / var(--units));
  width: calc(100% / var(--units));
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.interactive-measure .measure-unit img {
  width: 100%;
  height: auto;
  max-height: none;
  display: block;
}
.measure-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 64px;
  width: min(100%, 190px);
  margin: 12px auto;
  background: #e0f4e5;
  border: 2px solid #65bd84;
  font-size: 28px;
}
.measure-add img {
  height: 42px;
  width: 82px;
}
.measure-add[hidden],
.choices[hidden] {
  display: none !important;
}
@media (max-height: 550px) {
  .measure-add {
    margin: 6px auto;
    min-height: 52px;
  }
  .measure-add img {
    height: 32px;
  }
  .interactive-measure .measure-track {
    min-height: 40px;
  }
}

/* Generated same-level cloth patches keep square geometry within the visual cell. */
.cloth-generated {
  width: min(100%, 240px);
  aspect-ratio: 1;
  min-height: 0;
}
.cloth-generated > svg {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: block;
}
[data-type='cloth'] .choice svg,
[data-type='quarter'] .choice svg {
  height: clamp(55px, 12vh, 96px);
  max-width: 100%;
  flex-shrink: 1;
}
/* Equal columns make the missing number the geometric center, regardless of glyph width. */
.number-order {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 280px);
  gap: 10px;
  margin-inline: auto;
  align-items: center;
}
.number-order span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  box-sizing: border-box;
  padding: 12px 4px;
  text-align: center;
}
@media (max-width: 350px) {
  .number-order {
    gap: 8px;
  }
  .number-order span {
    padding: 10px 4px;
  }
}
/* Workbook six-picture circle selection: reversible until the large check button. */
.multi-scene .visual:empty {
  display: none;
}
.multi-scene .multi-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  flex: 1;
  min-height: 0;
  gap: 10px;
  width: 100%;
}
.multi-choice {
  position: relative;
  min-width: 0;
  min-height: 60px !important;
  padding: 10px !important;
  overflow: hidden;
  background: #fffaf0;
}
.multi-choice > img,
.multi-choice > svg {
  width: 100% !important;
  height: 100% !important;
  max-height: 140px !important;
  min-height: 0;
  object-fit: contain;
  flex: 1;
}
.multi-choice .selection-tick {
  display: none;
}
.multi-choice.selected {
  background: #eaf8ec;
}
.multi-choice.selected:after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 3px solid #219853;
  border-radius: 50%;
  pointer-events: none;
}
.multi-submit {
  width: min(100%, 220px);
  min-height: 52px;
  align-self: center;
  font-size: 30px;
  background: #d9f3e2;
  border: 2px solid #65b987;
  flex-shrink: 0;
}
.shared-chain {
  width: 100%;
  height: 100%;
  max-height: 340px !important;
}
.chain-undo {
  position: absolute;
  right: 12px;
  top: 42px;
  width: 44px;
  height: 44px;
  min-height: 44px;
  background: #eef7ec;
  font-size: 27px;
}
.chain-undo:disabled {
  visibility: hidden;
}
.estimate-measure {
  width: min(100%, 400px);
  padding: 0;
  gap: 10px;
}
.estimate-measure .train {
  width: 100%;
  height: auto;
}
.estimate-measure .train img {
  width: 100%;
  height: auto;
  display: block;
}
.estimate-measure .measure-track {
  display: flex;
  width: 100%;
  gap: 0;
  align-items: flex-end;
  min-height: 0;
}
.estimate-measure .measure-unit {
  display: block;
  flex: 0 0 calc(100% / var(--units));
  width: calc(100% / var(--units));
  box-shadow:
    inset 1px 0 #9faaa2,
    inset -1px 0 #9faaa2;
}
.estimate-measure .measure-unit img {
  width: 100%;
  height: auto;
  display: block;
  max-height: none;
}
.question-scene[data-type='measure'] .choices {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-height: 550px) {
  .multi-scene .multi-choices {
    gap: 6px;
  }
  .multi-choice {
    padding: 7px !important;
  }
  .multi-submit {
    min-height: 48px;
  }
  .shared-chain {
    max-height: 240px !important;
  }
  .multi-choice > img,
  .multi-choice > svg {
    max-height: 100px !important;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  #scene.multi-scene {
    display: flex !important;
  }
  .multi-scene .multi-choices {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
    gap: 5px;
  }
  .multi-submit {
    min-height: 44px;
    font-size: 24px;
  }
  .multi-scene .prompt {
    font-size: 16px;
  }
  .chain-undo {
    top: 4px;
    right: 4px;
  }
}
.grouped-share {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 5px;
}
.basket-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(var(--basket-rows), minmax(0, 1fr));
  min-height: 0;
  gap: 5px;
  justify-items: center;
}
.basket-grid img {
  width: 100%;
  height: 100%;
  max-height: 90px;
  min-height: 0;
  object-fit: contain;
}
.loose-apples {
  display: flex;
  justify-content: center;
  gap: 6px;
}
.loose-apples img {
  width: clamp(20px, 6vw, 32px);
  height: clamp(20px, 6vw, 32px);
  object-fit: contain;
}
.grouped-share .receivers {
  height: clamp(30px, 6vh, 50px);
}
.grouped-share .receivers img {
  height: 100%;
  width: auto;
}
[data-type='equal-two'] .choices {
  grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
}
.equation-fill-scene .visual {
  flex: 1;
  min-height: 40px;
}
.equation-fill-scene .visual .objects img {
  width: clamp(24px, 6vw, 40px);
  height: clamp(24px, 6vw, 40px);
}
.equation-slots {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 0.65fr 1fr;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.equation-slot {
  min-width: 0;
  min-height: 48px;
  border: 2px solid #b5c2b5;
  border-radius: 12px;
  background: #fff;
  font-size: 28px;
  font-weight: 750;
  display: flex;
  align-items: center;
  justify-content: center;
}
.equation-slot.active {
  background: #dcf5e6;
  border-color: #219c54;
  box-shadow: 0 0 0 1px #219c54;
}
.equation-slot img,
.fixed-equals img,
.symbol-keys img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.fixed-equals {
  display: flex;
  justify-content: center;
}
.equation-keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  flex-shrink: 0;
}
.equation-key {
  min-height: 44px;
  padding: 4px;
  font-size: 25px;
  font-weight: 700;
  border-radius: 12px;
  background: #fff0ce;
  display: flex;
  align-items: center;
  justify-content: center;
}
.equation-keys.symbol-keys {
  grid-template-columns: repeat(2, 1fr);
  min-height: 142px;
}
.symbol-keys .equation-key {
  align-self: center;
  min-height: 60px;
}
.equation-fill-scene .prompt {
  font-size: 18px;
}
@media (max-height: 550px) {
  .equation-fill-scene {
    gap: 5px !important;
  }
  .equation-fill-scene .prompt {
    font-size: 16px;
  }
  .equation-slot {
    min-height: 44px;
    font-size: 26px;
  }
  .equation-fill-scene .visual {
    min-height: 34px;
  }
  .equation-fill-scene .visual .objects img {
    width: 26px;
    height: 26px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  #scene.equation-fill-scene {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .equation-fill-scene .prompt {
    grid-column: 1;
    grid-row: 1;
  }
  .equation-fill-scene .visual {
    grid-column: 1;
    grid-row: 2 / 4;
  }
  .equation-fill-scene .equation-slots {
    grid-column: 2;
    grid-row: 1;
  }
  .equation-fill-scene .equation-keys {
    grid-column: 2;
    grid-row: 2 / 4;
  }
}

/* Both quantities remain visible through every fill-in step; no result shown. */
.addition-story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr);
  align-items: stretch;
  gap: 4px;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 180px;
}
.story-pile {
  border: 2px solid #b6d4be;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px;
  min-height: 0;
  min-width: 0;
  background: #f5fbf4;
}
.incoming-pile {
  border-style: dashed;
  background: #fff8df;
  border-color: #d5ba67;
}
.pile-label {
  font-size: 13px;
  line-height: 1.1;
  color: #5d675c;
  flex-shrink: 0;
}
.incoming-arrow {
  align-self: center;
  text-align: center;
  font-size: 25px;
  color: #518862;
}
.story-pile .objects {
  gap: 3px;
  min-height: 0;
  max-height: 100%;
  align-content: center;
}
.equation-fill-scene .story-pile .objects img {
  width: clamp(20px, 5.5vw, 32px);
  height: clamp(20px, 5.5vw, 32px);
}
@media (max-height: 550px) {
  .addition-story {
    max-height: 120px;
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
  }
  .story-pile {
    padding: 3px;
    gap: 2px;
  }
  .equation-fill-scene .story-pile .objects img {
    width: 22px;
    height: 22px;
  }
  .pile-label {
    font-size: 12px;
  }
  .incoming-arrow {
    font-size: 22px;
  }
}

.subtraction-story > span {
  position: relative;
  display: flex;
}
.taken-flower {
  opacity: 0.55;
}
.taken-flower:after {
  content: '';
  position: absolute;
  left: 0;
  top: 48%;
  width: 100%;
  height: 3px;
  background: #b53649;
  transform: rotate(-45deg);
  border-radius: 2px;
}

/* rolling-v26: seven workbook colors, large touch targets on phones. */
[data-type='rolling'] .choices {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}
[data-type='rolling'] .choice {
  min-height: 52px;
  padding: 5px 2px;
  border-radius: 50%;
}
[data-type='rolling'] .choice > img {
  height: 42px;
  max-height: 42px;
}
@media (max-width: 420px) {
  [data-type='rolling'] .choices {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-width: 320px;
    align-self: center;
    width: 100%;
  }
  [data-type='rolling'] .choice {
    border-radius: 18px;
  }
}

[data-type='rolling'] .choice > img {
  width: 42px;
  border-radius: 50%;
}
/* Actual-exam practice, v27 */
.exam-start {
  background: #476eab;
  margin-top: 12px;
}
.exam-objects {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 420px;
  margin: 10px auto;
}
.exam-objects img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}
.exam-story {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: center;
}
.exam-story > div {
  border: 2px dashed #b6cbb8;
  border-radius: 12px;
  padding: 8px;
}
.exam-story small {
  font-size: 17px;
}
.exam-rule {
  font-size: 20px;
  text-align: center;
  font-weight: bold;
}
.exam-tiles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
}
.tile-model {
  flex: 0 0 55px;
  border: 2px dashed #8cb09c;
  padding: 6px;
  border-radius: 8px;
}
.tile-target {
  max-width: 290px;
  flex: 1;
}
.exam-tiles svg {
  display: block;
  width: 100%;
  height: auto;
}
.exam-sequence {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.exam-sequence svg {
  width: 30%;
  max-width: 120px;
}
.exam-sequence b {
  font-size: 48px;
  padding: 0 16px;
}
.choices.exam-regions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 500px;
}
.exam-regions .choice {
  position: relative;
  padding: 6px;
  min-width: 0;
  min-height: 80px;
  border-radius: 10px;
}
.exam-regions .choice[data-region='A'] {
  background: #e6f0fb;
}
.exam-regions .choice[data-region='B'] {
  background: #e8f4e9;
}
.exam-regions .choice svg {
  display: block;
  width: 100%;
  max-height: 75px;
}
.exam-region-label {
  position: absolute;
  top: 0;
  left: 2px;
  font-size: 14px;
  font-weight: bold;
  color: #31485a;
}
[data-type^='exam-'] .visual > svg {
  display: block;
  width: 100%;
  max-width: 450px;
  max-height: 350px;
  margin: 0 auto;
}
[data-type='exam-quarter'] .multi-choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 420px;
}
[data-type='exam-quarter'] .choice svg {
  width: 100%;
  max-height: 140px;
}
[data-type='exam-rolling'] .choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
[data-type='exam-rolling'] .choice {
  min-width: 50px;
  flex: 0 1 65px;
  padding: 4px;
}
[data-type='exam-rolling'] .choice svg {
  width: 50px;
  height: 50px;
}
[data-type='exam-rotate'] .choices,
[data-type='exam-tiles'] .choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 420px;
}
[data-type='exam-rotate'] .choice svg {
  max-height: 100px;
  width: 100%;
}
[data-type='exam-tiles'] .choice svg {
  width: 100%;
  max-height: 55px;
}
.exam-connect-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  width: min(100%, 380px);
  aspect-ratio: 1;
  margin: 10px auto;
  border: 2px solid #8daf91;
  border-radius: 6px;
  overflow: hidden;
  background: #fff9e9;
  touch-action: manipulation;
}
.exam-connect-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.exam-connect-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid #bed2b7;
  border-radius: 0;
  background: transparent;
  z-index: 2;
  cursor: pointer;
  padding: 0;
  font-size: 30px;
  touch-action: manipulation;
}
.exam-connect-cell span {
  background: #fff9e9;
  border-radius: 50%;
  padding: 1px;
}
.exam-connect-cell.current {
  box-shadow: inset 0 0 0 4px var(--path-color);
}
.exam-connect-cell:focus-visible {
  outline: 3px solid #435d9a;
  outline-offset: -4px;
}
.exam-connect-status {
  text-align: center;
  font-size: 15px;
  min-height: 24px;
}
.exam-connect-controls {
  display: flex;
  gap: 14px;
  justify-content: center;
}
.exam-connect-controls button {
  border: 2px solid #83b497;
  border-radius: 12px;
  background: #eaf6ee;
  padding: 12px 20px;
  font-size: 20px;
  min-height: 48px;
}
@media (max-width: 420px) {
  .exam-objects img {
    width: 34px;
    height: 34px;
  }
  .exam-story {
    gap: 8px;
  }
  .exam-story > div {
    padding: 4px;
  }
  .exam-tiles {
    gap: 12px;
  }
  .exam-connect-cell {
    font-size: 26px;
  }
  .exam-sequence {
    gap: 4px;
  }
  .exam-sequence b {
    padding: 0 5px;
  }
  .exam-regions .choice {
    min-height: 64px;
  }
}
.exam-analogy {
  max-width: 390px;
  margin: auto;
}
.exam-analogy-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  border: 1px dashed #c3c8ad;
  border-radius: 12px;
  margin-bottom: 8px;
  padding: 3px;
}
.exam-analogy-row svg {
  width: 28%;
  height: auto;
  max-height: 98px;
}
.exam-analogy-row b {
  width: 28%;
  text-align: center;
  font-size: 40px;
}
.exam-analogy-row span {
  font-size: 17px;
  color: #6b8671;
}
#scene[data-type^='exam-'] .visual {
  flex: 1;
  min-height: 0;
  max-height: none;
  margin: 0;
  overflow: hidden;
}
[data-type='exam-equation'] .choices {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
[data-type='exam-equation'] .choice {
  font-size: 24px;
  white-space: nowrap;
}
[data-type='exam-connect'] .visual {
  container-type: size;
  gap: 0;
}
.exam-connect-board {
  flex: none;
  width: min(100%, 380px, calc(100cqh - 45px));
  margin: 4px auto;
}
.exam-connect-status {
  font-size: 14px;
  line-height: 1.3;
  min-height: 30px;
}
.exam-analogy {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.exam-analogy-row {
  flex: 1;
  min-height: 0;
  margin-bottom: 5px;
}
.exam-analogy-row svg {
  height: 100%;
  min-height: 0;
  max-height: 98px;
}
.exam-tiles {
  width: 100%;
  height: 100%;
  max-height: 100%;
}
.tile-target {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-target svg {
  max-height: 100%;
  object-fit: contain;
}
.tile-model {
  max-height: 95px;
}
.tile-model svg {
  max-height: 80px;
}
@media (max-height: 550px) {
  #scene[data-type^='exam-'] {
    gap: 6px;
  }
  #scene[data-type^='exam-'] .prompt {
    font-size: 15px;
    line-height: 1.25;
  }
  [data-type='exam-equation'] .choice {
    font-size: 22px;
    padding: 6px;
  }
  [data-type='exam-equation'] .exam-objects img {
    width: 23px;
    height: 23px;
  }
  [data-type='exam-equation'] .exam-objects {
    gap: 3px;
    margin: 4px auto;
  }
  .exam-connect-status {
    display: none;
  }
  .exam-connect-board {
    width: min(100%, 300px, 100cqh);
    margin: 0 auto;
  }
  .exam-connect-controls button {
    font-size: 18px;
    padding: 5px 16px;
    min-height: 40px;
  }
  .exam-connect-cell {
    min-height: 0;
    font-size: 24px;
  }
  .exam-analogy-row {
    padding: 1px;
    margin-bottom: 3px;
  }
  [data-type='exam-rotate'] .choice {
    min-height: 48px;
    padding: 3px;
  }
  [data-type='exam-rotate'] .choice svg {
    height: 44px;
  }
  .exam-rule {
    font-size: 16px;
  }
}

/* Full question text stays readable; short screens scroll without clipping the task. */
#scene.question-scene {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
}
#scene.question-scene .prompt {
  white-space: pre-wrap;
  overflow: visible;
  overflow-wrap: anywhere;
  line-height: 1.5;
  max-height: none;
}
#scene.question-scene .visual:not(:empty) {
  flex: 1 0 220px;
  min-height: 220px;
  max-height: none;
  margin: 0;
  overflow: visible;
}
#scene.question-scene.path-scene .visual {
  flex-basis: 330px;
  min-height: 330px;
}
#scene.question-scene[data-type='exam-connect'] .visual:not(:empty) {
  flex: 1 0 360px;
  min-height: 360px;
  height: 360px;
  container-type: normal;
}
#scene .exam-connect-board {
  width: min(100%, 300px);
  flex-shrink: 0;
}
