/* The existing portrait table remains the default. */
#play-viewport,#play-rotation{display:contents}
#play-shell{padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
.screen-chooser{display:flex;align-items:center;gap:4px;padding:4px;background:#0d1714;border:1px solid var(--line);border-radius:9px}
.screen-label{font-size:.875rem;color:var(--muted);padding:0 8px}
.screen-chooser button{display:flex;align-items:center;justify-content:center;gap:8px;min-height:38px;padding:8px 12px;background:transparent;border-radius:6px;color:var(--muted);font-size:.875rem;white-space:nowrap}
.screen-chooser button[aria-pressed=true]{background:#354b36;color:#f5dcaa;box-shadow:inset 0 0 0 1px #887b4e}
.screen-icon{display:inline-block;border:1.5px solid currentColor;border-radius:3px;flex:none}
.portrait-icon{width:12px;height:18px}.landscape-icon{width:18px;height:12px}
@media(max-width:900px){.site-header{flex-wrap:wrap;gap:12px}.screen-chooser{order:3;margin:auto}.header-actions{margin-left:auto}.screen-label{font-size:.875rem}}
@media(max-width:520px){.site-header{padding-bottom:10px}.screen-chooser{width:100%;justify-content:center}.screen-chooser button{flex:1;max-width:150px;min-height:40px}.screen-label{padding:0 12px}}

/* A short, wide play surface. Rotation is purely presentational. */
html.landscape-mode,html.landscape-mode body{width:100%;height:100%;overflow:hidden}
html.landscape-mode{--minimum-table-height:144px}
/* Clip only in physical screen coordinates. The rotated layer must not also
   be a fixed scroll container: keep its scrollport on an untransformed child. */
.landscape-mode #play-viewport{display:block;position:fixed;inset:var(--viewport-top,0px) auto auto var(--viewport-left,0px);width:var(--viewport-width,100vw);height:var(--viewport-height,100dvh);overflow:hidden;background:var(--bg)}
.landscape-mode #play-rotation{display:block;position:absolute;top:0;left:0;width:var(--play-width,100vw);height:var(--play-height,100dvh);transform:none;transform-origin:top left;overflow:visible}
.rotated-display #play-rotation{left:100%;transform:rotate(90deg)}
.landscape-mode #play-shell{position:relative;width:100%;height:100%;min-width:0;min-height:0;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain;background:var(--bg);padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);scrollbar-width:thin}
.rotated-display #play-shell{padding:env(safe-area-inset-left) env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)}
.landscape-mode .site-header{max-width:1180px;min-height:42px;padding:2px 12px;gap:10px;flex-wrap:nowrap}
.landscape-mode .brand{gap:8px;flex-shrink:0}.landscape-mode .brand-mark{width:24px;height:30px;font-size:20px;border-bottom-width:3px}
.landscape-mode h1{font-size:1rem;letter-spacing:0}.landscape-mode .brand-en,.landscape-mode .mode-label,.landscape-mode .desktop-text{display:none}
.landscape-mode .screen-chooser{order:0;margin:0 auto;width:auto;flex-shrink:0;padding:2px;gap:3px}
.landscape-mode .screen-label{display:none}.landscape-mode .screen-chooser button{flex:none;min-height:34px;padding:5px 10px;font-size:.875rem}
.landscape-mode .header-actions{gap:6px;margin:0}.landscape-mode .header-actions .icon-button{min-height:34px;font-size:.875rem;padding:5px 9px}
.landscape-mode .layout{max-width:1180px;padding:4px 12px 12px}
.landscape-mode .game-column{display:grid;grid-template-columns:minmax(0,1fr) 176px;gap:3px 10px;align-items:stretch}
.landscape-mode .mode-toolbar{grid-area:1/1;margin:0;min-width:0}
.landscape-mode .online-entry{min-height:34px;justify-content:center;padding:5px 12px;font-size:.875rem;gap:8px;border-radius:6px}
.landscape-mode .online-entry>span:nth-child(2){flex:0 1 auto}.landscape-mode .online-entry small,.landscape-mode .online-entry>span:last-child{display:none}.landscape-mode .online-entry-icon{font-size:1rem}
.landscape-mode .table-toolbar{grid-area:1/2;flex-wrap:nowrap;justify-content:flex-end;margin:0;gap:4px;min-width:0}
.landscape-mode .table-label,.landscape-mode #speed-label{display:none}
.landscape-mode .toolbar-controls{gap:5px;margin:0;min-width:0;width:100%;flex-wrap:nowrap;justify-content:flex-end}
.landscape-mode .toolbar-controls .icon-button,.landscape-mode .toolbar-controls select{min-height:34px;padding:5px 6px;font-size:.875rem;max-width:84px;flex-shrink:0}
.landscape-mode .toolbar-controls select{width:80px;min-width:0}
.landscape-mode .toolbar-controls:has(#round-result:not([hidden])) #speed{display:none}
.landscape-mode .online-strip{grid-area:2/1/3/3;gap:10px;padding:2px 0;margin:0;font-size:.875rem}
.landscape-mode .online-strip .text-button{padding:2px 0;font-size:.875rem}
.landscape-mode .table{grid-area:3/1;height:var(--fitted-table-height,clamp(var(--minimum-table-height),calc(var(--play-height) - 260px),380px));display:grid;grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:25px auto minmax(0,1fr);gap:5px 8px;padding:6px 9px;border-radius:9px;box-shadow:0 5px 15px #0002,inset 0 0 0 3px #112d2355}
.landscape-mode .table:before{display:none}
.landscape-mode .table-center{position:static;grid-area:1/2/2/5;transform:none;width:auto;display:flex;align-items:center;justify-content:flex-end;gap:14px;white-space:nowrap}
.landscape-mode .table-center .round-label{font-size:1rem;letter-spacing:.04em}.landscape-mode .round-label small{font-size:.75rem;margin-left:4px}
.landscape-mode .wall-info{gap:5px;margin:0}.landscape-mode .wall-info span{font-size:.75rem}.landscape-mode .table-center .wall-info strong{font-size:1.35rem}
.landscape-mode .wall-meter{display:none}.landscape-mode .pot-line{font-size:.75rem;margin:0}
.landscape-mode .table-dora{position:static;grid-area:1/1;display:flex;flex-direction:row;gap:6px;font-size:.75rem;white-space:nowrap}
.landscape-mode .table-dora .tile{width:18px;height:25px}
.landscape-mode .opponent,.landscape-mode .table-self{position:relative;inset:auto;transform:none;width:auto;min-width:0;max-width:none;padding:4px 6px;margin:0;background:#10291fe0;border:1px solid #b6d0aa25;border-radius:5px;align-self:stretch}
.landscape-mode .opponent.west{grid-area:2/1}.landscape-mode .opponent.north{grid-area:2/2}.landscape-mode .opponent.east{grid-area:2/3}
.landscape-mode .player-main{gap:5px}.landscape-mode .seat{width:20px;height:20px;font-size:.75rem;flex:none}
.landscape-mode .player-name{max-width:none;min-width:0;font-size:.875rem}.landscape-mode .player-score{font-size:1rem;letter-spacing:0}
.landscape-mode .opponent-score-line{margin-top:2px;gap:3px}.landscape-mode .cpu-state{font-size:.75rem;white-space:nowrap}
.landscape-mode .opponent.in-riichi{background:#493226;border-color:#efb15e;box-shadow:0 0 0 1px #da9b4944}
.landscape-mode .small-melds{gap:1px;max-width:none;margin-top:3px}.landscape-mode .small-melds .tile{width:11px;height:16px}.landscape-mode .small-melds .meld{margin:0 3px 0 0}
.landscape-mode .table-self{grid-area:2/4;display:grid;grid-template-columns:20px minmax(0,1fr);gap:2px 5px;font-size:.875rem;border-color:#b8a26780;background:#344333}
.landscape-mode .table-self strong{grid-area:2/1/3/3;font-size:1rem;justify-self:start}.landscape-mode .table-self .reach{grid-area:2/2;justify-self:end;align-self:center}
.landscape-mode .river{position:static;inset:auto;transform:none;--river-w:22px;--river-h:30px;--river-gap:2px;display:flex;align-content:flex-start;justify-content:flex-start;width:100%;height:100%;min-width:0;max-height:none;padding:2px;overflow-y:auto;overflow-x:hidden;border-top:1px solid #bfd0a52b}
.landscape-mode .river-west{grid-area:3/1}.landscape-mode .river-north{grid-area:3/2}.landscape-mode .river-east{grid-area:3/3}.landscape-mode .river-south{grid-area:3/4}
.landscape-mode .river .tile{width:var(--river-w);height:var(--river-h)}
.landscape-mode .start-card{padding:10px 18px;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:5px 20px;max-height:100%;overflow:auto;max-width:94%}
.landscape-mode .start-card .eyebrow{grid-area:1/1;text-align:left;font-size:.75rem}
.landscape-mode .start-card h2{grid-area:2/1;text-align:left;font-size:1.05rem;margin:0}
.landscape-mode .start-card p{grid-area:3/1;text-align:left;font-size:.8125rem;margin:0;line-height:1.5}
.landscape-mode .start-card:has([data-tile-loading]:not([hidden]))>p:not([data-tile-loading]){display:none}
.tile-loading{color:var(--muted);font-size:.85rem;line-height:1.5;margin:8px 0}.tile-loading .text-button{margin-left:10px}.tile-loading[hidden]{display:none}
.landscape-mode .start-card .primary{grid-area:1/2/4/3;padding:14px;font-size:.9375rem}
.landscape-mode .hand-area{display:contents}
.landscape-mode .action-bar{grid-area:3/2;margin:0;display:grid;grid-template-columns:1fr;grid-template-rows:repeat(3,minmax(44px,1fr));gap:6px}
.landscape-mode .action-bar button{width:100%;min-width:0;min-height:44px;padding:5px 8px;gap:3px;font-size:1rem;flex-direction:column}
.landscape-mode .action-bar small{display:block;font-size:.75rem}.landscape-mode .riichi-button span{font-size:.75rem}
.landscape-mode .hand-topline{grid-area:4/1/5/3;min-height:24px;margin:0;gap:6px;align-items:center}
.landscape-mode .hand-status{font-size:.875rem;line-height:1.4}.landscape-mode .hand-meta{gap:8px}.landscape-mode #draw-count{display:none}
.landscape-mode .action-timer{font-size:.875rem;gap:4px}.landscape-mode .action-timer strong{font-size:1.1rem}
.landscape-mode .action-time-track{grid-area:5/1/6/3;margin:0;height:3px}
.landscape-mode .hand{grid-area:6/1/7/3;grid-template-columns:repeat(14,minmax(0,1fr));gap:4px;min-height:0;padding:3px 1px 1px;align-items:end}
.landscape-mode .hand .tile{width:100%;height:auto;min-height:44px;max-height:60px;aspect-ratio:.77;border-radius:4px;border-bottom-width:4px}
.landscape-mode .hand .tile img{max-width:94%}.landscape-mode .hand .tile.drawn{transform:translateY(-2px)}.landscape-mode .hand .tile.drawn:after{display:none}
.landscape-mode .hand .tile.reservation-selected{transform:translateY(-3px)}.landscape-mode .hand.selecting-reservation{outline-offset:2px}
.landscape-mode .your-melds{grid-area:7/1/8/3;min-height:0;margin:0;gap:6px}.landscape-mode .your-melds:empty{display:none}.landscape-mode .your-melds .tile{width:21px;height:29px}
.landscape-mode .hand-preferences{grid-area:8/1;gap:8px;margin:0;align-items:center;justify-content:flex-start;flex-wrap:wrap}
.landscape-mode .hand-preferences .switch-label{font-size:.875rem}.landscape-mode .hand-preferences .switch-label small{display:none}
.landscape-mode .hand-preferences .reservation-state{font-size:.75rem;white-space:normal}
.landscape-mode .inline-reservations{grid-area:9/1/10/3;min-height:44px;padding-top:4px;margin:0;gap:12px}
.landscape-mode .inline-reservation-heading{flex-direction:row;align-items:center;gap:10px;font-size:.875rem}
.landscape-mode .inline-reservation-heading .text-button{min-height:38px;padding:5px;font-size:.8125rem}
.landscape-mode .inline-reservations .active-reservations{min-height:38px;padding:0}
.landscape-mode .inline-reservations .active-item button{min-height:38px;min-width:38px}
.landscape-mode .reservation-selection-hint{grid-area:10/1/11/3;margin:0;font-size:.875rem}
.landscape-mode .hand-footer,.landscape-mode .site-footer{display:none}
.landscape-mode .recent-event{grid-area:11/1/12/3;margin:0;padding-top:6px;min-height:30px;font-size:.875rem}
.landscape-mode .event-log{grid-area:12/1/13/3;margin:0;padding-top:8px;font-size:.875rem}
.landscape-mode .toast{max-width:calc(var(--play-width) - 28px);font-size:.875rem;padding:10px 15px}
.rotated-display .toast,.rotated-display .toast.show{top:calc(var(--viewport-top,0px) + var(--viewport-height,100vh)/2);left:calc(var(--viewport-left,0px) + var(--viewport-width,100vw) - 35px);transform:translate(-50%,-50%) rotate(90deg);width:max-content}

/* Top-layer dialogs are outside the rotated shell, so rotate them separately. */
.landscape-mode dialog{width:min(720px,calc(var(--play-width) - 28px));max-width:calc(var(--play-width) - 28px);max-height:calc(var(--play-height) - 24px);padding:18px 22px;overscroll-behavior:contain}
.landscape-mode dialog{position:fixed;inset:calc(var(--viewport-top,0px) + var(--viewport-height,100vh)/2) auto auto calc(var(--viewport-left,0px) + var(--viewport-width,100vw)/2);margin:0;transform:translate(-50%,-50%)}
.rotated-display dialog{transform:translate(-50%,-50%) rotate(90deg)}
.landscape-mode .dialog-header{margin-bottom:14px}.landscape-mode .result-buttons{flex-direction:row;gap:10px;margin-top:8px}
.landscape-mode .result-row{padding:7px 4px;grid-template-columns:30px minmax(0,1fr) 68px 82px;font-size:.875rem;gap:5px}
.landscape-mode .result-confirm-hint{margin:8px 0 0;font-size:.875rem}
.landscape-mode .final-result #result-content{display:grid;grid-template-columns:minmax(160px,.7fr) minmax(0,1.3fr);gap:4px 20px}
.landscape-mode .final-hero{grid-area:1/1;padding:6px 0;align-self:center}.landscape-mode .final-hero .eyebrow{font-size:.75rem;letter-spacing:.08em}
.landscape-mode .final-hero h2{font-size:1.2rem;margin:8px 0 4px}.landscape-mode .final-placement strong{font-size:2rem}
.landscape-mode .final-total{flex-wrap:wrap;gap:2px 8px;margin-top:5px}.landscape-mode .final-total>strong{font-size:1.6rem}
.landscape-mode .final-result .result-scores{grid-area:1/2;margin:0;align-self:center}
.landscape-mode .final-result .result-note,.landscape-mode .final-hand-details,.landscape-mode .final-result .result-confirm-hint,.landscape-mode .final-result .result-buttons{grid-column:1/-1}
.landscape-mode .final-hand-details{margin:0;padding:8px 0}.landscape-mode .final-result .result-buttons{flex-direction:row}
.landscape-mode .final-result .result-buttons .primary{min-height:44px;padding:10px 15px}
.landscape-mode .final-result .result-buttons .inspect-button{min-height:44px;padding:8px}

/* Browser bars can leave only about 300 px of height in native landscape. */
html.short-landscape{--minimum-table-height:124px}
.short-landscape .site-header{min-height:34px;padding-top:0;padding-bottom:0}
.short-landscape .screen-chooser button,.short-landscape .header-actions .icon-button{min-height:28px;padding-top:3px;padding-bottom:3px}
.short-landscape .layout{padding-top:2px}.short-landscape .game-column{row-gap:2px}
.short-landscape .online-entry,.short-landscape .toolbar-controls .icon-button,.short-landscape .toolbar-controls select{min-height:30px;padding-top:3px;padding-bottom:3px}
.short-landscape .action-bar{grid-template-rows:repeat(3,minmax(36px,1fr));gap:4px}
.short-landscape .action-bar button{min-height:36px}
.short-landscape .action-bar small,.short-landscape .riichi-button span{display:none}
.short-landscape .hand-topline{min-height:22px}
.short-landscape .hand .tile{max-height:44px}
