/* In short landscape windows the play surface comes first. Long room details can still scroll. */
html[data-landscape-play] #app:has(> .play-shell) {
 display:grid;grid-template-columns:minmax(0,1fr) clamp(70px,12vw,112px);grid-template-rows:100%;
 width:100%;height:100vh;height:100dvh;min-height:0;align-items:stretch;
}
html[data-landscape-play] #app > main.play-shell {
 grid-area:1/1;min-width:0;min-height:0;padding:0;overflow:auto;
}
html[data-landscape-play] #app:has(> .play-shell) > #roomBar {
 grid-area:1/2;width:100%;max-height:100%;margin:0;padding:3px;overflow:auto;
}
html[data-landscape-play] #app:has(> .play-shell) #roomBar :is(.room-toolbar,summary) {
 display:flex;flex-flow:column;align-items:stretch;justify-content:flex-start;gap:4px;padding:2px;text-align:center;
}
html[data-landscape-play] #app:has(> .play-shell) #roomBar :is(a,button,summary) {
 min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;
}
html[data-landscape-play] .play-shell .board-viewport {
 display:grid;width:100%;height:100%;min-height:0;align-items:start;justify-items:center;container-type:size;
}
html[data-landscape-play] .play-shell #gameSheet {width:100%;max-width:none;margin:0;border-radius:0}
html[data-landscape-play] #roomBar .room-toolbar a {display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:12px;line-height:1.15}
html[data-landscape-play] #roomBar .room-toolbar a strong {font-size:11px;white-space:nowrap;letter-spacing:0}
html[data-landscape-play] #app:has(> .play-shell) > .classic-keys {grid-column:1/-1}
html[data-landscape-play]:is([data-landscape-play="05"],[data-landscape-play="06"],[data-landscape-play="07"]) .play-shell #gameSheet {
 width:min(100%,calc(100cqh * var(--reel-aspect,1.58)));
}

/* Duel reels and their main action share the first screen. */
html[data-landscape-play] #main.wrap:has(#reelPK .rb-reel) {width:100%;max-width:none;padding:3px 7px;margin:0}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-page {width:100%;max-width:none;padding:0;margin:0}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-page > nav {margin:0;min-height:38px}
html[data-landscape-play] #reelPK:has(.rb-reel) :is(.rb-panel,.rb-side) {padding:4px 7px;margin:0}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-watch-head {display:flex;align-items:center;gap:5px;margin:0 0 3px}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-watch-head > div {display:flex;align-items:center;gap:7px;min-width:0}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-watch-head :is(h1,p) {margin:0;font-size:clamp(13px,2.5vw,20px)}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-columns {
 display:grid;grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr);
 gap:3px 7px;height:max(120px,calc(100dvh - 106px));align-items:stretch;
}
html[data-landscape-play] #reelPK .rb-main:has(.rb-reel) {display:contents}
html[data-landscape-play] #reelPK .rb-main .rb-reel {grid-area:1/1/4/2;width:100%;height:100%;max-width:none;margin:0;padding:5px;gap:3px;align-self:stretch}
html[data-landscape-play] #reelPK .rb-main .rb-reel > div {display:grid;grid-auto-rows:minmax(0,1fr)}
html[data-landscape-play] #reelPK .rb-main .rb-reel span {min-height:0;height:auto}
html[data-landscape-play] #reelPK .rb-reel-feedback {grid-area:1/2;min-height:0;margin:0;padding:2px}
html[data-landscape-play] #reelPK .rb-play-controls {grid-area:2/2;align-self:start;margin:0}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-side {grid-area:3/2;min-height:0;overflow:auto;min-width:0}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-side h2 {font-size:15px}
html[data-landscape-play] #reelPK:has(.rb-reel) .rb-side li {min-width:0;padding:2px;gap:3px;grid-template-columns:auto minmax(32px,1fr) auto auto}

/* Leave almost all of the short dimension to the puzzle. Put its controls alongside it. */
html[data-landscape-play] #app:has(.ca-layout) {display:flex;flex-direction:column}
html[data-landscape-play] #app:has(.ca-layout)>#main {order:-1;min-width:0}
html[data-landscape-play] #casualArena .ca-shell:has(.ca-layout) {min-height:0}
html[data-landscape-play] .ca-shell:has(.ca-layout) .ca-wrap {
 box-sizing:border-box;width:100%;height:100vh;height:100dvh;min-height:0;max-width:none;margin:0;
 padding:max(4px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
 display:grid;grid-template-columns:minmax(0,1.22fr) minmax(195px,1fr);grid-template-rows:auto auto auto minmax(0,1fr);
 column-gap:8px;row-gap:3px;
}
html[data-landscape-play] .ca-shell .ca-layout,html[data-landscape-play] .ca-layout .ca-stage {display:contents}
html[data-landscape-play] .ca-shell .ca-top {grid-area:1/2;height:auto;min-height:36px;padding:0;margin:0;gap:3px}
html[data-landscape-play] .ca-top .ca-title > span {display:none}
html[data-landscape-play] .ca-top .ca-title h1 {font-size:clamp(13px,2.2vw,19px);line-height:1.12;margin:0}
html[data-landscape-play] .ca-top button {height:36px;min-height:36px;min-width:36px;padding:3px}
html[data-landscape-play] .ca-layout .ca-stats {grid-area:2/2;margin:0;display:flex;gap:3px}
html[data-landscape-play] .ca-layout .ca-stats > * {flex:1 1 0}
html[data-landscape-play] .ca-layout .ca-stats > div {min-width:0;padding:1px 2px}
html[data-landscape-play] .ca-layout .ca-well {
 grid-area:1/1/5/2;align-self:center;width:100%;max-width:100%;max-height:100%;justify-self:center;
}
html[data-landscape-play] .ca-layout .ca-boardbox {max-width:100%;padding:4px;margin:auto;width:min(100%,calc(100dvh - 26px))}
html[data-landscape-play] .ca-shell[data-game="13"] .ca-boardbox {width:min(100%,calc((100dvh - 26px)*.73))}
html[data-landscape-play] .ca-shell[data-game="18"] .ca-boardbox {width:min(100%,calc((100dvh - 53px)*.86))}
html[data-landscape-play] .ca-shell:is([data-game="19"],[data-game="20"]) .ca-boardbox {width:100%}
html[data-landscape-play] .ca-layout .ca-bottom {grid-area:3/2;min-width:0;margin:0;padding:3px;max-height:47dvh;overflow:auto}
html[data-landscape-play] .ca-bottom .ca-instruction {padding:0;min-height:0}
html[data-landscape-play] .ca-bottom .ca-key-tip {display:none}
html[data-landscape-play] .ca-layout .ca-controls {margin:2px 0}
html[data-landscape-play] .ca-layout .ca-sidebar {grid-area:4/2;margin:0;min-height:0;overflow:auto;padding:5px;align-self:stretch}
html[data-landscape-play] .ca-shell[data-game="20"] .ca-spot-pictures {padding:2px}
html[data-landscape-play] .ca-shell[data-game="20"] .ca-spot-pictures h3 {margin:2px 0}

/* Festival boards use the available height and retain a separate column for moves. */
html[data-landscape-play] #festivalArena:not([data-mj-screen]):has(.fv-board[data-game]) {
 min-height:0;width:100%;max-width:none;padding:3px max(5px,env(safe-area-inset-right)) 4px max(5px,env(safe-area-inset-left));
}
html[data-landscape-play] #festivalArena:not([data-mj-screen]):has(.fv-board[data-game]) > .fv-head {
 max-width:none;height:40px;min-height:0;padding:0 0 2px;
}
html[data-landscape-play] #festivalArena:not([data-mj-screen]):has(.fv-board[data-game]) > .fv-head button {min-height:36px;height:36px;padding:3px 8px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]):has(.fv-board[data-game]) .fv-head h1 {font-size:18px;margin:0}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-fv-content] > .fv-board[data-game] {
 --available:calc(100dvh - 54px);width:100%;max-width:none;min-height:var(--available);margin:0;
 display:grid;grid-template-columns:minmax(0,1.65fr) minmax(175px,1fr);grid-auto-rows:min-content;align-content:center;align-items:center;gap:4px 7px;padding:3px;
}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board[data-game] > * {grid-column:2;min-width:0}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board[data-game] > :is(.rt-world,.fv-lane-frame,.fv-pool,.fv-chess,.fv-link-wrap) {
 grid-area:1/1/span 8/2;align-self:center;justify-self:center;max-width:100%;margin:0;
}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .rt-world {width:100%;height:var(--available);max-height:none;aspect-ratio:auto}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .fv-lane-frame {width:min(100%,calc(var(--available)*1.32))}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .fv-chess {width:min(100%,calc(var(--available)*.85))}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .fv-link-wrap {width:min(100%,calc(var(--available)*.92))}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .fv-pool {width:min(100%,calc(var(--available)*1.84))}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board :is(.fv-actions,.rt-controls,.fv-map-head,.fv-tip,.rt-ribbon) {margin:0;padding:2px;gap:3px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .fv-actions {flex-wrap:wrap}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board :is(.fv-button,.fv-guide > summary) {min-height:34px;padding:4px 6px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .pool-controls label {width:110px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board .fv-dpad {gap:2px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) .fv-board > .fv-result {grid-column:1/-1}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-fv-content] > .fv-board[data-game="23"] {
 grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr);grid-template-rows:auto minmax(0,1fr) auto;min-height:0;height:var(--available);align-content:stretch;
}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] > .fv-hero-row {grid-area:1/1}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] > .fv-map-head {grid-area:1/2}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] > .fv-felt.hero {grid-area:2/1;min-height:0;align-self:stretch;margin:0}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] > .fv-hero-hand-area {grid-area:2/2;align-self:stretch;min-height:0;display:flex;flex-direction:column}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-hand.tactics {min-height:0;align-items:stretch;overflow:auto;padding:2px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-hero-hand-head {min-height:28px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-hero-pages button {min-height:28px;height:28px}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-history-picture {height:32px;aspect-ratio:auto}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-actions:not(:has(.fv-guide)) {grid-area:3/2}
html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-actions:has(.fv-guide) {grid-area:3/1}

@media (max-height:300px) {
 html[data-landscape-play] .ca-layout .ca-bottom {display:flex;flex-direction:row;align-items:center;flex-wrap:nowrap;justify-content:space-between}
 html[data-landscape-play] .ca-layout .ca-instruction {min-width:0;flex:1 1 0}
 html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-hero-row .fv-hero {padding:2px}
 html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-hero .fv-commander-picture {width:26px;height:26px}
 html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-map-head {max-height:44px;overflow:auto}
 html[data-landscape-play] #festivalArena:not([data-mj-screen]) [data-game="23"] .fv-felt.hero {min-height:58px}
}
