/* The phone hand reserved full-card height above cropped cards, while the
   score/decision sheet grew to 76% of the screen. Budget both docks together
   and give the actual canvas the remaining space. Desktop rules stay intact. */
.mp-bar,.mp-hand-toggle,.mp-hand-hint{display:none;}
@media (max-width:640px), ((max-height:640px) and (pointer:coarse)){
  body[data-nexus-surface="table"] #siteNav{gap:6px;padding:4px 10px;min-height:54px;flex-wrap:wrap;max-width:100%;}
  body[data-nexus-surface="table"] #siteNav .logo{font-size:21px;margin-right:auto;}
  body[data-nexus-surface="table"] #siteNav #navMenu{display:inline-flex;min-height:44px;margin-right:46px;}
  body[data-nexus-surface="table"] #siteNav:has(#navMenu[aria-expanded="false"]) > :not(.logo):not(#navMenu):not(#navLinks){display:none !important;}
  body[data-nexus-surface="table"] #siteNav #navLinks{position:static;order:0;width:100%;max-height:48dvh;overflow:auto;}
  body[data-nexus-surface="table"] #siteNav #navLinks:not(.open){display:none;}
  body[data-nexus-surface="table"] #siteNav .nav-right{width:100%;min-width:0;max-width:100%;flex-wrap:wrap;justify-content:flex-start;margin-left:0;}
  body[data-nexus-surface="table"] #siteNav #authChipWrap{max-width:100%;min-width:0;}
  body[data-nexus-surface="table"] #siteNav #authBtn{min-width:0;overflow:hidden;text-overflow:ellipsis;}
  body[data-nexus-surface="table"] #siteNav #authOutBtn{flex-shrink:0;}
  body[data-nexus-surface="table"] #fsBtn{width:44px !important;height:44px !important;top:5px !important;right:7px !important;}
  body.mobile-play .board-wrap{position:relative;}
  body.mobile-play #board{height:calc(100% - var(--mp-dock-height,260px));min-height:90px;}
  body.mobile-play .nxbug-fab{display:none !important;}
  body.mobile-play .game-panel{
    position:fixed;left:6px;right:6px;top:auto;width:auto;
    bottom:calc(4px + env(safe-area-inset-bottom,0px) + var(--mp-keyboard,0px)) !important;
    max-height:calc(var(--mp-height,100dvh) * .32);border-radius:12px;transition:none;
  }
  body.mobile-play.mp-composing .game-panel,
  body.mobile-play .game-panel.mp-expanded{max-height:calc(var(--mp-height,100dvh) * .56);}
  body.mobile-play .gp-hdr{position:static;padding:0 8px;gap:4px;flex-wrap:wrap;}
  body.mobile-play .gp-hdr button{min-height:44px;min-width:44px;}
  body.mobile-play .gp-hdr .gp-min{display:none;}
  body.mobile-play .gp-scores{padding:5px 10px;gap:6px 14px;}
  body.mobile-play .gp-p .gp-pname{display:inline;font-size:12px;}
  body.mobile-play .gp-av{width:30px;height:30px;font-size:18px;}
  body.mobile-play .game-panel:not(.mp-expanded) :is(.gp-hdr,.gp-scores,.gp-myplay,.mp-secondary,.gp-talk){display:none;}
  body.mobile-play .mp-bar{display:flex;align-items:center;gap:6px;min-height:44px;padding:0 6px 0 12px;flex-shrink:0;}
  body.mobile-play .mp-round{margin-right:auto;color:var(--ui-text3);font:12px/1.2 'Spectral',serif;}
  body.mobile-play :is(.mp-details,.mp-hide,.mp-hand-toggle){min-height:44px;min-width:44px;background:none;border:0;color:var(--ui-text2);font:14px/1.2 'Spectral',serif;cursor:pointer;padding:0 8px;}
  body.mobile-play .mp-hand-toggle{display:inline-flex;align-items:center;margin-right:auto;}
  body.mobile-play .mp-hand-hint{display:inline;font:10px/1.2 'Spectral',serif;color:var(--ui-text3);}
  body.mobile-play .hand.collapsed .mp-hand-hint,body.mobile-play.mp-details-open .mp-hand-hint{display:none;}
  body.mobile-play .gp-phase{font:600 14px/1.3 'Spectral',serif;letter-spacing:0;text-transform:none;padding:4px 12px 8px;min-height:0;}
  body.mobile-play .gp-body{padding:0 12px 8px;min-height:0;flex:0 1 auto;overflow:auto;overscroll-behavior:contain;}
  body.mobile-play .gp-judge-badge{font:12px/1.3 'Spectral',serif;letter-spacing:0;padding:4px 7px;margin:0 0 5px;min-height:0;box-shadow:none;}
  body.mobile-play .gp-note{font-size:14px;line-height:1.35;margin-bottom:6px;}
  body.mobile-play .game-panel:not(.mp-expanded) .gp-body:has(.gp-argrow) > .gp-note{display:none;}
  body.mobile-play .gp-argrow{gap:5px;margin-top:0;}
  body.mobile-play .gp-picked{font:600 14px/1.3 'Spectral',serif;letter-spacing:0;overflow-wrap:break-word;}
  body.mobile-play .gp-arg{height:76px;min-height:76px;font:16px/1.35 'Spectral',serif;}
  body.mobile-play .gp-argrow:has(.mp-write) > .gp-go:not(.mp-write){display:none;}
  body.mobile-play .gp-go,body.mobile-play .gp-sitout,body.mobile-play .gp-mull{min-height:44px;font-size:13px;letter-spacing:.3px;white-space:normal;}
  body.mobile-play :is(.jp-next,.jp-appeal){min-height:44px;}
  body.mobile-play .gp-reveal{position:fixed;bottom:4px;top:auto;min-height:44px;z-index:90;}
  body.mobile-play .hand,body.mobile-play:has(.game-panel.open) .hand{
    position:fixed;left:0;right:0;width:100%;transform:none;max-height:none;
    bottom:calc(var(--mp-panel-height,0px) + 8px + env(safe-area-inset-bottom,0px)) !important;
    --hc-scale:.4;--hc:.4;--hc-crop:.66;
  }
  body.mobile-play .hand-box,body.mobile-play .hand.collapsed .hand-box{width:100%;padding:0 8px 5px;border-radius:12px;}
  body.mobile-play .hand-hdr{height:44px;min-height:44px;flex-wrap:nowrap;gap:0;}
  body.mobile-play .hand-hdr :is(.hand-lbl,.hand-chev){display:none;}
  body.mobile-play .hand-hdr #mHandTools{min-width:44px;min-height:44px;}
  body.mobile-play #handSize{display:none !important;}
  body.mobile-play #handCards{
    height:108px;max-height:108px;width:100%;max-width:100%;margin:0;padding:2px 4px;
    display:flex;flex-direction:row;align-items:flex-start;justify-content:flex-start;flex-wrap:nowrap;
    overflow-x:auto;overflow-y:hidden;gap:8px;scroll-padding:4px;
  }
  body.mobile-play .hand.game-hand:not(.view-list):not(.view-node):not(.view-locus) .hand-card{
    width:112px;height:104px;min-width:112px;flex:0 0 112px;margin:0;transform:none;border-radius:8px;
  }
  body.mobile-play .hand-card.sel{outline:2px solid var(--gold);outline-offset:-2px;transform:none;}
  body.mobile-play #hand .hc-mobile-title{bottom:2px;left:2px;right:2px;min-height:38px;padding:3px 5px;border-radius:5px;}
  body.mobile-play #hand .hc-mobile-title b{font:600 13px/1.15 'Spectral',serif;overflow-wrap:normal;word-break:normal;hyphens:none;}
  body.mobile-play .hand.view-list .hand-card{flex:0 0 170px;max-width:170px;min-height:80px;}
  body.mobile-play .hand.view-node .hand-card,body.mobile-play .hand.view-locus .hand-card{flex:0 0 104px;}
  body.mobile-play .hlv-seal{width:66px;height:66px;}
  body.mobile-play .hand.collapsed .hand-cards,body.mobile-play.mp-details-open .hand .hand-cards{display:none !important;}
  body.mobile-play.mp-keyboard .hand{display:none !important;}
  body.mobile-play.m-handtools .hand-hdr{height:auto;flex-wrap:wrap;}
  body.mobile-play.m-chrome #siteNav{position:fixed;left:6px;right:6px;top:54px;width:auto;max-height:calc(100dvh - 64px);overflow:auto;z-index:1100;zoom:1;}
  body.mobile-play.m-chrome #siteNav > *{zoom:1;}
  body.mobile-play.m-chrome .top-bar{display:none !important;}
  /* Checkbox labels previously received only the pixels left after a 100% input. */
  body[data-nexus-surface="table"] .dlg input:is([type="checkbox"],[type="radio"]){width:22px !important;min-width:22px;max-width:22px !important;min-height:22px;height:22px;flex:none;}
}
/* A rotated phone needs a shallower rail as well as a shorter turn sheet. */
@media (orientation:landscape) and (max-height:640px) and (pointer:coarse){
  body.mobile-play #board{width:66%;}
  body.mobile-play #gamePanel{left:auto;right:6px;top:6px;bottom:calc(6px + var(--mp-keyboard,0px)) !important;width:calc(34% - 12px);max-height:none;}
  body.mobile-play #hand{width:66%;right:auto;bottom:4px !important;}
  body.mobile-play #handCards{height:76px;max-height:76px;}
  body.mobile-play #hand.game-hand:not(.view-list):not(.view-node):not(.view-locus) .hand-card{height:72px;}
}
/* The phone setup was a long desktop form with Start below the fold and
   floating controls covering it. Keep choices in a scroll area and actions fixed. */
@media (max-width:640px), ((max-height:640px) and (pointer:coarse)){
  body[data-nexus-surface="table"]:has(.dlg-overlay.open) :is(#fsBtn,#mChrome,.nxbug-fab){display:none !important;}
  #setupOverlay.phone-setup{top:var(--ms-top,0px);bottom:auto;height:var(--ms-height,100dvh);padding:10px 12px;box-sizing:border-box;}
  #setupOverlay.phone-setup > .dlg{display:flex;flex-direction:column;padding:0;width:100%;max-width:460px;max-height:100%;overflow:hidden;}
  #setupOverlay .ms-header{display:flex;align-items:center;gap:12px;padding:16px 18px 10px;flex:none;}
  #setupOverlay .ms-header h3{font:600 24px/1.2 'Spectral',serif;text-transform:none;letter-spacing:0;color:var(--ui-text);margin:0;}
  #setupOverlay .ms-header p{font:14px/1.4 'Spectral',serif;color:var(--ui-text2);margin:4px 0 0;}
  #setupOverlay .ms-close{margin-left:auto;align-self:flex-start;flex:none;width:44px;height:44px;border:0;background:none;color:var(--ui-text2);font:22px/1 system-ui;cursor:pointer;}
  #setupOverlay .ms-scroll{padding:8px 18px 10px;overflow:auto;overscroll-behavior:contain;min-height:0;}
  #setupOverlay .ms-scroll .setup-row{margin:0 0 12px;gap:5px;}
  #setupOverlay .ms-scroll label{font:14px/1.3 'Spectral',serif;color:var(--ui-text2);}
  #setupOverlay .ms-scroll :is(input:not([type="checkbox"]),select,textarea){font:16px/1.35 'Spectral',serif;min-height:44px;padding:9px 11px;width:100%;min-width:0;box-sizing:border-box;}
  #setupOverlay .ms-scroll .setup-checkwrap{align-items:flex-start;}
  #setupOverlay .ms-scroll .setup-checklbl{font:14px/1.4 'Spectral',serif;}
  #setupOverlay .ms-scroll .setup-modwrap{width:100%;justify-content:space-between;flex-wrap:wrap;}
  #setupOverlay .ms-scroll .setup-modedit{min-height:44px;}
  #setupOverlay .ms-summary{font:13px/1.4 'Spectral',serif;color:var(--ui-text2);margin:-4px 0 16px;}
  #setupOverlay .ms-access{font:14px/1.4 'Spectral',serif;color:var(--ui-text2);margin:0 0 12px;}
  #setupOverlay .ms-advanced{border-top:1px solid var(--ui-border);border-bottom:1px solid var(--ui-border);}
  #setupOverlay .ms-advanced > summary{display:flex;align-items:center;min-height:44px;cursor:pointer;font:15px/1.3 'Spectral',serif;color:var(--ui-text2);list-style:none;}
  #setupOverlay .ms-advanced > summary::-webkit-details-marker{display:none;}
  #setupOverlay .ms-advanced > summary::after{content:'+';margin-left:auto;font:20px/1 system-ui;}
  #setupOverlay .ms-advanced[open] > summary::after{content:'−';}
  #setupOverlay .ms-options{padding:8px 0 2px;}
  #setupOverlay .ms-privacy{font:12px/1.4 'Spectral',serif;color:var(--ui-text3);margin:10px 0 4px;}
  #setupOverlay .ms-scroll > a{display:inline-flex;align-items:center;min-height:44px;font:14px/1.3 'Spectral',serif;border:0;padding:0;letter-spacing:0;text-transform:none;}
  #setupOverlay .ms-footer{flex:none;padding:10px 18px max(12px,env(safe-area-inset-bottom,0px));border-top:1px solid var(--ui-border);background:var(--ui-panel);}
  #setupOverlay .ms-footer .dlg-row{display:flex;gap:10px;margin:0;}
  #setupOverlay .ms-footer .dlg-btn{min-height:46px;font:600 16px/1.2 'Spectral',serif;text-transform:none;letter-spacing:0;}
  #setupOverlay #setupCancel{flex:0 0 auto;}
  #setupOverlay #setupGo{flex:1;min-width:0;}
  #setupOverlay .ms-footer #setupNote{font:13px/1.35 'Spectral',serif;max-height:20dvh;overflow:auto;}
  #setupOverlay .ms-footer #setupNote:empty{display:none;}
}

/* Completed games kept an obsolete hand above a short result sheet, and
   Close scrolled out of sight. Reserve the sheet for results, with its
   existing actions outside the scrolling content. Desktop remains unchanged. */
@media (max-width:640px), ((max-height:640px) and (pointer:coarse)){
  body.mobile-play.mp-finished .hand{display:none !important;}
  body.mobile-play.mp-finished .game-panel{max-height:calc(var(--mp-height,100dvh) * .72);}
  body.mobile-play.mp-finished .gp-body{display:flex;flex-direction:column;overflow:hidden;flex:0 1 auto;min-height:0;}
  body.mobile-play.mp-finished .gp-final{display:flex;flex-direction:column;overflow:hidden;min-height:0;}
  body.mobile-play .mp-result-content{overflow:auto;overscroll-behavior:contain;min-height:0;}
  body.mobile-play .mp-result-actions{display:flex;flex-shrink:0;gap:8px;padding-top:8px;background:var(--ui-panel);}
  body.mobile-play .mp-result-actions .gp-go{display:flex;align-items:center;justify-content:center;align-self:stretch;flex:1;min-width:0;min-height:44px;margin:0;white-space:normal;}
}
