/* The game keeps its state while the layout follows the available space. */
html{scroll-padding-bottom:calc(90px + env(safe-area-inset-bottom,0px))}
h1,h2{ text-wrap:balance }
.player-identity,.player-row>div,.lobby-row .room-description{min-width:0}
.player-row h2{overflow-wrap:break-word}
.turn-label{overflow-wrap:break-word;max-width:40%}
.board-tools .btn{min-width:0}
.switch-line{min-height:44px}
@media(min-width:901px){
  .game-layout{grid-template-columns:minmax(0,min(680px,calc(100svh - 325px))) minmax(310px,1fr)}
}
@media(min-width:901px) and (max-height:850px){
  .game-layout{grid-template-columns:minmax(0,min(680px,calc(100svh - 310px))) minmax(290px,1fr)}
}
@media(max-width:900px){
  .site-header{height:auto;min-height:calc(62px + env(safe-area-inset-top,0px))}
  .header-inner{height:auto;min-height:calc(62px + env(safe-area-inset-top,0px));padding-top:calc(10px + env(safe-area-inset-top,0px));padding-left:max(18px,env(safe-area-inset-left,0px));padding-right:max(18px,env(safe-area-inset-right,0px))}
  main{padding-left:max(14px,env(safe-area-inset-left,0px));padding-right:max(14px,env(safe-area-inset-right,0px));padding-bottom:calc(95px + env(safe-area-inset-bottom,0px))}
  .navigation{padding-left:max(12px,env(safe-area-inset-left,0px));padding-right:max(12px,env(safe-area-inset-right,0px))}
  .player-row h2{font-size:14px}.player-row .muted{font-size:12px}.turn-label{font-size:11px}
  select{font-size:16px!important}/* Prevent focus zoom on mobile Safari. */
  .coach-voice{grid-template-columns:1fr}
  .coach-voice #voice-help{grid-column:auto}
}
@media(max-width:900px) and (max-height:650px) and (orientation:portrait){
  .board-panel{width:100%;max-width:calc(100svh - 296px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));margin-inline:auto}
  .player-row h2{font-size:12px}.player-row .muted{font-size:10px}.turn-label{font-size:10px}
  .board-tools .icon{display:none}.board-tools .btn{font-size:11px}
  .opponent-row{gap:7px}.opponent-row .avatar{display:none}
}
/* Landscape phones and short desktop windows use a compact horizontal cockpit. */
@media(min-width:601px) and (max-height:500px){
  :root{--sidebar:64px}
  html{scroll-padding-bottom:20px}
  .site-header{position:fixed;inset:0 auto 0 0;width:calc(64px + env(safe-area-inset-left,0px));height:100dvh;min-height:0;border-right:1px solid var(--border)}
  .header-inner{height:100%;min-height:0;padding:7px 8px 7px calc(8px + env(safe-area-inset-left,0px));display:flex;flex-direction:column;gap:6px;align-items:stretch}
  .brand{height:39px;flex:none;justify-content:center}.brand>span{display:none}.brand .piece{width:25px;height:30px}
  .navigation{position:static;inset:auto;width:auto;padding:0;display:flex;flex-direction:column;gap:2px;background:transparent;border:0;backdrop-filter:none;flex:none;order:initial}
  .nav-button{min-height:44px;flex:none;padding:10px;border:0;border-radius:7px;gap:0;justify-content:center}.nav-button>span{display:none}.nav-button .icon{width:22px;height:22px}.nav-button.active{background:#bfda9c1a;color:var(--accent);border:0}
  .sidebar-bottom{display:flex;flex-direction:column;margin:0;padding:0;border:0}.sidebar-bottom p,.sidebar-bottom .about-nav{display:none}.header-custom{justify-content:center;padding:10px!important}.header-custom>span{display:none}
  main{margin:0 0 0 calc(64px + env(safe-area-inset-left,0px));padding:10px max(12px,env(safe-area-inset-right,0px)) max(12px,env(safe-area-inset-bottom,0px)) 12px;max-width:none}
  .intro,.site-footer{display:none}.is-lobby .intro{display:block;min-height:0;margin:0 0 18px;padding-top:6px}.is-lobby .intro h1{font-size:30px}.is-lobby .intro p{font-size:14px}
  .game-layout{display:grid;grid-template-columns:minmax(220px,calc(100svh - 138px - env(safe-area-inset-bottom,0px))) minmax(0,1fr);gap:18px;align-items:start}
  .board-panel{max-width:none;width:100%;margin:0}.opponent-row{min-height:32px;padding:6px 8px;margin-bottom:5px;gap:7px}.opponent-row .avatar{display:none}.player-identity{gap:1px 6px}.player-row h2,.bottom-row h2{font-size:12px}.player-row .muted{font-size:10px}.turn-label{font-size:10px;max-width:37%}.capture-line{font-size:10px}
  .board-wrap{grid-template-columns:16px minmax(0,1fr);grid-template-rows:auto 17px;margin:4px 4px 0 0}.ranks,.files{font-size:9px}.files{padding-top:1px}.bottom-row{min-height:26px;padding:4px 7px}.bottom-row .avatar,.saved-label{display:none}.board-tools{margin-top:7px;gap:5px;grid-template-columns:1.3fr 1fr 1fr 1fr}.board-tools .btn{min-height:44px;padding:6px 3px;font-size:10px}.board-tools .icon{display:none}.board-note{display:none}
  .rail{display:flex;gap:14px}.online-nudge{display:none}.companion-tabs{padding:0 7px;gap:3px}.companion-tabs button{min-height:44px;padding:10px 2px;font-size:13px}.companion>[role=tabpanel]{padding:16px}.companion h2{font-size:23px}.coach-glyph{margin:0 0 10px}.coach-glyph .icon{width:25px;height:25px}.coach-message{margin:12px 0 16px;min-height:0}.coach-message p{font-size:14px;line-height:1.5}.coach-actions{gap:8px}.coach-actions .btn{font-size:12px;min-height:44px;padding:8px}.coach-voice{grid-template-columns:1fr;margin-top:18px;padding-top:15px}.coach-voice select{font-size:16px}.moves-list{max-height:220px;min-height:140px}.moves-header{flex-wrap:wrap}.moves-header h2{font-size:22px}.theme-options{flex-wrap:wrap}.theme-choice{min-width:48px}.piece-options{gap:6px}.choice{min-height:80px;font-size:12px}.choice .piece{width:36px;height:36px}.theme-line{margin:14px 0}.theme-line>span{margin-bottom:8px}.settings-link{font-size:12px;gap:4px}.swatch{width:38px}.letter-piece{font-size:clamp(17px,3vh,25px)}
  .focus-mode main{padding-top:10px}.focus-mode .game-layout{display:block;max-width:calc(100svh - 138px - env(safe-area-inset-bottom,0px));margin-inline:auto}.focus-mode .board-note{display:none}
  .play-choices{display:grid;grid-template-columns:1.15fr 1fr;gap:14px}.play-choice:first-child{min-height:190px;padding:20px 95px 20px 20px}.play-choice h2{font-size:28px}.invite-art{width:74px}.play-choice.community-choice{display:flex;padding:22px;align-items:flex-start;gap:8px;justify-content:center}.community-choice>.icon{display:none}.community-choice h2{font-size:24px}.community-choice p{font-size:13px}.community-choice .btn{font-size:12px}.account-strip{flex-direction:row;align-items:center}.online-empty{min-height:170px}.online-columns{margin-bottom:12px}#toast{bottom:max(12px,env(safe-area-inset-bottom,0px));left:calc(50% + 32px);max-width:calc(100vw - 100px)}
}
@media(pointer:coarse){.theme-choice,.text-button,.switch-line{min-height:44px}.online-game-top>.btn{min-height:44px}}
@media print{main{margin:0;padding:0}.game-layout,.focus-mode .game-layout{display:block;max-width:none}.board-panel{width:100%;max-width:none}.board-wrap{max-width:560px}.board-tools{display:none}}
