/* Window-sized layouts shared by iPad, iPhone Duo and resizable web windows.
   Keep the same DOM, routes, controls and board state while the window changes. */
html[data-layout] .app-shell{padding-inline:max(16px,env(safe-area-inset-left)) max(16px,env(safe-area-inset-right));max-width:1440px}
html[data-layout] #native-viewport{min-width:0}
/* Translated tile labels must also fit narrow iPad split windows. */
html[data-layout] .home-primary{grid-template-columns:repeat(2,minmax(0,1fr))}
html[data-layout] .home-primary .action-card,html[data-layout] .home-primary .action-card>*{min-width:0;overflow-wrap:anywhere}
html[data-layout]:not([data-layout=compact]) .app-shell{grid-template-columns:88px minmax(0,1fr);grid-template-rows:calc(64px + env(safe-area-inset-top)) minmax(0,1fr);column-gap:24px}
html[data-layout]:not([data-layout=compact]) .native-header{grid-column:1/-1;grid-row:1}
html[data-layout]:not([data-layout=compact]) #native-viewport{grid-column:2;grid-row:2}
html[data-layout]:not([data-layout=compact]) .native-tabs{grid-column:1;grid-row:2;display:flex;flex-direction:column;align-items:stretch;justify-content:flex-start;gap:12px;height:auto;margin:0;padding:16px 0 max(16px,env(safe-area-inset-bottom));border-top:0;border-inline-end:1px solid var(--border);overflow-y:auto;overscroll-behavior:contain}
html[data-layout]:not([data-layout=compact]) .native-tabs button{flex:none;flex-direction:column;gap:6px;min-width:44px;min-height:64px;height:auto;padding:12px 6px;font-size:12px;white-space:normal;border-radius:14px}
html[data-layout]:not([data-layout=compact]) .native-tabs svg{flex:none}
html[data-layout]:not([data-layout=compact]) body:has(.native-tabs[hidden]) .app-shell{grid-template-columns:minmax(0,1fr)}
html[data-layout]:not([data-layout=compact]) body:has(.native-tabs[hidden]) #native-viewport{grid-column:1}
html[data-layout]:not([data-layout=compact]) .native-tabs[hidden]{display:none}
html[data-layout=wide] .native-view:not(.focus-view):not(.home-view){max-width:1040px;width:100%}
html[data-layout=wide] .home-view{max-width:920px;width:100%;padding-top:24px}
html[data-layout=wide] .native-sheet{width:min(680px,calc(100% - 48px));margin:auto;border-radius:24px;max-height:calc(100dvh - 64px)}
html[data-layout=wide] #view-collections #collection-dialog{max-width:none;width:100%}
html[data-layout=wide] #collection-captures{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;align-items:start}
html[data-layout=wide] #collection-captures .archive-item{min-width:0;margin:0}
html[data-layout=wide] #view-import .import-panel{max-width:920px;margin-inline:auto}
/* A short outer display keeps content height by moving navigation to the edge. */
html[data-layout=short] .app-shell{grid-template-columns:minmax(0,1fr) 76px;grid-template-rows:calc(48px + env(safe-area-inset-top)) minmax(0,1fr);column-gap:16px}
html[data-layout=short] #native-viewport{grid-column:1}
html[data-layout=short] .native-tabs{grid-column:2;gap:4px;padding-block:4px;border-inline-end:0;border-inline-start:1px solid var(--border)}
html[data-layout=short] .native-tabs button{min-height:48px;padding:6px 4px;font-size:11px;gap:3px}
html[data-layout=short] body:has(.native-tabs[hidden]) .app-shell{grid-template-rows:calc(48px + env(safe-area-inset-top)) minmax(0,1fr)}
/* Fullscreen gameplay owns the first grid row after its header is hidden. */
html[data-layout] body[data-view=play].play-expanded:has(.native-tabs[hidden]) .app-shell{grid-template-rows:minmax(0,1fr);grid-template-columns:minmax(0,1fr);padding-inline:max(4px,env(safe-area-inset-left)) max(4px,env(safe-area-inset-right))}
html[data-layout] body[data-view=play].play-expanded #native-viewport{grid-row:1;grid-column:1}
/* Play layout agrees with the actual space measured by native-shell. */
body:not(.play-expanded) #view-play.play-roomy .play-content{display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-rows:minmax(0,1fr);gap:20px;align-items:stretch}
body:not(.play-expanded) #view-play.play-roomy .play-content>.play-board-shell{grid-column:1;grid-row:1;align-self:center;justify-self:center;margin:0}
body:not(.play-expanded) #view-play.play-roomy .play-side-panel{grid-column:2;grid-row:1;display:flex;flex-direction:column;gap:12px;min-height:0;min-width:0;overflow-y:auto;overflow-x:hidden;padding:4px}
body:not(.play-expanded) #view-play.play-roomy .play-side-panel #play-players{position:relative;min-height:86px;padding:56px 0 0}
body:not(.play-expanded) #view-play.play-roomy .play-side-panel #native-play-context{position:static;inset:auto;width:100%;margin:0}
body:not(.play-expanded) #view-play.play-roomy .play-side-panel .native-play-bar{position:static;inset:auto;width:100%;display:grid;grid-template-columns:1fr 1fr;gap:8px}
body:not(.play-expanded) #view-play.play-roomy .play-side-panel .native-play-bar button{min-height:48px;white-space:normal}
/* Do not let a narrow split window inherit a landscape-only two-column game. */
body:not(.play-expanded) #view-play:not(.play-roomy) .play-content{display:flex;flex-direction:column;gap:6px}
@media(min-width:900px) and (min-height:600px){
 #view-review{width:100%;max-width:1320px}
 #view-review #native-review-scroll{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(320px,1fr);gap:24px;align-items:start}
 #view-review #native-review-board{position:sticky;top:0;width:100%;max-width:none;margin:0}
 #view-review #native-review-detail{min-width:0;overflow:visible;padding-top:0}
 #view-review .review-tabs{margin-top:0;min-height:48px}
 #view-editor{width:100%;max-width:1200px}
 #view-editor #brett{max-width:none;width:100%}
 #view-editor.editor-has-photo #editor-board-comparison>#review-photo:not([hidden]){height:auto;max-height:50dvh;aspect-ratio:1.35}
 #view-editor #native-editor-settings{width:100%;max-width:none}
 #view-editor .native-editor-actions{width:100%;flex-direction:row}
}
/* Progressive enhancement for browsers exposing actual display segments. No UA guesses. */
@media(horizontal-viewport-segments:2){
 #view-review #native-review-scroll{grid-template-columns:minmax(0,1fr) minmax(0,1fr);column-gap:max(24px,calc(env(viewport-segment-left 1 0,0px) - env(viewport-segment-right 0 0,0px)))}
 #view-editor.editor-has-photo #editor-board-comparison{column-gap:max(24px,calc(env(viewport-segment-left 1 0,0px) - env(viewport-segment-right 0 0,0px)))}
}
