/* Explicit geometry beats legacy 56x84 portrait rules and reserves space before lazy loading. */
.book-collection-card .book-profile{display:block;padding:0;gap:0;overflow:hidden}
.book-collection-card .book-profile img{display:block;width:100%;height:auto;aspect-ratio:2/3;max-height:none;min-height:0;object-fit:contain;background:#09161c}
.book-collection-card .book-profile .character-identity{position:static;padding:16px;background:#122329}
.book-collection-card .scene-card img{display:block;min-height:100px;object-fit:contain}
.card-expand{display:block;width:100%;min-height:44px;margin:8px 0 16px;padding:10px 16px;border:1px solid #7c9c99;border-radius:10px;background:#193339;color:#ecf2ed}
.card-viewer{position:fixed;inset:0;z-index:10000;display:flex;flex-direction:column;background:#04090dfc;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
.card-viewer header{display:flex;align-items:center;gap:8px;padding:10px 12px;flex-shrink:0;background:#101c22}
.card-viewer header span{flex:1;min-width:0;overflow-wrap:anywhere}.card-viewer button{min-height:44px;padding:8px 12px;border:1px solid #608b88;background:#183137;border-radius:10px;color:#eff5ef}
.card-viewer-canvas{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain}.card-viewer-canvas img{display:block;width:100%;height:100%;object-fit:contain;max-width:none;max-height:none}.card-viewer-canvas.zoomed img{width:200%;height:200%}
.more-menu{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:20px}.more-menu button{min-height:64px}
body[data-route='play'] .page-heading{display:none}
body[data-route='play'] .practice{margin-top:10px}
body[data-route='play'] .practice-top{padding:10px 14px}
body[data-route='play'] .practice-title small{margin-top:3px}
body[data-route='play'] .journey-goal{padding:6px 12px}
body[data-route='play'] .journey-goal small{margin-top:3px}
body[data-route='play'] .mode-tab{padding:10px 14px;min-height:44px}
body[data-route='play'][data-mode='sort'] .sort-board{padding:16px 16px 20px;gap:16px 10px;min-height:280px}
body[data-route='play'][data-mode='sort'] .instruction{min-height:0;padding:6px 14px 12px}
@media(max-width:900px){.mobile-nav{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:0;padding:6px 4px max(6px,env(safe-area-inset-bottom));min-height:64px}.mobile-nav button{min-width:0;min-height:48px;padding:4px 2px}.mobile-nav svg{width:22px;height:22px}.main{padding-bottom:calc(88px + env(safe-area-inset-bottom))}body[data-route='play'] .topbar{min-height:48px;padding-block:6px;gap:6px}body[data-route='play'] .mobile-brand{display:none}body[data-route='play'] .resources{width:100%;justify-content:flex-end;gap:10px}body[data-route='play'] .cloud-badge{margin-right:auto;max-width:120px}body[data-route='play'] .icon-button{width:36px;height:36px}}
@media(max-width:420px){.book-collection-card .book-profile img{width:100%;height:auto;aspect-ratio:2/3;max-height:none}}

/* 0.29.2 Block A — compact, no-scroll level viewport. */
.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
.level-compact-header{display:none}
@keyframes move-rejected{0%,100%{transform:translateX(0)}25%{transform:translateX(-5px)}50%{transform:translateX(5px)}75%{transform:translateX(-3px)}}
.flask-button.move-rejected{animation:move-rejected .22s ease-out}
@media (prefers-reduced-motion:reduce){.flask-button.move-rejected{animation:none;outline:2px solid var(--gold)}}
@media(max-width:900px){
 body[data-route='play']{overflow:hidden;height:100dvh}
 body[data-route='play'] .app-shell{height:100dvh;min-height:0;display:block}
 body[data-route='play'] .mobile-nav,body[data-route='play'] .topbar,body[data-route='play'] .side-panel,body[data-route='play'] .chapter-card{display:none!important}
 body[data-route='play'] .main{height:100dvh;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);overflow:hidden}
 body[data-route='play'] .workspace,body[data-route='play'] .workspace>div{height:100%;min-height:0;display:block}
 body[data-route='play'] .practice{height:100%;margin:0;border:0;border-radius:0;display:grid;grid-template-rows:56px minmax(0,1fr) auto;overflow:hidden;background-image:linear-gradient(#06111599,#06111599),url('assets/locations/academy-lab.png');background-position:center;background-size:cover;backdrop-filter:blur(4px)}
 body[data-route='play'][data-mode='match'] .practice{background-image:linear-gradient(#06111599,#06111599),url('assets/locations/academy-lab.png')}
 body[data-route='play'] .practice:before{inset:0;border:0;background:#06111533;backdrop-filter:blur(3px)}
 body[data-route='play'] .level-compact-header{height:56px;display:grid;grid-template-columns:44px minmax(0,1fr) auto 44px;align-items:center;gap:4px;padding:0 4px;position:relative;z-index:4;background:#07191df2;border-bottom:1px solid var(--line);white-space:nowrap}
 .level-back,.level-help{width:44px;height:44px;border:0;background:transparent;color:var(--gold)}.level-moves{color:var(--muted)}
 body[data-route='play'] .mode-tabs,body[data-route='play'] .practice-top,body[data-route='play'] .journey-goal,body[data-route='play'] .instruction,body[data-route='play'] .play-skills,body[data-route='play'] .essence-manifest{display:none!important}
 body[data-route='play'] .sort-board{grid-row:2;min-height:0!important;height:100%;align-content:center;padding:6px 8px 8px!important;gap:4px 4px!important;position:relative;z-index:2}
 body[data-route='play'] .flask-button{min-height:44px;padding:2px 3px 16px}
 body[data-route='play'] .flask-button svg{height:min(24dvh,150px);max-height:100%;width:100%}
 body[data-route='play'] .match-board{grid-row:2;min-height:0;max-height:100%;align-self:center;margin:4px auto;padding:4px}
 body[data-route='play'] .tools{grid-row:3;position:relative;z-index:5;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;padding:6px max(8px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));background:#061216f2;border-top:1px solid var(--line)}
 body[data-route='play'][data-mode='sort'] .tools:has([data-act='extra']){grid-template-columns:repeat(4,minmax(0,1fr))}
 body[data-route='play'] .tools .tool{display:none;min-height:44px;max-width:none;padding:4px 6px;gap:2px}
 body[data-route='play'] .tools [data-act='undo'],body[data-route='play'] .tools [data-act='hint'],body[data-route='play'] .tools [data-act='match-hint'],body[data-route='play'] .tools [data-act='restart'],body[data-route='play'][data-mode='sort'] .tools [data-act='extra']{display:flex}
 body[data-route='play'][data-mode='sort'] .tools .tool-with-reason{display:contents}
 body[data-route='play'][data-mode='sort'] .tools .tool-disabled-reason{display:none;position:fixed;left:50%;bottom:calc(64px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:101;max-width:min(88vw,420px);padding:10px 14px;border:1px solid #618778;border-radius:5px;background:#183b37;color:#f0e7d0;text-align:center}
 body[data-route='play'][data-mode='sort'] .tools .tool-with-reason:active .tool-disabled-reason{display:block}
 #toast{bottom:calc(62px + env(safe-area-inset-bottom));max-width:calc(100vw - 24px)}
}
@media(max-width:360px) and (max-height:600px){
 body[data-route='play'] .practice{grid-template-rows:50px minmax(0,1fr) auto}
 body[data-route='play'] .level-compact-header{height:50px;grid-template-columns:40px minmax(0,1fr) auto 40px}
 body[data-route='play'] .level-back,body[data-route='play'] .level-help{width:40px;height:44px}
 body[data-route='play'] .flask-button svg{height:min(22dvh,122px)}
 body[data-route='play'] .tools{padding-top:4px;gap:4px}
}
/* Tutorial completion CTA stays in the visible bottom region. */
@media(max-width:900px){body[data-route='tutorial'] .journey-intro{min-height:calc(100dvh - 90px - env(safe-area-inset-bottom));padding-bottom:88px;position:relative}body[data-route='tutorial'] .journey-intro>.button{position:sticky;bottom:calc(8px + env(safe-area-inset-bottom));z-index:5;display:flex;justify-content:center;min-height:48px}}

/* 0.29.3 Block A regression fixes. */
@media(max-width:900px){
 body[data-route='tutorial']{overflow:hidden;height:100dvh}
 body[data-route='tutorial'] .topbar,body[data-route='tutorial'] .mobile-nav{display:none!important}
 body[data-route='tutorial'] .main{height:100dvh;padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);overflow:hidden}
 body[data-route='tutorial'] .tutorial-compact{height:100%;display:grid;grid-template-rows:50px minmax(0,1fr) auto;overflow:hidden;background:#07191d}
 body[data-route='tutorial'] .tutorial-compact-header{display:flex;align-items:center;justify-content:space-between;padding:0 8px 0 16px;border-bottom:1px solid var(--line)}
 body[data-route='tutorial'] .tutorial-board{min-height:0!important;height:100%;align-content:center;padding:6px 8px!important;gap:4px!important}
 body[data-route='tutorial'] .flask-button{min-height:44px;padding:2px 3px 16px}
 body[data-route='tutorial'] .flask-button svg{height:min(22dvh,122px);max-height:100%;width:100%}
 body[data-route='tutorial'] .tutorial-bottom{position:relative;z-index:5;padding:6px 8px max(6px,env(safe-area-inset-bottom));background:#061216f2;border-top:1px solid var(--line);text-align:center}
 body[data-route='tutorial'] .tutorial-status{min-height:20px;display:flex;justify-content:center;gap:6px;align-items:center;margin-bottom:4px}
 body[data-route='tutorial'] .tutorial-status strong{color:var(--gold)}
 body[data-route='tutorial'] .tutorial-bottom>.button{width:100%;min-height:44px;margin:0;position:static!important}
 body[data-route='tutorial'] .tutorial-skip{border:0;background:transparent;color:var(--muted);text-decoration:underline;text-underline-offset:3px;min-height:44px;padding:8px}
}
@media(min-width:700px) and (max-width:900px) and (orientation:portrait){
 body[data-route='play'] .tools .tool{min-height:48px}
 body[data-route='play'] .flask-button svg,body[data-route='tutorial'] .flask-button svg{height:min(38dvh,360px)}
 body[data-route='play'] .sort-board,body[data-route='tutorial'] .tutorial-board{align-content:stretch;align-items:center}
}
@media(max-width:900px) and (orientation:landscape){
 body[data-route='play'] .sort-board{align-items:center;align-content:center;row-gap:2px!important;padding-block:2px!important}
 body[data-route='play'] .flask-button{display:grid;grid-template-rows:minmax(0,1fr) 14px;align-items:end;padding-bottom:0}
 body[data-route='play'] .flask-button svg{height:min(20dvh,78px)}
 body[data-route='play'] .flask-id{position:static;white-space:nowrap;text-align:center}
}

/* 0.29.4 A3/V — training layout + build label. */
.build-version{position:fixed;left:calc(16px + env(safe-area-inset-left));bottom:calc(12px + env(safe-area-inset-bottom));color:#b9c7c5;z-index:4;pointer-events:none}
.settings-version{margin:18px 0 0;color:var(--muted);text-align:center}
@media(max-width:900px){
 body[data-route='tutorial'] .tutorial-compact{grid-template-rows:50px auto minmax(0,1fr) auto}
 body[data-route='tutorial'] .tutorial-copy{padding:7px 12px 4px;text-align:center;background:#07191df2;position:relative;z-index:3}
 body[data-route='tutorial'] .tutorial-copy h1{margin:0 0 3px}
 body[data-route='tutorial'] .tutorial-copy p{margin:0;color:var(--muted)}
 body[data-route='tutorial'] .tutorial-board{grid-template-columns:repeat(3,minmax(0,1fr))!important;grid-template-rows:minmax(0,1fr)!important;align-items:center!important;align-content:center!important;justify-items:center;max-width:560px;width:100%;margin:0 auto}
 body[data-route='tutorial'] .flask-button{width:100%;height:100%;display:flex;align-items:center;justify-content:center;padding:2px 3px!important}
 body[data-route='tutorial'] .tutorial-hint .flask-visual{animation:hint 1.35s ease-in-out infinite}
 body[data-route='play'] .flask-id,body[data-route='tutorial'] .flask-id{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
}
@media(max-width:360px) and (max-height:600px){body[data-route='tutorial'] .flask-button svg{height:min(25dvh,132px)}}
@media(max-width:900px) and (orientation:landscape){body[data-route='tutorial'] .tutorial-compact{grid-template-rows:44px auto minmax(0,1fr) auto}body[data-route='tutorial'] .tutorial-copy{padding:2px 8px}body[data-route='tutorial'] .tutorial-copy h1{margin:0}body[data-route='tutorial'] .flask-button svg{height:min(28dvh,96px)}}
@media(prefers-reduced-motion:reduce){body[data-route='tutorial'] .tutorial-hint .flask-visual{animation:none;outline:2px solid var(--teal)}}

/* Build 49 R0: keep the four-slot Sort toolbar on one row on 320px portrait. */
@media(max-width:360px) and (orientation:portrait){
 body[data-route='play'][data-mode='sort'] .tools:has([data-act='extra']){
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  grid-template-rows:minmax(44px,auto)!important;
  flex-wrap:nowrap!important;
 }
}
