/* Shared responsive layout and office chrome (formerly in match-night.css).
   Keep these broad breakpoints before the phone-specific refinements. */
@media (max-width:1100px){
 .s-profile{grid-template-columns:1fr 1fr;grid-template-areas:"head head" "atts train" "record record";grid-template-rows:auto auto auto;height:auto}
}
@media (max-width:900px){
 #app{height:calc(100dvh - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto minmax(0,1fr) auto;grid-template-areas:"top" "nav" "view" "tick"}
 .top{display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:6px;padding:6px 8px}
 .logo{font-size:clamp(22px,6vw,30px)}
 .histnav .btn{min-width:32px;min-height:40px;padding:2px 4px}
 .readouts{grid-column:1/-1;grid-row:2;display:grid;grid-template-columns:repeat(4,minmax(0,1fr));margin:0}
 .ro{min-width:0;padding:3px 5px}.ro small{font-size:14px}.ro b{font-size:19px}
 .tbar .note{display:none}
 #continue{min-width:110px;min-height:44px;padding:4px 8px;font-size:22px}
 #continue small{font-size:14px}
 .nav{flex-direction:row;align-items:center;margin:6px 8px 0;padding:3px;overflow-x:auto;gap:4px}
 .nav h4{display:none}
 .nav .item{width:auto;min-height:40px;white-space:nowrap;flex:none}
 #view{overflow:auto;padding:8px;scroll-padding:8px}
 #view .screen{align-content:start}
 #view .wbody:has(> .grid),#view .well:has(> .grid){overflow-x:auto}
 #view .matchup{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr)}
 #view .matchup select{max-width:100%}
 .screen{height:auto;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:none!important;grid-template-areas:none!important}
 .screen>*{grid-area:auto!important}
 .wbody{overflow:visible}
 .wbody.tight,.wbody.flush{overflow-x:auto}
 .phead .wbody{grid-template-columns:auto 1fr}
 .phead .acts{grid-column:1/-1;flex-direction:row;flex-wrap:wrap}
 .phead .name{font-size:40px}
 .portrait.x3{width:96px;height:120px}
 .criteria{grid-template-columns:1fr}
 .tier{grid-template-columns:1fr}.tier>strong{text-align:left}
 .tick .keys{display:none}
 #toast{left:12px;right:12px;bottom:56px}
}
@media (max-width:600px){
 .free-table{display:none}
 .free-cards{display:grid;gap:8px}
 .free-sort{display:flex;align-items:end;flex-wrap:wrap;gap:8px}
 .free-sort .btn{min-height:36px}
 .free-card{display:grid;gap:8px;padding:8px 10px;border:2px solid var(--ink);background:var(--well);color:var(--white);text-align:left}
 .free-card[aria-pressed="true"]{border-color:var(--gold);background:var(--well-hover)}
 .free-card .who b{color:var(--gold)}
 .free-stats{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;text-align:center}
 .free-stats>span{padding:2px;background:var(--deep)}
 .free-stats small,.free-costs small{display:block;font-size:15px;color:var(--dim)}
 .free-costs{display:flex;gap:18px}
}

/* Phone interface */
.phone-only,.phone-tabs,.phone-sections{display:none}

@media (max-width:720px){
 #app{
  grid-template-areas:"top" "sections" "view" "phone";
  grid-template-rows:auto auto minmax(0,1fr) auto;
  background:#141e48;
 }
 #app,#tv{font:16px/1.42 'Atkinson Hyperlegible Next',system-ui,sans-serif}
 #app .nav,#app .tick{display:none}
 #app .top{
  display:grid;grid-template-columns:auto minmax(0,1fr) auto;
  gap:6px 8px;padding:7px 12px;background:var(--phone-chrome);box-shadow:none;
 }
 .top .histnav{grid-column:1;grid-row:1}
 .top .histnav [data-hist="fwd"]{display:none}
 .top .histnav .btn{min-width:40px;min-height:40px;font-size:18px}
 .top .logo{grid-column:2;grid-row:1;font-size:clamp(22px,6.8vw,32px);letter-spacing:0}
 .top #continue{grid-column:3;grid-row:1;padding:3px 8px;min-width:106px;min-height:40px;font-size:22px}
 .top #continue small{font:13px/1.15 'Atkinson Hyperlegible Next',system-ui,sans-serif}
 /* One compact full-width identity row; the career readouts stay together. */
 #headerIdentity{grid-row:2;grid-column:1/-1;max-width:none}
 #headerIdentity .player-identity-card{gap:7px;padding:2px 5px}
 #headerIdentity .player-identity-card>.portrait{width:32px;height:40px;flex-basis:32px}
 #headerIdentity .player-identity-text>b{font:700 15px/1.15 'Atkinson Hyperlegible Next',system-ui,sans-serif}
 #headerIdentity .player-identity-text>span{font-size:13px}
 #headerIdentity .btn{min-height:44px;padding:3px 7px;font-size:13px}
 /* Phone header: keep all four career readouts in one compact row. */
 .top .readouts{
  grid-row:3;grid-column:1/-1;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;
  background:none;border:none;
 }
 .top .ro{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:1px;min-width:0;background:#1a2855;padding:3px 6px}
 .top .ro small{font-size:13px;line-height:1.2}
 .top .ro small::after{content:none}
 .top .ro b{font:700 14px/1.2 'Atkinson Hyperlegible Next',system-ui,sans-serif;letter-spacing:0;overflow-wrap:anywhere;text-align:right;min-width:0}
 .phone-tabs,.phone-sections{display:grid;gap:3px;background:var(--phone-chrome)}
 .phone-sections{
  grid-area:sections;grid-auto-flow:column;grid-auto-columns:minmax(max-content,1fr);
  overflow-x:auto;padding:5px 10px;border-bottom:1px solid #384673;
 }
 .phone-sections:empty{display:none}
 .phone-tabs{grid-area:phone;grid-template-columns:repeat(5,minmax(0,1fr));padding:5px 7px;border-top:2px solid #44517b}
 .phone-tab{
  min-width:0;min-height:48px;border:1px solid transparent;background:none;
  padding:4px 5px;color:var(--white);font-weight:700;font-size:13px;
 }
 .phone-tab[aria-current="true"]{background:var(--gold);color:var(--ink);border-color:var(--ink);box-shadow:var(--bevel)}
 .phone-sections .phone-tab{min-height:44px;white-space:nowrap;background:#202d59}
 .phone-sections .phone-tab[aria-current="page"]{background:#3b4b79;border-color:var(--gold);color:#ffe08a}
 .phone-badge{display:inline-block;margin-left:3px;padding:0 4px;background:var(--blood);color:#fff;font-size:13px}
 #view{padding:12px;scroll-padding:10px;overscroll-behavior:contain}
 #view .screen{gap:12px}
 #view .win,#tv .win{box-shadow:2px 3px 0 rgba(0,0,0,.35)}
 #view .tbar{min-height:40px;padding:4px 9px;gap:6px;flex-wrap:wrap}
 #view .tbar .btn{min-height:44px}
 /* Comfortable thumb targets for every in-view button, including the small ones. */
 #view .btn,#view .btn.sm{min-height:44px}
 .top .histnav .btn{min-width:44px;min-height:44px}
 #view .wbody{padding:10px}
 #view .facts{grid-template-columns:repeat(2,minmax(0,1fr))}
 #view .facts b{font-size:24px}
 #view .tray li{grid-template-columns:28px minmax(0,1fr) auto}
 #view .tray .ic{width:24px}
 #view .tray b{font-weight:700}
 #view .tray small{font-size:14px}
 #view .phone-pair.phone-detail>.phone-master,
 #view .phone-pair.phone-detail>.phone-overview,
 #view .phone-pair:not(.phone-detail)>.phone-inspector,
 #view .phone-table{display:none}
 #view .phone-overview{order:2}
 #view .phone-only{display:block}
 #view .phone-card-list{display:grid;gap:7px}
 #view .phone-card{
  width:100%;min-height:51px;display:grid;gap:4px;text-align:left;
  padding:9px 11px;background:var(--well);color:var(--white);
  border:2px solid var(--ink);border-left:4px solid var(--phone-edge);
 }
 #view .phone-card.unbookable{color:var(--dim);border-left-color:var(--well-line);border-style:dashed solid dashed dashed}
 #view .phone-card:hover,#view .phone-card:focus-visible{border-left-color:var(--gold);background:var(--well-hover)}
 #view .phone-card b{font-weight:700;color:var(--gold)}
 #view .phone-card small,#view .phone-card-meta{font-size:13px;color:var(--dim)}
 .phone-card-line{display:flex;align-items:center;flex-wrap:wrap;justify-content:space-between;gap:4px 10px}
 .phone-card .who{min-width:0}
 #view .free-table{display:none}
 #view .free-filters{margin-bottom:8px}
 #view .free-filters>summary{display:flex;align-items:center;min-height:44px;padding:8px 10px;background:var(--stone-2);border:2px solid var(--ink);font-weight:700;cursor:pointer;list-style:none}
 #view .free-filters>summary::-webkit-details-marker{display:none}
 #view .free-filters>summary::after{content:"▾";margin-left:auto;padding-left:8px}
 #view .free-filters[open]>summary::after{content:"▴"}
 #view .free-filters>summary:focus-visible{outline:3px dashed var(--ink);outline-offset:2px}
 #view .free-cards{display:grid;gap:7px}
 #view .free-cards .free-card{border-left:4px solid var(--phone-edge)}
 #view .free-cards .free-card:hover,#view .free-cards .free-card:focus-visible{border-left-color:var(--gold)}
 #view .free-stats small,#view .free-costs small{font-size:13px}
 #view .free-costs{gap:20px}
 #view .free-sort .field{flex:1;min-width:130px}
 .phone-progress{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1px;margin-bottom:12px;background:var(--well-line);
 }
 .phone-progress div{background:var(--well);padding:8px 10px;color:var(--white)}
 .phone-progress small{display:block;color:var(--dim);font-size:13px}
 .phone-progress b{font-weight:700;color:var(--gold)}
 #view .s-desk .desk-actions{order:-1}
 #view .s-desk .desk-actions .wbody{padding:8px}
 #view .msglist button{min-height:46px}
 #view .letter{padding:12px}
 #view .letter h2{font-size:28px}
 #view .choice,#tv .choice{min-height:46px}
 #view .grid th,#view .grid td{font-size:14px}
 #view .grid td.wrap{white-space:normal}
 #view .phead .name{font-size:32px}
 #view .phead .portrait.x3{width:68px;height:85px}
 #view .tier .entries{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
 #view .tier .pent{min-width:0;overflow-wrap:anywhere}
 #toast{bottom:calc(58px + env(safe-area-inset-bottom,0px))}
 dialog{max-width:calc(100vw - 20px);max-height:calc(100dvh - 24px)}
 dialog .talk-actions .choice,dialog .btn{min-height:42px}
 #tv .strip{
  padding:6px 12px;font:700 14px/1.2 'Atkinson Hyperlegible Next',system-ui,sans-serif;
  gap:4px 10px;
 }
 #tv .strip .r{margin-left:auto}
 #tv .stage{padding:10px;gap:8px}
 #tv .s-back .wbody{overflow:visible;padding:0}
 #tv .s-back .match-night-matchup{padding:7px 10px;font-size:13px}
 #tv .s-back .match-night-matchup .mid .fin{font-size:20px}
 #tv .s-back .match-night-matchup .mu b{font-size:19px}
 #tv .s-back .scene{min-height:0;max-height:180px;padding:8px 10px;overscroll-behavior:contain}
 #tv .s-back .bub{font-size:14px}
 #tv .s-back .bub .portrait{width:27px;height:34px}
 #tv .s-back .decide2{max-height:none;padding:9px 10px}
 #tv .s-back .picks.five{grid-template-columns:minmax(0,1fr)}
 #tv .s-back .decision-option{min-height:48px}
 #tv .s-back .decision-option>span{font-size:14px}
 #tv .s-back .tags i{font-size:13px}
 #tv .s-back .section-h{font-size:24px}
 #tv .tv-foot{padding:8px 10px}
 #tv:has(.s-back) .tv-foot:not(:has(button)){display:none}
 #tv .score{padding:5px 9px;grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
 #tv .score .mid{display:flex;align-items:center;justify-content:center;gap:8px;padding:3px}
 #tv .score .live-stars{font-size:23px;min-height:0}
 #tv .score .clock{font-size:21px}
 #tv .score .phase{font-size:15px}
 #tv .score .side{gap:3px 6px}
 #tv .score .side h2{font-size:22px}
 #tv .score .portrait{width:30px;height:38px}
 #tv .score .stam{height:8px}
 #tv .s-live .now{padding:8px 10px;min-height:72px;gap:7px;font-size:24px}
 #tv .s-live .now .spk-pf{width:36px;height:45px}
 #tv .s-live .past{max-height:8.5rem;padding:4px 9px;font-size:18px}
 #tv .s-live .call{font-size:14px;min-height:43px;justify-content:center;padding:3px}
 #tv .s-live .call kbd{display:none}
 #tv .s-live .calls{grid-template-columns:repeat(3,minmax(0,1fr));gap:3px}
 #tv .s-live .speed .btn{min-height:38px;font-size:13px;white-space:normal}
 #tv .s-live .gauge{margin-bottom:4px}
 #tv .s-live .callhint{min-height:0;font-size:16px;margin:4px 0}
 /* Calls are the only live decision: on phones they come first in the Ringside panel,
    ahead of the agreed-plan summary, so they are on screen while commentary runs. */
 #tv .s-live .wbody:has(> .ringside-command){display:flex;flex-direction:column}
 #tv .s-live .wbody>.ringside-command{order:-1}
 #tv .s-live .wbody>.ringside-plan{order:1;margin-top:8px}
 #tv .decision{padding:8px}
 #tv .decision .win{max-height:calc(100dvh - 16px)}
 #tv .decision .wbody{overflow:auto}
}
@media (max-width:720px) and (max-height:760px){
 #tv .s-live .past{max-height:4.5rem}
 #tv .s-live .now{min-height:60px}
 #tv .s-live .section-h{margin:5px 0}
 #tv .s-live .wbody{padding:6px}
}


/* Phase 4: small-screen management controls with predictable scanning order. */
@media(max-width:720px){
 #view .management-filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:end;gap:8px}
 #view .management-filters label,#view .management-filters label:first-child{min-width:0;min-height:0}
 #view .management-filters label:first-child{grid-column:1/-1}
 #view .management-filters .filter-results{min-width:0;overflow-wrap:anywhere}
 #view .management-filters .btn{min-width:0;margin:0;white-space:normal}
 #view .office-filter-tabs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
 #view .office-filter-tabs .btn{min-width:0;min-height:44px;justify-content:space-between;gap:6px}
 #view .desk-brief>div,#view .phone-card .who>span{min-width:0}
 #view .desk-brief b,#view .desk-brief span,#view .phone-card{overflow-wrap:anywhere}
 #view .facts b,#tv .facts b{overflow-wrap:anywhere}
 #view .phone-card .record-link{display:inline-block;min-height:36px;line-height:27px;padding:4px 1px}
 #view .phone-card .record-link:focus-visible{outline-color:var(--gold)}
}
/* Shorter phones: keep section selection and filter controls usable without
   shrinking them into tiny buttons. The page itself remains the only scroller. */
@media(max-width:390px){
 #view{padding:8px}
 #view .screen{gap:8px}
 #view .management-filters{padding:7px;gap:6px}
 #view .office-filter-tabs{padding:5px}
 #view .free-stats{gap:2px}
 #view .free-card{padding:7px}
}
