/* Natural slide height and responsive controls; printed layouts remain independent. */
@media screen {
  .slide-card [hidden]{display:none!important}
  .workspace,.lesson-area,.stage-shell,.slide-card,.slide-content,.message,.math-workspace{min-width:0;max-width:100%}
  .lesson-area{padding:clamp(.65rem,1.5vw,1.3rem)}
  .stage-shell{max-width:1480px;align-items:start;gap:.75rem;--lesson-available-height:calc(100dvh - 210px)}
  .lesson-toolbar,.student-mode-note{max-width:1480px}
  .slide-card{min-height:0;width:100%;height:auto;container-type:inline-size}
  .slide-card .slide-content,.calm-mode .slide-card .slide-content{min-height:0;padding:clamp(.8rem,1.7vw,1.5rem);gap:clamp(.75rem,1.6vw,1.5rem);flex:1 0 auto}
  .slide-card .message{min-width:0;max-width:100%}
  .slide-card .message>*,.slide-card .interaction-card>*,.slide-card .character-mission>*{min-width:0;max-width:100%}
  .slide-card .math-workspace{overflow-x:visible;container-type:inline-size;container-name:activity}
  .slide-card .interaction-card,.slide-card .creative-activity,.slide-card .character-mission{grid-template-columns:minmax(0,1fr);align-items:start;align-content:start}
  .slide-card .interaction-card p,.slide-card .interaction-card b,.slide-card .interaction-card strong,.slide-card .interaction-card button{word-break:normal;overflow-wrap:break-word;white-space:normal}
  .slide-card .creative-drag-help{align-self:start;height:auto;min-height:0}
  .slide-card .message h3,.slide-card #slideBody{max-width:100%;overflow-wrap:anywhere}
  .slide-card .message h3{margin-top:0;margin-bottom:.65rem}
  .slide-card .message.auto-text-flow>#slideHeading,.slide-card .message.auto-text-flow>#slideBody{transform:none!important}
  .slide-card .mission-intro h3{font-size:clamp(1.2rem,2.5vw,1.55rem);line-height:1.3}
  .slide-card .character-mission>.creative-activity-title{display:none}
  .slide-card .message>p{margin-top:0;margin-bottom:.75rem}
  .slide-card .symbol-line{margin:0 0 .35rem}
  .slide-card .visual-example{max-width:100%;min-width:0;flex-wrap:wrap;gap:.6rem;margin:.65rem 0}
  .slide-card .visual-example>span{max-width:100%;overflow-wrap:anywhere}
  .slide-card .message video,.slide-card .message iframe{max-width:100%}
  .slide-card .answer-grid{min-width:0;margin-top:.7rem;gap:.5rem}
  .slide-card .answer-grid button{min-width:0;max-width:100%;overflow-wrap:anywhere}
  .slide-card .feedback:empty{min-height:0;margin:0;padding:0}
  .slide-card .slide-controls,.student-view .slide-card .slide-controls{position:static;min-width:0;flex-wrap:wrap;padding:.65rem .8rem;gap:.45rem}
  .slide-card .slide-controls button{min-height:44px;max-width:100%;white-space:normal;overflow-wrap:anywhere}
  .slide-card .first-then{flex-wrap:wrap;padding:.45rem .65rem;gap:.4rem}
  .slide-card .first-then>span{min-width:0;overflow-wrap:anywhere}
  .slide-rail{max-height:var(--lesson-available-height,calc(100dvh - 210px));overflow-y:auto;overflow-x:hidden;min-width:0;overscroll-behavior:contain;scrollbar-width:thin;align-self:start}
  .slide-rail .thumb{flex:none;min-width:0;width:100%;min-height:54px;padding:.4rem .25rem}
  .slide-rail .thumb .thumb-count{display:flex;gap:.3rem;justify-content:center;align-items:center}
  .question-attempted-tick{font:inherit;font-weight:800;color:var(--ink);padding:0 .15rem}
  .question-attempted-tick[hidden]{display:none}
  .thumb.question-attempted:not(.active){color:var(--ink);background:#edf3f7}
  .slide-card .shared-activity-controls{gap:.45rem;padding:.6rem 0;margin-top:.5rem}
  .slide-card .shared-activity-controls button{min-height:44px}
  .slide-card .interaction-card{max-width:100%;min-width:0}
  .slide-card .creative-practice,.slide-card .creative-card-bank{min-width:0;max-width:100%}
  .slide-card .creative-card-bank{grid-template-columns:repeat(auto-fit,minmax(min(190px,100%),1fr))}
  .slide-card .creative-picture-match{grid-template-columns:repeat(auto-fit,minmax(min(400px,100%),1fr));align-items:start}
  .slide-card .creative-picture-match>section{min-width:0}
  .slide-card .creative-picture-name-list{grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));align-items:start}
  .slide-card .creative-picture-name:not(.food-chain-slot){min-width:0;min-height:72px;height:auto;text-align:left;align-content:start}
  .slide-card .card-match-item{min-width:0;max-width:100%;height:auto}
  .slide-card .card-match-item>span{min-width:0;max-width:100%}
  #counterSupplySummary,.counter-supply-note{grid-column:1/-1}
  .slide-card .creative-sort-zones{grid-template-columns:repeat(auto-fit,minmax(min(240px,100%),1fr))}
  .slide-card .mission-order{grid-template-columns:repeat(auto-fit,minmax(min(190px,100%),1fr))}
  .slide-card .food-chain-track{max-width:100%;flex-direction:row;align-items:stretch;gap:.3rem;overflow-x:visible;padding-bottom:.5rem}
  .slide-card .food-chain-slot{flex:1 1 0;min-width:0;min-height:140px}
  .slide-card .food-chain-track:not(.auto-chain-stack) .food-chain-arrow{transform:none;height:auto}
  .slide-card .food-chain-track.auto-chain-stack{flex-direction:column;align-items:stretch}
  .slide-card .auto-chain-stack .food-chain-slot{width:100%;flex:none;min-height:94px;padding:.55rem}
  .slide-card .auto-chain-stack .food-chain-slot .card-match-item{display:grid;grid-template-columns:88px minmax(0,1fr);width:100%;align-items:center;text-align:left}
  .slide-card .auto-chain-stack .food-chain-slot .card-match-item img{height:72px;max-width:88px}
  .slide-card .auto-chain-stack .food-chain-arrow{transform:rotate(90deg);height:28px;flex:none}
  .food-web-workspace{display:grid;grid-template-columns:minmax(0,1fr);gap:.75rem;min-width:0}
  .food-web-bank-panel{display:grid;gap:.45rem;align-content:start;min-width:0}
  .slide-card .food-web-bank{grid-template-columns:repeat(auto-fit,minmax(min(130px,100%),1fr))}
  .slide-card .food-web-arrow-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:.4rem}
  .slide-card .food-web-activity>p{margin:.45rem 0}
  .slide-card .creative-table-wrap{max-width:100%}
  .slide-card .creative-sort-table{min-width:0}
  .slide-card .card-zone-heading,.slide-card .creative-sort-zone{min-width:0;overflow-wrap:anywhere}
  .slide-card .math-workspace svg{max-width:100%}
  .slide-card .coordinate-activity,.slide-card .coordinate-card-controls,.slide-card .coordinate-plot-wrap{min-width:0;max-width:100%}
  .slide-card .coordinate-plot-wrap{width:min(100%,max(360px,calc(var(--lesson-available-height,650px) - 160px)));margin-inline:auto}
  .slide-card .mission-story{padding:.75rem;gap:.75rem}
  .slide-card .mission-scene-picture{height:130px}
  .slide-card .mission-slot{min-height:120px}
  .slide-card .mission-story p{margin:.35rem 0 .65rem}
  .present-overlay .slide-card{min-height:0;max-width:1480px}
  .present-overlay{padding:3rem .8rem .8rem;overflow-x:hidden}
  @container activity (max-width:760px){
    .slide-card .mission-story,.slide-card .mission-map-layout{grid-template-columns:minmax(0,1fr)}
    .slide-card .mission-scene-picture{height:105px}
    .slide-card .creative-balance{grid-template-columns:minmax(0,1fr)}
    .slide-card .creative-balance>span{transform:rotate(90deg);justify-self:center}
  }
  @container (max-width:760px){
    .slide-content.has-side-character{grid-template-columns:minmax(0,1fr);gap:.75rem}
    .slide-content.has-side-character>.message{grid-column:1;grid-row:2}
    .slide-content .character-card.is-beside{display:grid;grid-template-columns:64px minmax(0,1fr);gap:.1rem .7rem;align-items:center;justify-items:start;text-align:left;width:100%;grid-column:1;justify-self:stretch}
    .character-card.is-beside .character-gesture{grid-column:1;grid-row:1/3;width:64px}
    .character-card.is-beside strong,.character-card.is-beside>span{grid-column:2;margin:0}
    .slide-card .creative-sort-table,.slide-card .creative-sort-table tbody,.slide-card .creative-sort-table tr,.slide-card .creative-sort-table td{display:block;width:100%}
    .slide-card .creative-sort-table thead{display:none}
  }
  @container (min-width:650px){
    .slide-card .coordinate-activity{grid-template-columns:minmax(145px,.55fr) minmax(0,1.45fr)}
    .slide-card .coordinate-bank{grid-template-columns:minmax(0,1fr)}
  }
  @container (min-width:760px){
    .food-web-workspace{grid-template-columns:minmax(145px,.45fr) minmax(0,1.55fr);align-items:start}
    .slide-card .food-web-bank{grid-template-columns:minmax(0,1fr)}
    .slide-card .food-web-bank .creative-practice-card{grid-template-columns:44px minmax(0,1fr);align-items:center;justify-items:start;text-align:left;padding:.45rem;gap:.45rem}
    .slide-card .food-web-bank .creative-practice-picture{width:44px;height:44px}
  }
  @media(min-width:901px){.setup-panel{position:sticky;top:var(--lesson-header-height,76px);max-height:calc(100dvh - var(--lesson-header-height,76px));overflow-y:auto;overflow-x:hidden;align-self:start}}
  @media(max-width:900px){
    .stage-shell{grid-template-columns:minmax(0,1fr)}
    .slide-rail{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(96px,100%),1fr));gap:.4rem;max-height:124px;overflow-x:hidden;overflow-y:auto}
    .slide-rail .thumb{min-width:0;min-height:48px}
    .lesson-toolbar{gap:.5rem;flex-wrap:wrap;margin-bottom:.7rem}
    .student-mode-note{gap:.35rem;flex-wrap:wrap;margin-bottom:.6rem}
  }
  @media(max-width:480px){
    .slide-card .slide-controls .speak-btn{flex:1 1 150px}
    .slide-card .answer-grid{grid-template-columns:minmax(0,1fr)}
    .slide-card .creative-card-bank{grid-template-columns:repeat(auto-fit,minmax(min(180px,100%),1fr))}
    .slide-card .creative-practice-card{overflow-wrap:anywhere}
    .slide-card .mission-order{grid-template-columns:repeat(auto-fit,minmax(min(180px,100%),1fr))}
    .slide-card .auto-chain-stack .food-chain-slot .card-match-item{grid-template-columns:66px minmax(0,1fr)}
    .slide-card .auto-chain-stack .food-chain-slot .card-match-item img{max-width:66px;height:62px}
  }
}
