/* Device layouts share one viewport budget. Long shelves and story text can
   scroll; navigation and the action for the current activity keep their space. */
@media (max-width:1366px) {
  body:not(.library-body), .library-body {
    --ck-header:calc(72px + env(safe-area-inset-top));
    --ck-rail:0px;
    --device-nav:calc(72px + env(safe-area-inset-bottom));
    --device-height:calc(100dvh - var(--ck-header) - var(--device-nav));
    --device-gutter:clamp(14px,2.2vw,28px);
  }
  .kingdom-topbar, .library-body .library-header {
    height:var(--ck-header); padding:calc(6px + env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) 6px max(18px,env(safe-area-inset-left)); gap:16px;
    margin-left:0; width:100%;
  }
  .kingdom-wordmark, .library-brand { gap:12px }
  .kingdom-wordmark>img, .library-brand>img { width:44px; height:55px }
  .kingdom-wordmark>span, .kingdom-wordmark b, .library-body .library-brand strong { font-size:21px!important }
  .kingdom-motto, .library-affiliation { display:block; font-size:12px; padding-left:16px }
  .local-save-indicator { display:none }
  .profile-button { width:54px; height:56px }
  .profile-button>img { width:42px; height:42px }
  .kingdom-rail, .kid-bottom-nav {
    position:fixed; inset:auto 0 0; transform:none; width:100%; max-width:none; height:var(--device-nav); min-height:0;
    display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:5px;
    padding:4px max(12px,env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
    border:0; border-top:2px solid #b38f4e; border-radius:0; overflow:visible; z-index:60;
  }
  .kingdom-rail a, .kid-bottom-nav a {
    display:flex; flex-direction:column; justify-content:center; width:100%; min-height:0; height:62px; gap:3px; padding:3px; border-radius:9px; font-size:12px;
  }
  .kingdom-rail a .toy-icon, .kid-bottom-nav a .toy-icon { width:32px; height:32px }
  .kingdom-rail a>span:not(.toy-icon) { font-size:12px }
  .kingdom-rail a[data-view=map] { display:flex }
  .kingdom-rail :is([data-view=parents],[data-view=settings],[data-view=achievements],.rail-spacer) { display:none }
  .screen:not(.game-screen):not(.free-screen) { inset:var(--ck-header) 0 var(--device-nav); height:auto; min-height:0; overscroll-behavior-y:contain; scroll-padding-block:14px }
  .library-body:has(.young-library), .library-body:has(.storyboards-shell) { padding-left:0; padding-bottom:var(--device-nav) }
  .library-body .library-footer { padding-bottom:22px }
  input[type=search], input[type=text], select { font-size:16px!important }
  .kingdom-dialog, .builder-tools-dialog, .modal-shell .modal-card {
    max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y:auto; overscroll-behavior:contain;
  }

  /* The invitation and activities scale into the first screen, including SE. */
  .home-storybook {
    display:grid; grid-template-rows:minmax(0,1fr) auto; gap:14px; height:var(--device-height); min-height:0;
    padding:0 0 16px; background-size:cover; background-position:63% center;
  }
  .home-hero { height:auto; min-height:0; padding:24px var(--device-gutter) 0; display:flex; align-items:center }
  .home-hero-copy { width:460px; max-width:48%; min-height:0; padding:22px; border-width:10px; border-image-width:10px }
  .home-hero h1 { font-size:clamp(36px,4.4vw,52px); line-height:1.08 }
  .home-hero h1 br { display:initial }
  .home-hero-copy>p { font-size:18px; margin:15px 0 18px }
  .home-actions .royal-button.gold { min-height:64px; font-size:26px }
  .home-discover { margin:0 var(--device-gutter); gap:16px; grid-template-columns:repeat(3,minmax(0,1fr)) }
  .home-discover .discovery-card { height:clamp(155px,22dvh,230px); min-height:0; padding:3px 8px 13px }
  .home-discover .discovery-card:last-child { grid-column:auto }
  .home-discover .discovery-card>img { height:calc(100% - 34px); min-height:0; max-width:280px }
  .home-discover .discovery-card h2 { font-size:clamp(20px,2.2vw,27px) }
  .home-footer { display:none }

  /* Compact introductions leave room for the first complete row of choices. */
  #projectScreen.kids-build-picker { inset:var(--ck-header) env(safe-area-inset-right) var(--device-nav) var(--ck-rail); height:auto; padding:18px var(--device-gutter) 28px }
  .build-picker-intro { grid-template-columns:minmax(0,.8fr) minmax(0,1.6fr); gap:18px; margin-bottom:16px }
  .build-picker-kicker { font-size:11px; margin-bottom:8px }
  .kids-build-picker .build-picker-heading h2 { font-size:clamp(32px,4vw,48px) }
  .build-picker-heading .academy-ornament { margin:14px 0 0; height:24px }
  .build-invitation { min-height:0; height:clamp(166px,24dvh,246px); flex-direction:row; padding:8px 12px; gap:12px }
  .build-invitation-art { width:44%; height:100%; min-height:0 }
  .build-invitation-copy { width:auto; text-align:center }
  .build-invitation h3 { font-size:clamp(22px,2.5vw,30px); margin:4px 0 12px }
  .build-invitation p, .build-next-label { display:none }
  .build-play-button { min-height:54px; font-size:21px; padding:8px 12px }
  .kids-build-picker .build-worlds { gap:8px }
  .kids-build-picker .build-worlds .chapter-card,
  .kids-build-picker .build-worlds .chapter-card.active { min-height:62px; padding:7px; gap:8px }
  .kids-build-picker .build-worlds .chapter-card img { width:32px; height:32px }
  .kids-build-picker .build-worlds .chapter-card strong { font-size:16px }
  .kids-build-picker .build-grid-heading { height:38px; min-height:38px; margin:0 }
  .kids-build-picker .lesson-filter { min-height:38px; font-size:12px }
  .kids-build-picker .build-picture-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px }
  .kids-build-picker .project-card { border-width:9px; border-image-width:9px }
  .kids-build-picker .lesson-card-picture { aspect-ratio:1.45 }
  .kids-build-picker .card-title { font-size:20px; min-height:48px; line-height:1.15 }
  .kids-build-picker .card-action-row { min-height:36px; padding-bottom:4px }
  .kids-build-picker .lesson-listen { width:44px; height:44px }

  /* Map rows always add up to the available screen, never to a fixed landscape. */
  #hubScreen.map-view { display:grid; grid-template-rows:auto minmax(0,1fr); overflow:hidden; padding:0; touch-action:pan-x pan-y }
  .map-view .hub-heading { position:static; width:100%; height:auto; min-height:0; padding:12px var(--device-gutter) 8px; margin:0 }
  .map-view .hub-heading h1 { font-size:clamp(25px,3vw,34px); margin:0 0 3px; line-height:1.12 }
  .map-view .hub-heading p { font-size:14px; margin:0; max-width:none }
  .map-view #hubContent { min-height:0; height:100% }
  .map-view .growing-city { display:grid; grid-template-rows:76px minmax(0,1fr) auto; height:100%; min-height:0 }
  .city-districts { margin:0; height:auto; min-height:0; padding:5px var(--device-gutter) 9px; gap:9px }
  .city-districts button { flex-direction:row; font-size:16px; padding:5px 9px; min-width:0; gap:9px }
  .city-districts button>span:last-child { text-align:left }
  .city-districts .toy-icon { width:28px; height:28px }
  .city-districts small { font-size:10px }
  .city-map-stage { display:grid; grid-template-rows:minmax(0,1fr) 114px 46px; height:100%; min-height:0; padding:0; overflow:hidden }
  .city-terrain, .city-terrain[data-mode=city] { grid-row:1; height:100%; min-height:0; overflow:hidden }
  .atlas-world { display:inline-block; width:auto; height:100%; min-height:260px; min-width:max(100%,760px); aspect-ratio:2 }
  .atlas-scroll { overflow:auto; touch-action:pan-x pan-y; overscroll-behavior:contain }
  .city-pin { width:46px; height:46px; font-size:21px }
  .city-preview {
    grid-row:2; position:relative; inset:auto; width:calc(100% - 24px); height:auto; min-height:0;
    margin:3px 12px; padding:3px 12px 3px 3px; border-width:8px; border-image-width:8px; gap:12px;
    display:grid; grid-template-columns:90px minmax(0,1fr); box-shadow:0 2px 4px #735c3526;
  }
  .city-preview-model { width:90px; height:88px; min-height:0; object-fit:contain }
  .city-preview-copy { display:grid; grid-template-columns:minmax(0,1fr) minmax(160px,25%); grid-template-rows:auto auto auto; align-content:center; align-items:center; gap:2px 16px }
  .city-preview-copy .city-eyebrow { grid-column:1; grid-row:1; margin:0; font-size:10px }
  .city-preview-copy h2 { grid-column:1; grid-row:2; font-size:25px; line-height:1.12; margin:0 }
  .city-preview-copy p:not(.city-eyebrow) { display:none }
  .city-piece-meter { grid-column:1; grid-row:3; margin-top:4px }
  .city-build-button { grid-column:2; grid-row:1/4; margin:0; min-height:55px; font-size:21px; padding:8px 12px; width:100%; gap:8px }
  .city-build-button .toy-icon { width:26px; height:26px }
  .city-site-nav { grid-row:3; position:static; transform:none; justify-self:center; align-self:center; height:44px; width:240px; min-height:0; padding:0 3px; margin:0; gap:6px }
  .city-site-nav button { width:44px; height:44px; min-height:44px; padding:9px }
  .city-site-nav span { font-size:11px }
  .city-site-nav>span { display:flex; align-items:center; justify-content:center; white-space:nowrap; gap:8px; flex:1 }
  .city-site-nav .city-site-position { font-size:11px }
  .map-mode-switch { top:9px; right:12px; left:auto; padding:3px }
  .map-mode-switch button { min-height:44px; padding:7px 10px; font-size:12px }
  .map-mode-switch .toy-icon { width:22px; height:22px }
  .atlas-compass { right:12px; bottom:14px; width:58px; height:58px }
  #hubScreen .atlas-pan-hint { bottom:10px; left:12px; font-size:10px; padding:5px 9px }
  .city-explore-list { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; padding:5px 12px; margin:0; overflow:visible }
  .city-explore-list button { width:100%; min-width:0; min-height:44px; padding:5px 8px; font-size:12px; line-height:1.15; gap:6px }
  .city-explore-list .toy-icon { width:19px; height:19px }
  .city-saving-note { position:absolute; width:1px; height:1px; padding:0; margin:0; overflow:hidden; clip-path:inset(50%) }
  .city-discovery { bottom:164px; top:auto; left:12px; right:auto; width:min(430px,calc(100% - 24px)); max-height:calc(100% - 180px); overflow:auto }

  /* Story shelves keep book titles and Read buttons in the first screen. */
  .library-body .library-welcome { min-height:0; height:clamp(206px,27dvh,310px); padding:16px var(--device-gutter) 62px }
  .library-welcome>div { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); grid-template-rows:auto 1fr; align-items:center; gap:3px 22px; width:min(780px,86%); max-width:none; height:100% }
  .library-welcome .academy-affiliation { font-size:10px; letter-spacing:1px; grid-column:1; margin:0 }
  .library-body .library-welcome h1 { grid-column:1; font-size:clamp(30px,3.6vw,43px); line-height:1.08; margin:0; max-width:13ch }
  .library-invitation { grid-column:2; grid-row:1/3; width:100%; max-width:360px; padding:7px; border-width:8px; border-image-width:8px }
  .library-invitation .academy-ornament { height:16px; margin-bottom:3px }
  .library-invitation h2 { font-size:24px }
  .library-invitation>p { font-size:14px; margin:4px 0 }
  .library-body #libraryContinue { min-height:44px; min-width:0; max-width:100%; font-size:15px; margin-top:5px }
  .library-body .library-shelf { padding:0 var(--device-gutter) 24px }
  .library-filters { margin:-57px 0 12px; max-width:none; gap:8px; min-height:54px }
  .library-filters button { min-height:54px; padding:7px; font-size:15px; gap:7px }
  .library-filters .toy-icon { width:25px; height:25px }
  .library-body .library-searchbar { position:static; margin:0 0 12px; width:100%; gap:12px; height:44px }
  .library-body .library-searchbar input { min-height:44px!important; width:220px; max-width:65%; font-size:16px!important; flex-basis:auto!important }
  .library-searchbar #storyCount { position:static; width:auto; height:auto; clip-path:none; font-size:12px; flex-basis:auto }
  .library-body .library-story-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px }
  .library-body .library-story-card { min-height:0; height:clamp(253px,36dvh,374px); padding:13px 12px 16px 19px }
  .library-body .story-card-cover { min-height:0; height:calc(100% - 100px); margin-bottom:-16px }
  .library-body .story-card-copy { padding:5px 3px 0; gap:6px }
  .library-body .story-card-copy h3, .library-body .story-card-copy h3 a { font-size:20px; line-height:1.12 }
  .book-reading-state { min-height:11px; font-size:10px }
  .story-card-copy .kid-button { min-height:46px; font-size:18px; padding:7px }

  /* A bounded book: longer prose scrolls independently of Listen and Next. */
  .library-body:has(.picture-reader) { --reader-header:calc(68px + env(safe-area-inset-top)) }
  .library-body .picture-reader { padding:0 12px 20px }
  .reader-topbar { height:var(--reader-header); min-height:0; padding:calc(7px + env(safe-area-inset-top)) 12px 7px; gap:14px }
  .reader-topbar h1 { font-size:22px }
  .reader-topbar>a { font-size:17px }
  .bookmark-button { width:48px; height:48px; min-height:48px }
  .reader-book {
    display:grid; height:calc(100dvh - var(--reader-header) - env(safe-area-inset-bottom)); min-height:0;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr); grid-template-rows:minmax(0,1fr) auto auto;
    border-width:8px; border-image-width:8px; overflow:hidden;
  }
  .reader-book .picture-page, .reader-book .story-pages { display:contents }
  .page-picture { grid-column:1; grid-row:1/4; min-height:0; max-height:none; height:100%; border-radius:5px 0 0 5px }
  .page-picture .scene-art { width:100%; min-width:0 }
  .story-page-copy { grid-column:2; grid-row:1; display:block; min-height:0; padding:20px 26px 8px; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin; scrollbar-color:#bea575 transparent; text-align:left }
  .story-page-copy h2 { font-size:28px; margin:9px 0 14px }
  .library-body .story-prose { font-size:calc(var(--story-font-size,23px) * 1.08 * var(--academy-accessible-text,1))!important; line-height:1.45!important; max-width:42ch }
  .wonder-prompt { margin-top:12px; padding-top:0 }
  .wonder-prompt summary { min-height:44px; font-size:15px }
  .reader-primary { grid-column:2; grid-row:2; padding:8px 20px; justify-content:center; gap:7px; position:static; width:auto }
  .library-body .listen-button { min-height:48px; min-width:160px; font-size:20px }
  .reader-primary .speech-status { font-size:11px; min-height:0; text-align:center }
  .reader-primary .speech-status:empty { display:none }
  .reader-wayfinding { grid-column:2; grid-row:3; position:static; width:auto; padding:8px 12px 10px; border-top:1px solid #c9b588 }
  .library-body .story-reader-controls { grid-template-columns:90px minmax(0,1fr) 110px; padding:0; gap:8px }
  .library-body .story-reader-controls .kid-button { min-height:48px; font-size:18px!important; padding:7px }
  .reader-book:has(.story-complete:not([hidden])) { display:block; height:auto; max-height:none; overflow:visible }
  .library-body .reader-grownups { margin:14px auto 0 }

  .library-body .watch-shell { padding:10px 16px 24px }
  .watch-heading { min-height:54px; height:54px; margin:0 0 10px; gap:16px }
  .watch-heading h1 { font-size:26px; line-height:1.15 }
  .watch-heading>a { min-height:44px; padding:7px 12px; font-size:16px }
  .watch-book { display:grid; grid-template-columns:1.3fr 1fr; grid-template-rows:minmax(0,1fr); height:calc(100dvh - 228px); min-height:170px; overflow:hidden; border-radius:18px }
  .library-body .watch-frame { height:100%; min-height:0; max-height:none; border-radius:0 }
  .library-body .watch-caption { margin:0; padding:16px; border-width:8px; border-image-width:8px; border-radius:0; min-height:0; overflow-y:auto; overscroll-behavior:contain; scrollbar-width:thin }
  .library-body .watch-caption p { font-size:22px; line-height:1.45 }
  .library-body .watch-controls.watch-transport { margin:10px 0 0; display:grid; grid-template-columns:1fr 1fr 1fr auto; gap:10px }
  .library-body .watch-transport .kid-button { min-height:54px; padding:7px 10px; font-size:18px; gap:7px }
  .watch-transport .toy-icon { width:24px; height:24px }
  .watch-transport label { min-height:44px; font-size:13px }
  .watch-timeline { margin:0; padding:6px 0!important; gap:10px!important; flex-wrap:nowrap!important }
  .watch-timeline #watchRestart { min-height:44px; font-size:14px; padding:7px 12px }
  .watch-controls .watch-slider { flex-basis:auto!important; min-width:60px; min-height:44px }
  .watch-timeline output { font-size:12px; white-space:nowrap }
  .library-body .watch-status { margin:0; min-height:0; font-size:12px!important }
  .watch-status:empty { display:none }
  .library-body .watch-scenes { margin:12px 0 0; padding-bottom:12px }

  /* Parent pages keep readable text but lose excessive panel padding. */
  .hub-screen:not(.map-view) { padding:22px var(--device-gutter) }
  .hub-heading { margin-bottom:18px }
  .hub-heading h1 { font-size:clamp(30px,3.6vw,43px); margin:0 0 8px }
  .hub-heading p { font-size:16px; margin:0 }
  .hub-screen[data-hub-view=parents] .hub-heading { position:static; max-width:none }
  .hub-screen[data-hub-view=parents] .hub-heading h1 { max-width:none; font-size:clamp(30px,3.6vw,43px) }
  .hub-screen[data-hub-view=parents] .family-profiles { margin:0; min-height:0 }
  .hub-screen[data-hub-view=parents] .profile-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px }
  .hub-screen[data-hub-view=parents] .family-profile { min-height:210px; padding:12px }
  .family-profile img { width:104px; height:104px; margin-bottom:8px }
  .family-profile b, .family-profile.add-builder>b { font-size:23px }
  .family-profile.add-builder>.toy-icon { width:85px; height:85px; min-height:85px }
  .parent-summary { margin-top:18px; padding:18px; display:block }
  .parent-summary h2 { font-size:26px; margin:0 0 13px }
  .parent-stats strong { font-size:32px }
  .parent-two-col { margin-top:18px; gap:18px }
  .settings-layout { gap:18px }
  .settings-layout>.settings-panel:not(.backup-panel):not(.keyboard-panel), .settings-panel { padding:18px }
  .settings-panel h2 { font-size:26px; gap:12px; margin-bottom:12px }
  .setting-row { min-height:76px; padding:12px 0; gap:16px }
  .setting-row b { font-size:18px }
  .setting-row small { font-size:14px; line-height:1.4 }
  .setting-row input[type=checkbox] { min-width:64px; width:64px }
  .keepsake-tabs { margin:14px 0 18px }
  .keepsake-tabs button { min-height:60px; font-size:18px; gap:9px }
  .creation-grid { gap:18px }
  .creation-preview { height:clamp(150px,23dvh,230px) }
  .collection-keepsake { min-height:0; padding:20px; margin-top:18px }

  /* Workshop controls reserve room for the canvas; catalogs scroll internally. */
  .free-screen { --workshop-header:calc(76px + env(safe-area-inset-top)) }
  .free-header { height:var(--workshop-header); padding:calc(6px + env(safe-area-inset-top)) 14px 6px; gap:14px }
  .workshop-brand { display:none }
  .free-header .workshop-title { display:block; flex:1; min-width:0 }
  .free-header h1 { font-size:24px; margin:0 0 3px }
  .free-header input { height:32px; width:min(240px,38vw); min-height:32px!important; padding:4px 10px; border:1px solid #bda16e; background:var(--academy-paper-image) center/cover; font-size:16px!important }
  .free-header .royal-button { min-height:48px; padding:10px 14px; font-size:16px }
  .free-workspace { height:calc(100dvh - var(--workshop-header)); min-height:0; display:grid; grid-template-columns:clamp(200px,25vw,300px) minmax(0,1fr) }
  .free-canvas-wrap { min-height:0; min-width:0; height:100% }
  .free-catalog { min-height:0; height:100%; overflow-y:auto; overscroll-behavior:contain; padding:14px }
  .free-catalog h2 { font-size:26px; margin-bottom:12px }
  .free-part { min-height:130px; padding:6px }
  .free-part img { height:85px }
  .free-part b { font-size:15px }
  .free-tools { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); width:min(760px,calc(100% - 24px)); padding:6px; gap:3px; bottom:calc(12px + env(safe-area-inset-bottom)); left:50%; right:auto; transform:translateX(-50%) }
  .free-tools button { min-height:58px!important; min-width:0; padding:5px 3px; gap:5px; font-size:14px; border:0 }
  .free-tools .toy-icon { width:26px; height:26px }
  .free-instruction { bottom:calc(93px + env(safe-area-inset-bottom)); padding:7px 12px; font-size:13px; max-width:calc(100% - 28px) }
  .free-environment { top:10px; left:12px; padding:5px 9px }
  .free-inspector-toggle { top:calc(var(--workshop-header) + 10px); right:12px; min-height:44px }
  .free-inspector { top:calc(var(--workshop-header) + 63px); max-height:calc(100dvh - var(--workshop-header) - 80px)!important; right:12px }

  #gameScreen { --device-game-header:calc(64px + env(safe-area-inset-top)) }
  #gameScreen .game-header { height:var(--device-game-header)!important; min-height:0; padding:calc(6px + env(safe-area-inset-top)) 14px 6px!important; display:grid; grid-template-columns:46px minmax(0,1fr) 46px; gap:14px }
  #gameScreen .game-brand { display:none }
  #gameScreen .game-back, #gameScreen .build-help { width:46px; height:46px; min-width:46px; min-height:46px; padding:9px }
  #gameScreen .build-progress { width:100%; min-width:0; padding:0 12px; gap:3px 12px; grid-template-columns:minmax(0,1fr) auto }
  #gameScreen .active-build-title { grid-column:1; grid-row:1/3; min-height:0 }
  #gameScreen #activeLessonName { font-size:22px; line-height:1.12 }
  #gameScreen .build-progress-label { grid-column:2; grid-row:1; font-size:15px; white-space:nowrap }
  #gameScreen .stability-track { grid-column:2; grid-row:2; width:100px; height:4px }
  #gameScreen .mission-panel, #gameScreen .mission-panel.collapsed { inset:calc(var(--device-game-header) + 12px) auto auto 16px!important; width:310px!important }
  #gameScreen .puppy-bubble { min-height:82px; padding:9px; border-width:9px; border-image-width:9px; gap:8px; flex-wrap:nowrap }
  #gameScreen .mission-action { width:auto; flex:1 1 auto; text-align:left }
  #gameScreen .mission-action strong { font-size:23px!important }
  #gameScreen #voiceReplayBtn { min-width:46px; width:46px; height:46px; padding:9px }
  #gameScreen .listen-label { display:none }
}

/* On tablets the action card sits on the landscape, leaving more map to explore. */
@media (min-width:701px) and (max-width:1366px) and (min-height:541px) {
  .city-map-stage { display:block; position:relative }
  .city-terrain, .city-terrain[data-mode=city] { height:100% }
  .city-preview { position:absolute; left:12px; bottom:12px; width:420px; height:108px; margin:0; grid-template-columns:67px minmax(0,1fr); gap:8px; padding:4px }
  .city-preview-model { width:67px; height:79px }
  .city-preview-copy { grid-template-columns:minmax(0,1fr) 145px; gap:3px 8px }
  .city-preview-copy h2 { font-size:21px }.city-build-button { font-size:18px; min-height:54px; padding:7px }
  .city-site-nav { position:absolute; left:auto; right:12px; bottom:12px; width:240px }
  .atlas-compass { bottom:70px }
  .city-discovery { bottom:130px; max-height:calc(100% - 145px) }
}

@media (min-width:901px) and (max-width:1366px) {
  .hub-screen[data-hub-view=parents] #hubContent { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.15fr); gap:18px }
  .hub-screen[data-hub-view=parents] .profile-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px }
  .hub-screen[data-hub-view=parents] .family-profile { min-height:220px; padding:10px 6px }
  .hub-screen[data-hub-view=parents] .family-profile img { width:90px; height:90px }
  .hub-screen[data-hub-view=parents] .family-profile b { font-size:21px }
  .hub-screen[data-hub-view=parents] .parent-summary { margin:0; padding:18px }
  .hub-screen[data-hub-view=parents] .parent-stats { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px }
  .hub-screen[data-hub-view=parents] .parent-stats>div { padding:0; border:0 }
  .hub-screen[data-hub-view=parents] .parent-two-col { grid-column:1/-1; margin:0 }
}

@media (min-width:701px) and (max-width:1000px) and (orientation:portrait) {
  .kids-build-picker .build-picture-grid, .library-body .library-story-grid { grid-template-columns:repeat(3,minmax(0,1fr)) }
  .home-hero-copy { max-width:60%; width:440px }
  .reader-book { grid-template-columns:1fr; grid-template-rows:minmax(0,.9fr) minmax(0,1fr) auto auto }
  .page-picture { grid-column:1; grid-row:1 }
  .story-page-copy { grid-column:1; grid-row:2; text-align:center; padding:20px 42px 8px }
  .library-body .story-prose { margin:0 auto }
  .reader-primary { grid-column:1; grid-row:3 }
  .reader-wayfinding { grid-column:1; grid-row:4; padding:8px 24px 12px }
  .library-body .story-reader-controls { grid-template-columns:120px minmax(0,1fr) 140px }
}

@media (max-width:700px) {
  body:not(.library-body), .library-body { --ck-header:calc(60px + env(safe-area-inset-top)); --device-nav:calc(68px + env(safe-area-inset-bottom)); --device-gutter:12px }
  .kingdom-topbar, .library-body .library-header { padding-inline:10px; gap:9px }
  .kingdom-wordmark, .library-brand { gap:7px }
  .kingdom-wordmark>img, .library-brand>img { width:30px; height:42px }
  .kingdom-wordmark>span, .kingdom-wordmark b, .library-body .library-brand strong { font-size:14px!important }
  .kingdom-motto, .library-affiliation { font-size:9px; padding-left:8px; max-width:90px; white-space:normal }
  .profile-button { width:44px; height:45px; flex-shrink:0 }
  .profile-button>img { width:34px; height:34px }
  .library-body .grownup-link { min-height:44px; width:44px; padding:8px }
  .kingdom-rail, .kid-bottom-nav { padding-inline:5px; gap:3px }
  .kingdom-rail a, .kid-bottom-nav a { height:58px; gap:3px; font-size:11px }
  .kingdom-rail a>span:not(.toy-icon) { font-size:11px }
  .kingdom-rail a .toy-icon, .kid-bottom-nav a .toy-icon { width:28px; height:28px }
  .home-storybook { gap:9px; padding-bottom:10px }
  .home-hero { padding:10px 10px 0; align-items:flex-end }
  .home-hero-copy { width:100%; max-width:none; padding:8px 12px 10px }
  .home-hero-copy .academy-ornament { height:13px; margin:0 auto 3px }
  .home-hero h1 { font-size:clamp(29px,8.8vw,36px); line-height:1.06 }
  .home-hero-copy>p { margin:7px 0 10px; font-size:14px }
  .home-actions .royal-button.gold { min-height:54px; font-size:24px }
  .home-discover { grid-template-columns:1fr 1fr; gap:10px; margin:0 10px }
  .home-discover .discovery-build { display:none }
  .home-discover .discovery-card { height:clamp(122px,18.5dvh,160px); padding:2px 4px 10px; border-width:8px; border-image-width:8px }
  .home-discover .discovery-card>img { height:calc(100% - 33px) }
  .home-discover .discovery-card h2 { font-size:17px; line-height:1.1 }

  #projectScreen.kids-build-picker { padding:13px 12px 24px }
  .build-picker-intro { display:block; margin-bottom:12px }
  .kids-build-picker .build-picker-heading { margin:0 0 10px; gap:3px; padding:0 2px }
  .build-picker-kicker { font-size:9px; margin:0 }
  .kids-build-picker .build-picker-heading h2 { font-size:28px; line-height:1.1 }
  .build-invitation { height:clamp(116px,17dvh,150px); min-height:0; border-width:8px; border-image-width:8px; padding:4px; gap:8px }
  .build-invitation-art { width:38%; height:100% }
  .build-invitation-copy { text-align:left }
  .build-invitation h3 { font-size:19px; margin:0 0 8px }
  .build-play-button { min-height:46px; font-size:16px; padding:6px; gap:6px }
  .kids-build-picker .build-worlds { gap:5px }
  .kids-build-picker .build-worlds .chapter-card,
  .kids-build-picker .build-worlds .chapter-card.active { min-height:65px; padding:5px 3px; gap:3px; flex-direction:column }
  .kids-build-picker .build-worlds .chapter-card img { width:25px; height:25px }
  .kids-build-picker .build-worlds .chapter-card strong { font-size:11px; min-height:20px }
  .kids-build-picker .build-picture-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px 10px }
  .kids-build-picker .project-card { border-width:8px; border-image-width:8px }
  .kids-build-picker .lesson-card-picture { aspect-ratio:1.36 }
  .kids-build-picker .card-title { font-size:17px; min-height:44px; padding:2px }
  .kids-build-picker .card-action-row { padding-left:6px; justify-content:flex-start }

  .map-view .hub-heading { padding:10px 14px 6px }
  .map-view .hub-heading h1 { font-size:26px; letter-spacing:-.6px; margin-bottom:2px }
  .map-view .hub-heading p { font-size:12px; line-height:1.3 }
  .map-view .growing-city { grid-template-rows:70px minmax(0,1fr) auto }
  .city-districts { padding:5px 10px 8px; gap:5px }
  .city-districts button { flex-direction:column; gap:2px; font-size:11px; padding:4px 2px; border-radius:9px; line-height:1.12 }
  .city-districts button>span:last-child { text-align:center }
  .city-districts .toy-icon { width:23px; height:23px }
  .city-districts small { font-size:8px }
  .city-map-stage { grid-template-rows:minmax(0,1fr) 109px 44px }
  .city-preview { width:calc(100% - 16px); margin:3px 8px; padding:3px; gap:6px; grid-template-columns:60px minmax(0,1fr) }
  .city-preview-model { width:60px; height:78px }
  .city-preview-copy { grid-template-columns:minmax(0,1fr) 124px; gap:2px 7px }
  .city-preview-copy h2 { font-size:18px; line-height:1.12 }
  .city-preview-copy .city-eyebrow { font-size:9px }
  .city-build-button { min-height:52px; font-size:16px; padding:5px; gap:4px }
  .city-build-button .toy-icon { width:20px; height:20px }
  .city-site-nav { width:240px }
  .map-mode-switch { left:9px; right:auto; top:8px }
  .map-mode-switch button { font-size:11px; min-height:44px; padding:6px 8px }
  .map-mode-switch .toy-icon { width:19px; height:19px }
  .atlas-compass { width:42px; height:42px; right:10px; bottom:10px }
  .city-explore-list { padding:3px 8px 5px; gap:5px }
  .city-explore-list button { font-size:10px; padding:4px; gap:3px }
  .city-explore-list .toy-icon { width:17px; height:17px }
  .city-discovery { bottom:156px; max-height:calc(100% - 165px) }

  .library-body .library-welcome { height:clamp(190px,27dvh,230px); padding:12px 12px 60px }
  .library-welcome>div { width:100%; grid-template-columns:minmax(0,1.1fr) minmax(0,1fr); gap:4px 12px }
  .library-welcome .academy-affiliation { font-size:8px; letter-spacing:.5px }
  .library-body .library-welcome h1 { font-size:29px; max-width:10ch }
  .library-invitation { padding:5px; border-width:7px; border-image-width:7px }
  .library-invitation h2 { font-size:20px; line-height:1.1 }
  .library-invitation .academy-ornament, .library-invitation>p { display:none }
  .library-body #libraryContinue { min-height:44px; width:100%; font-size:12px; padding:5px; gap:3px }
  .library-body #libraryContinue .ui-symbol { width:16px; height:16px }
  .library-filters { gap:5px; margin:-54px 0 10px }
  .library-filters button { min-height:51px; flex-direction:column; font-size:11px; padding:4px; gap:3px }
  .library-filters .toy-icon { width:20px; height:20px }
  .library-body .library-searchbar { height:44px; margin-bottom:10px }
  .library-body .library-searchbar input { width:66%; max-width:66%; padding:7px 10px!important }
  .library-body .library-searchbar #storyCount { font-size:11px }
  .library-body .library-story-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px 10px }
  .library-body .library-story-card { height:clamp(240px,33dvh,290px); padding:11px 10px 13px 16px }
  .library-body .story-card-cover { height:calc(100% - 97px) }
  .library-body .story-card-copy h3, .library-body .story-card-copy h3 a { font-size:17px }
  .story-card-copy .kid-button { min-height:46px; font-size:17px }
  .book-reading-state { font-size:9px }

  .library-body:has(.picture-reader) { --reader-header:calc(60px + env(safe-area-inset-top)) }
  .library-body .picture-reader { padding-inline:0 }
  .reader-topbar { gap:8px; padding-inline:10px }
  .reader-topbar h1 { font-size:16px; line-height:1.15 }
  .reader-topbar>a { font-size:13px; min-height:44px; gap:4px }
  .bookmark-button { width:44px; height:44px; min-height:44px }
  .reader-book { grid-template-columns:1fr; grid-template-rows:clamp(145px,28dvh,300px) minmax(0,1fr) auto auto; border:0; border-radius:0 }
  .page-picture { grid-column:1; grid-row:1; height:100%; min-height:0; max-height:none; border-radius:0 }
  .page-picture .scene-art { transform:translate(-50%,-42%) }
  .story-page-copy { grid-column:1; grid-row:2; padding:14px 22px 8px; text-align:center }
  .story-page-copy h2 { font-size:26px; margin:0 0 10px }
  .library-body .story-prose { font-size:calc(var(--story-font-size,23px) * var(--academy-accessible-text,1))!important; line-height:1.42!important; max-width:32ch; margin:0 auto }
  .reader-primary { grid-column:1; grid-row:3; padding:7px 16px; gap:6px }
  .library-body .listen-button { min-width:160px; min-height:46px; font-size:19px }
  .reader-wayfinding { grid-column:1; grid-row:4; padding:7px 12px 9px }
  .library-body .story-reader-controls { grid-template-columns:90px minmax(0,1fr) 105px; gap:8px }
  .reader-book:has(.story-complete:not([hidden])) { height:auto; min-height:calc(100dvh - var(--reader-header)) }
  .library-body .story-complete { min-height:0; padding:24px 18px }
  .story-complete h2 { font-size:34px }

  .library-body .watch-shell { padding:8px 12px 22px }
  .watch-heading { height:56px; min-height:56px; gap:9px; margin-bottom:8px }
  .watch-heading h1 { font-size:20px; text-align:left }
  .watch-heading>a { font-size:0; width:44px; padding:9px }
  .watch-book { grid-template-columns:1fr; grid-template-rows:minmax(0,1.2fr) minmax(0,1fr); height:calc(100dvh - 270px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); min-height:250px }
  .watch-frame .scene-art { width:100%; left:0; transform:translateY(-42%) }
  .library-body .watch-caption { padding:10px 12px; justify-content:flex-start }
  .library-body .watch-caption p { font-size:20px; line-height:1.4 }
  .watch-caption>span { font-size:10px; margin:0 0 5px }
  .library-body .watch-controls.watch-transport { margin:9px 0 0; grid-template-columns:1fr 1fr; gap:7px }
  .library-body .watch-transport .kid-button { min-height:48px; font-size:15px; padding:6px; gap:5px }
  .watch-transport #watchPlay { grid-row:2; grid-column:1 }
  .watch-transport .toy-icon { width:21px; height:21px }
  .watch-timeline #watchRestart { font-size:12px; padding:6px 9px }
  .watch-timeline output { font-size:10px }

  .hub-screen:not(.map-view) { padding:18px 13px }
  .hub-heading h1, .hub-screen[data-hub-view=parents] .hub-heading h1 { font-size:30px }
  .hub-heading p { font-size:14px }
  .hub-screen[data-hub-view=parents] .profile-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px }
  .hub-screen[data-hub-view=parents] .family-profile { min-height:190px; padding:9px 5px; border-width:8px; border-image-width:8px }
  .family-profile img { width:84px; height:84px }
  .family-profile b, .family-profile.add-builder>b { font-size:20px }
  .family-profile.add-builder>.toy-icon { width:67px; height:67px; min-height:67px }
  .family-profile span { font-size:11px }
  .parent-summary { padding:14px 10px }
  .parent-summary h2 { font-size:24px }
  .parent-stats { gap:10px }
  .parent-stats strong { font-size:30px }
  .settings-layout>.settings-panel:not(.backup-panel):not(.keyboard-panel), .settings-panel { padding:14px 11px }
  .settings-panel h2 { font-size:24px; gap:9px }
  .settings-panel h2 .toy-icon { width:29px; height:29px }
  .setting-row { min-height:72px; padding:11px 0; gap:12px }
  .setting-row b { font-size:17px }
  .setting-row small { font-size:13px }
  .setting-row input[type=checkbox] { width:60px; min-width:60px }
  .setting-row select { max-width:110px }
  .keepsake-tabs { gap:6px; margin:12px 0 15px }
  .keepsake-tabs button { min-height:65px; font-size:13px; padding:6px 3px; flex-direction:column; gap:4px }
  .keepsake-tabs .toy-icon { width:25px; height:25px }
  .creation-grid { grid-template-columns:1fr }

  .free-screen { --workshop-header:calc(72px + env(safe-area-inset-top)) }
  .free-header { padding-inline:10px; gap:9px }
  .free-header h1 { font-size:20px; line-height:1.12 }
  .free-header input { width:min(180px,44vw); padding:3px 7px }
  .free-header .royal-button:last-child { min-width:74px; max-width:86px; font-size:13px!important; padding:7px!important }
  .free-workspace { display:flex; flex-direction:column }
  .free-canvas-wrap { flex:1 1 0; height:auto; min-height:0 }
  .free-catalog { flex:0 0 212px; height:212px; order:2; padding:7px 10px calc(8px + env(safe-area-inset-bottom)); overflow:hidden }
  .free-catalog-heading { min-height:38px }
  .free-catalog h2 { font-size:22px; margin:0 }
  .free-catalog.collapsed { flex-basis:calc(62px + env(safe-area-inset-bottom)); height:calc(62px + env(safe-area-inset-bottom)) }
  [data-free=toggle-catalog][aria-expanded=false] .toy-icon { transform:rotate(180deg) }
  .free-categories { margin:4px 0 7px; gap:6px }
  .free-categories button { min-height:44px; padding:7px 10px; font-size:12px }
  .free-parts { gap:9px }
  .free-part { flex:0 0 92px; width:92px; min-width:92px; height:100px; min-height:100px; padding:5px }
  .free-part img { height:57px }
  .free-part b { font-size:12px }
  .free-tools { left:8px; right:8px; transform:none; width:auto; max-width:none; bottom:8px; padding:5px; gap:2px }
  .free-tools button { min-height:51px!important; font-size:11px; padding:3px 1px; gap:3px }
  .free-tools .toy-icon { width:23px; height:23px }
  .free-instruction { bottom:82px; padding:6px 9px; font-size:12px; line-height:1.25; max-width:calc(100% - 24px) }
  .free-environment { top:8px; left:8px; right:103px; padding:4px 6px }
  .free-environment select { font-size:16px!important; max-width:145px; min-height:36px!important }
  .free-inspector-toggle { top:calc(var(--workshop-header) + 8px); right:8px; padding:8px; font-size:13px }
  .free-inspector { top:calc(var(--workshop-header) + 60px); right:8px }
  .modal-shell { padding:12px }
  .modal-shell .modal-card { padding:17px; border-width:9px!important; border-image-width:9px }
  .modal-shell #observePreview { max-height:24dvh }
  .modal-shell .modal-card h2 { font-size:27px!important }
  .modal-shell .modal-card p { font-size:16px!important; line-height:1.45!important }
  #gameScreen .game-header { padding-inline:10px!important; gap:8px }
  #gameScreen .build-progress { padding:0; grid-template-columns:1fr; gap:3px }
  #gameScreen .active-build-title { grid-column:1; grid-row:1 }
  #gameScreen #activeLessonName { font-size:17px }
  #gameScreen .build-progress-label { grid-column:1; grid-row:2; font-size:12px; text-align:center }
  #gameScreen .stability-track { display:none }
  #gameScreen .mission-panel, #gameScreen .mission-panel.collapsed { inset:calc(var(--device-game-header) + 8px) auto auto 10px!important; width:calc(100% - 20px)!important }
  #gameScreen .puppy-bubble { min-height:58px; padding:3px 5px; border-width:7px; border-image-width:7px }
  #gameScreen .mission-action strong { font-size:19px!important }
  #gameScreen .piece-tray, #gameScreen .piece-tray.collapsed { bottom:calc(9px + env(safe-area-inset-bottom))!important; padding:8px 10px 10px!important; gap:6px }
  #gameScreen .piece-tray:not(.collapsed) { display:flex!important; flex-direction:column; height:clamp(222px,34dvh,264px); min-height:0 }
  #gameScreen .build-stage { min-height:23px; padding-bottom:3px; font-size:12px }
  #gameScreen .toybox-heading { height:24px; min-height:24px }
  #gameScreen .tray-title { font-size:19px!important }
  #gameScreen .piece-list { flex:1 1 auto; height:auto!important; min-height:0; padding:2px 2px 5px!important }
  #gameScreen .piece-card { height:100%!important; min-height:0; display:flex; flex-direction:column }
  #gameScreen .piece-preview { flex:1 1 auto; min-height:0; height:auto!important; width:100% }
  #gameScreen .piece-card-copy { flex:0 0 auto; min-height:20px }
  #gameScreen .play-actions { flex:0 0 50px; height:50px; min-height:50px }
  #gameScreen .place-assist, #gameScreen .test-button { min-height:50px; height:50px; font-size:22px }
}

/* Short landscape devices use a side rail and a horizontal map dock. */
@media (max-width:1366px) and (max-height:540px) and (orientation:landscape) {
  body:not(.library-body), .library-body { --ck-header:calc(54px + env(safe-area-inset-top)); --ck-rail:calc(76px + env(safe-area-inset-left)); --device-nav:env(safe-area-inset-bottom); --device-height:calc(100dvh - var(--ck-header) - var(--device-nav)) }
  .kingdom-topbar, .library-body .library-header { padding-block:4px; gap:12px }
  .kingdom-wordmark>img, .library-brand>img { width:33px; height:43px }
  .kingdom-wordmark>span, .kingdom-wordmark b, .library-body .library-brand strong { font-size:16px!important }
  .profile-button { width:43px; height:44px }.profile-button>img { width:33px; height:33px }
  .kingdom-rail, .kid-bottom-nav { inset:var(--ck-header) auto 0 0; width:var(--ck-rail); height:auto; padding:4px 4px calc(4px + env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left)); display:grid; grid-template-columns:1fr; grid-template-rows:repeat(5,minmax(0,1fr)); gap:1px; border:0; border-right:1px solid #b38f4e }
  .kingdom-rail a, .kid-bottom-nav a { min-height:44px; height:100%; padding:2px; font-size:10px; gap:1px }
  .kingdom-rail a .toy-icon, .kid-bottom-nav a .toy-icon { width:24px; height:24px }
  .kingdom-rail a>span:not(.toy-icon) { font-size:10px }
  .screen:not(.game-screen):not(.free-screen) { left:var(--ck-rail); right:env(safe-area-inset-right); bottom:var(--device-nav) }
  .library-body:has(.young-library), .library-body:has(.storyboards-shell) { padding-left:var(--ck-rail); padding-right:env(safe-area-inset-right) }
  .library-body .library-header { width:calc(100% + var(--ck-rail) + env(safe-area-inset-right)); margin-left:calc(-1 * var(--ck-rail)) }
  .home-storybook { grid-template-columns:1.15fr 1fr; grid-template-rows:1fr; gap:12px; padding:12px }
  .home-hero { padding:0; align-items:center }
  .home-hero-copy { width:100%; max-width:none; padding:12px; border-width:8px; border-image-width:8px }
  .home-hero h1 { font-size:30px }.home-hero-copy>p { font-size:13px; margin:8px 0 }
  .home-hero-copy .academy-ornament { height:14px; margin-bottom:3px }
  .home-actions .royal-button.gold { min-height:48px; font-size:21px }
  .home-discover { margin:0; gap:9px; grid-template-columns:1fr; grid-template-rows:1fr 1fr; align-self:stretch }
  .home-discover .discovery-build { display:none }
  .home-discover .discovery-card { height:auto; display:grid; grid-template-columns:80px minmax(0,1fr); align-items:center; padding:6px; gap:8px; border-width:8px; border-image-width:8px }
  .home-discover .discovery-card>img { height:85px; width:80px }
  .home-discover .discovery-card h2 { font-size:19px; text-align:left }
  .home-discover .discovery-card.discovery-build { display:none }
  #projectScreen.kids-build-picker { padding:8px 12px 20px }
  .build-picker-intro { grid-template-columns:minmax(0,.85fr) minmax(0,1.4fr); gap:12px; margin-bottom:8px }
  .kids-build-picker .build-picker-heading h2 { font-size:27px; line-height:1.05 }.build-picker-heading .academy-ornament { display:none }.build-picker-kicker { font-size:9px; margin:0 0 4px }
  .build-invitation { height:68px; border-width:7px; border-image-width:7px; padding:3px; gap:7px }.build-invitation-art { width:45px; height:48px }
  .build-invitation-copy { display:flex; align-items:center; gap:10px; min-width:0 }.build-invitation h3 { font-size:17px; margin:0; flex:1 }.build-play-button { min-height:44px; font-size:15px; width:140px; padding:5px; gap:5px }.build-play-button .toy-icon { width:20px; height:20px }
  .kids-build-picker .build-worlds .chapter-card, .kids-build-picker .build-worlds .chapter-card.active { min-height:46px; padding:4px; gap:6px }.kids-build-picker .build-worlds .chapter-card img { width:23px; height:23px }.kids-build-picker .build-worlds .chapter-card strong { font-size:13px }
  .kids-build-picker .build-grid-heading { height:34px; min-height:34px }.kids-build-picker .lesson-filter { min-height:34px }
  .kids-build-picker .build-picture-grid { gap:10px }.kids-build-picker .lesson-card-picture { aspect-ratio:2.65 }.kids-build-picker .card-title { min-height:38px; font-size:16px }.kids-build-picker .card-action-row { min-height:32px }
  .library-body .library-welcome { height:56px; padding:3px 12px }
  .library-welcome>div { width:100%; height:100%; grid-template-columns:minmax(0,1fr) 190px; gap:12px }
  .library-welcome .academy-affiliation { display:none }.library-body .library-welcome h1 { grid-row:1/3; font-size:25px; max-width:none }
  .library-invitation { padding:0; border:0; box-shadow:none }.library-invitation h2, .library-invitation>p, .library-invitation .academy-ornament { display:none }
  .library-body #libraryContinue { min-height:44px; margin:0; width:100%; font-size:15px }
  .library-body .library-shelf { padding-inline:12px }.library-filters { margin:0 0 5px; min-height:44px; gap:6px }.library-filters button { min-height:44px; font-size:12px; padding:4px; gap:6px }.library-filters .toy-icon { width:21px; height:21px }
  .library-body .library-searchbar { margin:0 0 6px; height:44px }.library-body .library-story-grid { gap:12px }
  .library-body .library-story-card { height:180px; min-height:0; padding:8px 9px 11px 14px }.library-body .story-card-cover { height:80px; margin-bottom:-12px }.library-body .story-card-copy { gap:4px; padding-top:3px }.library-body .story-card-copy h3, .library-body .story-card-copy h3 a { font-size:15px }.book-reading-state { display:none }.story-card-copy .kid-button { min-height:44px; font-size:15px; padding:5px }
  .map-view .hub-heading { padding:8px 14px 4px }.map-view .hub-heading h1 { font-size:24px }.map-view .hub-heading p { display:none }
  .map-view .growing-city { grid-template-rows:55px minmax(0,1fr) auto }
  .city-districts { padding:3px 12px 5px; gap:6px }.city-districts button { font-size:12px; flex-direction:row; padding:4px 6px; gap:5px }.city-districts .toy-icon { width:23px; height:23px }
  .city-map-stage { grid-template-columns:minmax(0,1fr) 230px; grid-template-rows:minmax(0,1fr) 46px; background:var(--academy-paper-image) center/cover }
  .city-terrain, .city-terrain[data-mode=city] { grid-column:1; grid-row:1/3 }
  .city-preview { grid-column:2; grid-row:1; width:calc(100% - 12px); grid-template-columns:1fr; margin:5px 6px 2px; gap:0; padding:5px; text-align:center }
  .city-preview-model { display:none }
  .city-preview-copy { display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr) 44px; height:100%; min-height:0; gap:5px; align-content:stretch }
  .city-preview-copy h2 { grid-column:1; grid-row:1; min-height:0; font-size:18px; line-height:1.08; overflow-y:auto }
  .city-preview-copy .city-eyebrow, .city-preview-copy .city-piece-meter { display:none }
  .city-build-button { grid-column:1; grid-row:2; height:44px; min-height:44px; font-size:17px; margin:0; padding:5px }
  .city-site-nav { grid-column:2; grid-row:2; width:222px }
  .map-mode-switch { left:8px; right:auto; top:7px }.map-mode-switch button { font-size:11px; min-height:44px; padding:5px 7px }
  .city-explore-list { padding-block:3px }
  .city-discovery { bottom:12px; max-height:calc(100% - 24px) }
  .city-pin { width:44px; height:44px; font-size:20px }
  #hubScreen .atlas-pan-hint { display:none }
  .library-body:has(.picture-reader) { --reader-header:54px }
  .reader-book { grid-template-columns:minmax(0,.9fr) minmax(0,1.2fr); grid-template-rows:minmax(0,1fr) auto auto; border:0 }
  .page-picture { grid-column:1; grid-row:1/4 }
  .story-page-copy { grid-column:2; grid-row:1; padding:12px 20px 5px; text-align:left }
  .story-page-copy h2 { font-size:24px; margin:0 0 8px }
  .library-body .story-prose { font-size:calc(var(--story-font-size,23px) * var(--academy-accessible-text,1))!important; line-height:1.4!important }
  .reader-primary { grid-column:2; grid-row:2; padding:4px 14px }
  .reader-wayfinding { grid-column:2; grid-row:3; padding:5px 12px }
  .library-body .listen-button { min-height:44px; font-size:17px }
  .library-body .story-reader-controls .kid-button { min-height:44px; font-size:16px!important }
  .library-body .watch-shell { padding:5px 12px 18px }
  .watch-heading { height:45px; min-height:45px; margin-bottom:5px }.watch-heading h1 { font-size:21px }
  .watch-book { grid-template-columns:1.1fr 1fr; grid-template-rows:minmax(0,1fr); min-height:120px; height:calc(100dvh - 175px) }
  .library-body .watch-caption { padding:10px; justify-content:flex-start }.library-body .watch-caption p { font-size:18px; line-height:1.35 }
  .library-body .watch-controls.watch-transport { margin-top:6px; grid-template-columns:1fr 1fr 1fr auto; gap:8px }.watch-transport #watchPlay { grid-row:auto; grid-column:auto }.library-body .watch-transport .kid-button { min-height:44px; font-size:15px }
  .watch-timeline { padding:3px 0!important }
  .free-screen { --workshop-header:58px }.free-header h1 { font-size:18px }.free-header input { width:210px; height:28px; min-height:28px!important }
  .free-workspace { display:grid; grid-template-columns:185px minmax(0,1fr) }
  .free-catalog { order:0; height:100%; padding:8px; overflow:auto; min-height:0 }
  .free-catalog.collapsed { height:100%; flex-basis:auto }
  .free-catalog.collapsed .free-categories { display:flex }.free-catalog.collapsed .free-parts { display:grid }
  .free-catalog h2 { font-size:21px; margin-bottom:6px }.free-catalog>.search-field { display:none }
  .free-catalog-heading .mobile-only { display:none!important }
  .free-categories { flex-wrap:wrap; overflow:visible; gap:4px; margin:4px 0 8px }.free-categories button { min-height:44px; padding:5px; font-size:11px }
  .free-parts { display:grid; grid-template-columns:1fr 1fr; overflow:visible; gap:7px }.free-part { width:auto; min-width:0; height:100px; min-height:100px }.free-part img { height:58px }
  .free-tools { min-height:0; bottom:6px }.free-tools button { min-height:46px!important; font-size:11px; padding:2px }
  .free-tools .toy-icon { width:22px; height:22px }.free-instruction { display:none }
  #gameScreen { --device-game-header:58px }
  #gameScreen .game-header { height:58px!important; padding:6px 10px!important; gap:10px }
  #gameScreen .build-progress { position:static; width:100%; min-width:0; padding:0 10px; grid-template-columns:minmax(0,1fr) auto }
  #gameScreen #activeLessonName { font-size:20px }
  #gameScreen .mission-panel, #gameScreen .mission-panel.collapsed { inset:68px auto auto 12px!important; width:min(280px,calc(100% - 285px))!important }
  #gameScreen .puppy-bubble { min-height:60px; padding:5px; border-width:7px; border-image-width:7px; flex-wrap:nowrap }
  #gameScreen .mission-action { width:auto; flex:1; text-align:left }.mission-action strong { font-size:18px!important }
  #gameScreen #voiceReplayBtn { width:44px; height:44px; min-width:44px; min-height:44px; padding:8px }
  #gameScreen .piece-tray, #gameScreen .piece-tray.collapsed { inset:68px 10px 10px auto!important; width:246px!important; height:calc(100dvh - 78px)!important; min-height:0; max-height:none; transform:none!important; padding:8px 9px 10px!important; display:flex!important; flex-direction:column; gap:6px }
  #gameScreen .build-stage { min-height:22px; font-size:12px; padding-bottom:3px }.build-stage #buildStageDots { gap:4px }
  #gameScreen .toybox-heading { height:22px; min-height:22px }.toybox-heading .tray-title { font-size:18px!important }
  #gameScreen .piece-list { flex:1 1 auto; height:auto!important; min-height:0; padding:2px 2px 5px!important }
  #gameScreen .piece-card { flex:0 0 99px!important; width:99px!important; min-width:99px!important; height:100%!important; min-height:0; display:flex; flex-direction:column }
  #gameScreen .piece-preview { flex:1 1 auto; min-height:0; height:auto!important; width:100% }.piece-card-copy { flex:0 0 auto }
  #gameScreen .piece-card strong { font-size:13px!important }
  #gameScreen .play-actions { flex:0 0 50px; height:50px; min-height:50px; grid-template-columns:minmax(0,1fr) 44px 44px; gap:6px }
  #gameScreen .place-assist, #gameScreen .test-button { height:50px; min-height:50px; font-size:18px }
  #gameScreen .piece-prompt { font-size:14px }

  /* Keep touch controls clear of a landscape notch and the home indicator. */
  .library-body .picture-reader { padding-inline:env(safe-area-inset-left) env(safe-area-inset-right) }
  .reader-topbar { padding-left:max(10px,env(safe-area-inset-left)); padding-right:max(10px,env(safe-area-inset-right)) }
  .library-body .watch-shell { padding:calc(5px + env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 18px max(12px,env(safe-area-inset-left)) }
  .watch-book { height:calc(100dvh - 175px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) }
  .free-header, #gameScreen .game-header { padding-left:max(10px,env(safe-area-inset-left))!important; padding-right:max(10px,env(safe-area-inset-right))!important }
  .free-workspace { grid-template-columns:calc(185px + env(safe-area-inset-left)) minmax(0,1fr); padding-right:env(safe-area-inset-right) }
  .free-catalog { padding-left:calc(8px + env(safe-area-inset-left)); padding-bottom:calc(8px + env(safe-area-inset-bottom)) }
  .free-tools { bottom:calc(6px + env(safe-area-inset-bottom)) }
  .free-inspector, .free-inspector-toggle { right:calc(12px + env(safe-area-inset-right)) }
  #gameScreen .mission-panel, #gameScreen .mission-panel.collapsed { left:calc(12px + env(safe-area-inset-left))!important }
  #gameScreen .piece-tray, #gameScreen .piece-tray.collapsed { right:calc(10px + env(safe-area-inset-right))!important; bottom:calc(10px + env(safe-area-inset-bottom))!important; height:calc(100dvh - 78px - env(safe-area-inset-bottom))!important }
}

@media (max-width:1366px) and (max-height:360px) and (orientation:landscape) {
  .map-view .hub-heading { display:none }
  .city-preview { padding:2px }
  .city-preview-copy { gap:2px }
  .city-preview-copy h2 { font-size:16px }
}

@media (max-width:360px) {
  .kingdom-wordmark>span, .kingdom-wordmark b, .library-body .library-brand strong { font-size:12px!important }
  .kingdom-motto, .library-affiliation { font-size:8px; max-width:79px }
  .map-view .hub-heading h1 { font-size:23px }
  .city-preview { grid-template-columns:43px minmax(0,1fr); gap:4px }.city-preview-model { width:43px }
  .city-preview-copy { grid-template-columns:minmax(0,1fr) 107px; gap:3px }.city-preview-copy h2 { font-size:16px }.city-build-button { font-size:14px }
  .library-body .library-welcome h1 { font-size:25px }.library-invitation h2 { font-size:18px }
  .library-body .story-card-copy h3, .library-body .story-card-copy h3 a { font-size:15px }
  .story-page-copy { padding-inline:17px }.library-body .story-reader-controls { grid-template-columns:80px minmax(0,1fr) 91px }
  .free-header h1 { font-size:18px }.free-header input { width:134px }.free-header .royal-button:last-child { min-width:65px; max-width:68px; font-size:12px!important }
}

@media (max-width:700px) and (max-height:640px) and (orientation:portrait) {
  .map-view .hub-heading p { display:none }
  .map-view .hub-heading { padding:9px 12px 5px }
  .map-view .growing-city { grid-template-rows:60px minmax(0,1fr) auto }
  .city-districts { padding-top:2px; padding-bottom:5px }
  .city-districts .toy-icon { width:20px; height:20px }
  .city-map-stage { grid-template-rows:minmax(0,1fr) 100px 44px }
  .city-preview-model { height:65px }
  .city-explore-list { padding-block:2px }
  .home-hero-copy { padding:5px 10px 7px }
  .home-hero h1 { font-size:29px }.home-hero-copy>p { font-size:12px; margin:5px 0 7px }
  .home-actions .royal-button.gold { min-height:48px; font-size:22px }
  .home-discover .discovery-card { height:112px }
  .home-discover .discovery-card h2 { font-size:15px }
  .free-catalog { flex-basis:196px; height:196px; padding-top:4px; padding-bottom:5px }
  .free-catalog-heading { min-height:34px }.free-catalog h2 { font-size:20px }
  .free-part { height:90px; min-height:90px }.free-part img { height:49px }
  .free-instruction { display:none }
}
