:root {
  color-scheme: dark;
  background: #0b1424;
  color: #eff7ff;
  font-family: Inter, system-ui, sans-serif;
  --panel: #101d35;
  --edge: #3e597a;
  --blue: #185e9a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
button, .exit {
  color: inherit;
  background: #172c48;
  border: 1px solid var(--edge);
  border-radius: .5rem;
  padding: .45rem .7rem;
  min-height: 2.5rem;
  font: 650 .875rem/1.2 system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled), .exit:hover { background: #24496f; }
button:focus-visible, a:focus-visible { outline: 3px solid #f7a05f; outline-offset: 2px; }
button[aria-pressed="true"], #next { background: var(--blue); border-color: #6cb9f2; }
button:disabled { opacity: .5; cursor: default; }
.exit { display: inline-flex; align-items: center; text-decoration: none; }
.toolbar, .controls {
  background: var(--panel);
  padding: .38rem max(.5rem, env(safe-area-inset-right)) .38rem max(.5rem, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toolbar { border-bottom: 1px solid var(--edge); flex-wrap: wrap; }
#lesson-name { color: #d1e5ff; font-weight: 700; flex: 1; }
.tools { display: flex; gap: .35rem; flex-wrap: wrap; }
.controls {
  border-top: 1px solid var(--edge);
  justify-content: center;
  padding-bottom: max(.38rem, env(safe-area-inset-bottom));
}
#progress { min-width: 4.3rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
#next { min-width: 8.3rem; }
.stage-wrap {
  container-type: size;
  display: grid;
  place-items: center;
}
.stage {
  container-type: inline-size;
  position: relative;
  width: min(calc(100cqw - 16px), calc((100cqh - 12px) * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: .65rem;
  color: #14243e;
  background: #f6faff;
  box-shadow: 0 10px 40px #0008;
}
#slide { height: 100%; }
#slide[data-ready] { cursor: pointer; }
.frame {
  height: 100%;
  padding: 2.75cqw 4.4cqw;
  border-top: .65cqw solid #3288c9;
  background: linear-gradient(150deg, white, #f4f9ff 65%, #e9f3ff);
  display: flex;
  flex-direction: column;
  gap: 1.25cqw;
}
.phase {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  color: #24669c;
  font-size: 1.6cqw;
  font-weight: 800;
  letter-spacing: .05em;
}
.timing { color: #526d83; letter-spacing: normal; }
.frame h1 { margin: 0; font-size: 5.1cqw; line-height: 1.04; letter-spacing: -.035em; }
.subtitle { font-size: 3.7cqw; font-weight: 650; color: #24517a; }
.target {
  margin: auto 0 1cqw;
  padding: 2.2cqw;
  font-weight: 700;
  font-size: 3.45cqw;
  background: #e2efff;
  border: 1px solid #9fc8ee;
  border-radius: .65rem;
}
.target strong { color: #205d95; }
.routine {
  list-style-position: inside;
  display: grid;
  gap: .9cqw;
  margin: .9cqw 0 0;
  padding: 0;
  font-size: 2.8cqw;
  font-weight: 700;
}
.routine li { border-radius: .5rem; background: #e4effc; padding: 1cqw 1.6cqw; }
.routine li::marker { color: #21679f; font-weight: 800; }
.proficiency { list-style: none; }
.say-level { margin: auto 0 0; padding: 1.1cqw 1.6cqw; border-radius: .5rem; background: #174c7c; color: white; font-size: 2.5cqw; font-weight: 750; }
.problem h1 { font-size: 4.5cqw; }
.prompt {
  color: #152942;
  font-weight: 700;
  font-size: 4.05cqw;
  line-height: 1.19;
  margin: 1.2cqw 0 0;
  white-space: pre-wrap;
}
.prompt.dense { font-size: 3.35cqw; }
.problem.has-reveals .prompt { font-size: 3.03cqw; margin-top: .15cqw; }
.problem.has-reveals .prompt.dense { font-size: 2.72cqw; }
.model h1 { font-size: 4.5cqw; }
.diagram {
  flex: 1;
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: .55cqw;
}
.diagram-label { color: #205d95; font-size: 2.15cqw; font-weight: 800; }
.diagram-image {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #fff;
  border-radius: .5rem;
}
.diagram-caption { font-size: 1.9cqw; line-height: 1.2; }
.diagram-summary { font-weight: 730; }
.diagram-talk { margin-top: .3cqw; color: #315a7d; }
.has-diagram .prompt { font-size: 2.6cqw; }
.work {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: .6cqw;
  overflow: auto;
  margin-top: auto;
  scrollbar-color: #7597b6 #e0eaf5;
}
.step {
  font-size: 2.2cqw;
  line-height: 1.17;
  padding: .72cqw 1.12cqw;
  border-radius: .42rem;
  color: #173c61;
  background: #e1eefc;
}
.step.hint { background: #fff0d9; color: #723b0e; }
.step.equation, .step.answer { font-weight: 800; color: #fff; background: #1d4d7c; text-align: center; }
.step.answer { background: #146759; }
.think { margin: auto 0 0; color: #315a7d; font-size: 1.85cqw; font-weight: 700; }
.source-slide { display: block; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.frame.scale-poster {
  padding: .75cqw;
  border: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: .55cqw;
  background: #fff;
}
.scale-poster .say-level { margin: 0; text-align: center; }
#notes {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  max-height: 48%;
  overflow: auto;
  background: #112746;
  color: #fff;
  padding: .8rem 1rem;
  font-size: clamp(.9rem, 2cqw, 1.3rem);
}
.status { margin: 1.25rem; }
dialog {
  color: #eff7ff;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: .8rem;
  width: min(48rem, 94vw);
  max-height: 86dvh;
  padding: 1rem;
}
dialog::backdrop { background: #081527dd; }
dialog header { display: flex; justify-content: space-between; gap: .5rem; align-items: center; margin-bottom: .8rem; }
dialog h2 { margin: 0; font-size: 1.25rem; }
.slide-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); gap: .5rem; }
.slide-list button { text-align: left; white-space: normal; }
.slide-list button[aria-current] { border-color: #f7a05f; }
.immersive { position: fixed; inset: 0; }
.immersive #lesson-name { visibility: hidden; }
.immersive .stage { border-radius: 0; }
@media (max-width: 620px) and (orientation: portrait) {
  #lesson-name { text-align: right; }
  .tools { width: 100%; }
  .stage { width: calc(100cqw - 16px); }
  .stage:has(.frame) { aspect-ratio: auto; height: min(100%, max(88cqw, 23rem)); }
  .frame { padding: 4cqw; gap: 2cqw; }
  .frame h1, .problem h1, .model h1 { font-size: max(1.27rem, 6cqw); }
  .phase, .think { font-size: .78rem; }
  .subtitle, .target, .routine, .say-level { font-size: 1rem; }
  .prompt, .prompt.dense, .problem.has-reveals .prompt, .problem.has-reveals .prompt.dense { font-size: .99rem; }
  .step { font-size: .91rem; padding: .28rem .45rem; }
  .diagram-label, .diagram-caption { font-size: .9rem; }
  .stage:has(.diagram) { height: min(100%, max(109cqw, 27rem)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .toolbar, .controls { padding-block: .2rem; }
  button, .exit { padding-block: .25rem; min-height: 2rem; }
}
@media (pointer: coarse) and (orientation: portrait) {
  button, .exit { min-height: 2.75rem; }
}

.quick-question {
  margin: 0;
  padding: .7cqw 1.1cqw;
  border-radius: .42rem;
  background: #e1eefc;
  color: #173c61;
  font-size: 2.45cqw;
  font-weight: 750;
}
.quick-solution {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 1.2cqw;
  grid-template-columns: minmax(0, 1fr);
}
.quick-solution:has(.diagram) {
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
}
.quick-revealed h1 { font-size: 3.65cqw; }
.quick-revealed .diagram-label { font-size: 1.7cqw; }
.quick-work {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .55cqw;
  justify-content: center;
}
.quick-steps {
  min-height: 0;
  display: grid;
  gap: .55cqw;
  overflow: auto;
  scrollbar-color: #7597b6 #e0eaf5;
}
.quick-equations {
  display: flex;
  flex-wrap: wrap;
  gap: .45cqw;
}
.quick-equations .step { flex: 1 1 auto; }
.quick-solution .step {
  font-size: 1.85cqw;
  padding: .55cqw .7cqw;
}
.quick-solution .answer { font-size: 2.15cqw; }

@media (max-width: 620px) and (orientation: portrait) {
  .quick-revealed h1, .quick-question { font-size: 1rem; }
  .quick-solution:has(.diagram) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(3.5rem, 1fr) auto;
    overflow: auto;
  }
  .quick-revealed .diagram-label, .quick-solution .step, .quick-solution .answer {
    font-size: .85rem;
    padding: .22rem .35rem;
  }
}

.place-bar {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  column-gap: 1rem;
  row-gap: .15rem;
  padding: .32rem .65rem;
  background: #1b3654;
  border-radius: .4rem;
}
#current-place {
  font-size: clamp(1rem, 2.1vw, 1.55rem);
  line-height: 1.2;
}
#current-place:empty, #next-place:empty { display: none; }
#next-place {
  margin-inline-start: auto;
  color: #d1e5ff;
  font-size: clamp(.85rem, 1.4vw, 1.05rem);
}
.slide-choice { display: grid; gap: .2rem; }
.slide-reference { color: #a8dbff; }
#more-problems h3 { margin-bottom: .5rem; font-size: 1rem; }

/* Combined money experience uses the existing stage and shared classroom timer. */
.coin-reference { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-around; gap:.65rem; padding:.65rem; border-radius:.6rem; background:#e2efff; color:#173c61; }
.coin-card { display:flex; align-items:center; gap:.5rem; font-size:clamp(1rem,1.6cqw,1.4rem); }
.reference-coin { display:grid; place-items:center; flex:none; width:var(--coin-size); height:var(--coin-size); border:3px double #536273; border-radius:50%; background:#d9dfe5; color:#193c60; font-size:1rem; font-weight:800; }
.reference-coin.coin-1 { background:#c58c63; }
.dollar-reference { font-size:clamp(1rem,1.8cqw,1.5rem); }
.coin-dialog { width:min(65rem,94vw); }
.coin-dialog .coin-reference { margin:1rem 0; }
.combined-money .independent-coins { gap:.75cqw; }
.independent-coins h1 { font-size:4cqw; }
.independent-coins .routine { font-size:2.25cqw; gap:.55cqw; margin:0; }
.independent-coins .routine li { padding:.65cqw 1cqw; }
.independent-coins .coin-reference { margin-top:auto; }
.combined-money .proficiency { font-size:2.3cqw; }
.combined-money .controls { padding-inline:6rem; }
@media(max-width:620px) and (orientation:portrait) {
 .combined-money .independent-coins { overflow:auto; }
 .independent-coins .routine, .combined-money .proficiency { font-size:1rem; }
 .coin-card { font-size:1rem; }
 .combined-money .controls { padding-inline:.5rem; padding-bottom:3.5rem; }
}

.assessment-dialog { width:min(66rem,96vw); max-height:94dvh; }
.assessment-views { display:flex; gap:.5rem; margin-bottom:.75rem; }
.assessment-body { color:#173c61; background:#f6faff; border-radius:.6rem; padding:1rem; }
.assessment-target { margin:0 0 .75rem; font-size:clamp(1rem,2.2vw,1.7rem); font-weight:700; }
.assessment-levels { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.75rem; padding:0; margin:0; list-style:none; }
.assessment-levels li { padding:.8rem; font-size:clamp(1.05rem,2vw,1.6rem); font-weight:700; border:3px solid #247eb9; border-radius:.6rem; background:white; }
.assessment-levels li:nth-child(1) { border-color:#db3d49; }
.assessment-levels li:nth-child(2) { border-color:#e59b13; }
.assessment-levels li:nth-child(3) { border-color:#449831; }
.assessment-stem { padding:.8rem; margin:.75rem 0 0; background:#174c7c; color:white; font-size:clamp(1rem,2vw,1.5rem); font-weight:700; border-radius:.5rem; }
.assessment-poster { width:100%; max-height:65dvh; object-fit:contain; display:block; }
@media(max-width:620px) { .assessment-levels { grid-template-columns:1fr; } }
