/* Child-friendly reading scale. All sizes follow the user's browser text size. */
:root {
  --reading-blue:#165596;
  --reading-orange:#a44b09;
  --reading-red:#a3353c;
  --font-reader:"Trebuchet MS","Avenir Next",Avenir,system-ui,sans-serif;
}
body { line-height:1.65; }
body :where(button,input,select,textarea) { font-family:var(--font-reader); }
body :where(h1,h2,h3) { text-wrap:balance; }
body :where(p,li,legend,label,figcaption) { overflow-wrap:break-word; }
body strong.reading-keyword { display:inline!important; font-size:inherit!important; font-family:inherit!important; font-weight:800!important; line-height:inherit!important; letter-spacing:inherit!important; text-transform:none!important; }
strong.reading-keyword--idea { color:var(--reading-blue)!important; }
strong.reading-keyword--action { color:var(--reading-orange)!important; }
strong.reading-keyword--care { color:var(--reading-red)!important; }
/* On a dark illustration caption use weight, not low-contrast colored words. */
body :where(.chapter-art-label,.adventure-story-art figcaption,.chapter-illustration figcaption,.erato-hero,.erato-story-art figcaption) strong.reading-keyword { color:inherit!important; }
body .container { max-width:1410px; padding-inline:clamp(18px,3vw,46px); }
body .header-inner { max-width:1490px; flex-wrap:wrap; gap:20px 28px; padding:22px clamp(18px,3vw,46px); }
body .brand { font-size:1.75rem; }
body .brand-small { font-size:.8rem; letter-spacing:.055em; line-height:1.5; white-space:normal; max-width:260px; }
body .main-nav { gap:14px 25px; flex-wrap:wrap; font-size:.95rem; }
body .main-nav a { padding-block:10px; white-space:normal; }
body .nav-count { width:auto; min-width:26px; height:auto; min-height:26px; padding:1px 5px; font-size:.85rem; }
body .player-button { font-size:.95rem; max-width:270px; padding:8px 13px; min-height:50px; }
body .player-button #player-name { max-width:150px; }
body .avatar { width:35px; height:35px; font-size:.95rem; }
body .header-player-group { gap:10px; max-width:none; }
body .header-play-balance { font-size:.9rem; min-height:40px; padding:6px 12px; flex-wrap:wrap; }
body .hero-copy>p { max-width:55ch; }
body .btn { min-height:52px; padding:13px 22px; font-size:1rem; white-space:normal; height:auto; text-align:center; }
body .btn-small { min-height:46px; padding:10px 16px; font-size:.95rem; }
body .text-button,body .text-link { line-height:1.6; }
body .icon-button { width:44px; height:44px; flex-shrink:0; }
body .eyebrow { letter-spacing:.08em; line-height:1.6; }
body .page-intro p { max-width:70ch; }
body .section-head { flex-wrap:wrap; align-items:center; }
body .section-head a { white-space:normal; }
body .timeline { grid-template-columns:repeat(7,minmax(165px,1fr)); gap:9px; padding-bottom:24px; }
body .timeline-node { min-width:150px; }
body .timeline-dot { width:44px; height:44px; }
body .timeline>li:before { top:22px; }
body .featured-row { grid-template-columns:minmax(0,1.7fr) minmax(0,1fr); }
body .featured { grid-template-columns:minmax(0,.8fr) minmax(0,1.3fr); gap:24px; padding:27px; }
body .featured p,body .notebook-teaser p { max-width:58ch; }
body .method-item p { max-width:45ch; }
body .game-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
body .game-card { min-width:0; }
body .game-card-body { padding:24px; }
body .game-card-footer { flex-wrap:wrap; gap:12px; }
body .filters { align-items:stretch; flex-wrap:wrap; }
body .chip { min-height:48px; padding:11px 19px; }
body .site-footer { align-items:flex-start; gap:24px; flex-wrap:wrap; }
body .site-footer>div { flex-wrap:wrap; }
body .game-header { flex-wrap:wrap; gap:22px; }
body .game-header p { max-width:65ch; }
body .game-host { margin-top:30px; }
body .game-bottom { flex-wrap:wrap; gap:18px; }
body .chapter-toolbar { gap:18px; flex-wrap:wrap; }
body .chapter-toolbar-actions { flex-wrap:wrap; gap:16px; }
body .chapter-story-page { padding:clamp(26px,4vw,48px); }
body .chapter-beats p,body .chapter-coda { font-size:1.1rem; line-height:1.8; }
body .chapter-story-navigation { gap:20px; align-items:flex-start; flex-wrap:wrap; }
body .chapter-page-dots { flex-wrap:wrap; gap:8px; }
body .chapter-page-dots button { width:44px; height:44px; font-size:.95rem; }
body :where(.chapter-primary,.chapter-secondary,.chapter-skip,.chapter-text-button) { min-height:50px; padding:12px 17px; font-size:1rem; line-height:1.5; white-space:normal; }
body :where(.chapter-history,.chapter-story-note,.level-save-message,.action-save-note) { font-size:.9rem; line-height:1.7; }
body .level-navigation { padding:26px; }
body .level-nav-heading { flex-wrap:wrap; align-items:flex-start; gap:15px; }
body .level-nav-heading p { font-size:1rem; }
body .level-nav-heading .eyebrow { font-size:.9rem; }
body .level-total { font-size:.9rem; max-width:none; white-space:normal; }
body .level-step { min-height:100px; padding:18px; align-items:flex-start; gap:13px; }
body .level-step[aria-current=step] { padding:17px; }
body .level-step-symbol { width:34px; height:34px; flex:0 0 34px; font-size:1rem; }
body .level-step strong { font-size:1.25rem; line-height:1.3; }
body .level-step small { font-size:.9rem; line-height:1.6; margin-top:6px; }
body .level-locked { font-size:.85rem; }
body .level-nav-note { font-size:.9rem; }
body .level-lab-heading { flex-wrap:wrap; gap:20px; padding:30px 32px 0; }
body .level-task-dots { flex-wrap:wrap; gap:9px; }
body .level-task-dots li { width:34px; height:34px; font-size:1rem; }
body .level-lab h2 { font-size:clamp(1.6rem,3vw,2.1rem); }
body .level-intro { font-size:1.1rem; line-height:1.8; margin:20px 32px 30px; max-width:80ch; }
body .level-lab-layout { grid-template-columns:minmax(0,1fr) minmax(0,1.15fr); }
body .level-lab-controls { padding:30px; min-width:0; }
body .level-lab-picture { min-width:0; padding:26px; }
body .level-lab-picture>p { font-size:1rem; line-height:1.75; }
body .level-task-instruction { font-size:1.1rem; line-height:1.8; padding:22px 24px; }
body .task-guide-heading { font-size:1rem; }
body .task-guide p { margin:10px 0 16px; }
body .task-steps { padding-left:1.5em; }
body .task-steps li { padding-left:7px; margin-block:12px; }
body .task-guide-tip { font-size:1rem; line-height:1.75; padding-top:14px; }
body .level-field { margin-block:22px; }
body .level-field>label,body .level-choice legend { font-size:1.05rem; line-height:1.65; }
body .level-field>label { flex-wrap:wrap; gap:8px 18px; }
body .level-field-help { font-size:1rem; }
body .level-choice>label { font-size:1.05rem; gap:14px; padding:17px 18px; margin-block:10px; }
body .level-choice input { width:22px; height:22px; margin-top:6px; }
body .level-input-row { flex-wrap:wrap; gap:14px; }
body .level-input-row input[type=number] { min-height:58px; max-width:310px; font-size:1.2rem; padding:13px 16px; }
body input[type=range] { min-height:44px; }
body .level-score-note { font-size:.95rem; line-height:1.75; margin-top:20px; }
body .level-feedback { font-size:1.05rem; }
body .level-feedback:not(:empty) { padding:19px 21px; }
body :where(.level-reset,.level-ending-replay) { font-size:.95rem; min-height:48px; }
body .lab-controls { min-width:0; }
body .lab-stage { min-width:0; }
body .scene-caption { font-size:1rem; line-height:1.75; }
body :where(.lab-layout,.arch-layout,.newton-layout,.riemann-layout) { gap:26px; }
body .control-row { flex-wrap:wrap; gap:12px; }
body input:not([type=range]):not([type=radio]):not([type=checkbox]) { min-height:50px; max-width:100%; }
body select { min-height:50px; max-width:100%; }
body label { line-height:1.65; }
body .action-heading { flex-wrap:wrap; gap:18px; }
body .action-intro { font-size:1.1rem; }
body .action-instructions { font-size:1.1rem; padding:22px 26px; }
body .action-instructions>strong { font-size:1rem; }
body .action-instructions li { padding:6px 0; }
body .action-task-marks span,body .action-task-marks strong { width:34px; height:34px; font-size:1rem; }
body .action-hp-label { flex-wrap:wrap; }
body .action-hp-label>span:last-child { font-size:.95rem; }
body .action-progress-row { flex-wrap:wrap; font-size:1rem; gap:14px; }
body .action-controls { padding:26px 30px 0; gap:23px; }
body .action-control-range,body .action-control-select { font-size:1rem; flex-basis:240px; }
body .action-control-select select { font-size:1.05rem; }
body .action-feedback { font-size:1.05rem; }
body .action-footer { flex-wrap:wrap; }
body .action-footer>p { font-size:.95rem; flex-basis:320px; }
body .action-phase-panel { padding:22px; overflow:auto; }
body .action-phase-panel>div { max-width:520px; padding:26px; }
body .action-phase-panel p { font-size:1rem; }
body .action-stage-wrap:has(.action-phase-panel:not([hidden])) { min-height:370px; }
body .adventure-story-copy { padding:clamp(26px,4vw,45px); }
body .adventure-story-paragraph { font-size:1.1rem; line-height:1.85; }
body .music-panel { position:relative; top:auto; }
body .music-panel-inner { max-width:1490px; display:flex; flex-wrap:wrap; gap:18px 25px; padding:17px clamp(18px,3vw,46px); }
body .music-toggle { min-height:50px; font-size:1rem; }
body .music-caption { min-width:180px; flex:1 1 210px; }
body .music-caption strong { font-size:1rem; }
body .music-caption span { font-size:.9rem; line-height:1.5; }
body .music-picker { flex:1 1 270px; min-width:0; gap:6px; }
body .music-picker label { font-size:.9rem; flex:auto; }
body .music-track-select { font-size:1rem; min-height:50px; }
body .music-adjustments { font-size:.9rem; gap:12px; flex-wrap:wrap; }
body .music-adjustments label { font-size:.9rem; }
body .music-credits-link { font-size:.9rem; min-height:44px; }
body .music-adjustments input { width:115px; }
body .wallet-resources { gap:16px; }
body .wallet-resource { min-width:0; flex-wrap:wrap; padding:21px; }
body .wallet-resource-label { font-size:1rem; white-space:normal; }
body .wallet-resource-detail,body .wallet-welcome-label { font-size:.9rem; }
body .arcade-wallet { grid-template-columns:minmax(0,1fr) minmax(0,1.1fr); gap:24px; }
body .wallet-actions { grid-column:1/-1; max-width:none; align-items:flex-start; }
body .wallet-welcome { font-size:.95rem; }
body .refill-breakdown { gap:12px; }
body .refill-breakdown dt { min-height:0; font-size:1rem; }
body .refill-breakdown dd { margin-top:12px; }
body .level-failure-overlay { align-items:start; padding:clamp(18px,5vh,50px) 18px; }
body .level-failure-card { margin-block:auto; max-height:none; }
body dialog { max-height:calc(100dvh - 36px); overflow:auto; width:min(820px,calc(100vw - 32px)); }
body .dialog-shell { padding:clamp(24px,4vw,42px); }
body .dialog-heading { gap:20px; align-items:flex-start; }
body .toast { font-size:1rem; line-height:1.65; }
body .review-study { max-width:930px; padding:clamp(26px,4vw,48px); }
body .review-prompt { font-size:1.2rem; line-height:1.8; }
body .review-choice { font-size:1.1rem; padding:20px 22px; }
body .review-choices { gap:16px; }
body .review-feedback { font-size:1.1rem; line-height:1.8; }
body .review-study .eyebrow { font-size:.9rem; }
body .inventory-summary { flex-wrap:wrap; }
body .inventory-honors { gap:14px; }
body .inventory-honor { padding:18px 10px; }
body .inventory-honor small { font-size:.9rem; }
/* Explicit enlargement for diagrams keeps live coordinates and drag targets intact. */
.reading-diagram-button { margin:14px 0; font:700 .95rem/1.5 var(--font-reader); min-height:48px; padding:10px 16px; border:1px solid #a7bacb; border-radius:10px; color:#165596; background:#f7fbff; }
.reading-diagram-dialog { padding:26px; background:#fffdf5; border:2px solid #bac9d7; border-radius:20px; }
.reading-diagram-dialog::backdrop { background:#14213eaa; }
.reading-diagram-toolbar { display:flex; flex-wrap:wrap; justify-content:space-between; gap:14px; align-items:center; margin-bottom:15px; }
.reading-diagram-toolbar h2 { font:700 1.3rem/1.4 var(--font-reader); margin:0; }
.reading-diagram-scroll { overflow:auto; background:#f6f3e8; border-radius:12px; max-height:65dvh; }
.reading-diagram-scroll svg { display:block; width:1100px; max-width:none; height:auto; pointer-events:none; }
.reading-diagram-dialog>p { font-size:1rem; margin:16px 0 0; }
@media(max-width:1180px) {
  body .main-nav { order:3; width:100%; justify-content:center; }
  body .header-player-group { margin-left:auto; flex-direction:row; }
  body .header-play-balance { font-size:.9rem; }
  body .level-lab-layout,body .lab-layout,body .arch-layout,body .newton-layout,body .riemann-layout { grid-template-columns:minmax(0,1fr)!important; }
  body .chapter-storybook,body .adventure-story { grid-template-columns:minmax(0,1fr)!important; }
  body .chapter-illustration img,body .adventure-story-art img { max-height:450px; object-fit:contain; }
  body .chapter-art-label { position:static; padding:24px; background:#25483b; }
  body .level-lab-picture [data-level-visual] { max-width:800px; margin:auto; }
  body .lab-stage>svg { max-height:570px; }
  body .game-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body .featured-row { grid-template-columns:minmax(0,1fr); }
  body .notebook-teaser { padding:28px; }
  body .hero { gap:30px; }
}
@media(max-width:760px) {
  body .header-inner { gap:20px; }
  body .header-player-group { flex-wrap:wrap; flex-direction:column; }
  body .hero { grid-template-columns:minmax(0,1fr); padding-top:30px; }
  body .hero-art { max-width:600px; margin:auto; }
  body .method-strip,body .inventory-grid { grid-template-columns:minmax(0,1fr); }
  body .method-strip { gap:25px; }
  body .section-head { align-items:flex-start; }
  body .ribbon { flex-wrap:wrap; }
  body .level-steps { gap:10px; }
  body .level-step { display:block; padding:15px 10px; }
  body .level-step[aria-current=step] { padding:14px 9px; }
  body .level-step-symbol { margin-bottom:10px; }
  body .level-step strong { font-size:1.1rem; }
  body .level-step small { font-size:.9rem; }
  body .level-locked { display:none; }
  body .level-navigation { padding:22px 18px; }
  body .level-nav-heading { gap:12px; }
  body .level-lives { margin-left:0; white-space:normal; }
  body .arcade-wallet { display:flex; flex-direction:column; }
  body .wallet-resource { padding:17px; }
  body .music-panel-inner { gap:15px; }
  body .music-caption { flex-basis:170px; }
  body .music-picker { flex-direction:column; align-items:stretch; flex-basis:100%; }
  body .music-picker label { flex-basis:auto; }
  body .music-adjustments { width:100%; justify-content:flex-start; }
  body .music-adjustments input { flex:1; max-width:230px; }
  body .inventory-chapter { padding:24px 18px; }
  body .inventory-honors { gap:9px; }
  body .inventory-honor strong { font-size:.95rem; }
  body .inventory-honor small { font-size:.85rem; }
}
@media(max-width:540px) {
  body .container { padding-inline:16px; }
  body .header-inner { padding:20px 16px; display:grid; grid-template-columns:minmax(0,1fr); gap:18px; }
  body .brand { justify-self:center; }
  body .brand-small { font-size:.8rem; max-width:none; }
  body .brand-symbol { width:43px; height:43px; }
  body .header-player-group { margin:0; width:100%; flex-direction:row; justify-content:center; gap:12px; }
  body .header-player-group .player-button { max-width:220px; }
  body .header-player-group .player-button #player-name { max-width:110px; }
  body .main-nav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px 16px; text-align:center; }
  body .main-nav a { font-size:.95rem; }
  body .game-grid,body .featured { grid-template-columns:minmax(0,1fr); }
  body .featured .card-illustration { height:auto; min-height:180px; }
  body .game-card-body { padding:23px; }
  body .page-intro.split { align-items:flex-start; flex-direction:column; }
  body .section { padding-top:34px; }
  body .level-steps { grid-template-columns:minmax(0,1fr); }
  body .level-step { display:flex; min-height:84px; padding:16px; }
  body .level-step[aria-current=step] { padding:15px; }
  body .level-step-symbol { margin-bottom:0; }
  body .level-step strong { font-size:1.15rem; }
  body .level-step small { font-size:.9rem; }
  body .level-lab-heading { padding:24px 20px 0; }
  body .level-intro { margin:18px 20px 26px; }
  body .level-lab-controls { padding:24px 18px; }
  body .level-task-instruction { padding:20px 17px; }
  body .level-lab-picture { padding:18px 8px; }
  body .level-choice>label { padding:16px 13px; }
  body .level-form-actions { flex-direction:column; align-items:stretch; }
  body .chapter-story-page { padding:25px 20px; }
  body .chapter-story-navigation { flex-direction:column; align-items:stretch; }
  body .chapter-story-actions { flex-wrap:wrap; gap:13px; }
  body .chapter-story-actions>button { flex:1 1 190px; }
  body .action-instructions { margin-inline:18px; padding:20px 17px; }
  body .action-intro { padding-inline:20px; }
  body .action-heading,body .action-controls { padding-inline:20px; }
  body .action-phase-panel { padding:12px; }
  body .action-phase-panel>div { padding:22px 18px; }
  body .action-stage-wrap:has(.action-phase-panel:not([hidden])) { min-height:420px; }
  body .action-phase-panel strong { font-size:1.3rem; }
  body .action-footer { padding-inline:20px; }
  body .adventure-story-copy { padding:25px 21px; }
  body .wallet-resources { flex-wrap:wrap; display:flex; }
  body .wallet-resource { flex:1 1 150px; }
  body .refill-breakdown { grid-template-columns:minmax(0,1fr); }
  body .refill-breakdown>div { border:0; padding-block:14px; }
  body .review-study { padding:26px 20px; }
  body .review-prompt { font-size:1.15rem; }
  body .review-choice { padding:18px 14px; font-size:1.05rem; }
  body .inventory-honors { grid-template-columns:minmax(0,1fr); }
  body .inventory-honor { display:grid; grid-template-columns:75px minmax(0,1fr); align-items:center; text-align:left; column-gap:16px; }
  body .inventory-honor .honor-emblem { grid-row:1 / 3; margin:12px auto; }
  body .inventory-honor strong { font-size:1.05rem; }
  body .inventory-honor small { font-size:.9rem; grid-column:2; margin-top:0; }
  body .reading-diagram-dialog { padding:18px; }
}
@media(prefers-reduced-motion:reduce) { body .btn:hover { transform:none; } }
@media print { .reading-keyword { color:inherit; } .reading-diagram-button { display:none; } }
/* Longer status labels must wrap rather than push tablet layouts off-screen. */
body .game-title-row { flex-wrap:wrap; gap:24px; }
body .game-title-row>div:first-child { flex:1 1 520px; min-width:0; }
body .game-status { flex:0 1 225px; min-width:0; white-space:normal; text-align:left; }
body .game-status .small { font-size:.95rem; white-space:normal; }
body .breadcrumb { flex-wrap:wrap; }
body .book-numbers { flex-wrap:wrap; gap:24px 40px; }
body .book-number { flex:1 1 130px; }
body .book-number span { white-space:normal; letter-spacing:.04em; line-height:1.6; font-size:.9rem; }
body .book-summary strong.reading-keyword { color:inherit!important; }

/* Chapter-only reading floor. The arcade retains its existing size at every
   viewport. In particular its mobile root-size rule must not shrink lessons. */
[data-reading-content] {
  --chapter-body-size:max(1.1rem,22px);
  --chapter-label-size:max(1rem,20px);
}
#game-host[data-reading-content] :where(
  .chapter-beats p,.chapter-coda,.chapter-discovery p,
  .level-intro,.level-task-instruction,.task-guide,.task-guide p,.task-steps li,
  .level-lab-picture>p,.level-feedback,
  .lab-controls p,.lab-feedback,.scene-caption,
  .action-intro,.action-instructions,.action-instructions li,.action-feedback,
  .action-hint,.adventure-story-paragraph,.adventure-discovery p,.adventure-bookmark p,
  .victory-mini-story p,.victory-expanded-story p,
  .review-prompt,.review-prompt p,.review-choice,.review-feedback p
),
.chapter-preview[data-reading-content] :where(.chapter-dialogue p,.chapter-narration,.chapter-coda) {
  font-size:var(--chapter-body-size);
  line-height:1.8;
}
#game-host[data-reading-content] :where(
  .chapter-dialogue strong:not(.reading-keyword),.chapter-kicker,.chapter-page-count,
  .chapter-story-note,.chapter-history,.chapter-journal-count,.chapter-journal-label,
  .chapter-primary,.chapter-secondary,.chapter-skip,.chapter-text-button,
  .level-field>label,.level-field-help,.level-choice legend,.level-choice>label,
  .level-step small,.level-nav-note,.level-score-note,.level-save-message,
  .task-guide-heading,.action-control-range,.action-control-select,.action-footer>p,
  .action-phase-panel p,.review-help,.review-source,.review-footer,.btn
) {
  font-size:var(--chapter-label-size);
  line-height:1.65;
}
#game-host[data-reading-content] .task-guide-tip { font-size:var(--chapter-label-size); }
#game-host[data-reading-content] :where(.chapter-story-heading,.chapter-story-actions,.level-form-actions) { flex-wrap:wrap; }
/* The Alexandria expedition has its own story renderer and controls. */
#game-host[data-reading-content] :where(.erato-story-narration,.erato-story-beats .erato-dialogue p,.erato-dialogue p) {
  font-size:max(1.2rem,22px);
}
#game-host[data-reading-content] .erato-story-coda { font-size:max(1.25rem,22px); }
#game-host[data-reading-content] .erato-story-record p { font-size:var(--chapter-body-size); }
#game-host[data-reading-content] :where(.erato-story-beats .erato-dialogue strong:not(.reading-keyword),.erato-primary,.erato-secondary,.erato-story-skip) {
  font-size:var(--chapter-label-size);
  line-height:1.65;
}
