/* Keep the player and catalogue inside the visible mobile viewport. */
@media (orientation: landscape) and (pointer: coarse) {
  body.cl-running #content > .cl-play[data-world="phonemes"] #cl-settings {
    --tab-edge-inset: env(safe-area-inset-right, 0px);
    position: fixed;
    inset: 50% 0 auto auto;
    translate: 0 -50%;
    transform: none;
    box-sizing: border-box;
    padding: 0 var(--tab-edge-inset) 0 0;
    width: calc(44px + var(--tab-edge-inset));
    height: 54px;
    border: 1px solid var(--player-border, #8baebf);
    border-radius: 12px 0 0 12px;
    background: var(--player-button, #ecf7fc);
    color: var(--player-ink, #24506a);
    opacity: 1;
    z-index: 11;
  }
  body.cl-running #content > .cl-play[data-world="phonemes"] #cl-settings svg {
    width: 24px;
    height: 24px;
    transform: none;
  }
}

@media (pointer: coarse) {
  .catalog-shell .catalog-tools { display: none; }

  .cl-play #cl-skip kbd,
  body[data-mobile-lesson] button kbd { display: none; }

  .lake-shore .lake-landmark {
    position: absolute;
    z-index: 2;
    display: grid;
    justify-items: center;
    gap: 3px;
    translate: -50% 0;
    pointer-events: none;
  }

  .lake-landmark-label {
    padding: 4px 9px;
    color: #fff6df;
    background: #153c39eb;
    border: 1px solid #dbbd839c;
    border-radius: 20px;
    font: 750 clamp(12px, 2.15vmin, 16px)/1.15 system-ui, sans-serif;
  }

  .lake-landmark-icon {
    position: relative;
    width: 40px;
    height: 9px;
    background: repeating-linear-gradient(90deg, #cf9859 0 7px, #a76c44 7px 8px);
    border: 1px solid #493826;
    border-radius: 3px;
    box-shadow: 0 2px 3px #173a35a0;
  }

  .lake-landmark[data-landmark="finish"] .lake-landmark-icon::after {
    content: '';
    position: absolute;
    bottom: 7px;
    left: 60%;
    width: 14px;
    height: 17px;
    border-left: 2px solid #5e412b;
    background: conic-gradient(#173a35 25%, #fff6df 0 50%, #173a35 0 75%, #fff6df 0) left top / 9px 8px repeat-x;
  }
}

.lake-landmark { display: none; }

@media (max-width: 900px), (max-height: 550px), (pointer: coarse) {
  html:has(body.cl-running) {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    scroll-behavior: auto;
  }

  body.cl-running {
    background: #19322e;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body.cl-running .frame {
    position: fixed;
    inset: var(--play-top, 0px) auto auto var(--play-left, 0px);
    display: block;
    width: var(--play-width, 100%);
    height: var(--play-height, 100dvh);
    min-height: 0;
    overflow: hidden;
    contain: layout;
  }

  body.cl-running :is(#main, #content) {
    box-sizing: border-box;
    min-height: 0;
    height: 100%;
    margin: 0;
    padding: 0;
  }

  body.cl-running #content > :is(.cl-game-page, .cl-play) {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 100%;
    min-height: 0;
  }

  body.cl-running #content > .cl-game-page {
    display: block;
  }

  body.cl-running #content > .cl-play .cl-viewport {
    height: 100%;
    max-height: 100%;
    min-height: 0;
  }

  /* The illustration can extend into the iPhone insets. Keep the player controls reachable. */
  body.cl-running #content > .cl-play > #cl-exit {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
  }

  body.cl-running #content > .cl-play > #cl-settings {
    right: env(safe-area-inset-right, 0px);
  }

  body.cl-running #content > .cl-play:is([data-world-game="9"], [data-world-game="40"], [data-world-game="66"], [data-world-game="43"], [data-world-game="33"], [data-world-game="179"], [data-world-game="188"], [data-world-game="61"]) > #cl-settings {
    --tab-edge-inset: env(safe-area-inset-right, 0px);
    right: 0;
    width: calc(clamp(24px, 2.65vw, 42px) + var(--tab-edge-inset));
    padding-right: var(--tab-edge-inset);
  }

  body.cl-running #content > .cl-play .cl-head > div {
    right: calc(60px + env(safe-area-inset-right, 0px));
  }

  body.cl-running #content > .cl-play > #cl-drawer {
    height: 100%;
    padding-right: env(safe-area-inset-right, 0px);
  }

  body[data-mobile-lesson] {
    min-height: 100dvh;
    overscroll-behavior-y: none;
  }

  /* These players have art, controls and captions in separate tracks. */
  body.cl-running #content > .cl-play:is([data-world-game="89"], [data-world-game="50"], [data-world-game="250"], [data-world-game="39"]) {
    display: block;
    width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }

  #content > .cl-play:is([data-world-game="89"], [data-world-game="50"], [data-world-game="250"], [data-world-game="39"]) .cl-viewport {
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    width: 100%;
    max-width: none;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  #content > .cl-play:is([data-world-game="89"], [data-world-game="50"], [data-world-game="250"], [data-world-game="39"]) #cl-stage {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    width: 100%;
    max-width: none;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  #content > .cl-play:is([data-world-game="89"], [data-world-game="50"], [data-world-game="250"], [data-world-game="39"]) #cl-notes:empty { display: none; }

  #content > .cl-play:is([data-world-game="89"], [data-world-game="39"]) > #cl-settings {
    width: 32px;
    min-width: 32px;
    height: 44px;
  }

  body.cl-running #content > .cl-play[data-world-game="250"] {
    --apiary-menu-gutter: calc(50px + env(safe-area-inset-right, 0px));
  }
  body.cl-running #content > .cl-play[data-world-game="250"] > #cl-settings {
    box-sizing: border-box;
    inset: auto env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) auto;
    width: 44px;
    min-width: 44px;
    height: 44px;
    border-radius: 10px 0 0 0;
    transform: none;
  }
  body.cl-running #content > .cl-play[data-world-game="250"] :is(.apiary-board, .apiary-instruction) {
    left: 40.3%;
    right: max(3.4%, var(--apiary-menu-gutter));
    width: auto;
  }
  @media (orientation: portrait) {
    body.cl-running #content > .cl-play[data-world-game="250"] :is(.apiary-board, .apiary-instruction) {
      left: 4%;
      right: max(4%, var(--apiary-menu-gutter));
    }
  }

  #content > .cl-play #cl-stage > :is(.owners-lesson, .mountain-queue, .city-scene, .apiary) {
    box-sizing: border-box;
    flex: 1 1 0;
    width: 100%;
    max-width: none;
    height: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    aspect-ratio: auto;
  }

  #content > .cl-play #cl-stage > :is(.owners-lesson, .mountain-queue, .city-scene) {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
  }


  #content > .cl-play #cl-stage :is(.owners-stage, .mq-field, .city-square) {
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    min-width: 0;
    min-height: 0;
    aspect-ratio: auto;
  }

  body:is([data-mobile-lesson="25"], [data-mobile-lesson="34"], [data-mobile-lesson="296"], [data-mobile-lesson="315"], [data-mobile-lesson="330"]) {
    display: block;
    padding: 0;
  }

  body[data-mobile-lesson="25"] #market,
  body[data-mobile-lesson="296"] > main,
  body:is([data-mobile-lesson="34"], [data-mobile-lesson="315"], [data-mobile-lesson="330"]) #lesson {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    aspect-ratio: auto;
  }

  body[data-mobile-lesson="296"] { --board-width: 100vw; --board-height: 100dvh; }

  body:is([data-mobile-lesson="34"], [data-mobile-lesson="315"], [data-mobile-lesson="330"]) #lesson {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  body[data-mobile-lesson="315"] #lesson { grid-template-rows: auto minmax(0, 1fr); }
  body[data-mobile-lesson="330"] #lesson { grid-template-rows: minmax(0, 1fr) auto; }

  body[data-mobile-lesson="34"] #field,
  body[data-mobile-lesson="330"] .pond {
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
  }
}

@media (orientation: landscape) and (max-height: 460px) and (pointer: coarse) {
  #content .cl-play #cl-skip:not([hidden]) {
    box-sizing: border-box;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 0;
    line-height: 0;
    text-decoration: none;
  }

  #content .cl-play #cl-skip::before {
    content: '';
    width: 20px;
    height: 16px;
    background: currentColor;
    clip-path: polygon(0 8%, 72% 50%, 0 92%, 0 8%, 83% 8%, 100% 8%, 100% 92%, 83% 92%, 83% 8%);
  }

  .lake-landmark[data-landmark="start"] .lake-landmark-label { transform: translateX(-16px); }

  body[data-mobile-lesson="242"] .mast { min-height: 45px; }
  body[data-mobile-lesson="242"] main { gap: 4px; padding-bottom: 6px; }
  body[data-mobile-lesson="242"] .trail button { min-height: 30px; }
  body[data-mobile-lesson="242"] .instruction { min-height: 69px; padding: 6px 13px; gap: 6px 12px; }
  body[data-mobile-lesson="242"] .instruction h2 { font-size: clamp(18px, 3.1vw, 23px); }
  body[data-mobile-lesson="242"] #round-text { margin-top: 2px; line-height: 1.17; }

  body[data-mobile-lesson="340"] #exercises {
    width: calc(100% - 116px);
    margin-inline: auto;
  }

  .cl-play[data-world-game="89"] #cl-stage .owners-stage {
    --owners-art-height: max(100%, min(42vw, calc(100% + clamp(27px, 12dvh, 42px))));
    background-size: 100% var(--owners-art-height);
    background-position: center bottom;
  }

  .cl-play[data-world-game="89"] #cl-stage .owners-cast { inset: auto 0 0; height: var(--owners-art-height); }

  #content .cl-play.city-player .cl-head { min-height: 44px; border-radius: 0; }

  #content .cl-play #cl-stage .city-square { container-type: size; }
  #content .cl-play #cl-stage .city-grid { inset: 23% 32% 7% 32%; gap: 4px 6px; }
  #content .cl-play #cl-stage .city-shutter { font-size: clamp(12px, min(3.4cqw, 7.2cqh), 23px); }
  #content .cl-play #cl-stage .city-panel { inset-block: 30% 12%; }
  #content .cl-play #cl-stage .city-footer { min-height: 44px; min-width: 0; padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); }
  #content .cl-play #cl-stage .city-footer strong { font-size: clamp(15px, 2.6vw, 19px); }
  #content .cl-play #cl-stage .city-footer button { flex: 0 0 44px; width: 44px; height: 44px; }
  #content .cl-play #cl-stage .city-footer svg { width: 25px; height: 25px; }

  body.cl-running #content > .cl-play:is(.sail-player, .tatti-player) {
    display: block;
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }

  #content .cl-play:is(.sail-player, .tatti-player) .cl-viewport {
    display: grid;
    box-sizing: border-box;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  #content .cl-play:is(.sail-player, .tatti-player) .cl-head {
    min-height: 44px;
    padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    gap: 6px;
  }

  #content .cl-play:is(.sail-player, .tatti-player) #cl-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    margin: 0;
  }

  #content .cl-play #cl-stage :is(.sail-scene, .tatti-scene) {
    grid-template-rows: minmax(0, 1fr) auto;
    border: 0;
    border-radius: 0;
  }

  #content .cl-play #cl-stage .sail-scene { container-type: size; }
  #content .cl-play #cl-stage .sail-board {
    grid-auto-rows: minmax(0, 1fr);
    width: 71%;
    height: 100%;
    min-height: 0;
    gap: 4px 6px;
    margin: 0 8px 0 0;
    padding: 7px 0;
  }
  #content .cl-play #cl-stage .sail-card { min-height: 0; font-size: clamp(14px, 7.4cqh, 23px); }
  #content .cl-play #cl-stage .sail-captain { bottom: 44px; width: min(24cqw, calc((100cqh - 54px) * .76)); }
  #content .cl-play #cl-stage .sail-footer { min-height: 44px; padding-block: 2px; }
  #content .cl-play #cl-stage .sail-repeat { min-height: 40px; }

  #content .tatti-player .cl-head { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.35fr); }
  #content .tatti-player .tatti-modes { grid-area: auto; }
  #content .tatti-player .cl-head #cl-skip:not([hidden]) { position: static; order: -1; background: #eae6d5; }
  #content .tatti-player .cl-head :is(.tatti-listen, #cl-restart, #cl-exit) span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  #content .tatti-player #cl-stage .tatti-board { inset: 6% 4% 6% 32%; grid-template-rows: 1fr 1fr; align-items: center; gap: 6px; }
  #content .tatti-player #cl-stage :is(.tatti-pool, .tatti-tray) {
    --tile-width: clamp(42px, 11vw, 112px);
    --tile-height: clamp(38px, 16dvh, 61px);
    min-height: var(--tile-height);
  }
  #content .tatti-player #cl-stage .tatti-tray { padding: 5px; }
  #content .tatti-player #cl-stage .tatti-marmot { width: min(37%, 63dvh); bottom: 10%; }
  #content .tatti-player #cl-stage .tatti-hint { left: 8px; bottom: 5px; }
  #content .tatti-player #cl-stage .tatti-instruction { min-height: 42px; padding: 4px 8px; font-size: clamp(16px, 3vw, 24px); }
}

@media (orientation: landscape) and (max-height: 460px) and (pointer: coarse) {
  #content .cl-play:is(.sail-player, .tatti-player, .city-player, [data-world-game="89"], [data-world-game="46"]:has(.hh-scene), [data-world-game="13"]) .cl-viewport {
    position: relative;
    grid-template-rows: minmax(0, 1fr);
  }

  #content .cl-play:is(.sail-player, .tatti-player, .city-player, [data-world-game="89"], [data-world-game="46"]:has(.hh-scene), [data-world-game="13"]) .cl-head {
    position: absolute;
    inset: 0 0 auto;
    z-index: 5;
    box-sizing: border-box;
    min-height: 44px;
    padding-block: 0;
    border: 0;
    border-radius: 0;
    background: color-mix(in srgb, var(--city-paper, var(--tatti-paper, var(--sail-paper, var(--paper, #214641)))) 88%, transparent);
  }

  #content .cl-play:is(.sail-player, .tatti-player, .city-player, [data-world-game="89"]) .cl-head h1 {
    font-size: clamp(18px, 2.8vw, 27px);
  }

  #content .cl-play #cl-stage .sail-board { padding-block-start: 52px; }
  #content .cl-play #cl-stage .sail-captain { width: min(24cqw, calc((100cqh - 93px) * .76)); }
  #content .tatti-player #cl-stage .tatti-board { inset-block-start: max(51px, 22%); }
  #content .tatti-player #cl-stage .tatti-marmot { width: min(37%, 55dvh); }
  #content .city-player #cl-stage .city-grid { inset-block-start: max(48px, 23%); }

  #content .cl-play[data-world-game="89"] #cl-stage .owners-item { top: max(67px, var(--item-y, 21%)); }
  #content .cl-play[data-world-game="46"]:has(.hh-scene) .cl-head { background: #fff3d9e9; }
  #content .cl-play[data-world-game="46"] #cl-stage .hh-card { top: max(48px, 16%); height: 61%; }
  #content .cl-play[data-world-game="46"] #cl-stage .hh-choices { top: max(48px, 16%); }

  #content .cl-play[data-world-game="13"] { --header: 44px; --footer: 48px; }
  #content .cl-play[data-world-game="13"] #cl-stage { height: 100%; }
  #content .cl-play[data-world-game="13"] #cl-stage .eh-princess { height: calc(97% - 36px); }
  #content .cl-play[data-world-game="13"] #cl-stage .eh-tray {
    top: calc(50% + 16px);
    width: max(281px, 36%);
    height: min(148px, calc(100% - 50px));
    padding: 4px 8px;
  }
  #content .cl-play[data-world-game="13"] #cl-stage .eh-row { gap: max(4px, .65cqw); }

  #content .cl-play #cl-stage .mq-top {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    min-height: 44px;
    padding: 3px max(8px, env(safe-area-inset-right)) 3px max(8px, env(safe-area-inset-left));
    background: #104b50e8;
  }

  #content .cl-play #cl-stage .mq-numbers { grid-area: auto; justify-content: center; }
  #content .cl-play #cl-stage .mq-top h2 { font-size: clamp(15px, 2.45vw, 24px); }
  #content .cl-play #cl-stage .mq-instruction { font-size: clamp(13px, 2.15vw, 18px); }
  #content .cl-play #cl-stage .mq-listen { min-height: 25px; font-size: 13px; }

  body:is([data-mobile-lesson="42"], [data-mobile-lesson="115"], [data-mobile-lesson="315"], [data-mobile-lesson="34"], [data-mobile-lesson="112"], [data-mobile-lesson="21"]) :is(#lesson, .screen) {
    position: relative;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  body:is([data-mobile-lesson="42"], [data-mobile-lesson="115"], [data-mobile-lesson="315"], [data-mobile-lesson="34"], [data-mobile-lesson="112"], [data-mobile-lesson="21"]) :is(#lesson, .screen) > header {
    position: absolute;
    z-index: 5;
    inset: 0 0 auto;
    box-sizing: border-box;
    min-height: 44px;
    padding-block: 0;
    border: 0;
    background: #fff7e9e8;
  }

  body[data-mobile-lesson="115"] .field .gallery,
  body[data-mobile-lesson="42"] .content .picker,
  body[data-mobile-lesson="315"] .board .tray { margin-top: 48px; }

  body[data-mobile-lesson="42"] .art canvas { object-position: center 68%; }
  body[data-mobile-lesson="42"] .picker #tiles { grid-auto-rows: 53px; }
  body[data-mobile-lesson="42"] .picker .tile img { flex-basis: 50%; height: 50%; }
  body[data-mobile-lesson="42"] .picker .tile span { overflow-wrap: normal; hyphens: auto; font-size: 10px; }
  body[data-mobile-lesson="115"] .stage #cast { inset-block-start: 44px; }
  body[data-mobile-lesson="315"] #lesson { grid-template-rows: minmax(0, 1fr); }
  body[data-mobile-lesson="315"] #lesson .stage .actor { max-height: calc(100% - 43px); }

  body[data-mobile-lesson="112"] #lesson :is(.field, .celebration) { padding-top: 44px; }
  body[data-mobile-lesson="112"] #lesson .field { gap: 5px; background: #cedeb2; }
  body[data-mobile-lesson="112"] #lesson .action { background-size: 100% 200%; }

  body[data-mobile-lesson="21"] .scene-slot { min-height: 0; }
  body[data-mobile-lesson="21"] .scene-slot .scene { height: 100%; }
  body[data-mobile-lesson="21"] .scene-slot .tag::before { height: max(49px, 13dvh); }
}

@media (max-width: 900px) and (orientation: portrait) {
  .cl-play[data-world-game="26"] #cl-stage > .sound-place {
    --pool-top: max(86px, calc(env(safe-area-inset-top) + 77px));
    --pool-bottom: max(72px, calc(env(safe-area-inset-bottom) + 57px));
    background: linear-gradient(#c5e9e9 0 var(--pool-top), #38aeb7 68%, #197584);
  }

  .cl-play[data-world-game="26"] #cl-stage > .sound-place::before { content: none; }

  .cl-play[data-world-game="26"] #cl-stage .sound-place .sp-pool {
    inset: var(--pool-top) 0 auto;
    height: calc(100% - var(--pool-top) - var(--pool-bottom));
    transform: none;
    aspect-ratio: auto;
    box-shadow: none;
  }

  .cl-play[data-world-game="26"] #cl-stage .sound-place .ag-top {
    top: calc(var(--pool-top) - 34px);
    left: 8px;
  }

  .cl-play[data-world-game="26"] #cl-stage .sound-place .ag-controls {
    top: auto;
    bottom: max(9px, env(safe-area-inset-bottom));
  }

  .cl-play[data-world-game="26"] #cl-stage .sound-place .ag-status:not(:empty) {
    top: auto;
    bottom: var(--pool-bottom);
    max-width: calc(100% - 16px);
  }

  .cl-play[data-world-game="26"] > #cl-settings { width: 32px; min-width: 32px; height: 44px; }

  body[data-mobile-lesson="42"] #lesson {
    height: 100dvh;
    min-height: 0;
    padding-block: 6px;
    gap: 4px;
  }

  body[data-mobile-lesson="315"] #lesson .board {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 5px;
  }

  body[data-mobile-lesson="315"] #lesson .scene { grid-template-rows: minmax(0, 1fr) auto; }
  body[data-mobile-lesson="315"] #lesson .stage { min-height: 0; height: 100%; aspect-ratio: auto; }

}

@media (max-width: 900px), (max-height: 550px), (pointer: coarse) {
  body[data-mobile-lesson="25"] #market {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #651c4e;
  }
  body[data-mobile-lesson="25"] #market > header {
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  }
  body[data-mobile-lesson="25"] #market h1 {
    position: static;
    text-align: left;
    font-size: clamp(17px, 4.7vw, 28px);
    text-wrap: balance;
  }
  body[data-mobile-lesson="25"] #market .market-tools { position: static; flex: none; gap: 4px; }
  body[data-mobile-lesson="25"] #market .market-tools .icon { width: 42px; height: 42px; font-size: 18px; }
  body[data-mobile-lesson="25"] #market .market-quantities {
    position: static;
    grid-row: 2;
  }
  body[data-mobile-lesson="25"] #market .market-digits button { min-width: 42px; min-height: 40px; font-size: 28px; }
  body[data-mobile-lesson="25"] #market .market-word-modes button { min-height: 32px; font-size: clamp(12px, 3.4vw, 16px); }

  body[data-mobile-lesson="25"] #market :is(.market-art, .market-cast-motion) { grid-area: 1 / 1 / -1 / -1; }
  body[data-mobile-lesson="25"] #market .market-display {
    position: static;
    grid-row: 3;
    width: min(39%, 370px);
    min-height: 0;
    justify-self: center;
    translate: 9% 0;
    padding-block: 3px 5px;
    gap: 3px;
    grid-template-rows: auto minmax(0, 1fr);
  }
  body[data-mobile-lesson="25"] #market .market-model {
    min-height: 28px;
    max-width: 100%;
    white-space: normal;
    font-size: clamp(12px, 3vw, 16px);
  }
  body[data-mobile-lesson="25"] #market .market-model .speaker { flex: 0 0 12px; height: 12px; }
  body[data-mobile-lesson="25"] #market .market-items {
    height: 100%;
    min-height: 0;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    align-items: end;
    gap: 2px 4px;
  }
  body[data-mobile-lesson="25"] #market .market-items[data-count="8"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  body[data-mobile-lesson="25"] #market .market-items img {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: 96px;
    justify-self: center;
  }
  body[data-mobile-lesson="25"] #market .market-shelf {
    position: static;
    grid-row: 4;
    height: auto;
    margin-inline: max(6px, env(safe-area-inset-left)) max(6px, env(safe-area-inset-right));
    grid-template-columns: 34px minmax(0, 1fr) 34px;
  }
  body[data-mobile-lesson="25"] #market .market-product { height: 42px; }
  body[data-mobile-lesson="25"] #market .market-product img { width: 100%; height: 28px; }
  body[data-mobile-lesson="25"] #market .shelf-arrow { width: 100%; height: 42px; }
  body[data-mobile-lesson="25"] #market > footer {
    position: static;
    grid-row: 5;
    margin-block: 5px 3px;
    font-size: clamp(12px, 3.4vw, 17px);
    text-align: center;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  body[data-mobile-lesson="25"] #market > header,
  body[data-mobile-lesson="25"] #market .market-quantities { background: #65ecf2; }
  body[data-mobile-lesson="25"] #market :is(.market-art, .market-cast-motion) {
    grid-area: 3 / 1 / 4 / -1;
    height: 125%;
  }
  body[data-mobile-lesson="25"] #market .market-display {
    width: 47%;
    height: min(48%, 200px);
    align-self: end;
    margin-bottom: clamp(22px, 5.7dvh, 45px);
  }
}

@media (orientation: landscape) and (max-height: 550px) {
  body[data-mobile-lesson="25"] #market .market-quantities {
    display: flex;
    justify-content: center;
    gap: clamp(12px, 2vw, 24px);
  }
  body[data-mobile-lesson="25"] #market .market-digits { gap: clamp(10px, 1.8vw, 22px); }
  body[data-mobile-lesson="25"] #market .market-digits button { min-height: 38px; }
  body[data-mobile-lesson="25"] #market .market-product,
  body[data-mobile-lesson="25"] #market .shelf-arrow { height: 36px; }
}

/* The catalogue has one scrollable list. Match the outer layout to the same
   viewport so it cannot scroll separately as the browser toolbars resize. */
html:has(body[data-view="classic"] #content > .catalog-shell) {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

body[data-view="classic"]:has(#content > .catalog-shell) {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body[data-view="classic"]:has(#content > .catalog-shell) :is(.frame, #main, #content, .catalog-shell) {
  height: 100%;
  min-height: 0;
}

@media (max-width: 650px) and (orientation: portrait) {
  .catalog-shell {
    --catalog-gutter: 10px;
    --catalog-toolbar-height: 0px;
    --catalog-hero-height: 68px;
    grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
  }

  .catalog-shell .catalog-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 7px;
    padding: max(7px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  }

  .catalog-shell .catalog-brand {
    grid-area: 1 / 1;
    align-self: stretch;
    gap: 7px;
    min-height: 40px;
    margin: 0;
  }

  .catalog-shell .catalog-brand strong { font-size: clamp(18px, 5.3vw, 27px); }
  .catalog-shell .catalog-emblem { width: 29px; }

  .catalog-shell .cl-groups {
    grid-area: 2 / 1 / 3 / -1;
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    grid-auto-rows: minmax(44px, auto);
    align-content: start;
    max-height: 214px;
    gap: 4px;
    padding: 0;
  }

  .catalog-shell .cl-groups button {
    gap: 6px;
    min-width: 0;
    min-height: 44px;
    padding: 4px 6px;
    border: 1px solid #89afcb32;
    border-radius: 9px;
    background: #283954;
    font-size: clamp(12px, 3.35vw, 15px);
    line-height: 1.13;
  }

  .catalog-shell .cl-groups button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .catalog-shell .cl-groups button[aria-pressed=true] { background: #91f0c6; }
  .catalog-shell .catalog-category-icon { width: 25px; }

  .catalog-shell .catalog-other {
    grid-area: 1 / 2;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 0;
    padding: 0;
  }

  .catalog-shell .catalog-other button {
    min-height: 40px;
    max-width: 86px;
    padding: 3px 6px;
    font-size: 11px;
  }

  .catalog-shell .catalog-toolbar {
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px var(--catalog-gutter);
  }

  .catalog-shell .catalog-search { max-width: none; }
  .catalog-shell .catalog-search input { height: 44px; font-size: 16px; }
  .catalog-shell .catalog-glass { top: 14px; }
  .catalog-shell .catalog-control { width: 42px; height: 44px; }

  .catalog-shell .catalog-ages {
    order: 1;
    display: grid;
    flex: 0 0 100%;
    grid-template-columns: repeat(4, minmax(0,1fr));
  }

  .catalog-shell .cat-age { height: 40px; }
  .catalog-shell .catalog-hero { padding: 8px 12px; border-radius: 13px; }
  .catalog-shell .catalog-main #cl-matches .catalog-hero h2 {
    width: 77%;
    font-size: clamp(20px, 5.35vw, 26px);
  }

  .catalog-shell .catalog-main #cl-matches {
    padding-bottom: max(var(--catalog-gutter), env(safe-area-inset-bottom));
    scrollbar-gutter: auto;
  }

  .catalog-shell .cl-game-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .catalog-shell .cl-game-list .cl-cover { aspect-ratio: 4 / 3; }
  .catalog-shell .cl-game-list .cl-item strong {
    gap: 6px;
    min-height: 46px;
    padding: 7px 8px;
    font-size: clamp(13px, 3.9vw, 17px);
  }
}

@media (orientation: landscape) and (max-height: 460px) and (max-width: 1100px) {
  .catalog-shell {
    --catalog-hero-height: 65px;
    --catalog-toolbar-height: 46px;
    grid-template-columns: clamp(208px, 32vw, 278px) minmax(0, 1fr);
  }

  .catalog-shell .catalog-side {
    padding: max(6px, env(safe-area-inset-top)) 6px max(5px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .catalog-shell .catalog-main { padding-inline-end: env(safe-area-inset-right, 0px); }

  .catalog-shell .catalog-brand { margin-bottom: 5px; }
  .catalog-shell .catalog-emblem { width: 30px; }
  .catalog-shell .cl-groups {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 4px;
  }
  .catalog-shell .cl-groups button {
    padding: 3px 4px;
    min-height: 44px;
    gap: 4px;
    border: 1px solid #89afcb32;
    background: #283954;
    font-size: 12px;
  }
  .catalog-shell .cl-groups button[aria-pressed=true] { background: #91f0c6; }
  .catalog-shell .cl-groups button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .catalog-shell .catalog-category-icon { width: 22px; }
  .catalog-shell .catalog-other { padding-top: 5px; }
  .catalog-shell .catalog-other button { min-height: 29px; }
  .catalog-shell .catalog-hero { padding-block: 8px; }
}

/* Reserve space for instruction panels when the scene has controls near the bottom edge. */
body.cl-running #content .cl-play,
body[data-mobile-lesson] {
  --instruction-width: min(46rem, 86%, calc(100% - 24px));
  --instruction-gap: clamp(5px, 1.15dvh, 10px);
  --instruction-paper: #fff6e6f5;
  --instruction-border: #a78e594d;
}

body.cl-running #content .cl-play #cl-stage :is(.eh-footer, .sb-footer, .owners-footer, .sail-footer, .tatti-instruction, .city-footer),
body[data-mobile-lesson="21"] .screen > .instruction,
body[data-mobile-lesson="237"] .lesson > .instruction,
body[data-mobile-lesson="115"] .screen > .instruction,
body[data-mobile-lesson="42"] #lesson > footer,
body[data-mobile-lesson="315"] #lesson .instruction-bar,
body:is([data-mobile-lesson="34"], [data-mobile-lesson="112"], [data-mobile-lesson="154"], [data-mobile-lesson="330"]) #lesson > footer {
  box-sizing: border-box;
  justify-self: center;
  justify-content: center;
  align-self: center;
  width: fit-content;
  max-width: var(--instruction-width);
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: var(--instruction-gap) auto;
  padding: 5px clamp(10px, 2vw, 18px);
  gap: 6px clamp(7px, 1.4vw, 15px);
  border: 1px solid var(--instruction-border);
  border-radius: clamp(13px, 2vw, 22px);
  background: var(--instruction-paper);
  box-shadow: 0 3px 8px #23362a32;
  text-align: center;
}

body.cl-running #content .cl-play #cl-stage :is(.eh-footer, .sb-footer, .owners-footer, .sail-footer),
body[data-mobile-lesson="315"] #lesson .instruction-bar,
body:is([data-mobile-lesson="34"], [data-mobile-lesson="112"], [data-mobile-lesson="154"], [data-mobile-lesson="330"]) #lesson > footer { flex-wrap: wrap; }

body.cl-running #content .cl-play #cl-stage .sail-footer .sail-repeat,
body[data-mobile-lesson="315"] #lesson .instruction-bar #replay { margin-inline: 0; }

body.cl-running #content .cl-play #cl-stage .eh-footer .ag-status,
body[data-mobile-lesson="315"] #lesson .instruction-bar > p { text-align: center; }

/* Full-scene artwork belongs to the playfield, with a solid surface behind its controls. */
body.cl-running #content .cl-play #cl-stage .owners-lesson {
  background: #ecc39b;
}

@media (orientation: landscape) {
  #content .cl-play[data-world="grammar"][data-world-game="89"] .cl-head {
    background: transparent;
    border-color: transparent;
  }

  #content .cl-play[data-world="grammar"][data-world-game="89"] .cl-head h1 {
    color: #234b46;
    text-shadow: 0 0 5px #fff9ec;
  }
}

body.cl-running #content > .cl-play[data-world-game="50"] {
  --mq-menu-size: 44px;
}
body.cl-running #content > .cl-play[data-world-game="50"] > #cl-settings {
  box-sizing: border-box;
  inset: auto env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) auto;
  width: var(--mq-menu-size);
  min-width: var(--mq-menu-size);
  height: var(--mq-menu-size);
  border-radius: 10px 0 0 0;
  transform: none;
}

/* Paint one backdrop under the scene and controls. The playfield keeps its own
   grid track so the panels do not cover the characters and objects. */
body.cl-running #content .cl-play #cl-stage .mountain-queue {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: #85c7b9 url("games/mountain-queue/station.png") center bottom / cover no-repeat;
}
body.cl-running #content .cl-play #cl-stage .mountain-queue:has(> .mq-field[data-scene-mode]:not([data-scene-mode="train"])) {
  background-image: url("games/mountain-queue/backdrops.png");
  background-position: var(--mq-queue-backdrop, 0 0);
  background-size: 200% 300%;
}
.mountain-queue:has(> .mq-field[data-scene-mode="room"]) { --mq-queue-backdrop: 100% 0; }
.mountain-queue:has(> .mq-field[data-scene-mode="tower"]) { --mq-queue-backdrop: 0 50%; }
.mountain-queue:has(> .mq-field[data-scene-mode="helpers"]) { --mq-queue-backdrop: 100% 50%; }
.mountain-queue:has(> .mq-field[data-scene-mode="nested"]) { --mq-queue-backdrop: 0 100%; }
.mountain-queue:has(> .mq-field[data-scene-mode="find"]) { --mq-queue-backdrop: 100% 100%; }
body.cl-running #content .cl-play #cl-stage .mountain-queue > .mq-field {
  grid-area: 3 / 1 / 4 / -1;
  container-type: size;
  background: none;
}
body.cl-running #content .cl-play #cl-stage .mountain-queue .mq-actor {
  width: min(var(--size), 88cqh);
}
body.cl-running #content .cl-play #cl-stage .mountain-queue > .mq-top {
  grid-area: 1 / 1 / 2 / -1;
  z-index: 2;
  background: #104b50e8;
}
body.cl-running #content .cl-play #cl-stage .mountain-queue > .mq-footer { display: contents; }
body.cl-running #content .cl-play #cl-stage .mountain-queue .mq-prompt {
  grid-area: 2 / 1 / 3 / -1;
  z-index: 2;
  justify-self: center;
  max-width: var(--instruction-width);
  min-height: 0;
  margin-block-start: var(--instruction-gap);
  padding: 4px 10px;
  border: 1px solid var(--instruction-border);
  border-radius: 14px;
  background: var(--instruction-paper);
  box-shadow: 0 2px 6px #23362a26;
}
body.cl-running #content .cl-play #cl-stage .mountain-queue .mq-direction {
  grid-row: 4;
  z-index: 2;
  width: min(76%, 155px);
  margin-block-end: max(var(--instruction-gap), env(safe-area-inset-bottom));
}
body.cl-running #content .cl-play #cl-stage .mountain-queue .mq-previous {
  grid-column: 1;
  justify-self: end;
  margin-inline-end: 4px;
}
body.cl-running #content .cl-play #cl-stage .mountain-queue .mq-next {
  grid-column: 2;
  justify-self: start;
  margin-inline-start: 4px;
  max-width: calc(100% - var(--mq-menu-size) - env(safe-area-inset-right, 0px) - 12px);
}

@media (orientation: portrait) {
  body.cl-running #content .cl-play #cl-stage .mountain-queue:has(> .mq-field[data-scene-mode="train"]) {
    background-position: 33% bottom;
    background-size: auto 130%;
  }
  .mq-field[data-scene-mode="bed"] :is([data-sprite="mattress"], [data-sprite="quilt"]) {
    translate: 0 min(8dvh, 52px);
  }
  .mq-field[data-scene-mode="bed"] :is([data-sprite="pillow"], [data-sprite="sleeper"]) {
    translate: 0 min(15dvh, 93px);
  }
}

body.cl-running #content .cl-play #cl-stage .mountain-queue > .mq-field[data-scene-mode="room"] {
  grid-area: 1 / 1 / -1 / -1;
  pointer-events: none;
}
.mq-field[data-scene-mode="room"] [data-queue-piece="backpack"] {
  left: 45% !important;
  top: 85% !important;
  width: min(11cqw, 15cqh) !important;
}
.mq-field[data-scene-mode="room"] [data-queue-piece="scarf"] {
  top: 65% !important;
  width: min(14cqw, 23cqh) !important;
}
.mq-field[data-scene-mode="room"] [data-queue-piece="hat"] {
  left: 86% !important;
  top: calc(21% + min(4cqw, 9cqh)) !important;
  width: min(11cqw, 22cqh) !important;
}
@media (orientation: portrait) {
  #content .cl-play #cl-stage .mountain-queue:has(.mq-field[data-scene-mode="room"]) .mq-prompt {
    justify-self: start;
    max-width: 75%;
    margin-inline-start: 8px;
  }
}

.mq-field[data-scene-mode="tower"] {
  --stack-unit: min(26cqw, 30cqh);
  --stack-base: 91cqh;
}
.mq-field[data-scene-mode="tower"] .mq-piece { left: 55.5% !important; }
.mq-field [data-sprite="tower-fox"] {
  top: calc(var(--stack-base) - .5 * var(--stack-unit)) !important;
  width: var(--stack-unit) !important;
}
.mq-field [data-sprite="tower-rabbit"] {
  top: calc(var(--stack-base) - 1.32 * var(--stack-unit)) !important;
  width: calc(.8 * var(--stack-unit)) !important;
}
.mq-field [data-sprite="tower-squirrel"] {
  top: calc(var(--stack-base) - 2 * var(--stack-unit)) !important;
  width: calc(.62 * var(--stack-unit)) !important;
}
.mq-field[data-scene-mode="tower"] [data-sprite="light"] {
  top: 14% !important;
  width: min(11cqw, 24cqh) !important;
}
body.cl-running #content .cl-play #cl-stage .mountain-queue:has(.mq-field[data-scene-mode="tower"]) .mq-prompt {
  justify-self: start;
  max-width: 47%;
  margin-inline-start: max(8px, env(safe-area-inset-left));
}

.mq-field[data-scene-mode="helpers"] { --team-unit: min(24cqw, 83cqh); --team-center: 48%; }
.mq-field[data-scene-mode="helpers"]:is([data-queue-step="4"], [data-queue-step="9"]) { --team-center: 52%; }
.mq-field[data-scene-mode="helpers"] .mq-piece {
  top: calc(93% - .5 * var(--team-unit)) !important;
  width: var(--team-unit) !important;
}
.mq-field[data-scene-mode="helpers"] [data-sprite="wagon"] { left: calc(var(--team-center) - 1.44 * var(--team-unit)) !important; }
.mq-field [data-sprite="helper-rabbit"] { left: calc(var(--team-center) - .45 * var(--team-unit)) !important; }
.mq-field [data-sprite="helper-hedgehog"] { left: calc(var(--team-center) + .41 * var(--team-unit)) !important; }
.mq-field [data-sprite="helper-squirrel"] { left: calc(var(--team-center) + 1.39 * var(--team-unit)) !important; }

.mq-field[data-scene-mode="nested"] {
  --box-unit: min(46cqw, 78cqh);
  --tabletop: 80cqh;
  --capsule-unit: calc(.73 * var(--box-unit));
  --capsule-center: calc(var(--tabletop) - .38 * var(--box-unit));
}
.mq-field[data-scene-mode="nested"]:has(> [data-queue-piece="pouch"]:not(.mq-leaving)) {
  --capsule-unit: calc(.48 * var(--box-unit));
  --capsule-center: calc(var(--tabletop) - .49 * var(--box-unit));
}
.mq-field[data-scene-mode="nested"]:has(> [data-queue-piece="box"]:not(.mq-leaving)) {
  --capsule-unit: calc(.34 * var(--box-unit));
  --capsule-center: calc(var(--tabletop) - .52 * var(--box-unit));
}
.mq-field[data-scene-mode="nested"] [data-sprite="box"] {
  top: calc(var(--tabletop) - .49 * var(--box-unit)) !important;
  width: var(--box-unit) !important;
}
.mq-field[data-scene-mode="nested"] [data-sprite="pouch"] {
  top: calc(var(--tabletop) - .42 * var(--box-unit)) !important;
  width: calc(.86 * var(--box-unit)) !important;
}
.mq-field[data-scene-mode="nested"]:has(> [data-queue-piece="box"]:not(.mq-leaving)) [data-sprite="pouch"] {
  width: calc(.55 * var(--box-unit)) !important;
}
.mq-field[data-scene-mode="nested"] [data-sprite="capsule"] {
  top: var(--capsule-center) !important;
  width: var(--capsule-unit) !important;
}
.mq-field[data-scene-mode="nested"] [data-sprite="token"] {
  top: calc(var(--tabletop) - .1 * var(--box-unit)) !important;
  width: calc(.35 * var(--box-unit)) !important;
}
.mq-field[data-scene-mode="nested"]:has(> [data-queue-piece="capsule"]:not(.mq-leaving)) [data-sprite="token"] {
  top: calc(var(--capsule-center) + .16 * var(--capsule-unit)) !important;
  width: calc(.44 * var(--capsule-unit)) !important;
}

.mq-field[data-scene-mode="find"] { --cabinet-unit: min(44cqw, 80cqh); }
.mq-field[data-scene-mode="find"] [data-queue-piece="cabinet"] {
  top: 49% !important;
  width: var(--cabinet-unit) !important;
}
.mq-field[data-scene-mode="find"] [data-queue-piece="daypack"] {
  top: calc(49% + .145 * var(--cabinet-unit)) !important;
  width: calc(.42 * var(--cabinet-unit)) !important;
}
.mq-field[data-scene-mode="find"] [data-queue-piece="torch"] {
  top: calc(49% + .16 * var(--cabinet-unit)) !important;
  left: calc(50% + .075 * var(--cabinet-unit)) !important;
  width: calc(.22 * var(--cabinet-unit)) !important;
}
body.cl-running #content .cl-play #cl-stage .tatti-scene {
  background: #d4ae7b;
}
body.cl-running #content .cl-play #cl-stage .city-scene {
  background: #8981a9;
}
body.cl-running #content .cl-play.city-player #cl-stage .city-footer {
  padding: 0 8px;
  text-align: start;
}
@media (orientation: portrait) {
  body.cl-running #content > .cl-play.city-player > #cl-settings {
    inset: auto env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) auto;
    transform: none;
    border-radius: 9px 0 0 0;
  }
  body.cl-running #content .cl-play.city-player #cl-stage .city-footer {
    max-width: calc(100% - 78px - 2 * env(safe-area-inset-right, 0px));
  }
}
body.cl-running #content .cl-play #cl-stage .eh-stage {
  grid-template-rows: minmax(0, 1fr) auto;
  background: #bdc59a;
}
body.cl-running #content .cl-play #cl-stage .sb-game {
  grid-template-rows: minmax(0, 1fr) auto;
  background: #d6b375;
}

body[data-mobile-lesson="21"] .screen {
  background: #d3b17a;
}
body[data-mobile-lesson="237"] .lesson { background: #a7e3f1; }
body[data-mobile-lesson="115"] .screen {
  background: #c7b17e;
  --instruction-paper: #214a46f2;
}
body[data-mobile-lesson="42"] #lesson { background-color: #cad6b7; }
body[data-mobile-lesson="315"] #lesson .scene { background-color: #cad6ad; }
@media (max-width: 900px), (max-height: 550px), (pointer: coarse) {
  body[data-mobile-lesson="34"] #lesson {
    position: relative;
    grid-template-rows: minmax(0, 1fr);
  }
  body[data-mobile-lesson="34"] #lesson > .toolbar {
    position: absolute;
    z-index: 5;
    inset: 0 0 auto;
    min-height: 44px;
    gap: 6px;
    padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
    background: transparent;
    pointer-events: none;
  }
  body[data-mobile-lesson="34"] .toolbar h1 {
    font-size: clamp(15px, 4.5vw, 24px);
    text-shadow: 0 0 5px #e6faff;
  }
  body[data-mobile-lesson="34"] .toolbar-actions { gap: 5px; }
  body[data-mobile-lesson="34"] .toolbar-actions button {
    padding-inline: 8px;
    font-size: clamp(12px, 3.25vw, 14px);
    background: #fbfcffcf;
    pointer-events: auto;
  }
  body[data-mobile-lesson="34"] #lesson > .instructions {
    position: absolute;
    z-index: 5;
    inset: calc(max(44px, 2.75rem) + env(safe-area-inset-top)) 0 auto;
    margin: 4px auto 0;
    pointer-events: none;
    flex-wrap: nowrap;
  }
  body[data-mobile-lesson="34"] #command { font-size: clamp(15px, 4vw, 20px); }
  body[data-mobile-lesson="34"] #hint { font-size: clamp(12px, 3vw, 14px); }
  body[data-mobile-lesson="34"] #listen { min-height: 36px; padding: 4px 9px; font-size: 13px; pointer-events: auto; }
}
@media (orientation: portrait) and (max-height: 550px) {
  body[data-mobile-lesson="34"] #listen { gap: 0; min-width: 36px; padding-inline: 4px; font-size: 0; }
}
@media (orientation: landscape) and (max-height: 460px) and (pointer: coarse) {
  body[data-mobile-lesson="34"] #field { container-type: size; }
  body[data-mobile-lesson="34"] #field .piece { max-width: 16cqh; }
  body[data-mobile-lesson="34"] #field .piece[data-place="top"] { max-width: min(16cqh, max(18px, 30cqh - 44px)); }
  body[data-mobile-lesson="34"] .toolbar h1 { font-size: clamp(16px, 2.7vw, 22px); }
  body[data-mobile-lesson="34"] #lesson > .instructions {
    inset: env(safe-area-inset-top) calc(172px + env(safe-area-inset-right)) auto
      max(clamp(130px, 27vw, 200px), calc(135px + env(safe-area-inset-left)));
    width: auto;
    max-width: none;
    padding: 3px 6px;
  }
  body[data-mobile-lesson="34"] #command { font-size: clamp(13px, 2.2vw, 19px); }
  body[data-mobile-lesson="34"] #hint { font-size: 11px; }
  body[data-mobile-lesson="34"] #listen { gap: 0; min-width: 36px; padding-inline: 4px; font-size: 0; }
}
body[data-mobile-lesson="112"] #lesson { background-color: #bdd4a2; }
body[data-mobile-lesson="330"] #lesson {
  position: relative;
  grid-template-rows: minmax(0, 1fr);
  background: #88cab9;
}
body[data-mobile-lesson="330"] #lesson > footer {
  position: absolute;
  z-index: 4;
  inset: auto 0 var(--instruction-gap);
  margin-block: 0;
}

body.cl-running #content .cl-play #cl-stage :is(.breath-instructions, .vt-stage > .ag-status),
body[data-mobile-lesson="25"] #market > footer,
body[data-mobile-lesson="296"] > main > footer {
  width: max-content;
  max-width: var(--instruction-width);
}

body.cl-running #content .cl-play #cl-stage .breath-instructions .ag-status { min-width: 0; overflow-wrap: anywhere; }

body.cl-running #content .cl-play #cl-stage .vt-stage > .ag-status,
body[data-mobile-lesson="25"] #market > footer,
body[data-mobile-lesson="296"] > main > footer {
  inset-inline: 0;
  margin-inline: auto;
  padding-inline: clamp(10px, 2.1vw, 20px);
  border-radius: clamp(13px, 2vw, 22px);
}
body[data-mobile-lesson="25"] #market > footer { inset-block-end: var(--instruction-gap); }
body[data-mobile-lesson="25"] #market > footer { height: auto; min-height: 24px; padding-block: 3px; }

body.cl-running #content .cl-play #cl-stage :is(.bs-foot, .qb-foot, .br-foot, .mb-foot) {
  inset-inline: 0;
  width: fit-content;
  max-width: var(--instruction-width);
  margin-inline: auto;
  justify-content: center;
  gap: 7px clamp(8px, 1.4vw, 18px);
}

body[data-mobile-lesson="2"] #app .script .cue,
body[data-mobile-lesson="242"] main .instruction,
body[data-mobile-lesson="283"] main .panel {
  width: fit-content;
  max-width: var(--instruction-width);
  margin-inline: auto;
}

@media (orientation: portrait), (hover: hover) {
  body.cl-running #content .cl-play #cl-stage :is(.tatti > .tt-instruction, .tt-build-footer, .builder-store > .bs-instruction, .farm-yard > .fy-instruction, .school-stage > .school-status) {
    box-sizing: border-box;
    justify-self: center;
    justify-content: center;
    align-self: center;
    width: fit-content;
    min-height: 0;
    max-width: var(--instruction-width);
    margin: var(--instruction-gap) auto;
    padding: 6px clamp(10px, 2vw, 18px);
    border: 1px solid var(--instruction-border);
    border-radius: 15px;
    box-shadow: 0 3px 8px #23362a32;
    text-align: center;
  }

  body.cl-running #content .cl-play #cl-stage .tatti > .tt-build-footer > .tt-instruction { background: none; }
  body.cl-running #content .cl-play #cl-stage > .tatti {
    background: #dab979;
  }
  body.cl-running #content .cl-play #cl-stage > .builder-store {
    background: #d6b077;
  }
  body.cl-running #content .cl-play #cl-stage > .farm-yard {
    background: #92ad55;
  }
  body.cl-running #content .cl-play #cl-stage > .school-stage {
    grid-template-rows: minmax(0, 1fr) auto;
    background: #a18359;
  }
}

@media (hover: hover) and (min-width: 901px) {
  body.cl-running #content .cl-play #cl-stage .mq-instruction,
  body.cl-running #content .cl-play #cl-stage .eh-footer .ag-status { font-size: clamp(17px, 1.75vw, 24px); }
  body.cl-running #content .cl-play #cl-stage .eh-footer .eh-hear { font-size: clamp(15px, 1.35vw, 20px); }
}

@media (orientation: landscape) and (max-height: 460px) and (pointer: coarse) {
  body.cl-running #content .cl-play #cl-stage :is(.eh-footer, .sb-footer, .owners-footer, .sail-footer, .tatti-instruction, .city-footer),
  body[data-mobile-lesson="21"] .screen > .instruction,
  body[data-mobile-lesson="237"] .lesson > .instruction,
  body[data-mobile-lesson="115"] .screen > .instruction,
  body[data-mobile-lesson="42"] #lesson > footer,
  body[data-mobile-lesson="315"] #lesson .instruction-bar,
  body:is([data-mobile-lesson="34"], [data-mobile-lesson="112"], [data-mobile-lesson="154"], [data-mobile-lesson="330"]) #lesson > footer {
    margin-block: 0 var(--instruction-gap);
    padding-block: 1px;
    font-size: clamp(14px, 2.2vw, 19px);
  }
  body.cl-running #content .cl-play #cl-stage .sail-footer strong,
  body.cl-running #content .cl-play #cl-stage .city-footer strong { font-size: clamp(14px, 2.25vw, 19px); }
  body.cl-running #content .cl-play #cl-stage .tatti-instruction { padding-block: 6px; }
  body[data-mobile-lesson="21"] .screen > .instruction { padding-block: 6px; }
  body[data-mobile-lesson="330"] #lesson > footer { margin-block: 0; }
}
