/* Keep each table's sticky heading at the start of its own scroll surface. */
body.kzs-design #recordsWrap .tbl-scroll{overflow:auto;max-height:70dvh;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;isolation:isolate}
body.kzs-design #recordsWrap .tbl-scroll>table{min-width:760px}
body.kzs-design #recordsWrap .tbl-scroll>table th:nth-child(2),body.kzs-design #recordsWrap .tbl-scroll>table td:nth-child(2){min-width:190px}
body.kzs-design #recordsWrap thead th{position:sticky;top:0!important;z-index:2;background:var(--wh)}
.roster-jersey{display:inline-block;margin-left:6px;padding:1px 4px;border-radius:4px;background:var(--bg);color:var(--mu);font:600 10px/1.5 Inter,system-ui,sans-serif;vertical-align:middle;white-space:nowrap}
.roster-jersey[hidden]{display:none!important}
.team-header-actions{display:flex;align-items:center;flex-shrink:0}
#teamModal .modal-tab-panel.active,#playerTabGames,.match-body{overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch}
#teamModalBg,#modalBg,#matchModalBg,#noteModalBg{overscroll-behavior:contain}
html.kzs-modal-locked{overflow:hidden;overscroll-behavior:none}
#teamModal .roster-table tr[role=button]:focus-visible{outline:2px solid var(--or);outline-offset:-2px}

@media(max-width:700px),(max-width:1000px) and (pointer:coarse){
  /* The keyboard changes the visual viewport without always changing 100vh. */
  body #teamModalBg,body #modalBg,body #matchModalBg,body #noteModalBg{top:var(--kzs-visual-top,0px);bottom:auto;height:var(--kzs-visual-height,100dvh);padding:8px 0 0!important;align-items:flex-end;overflow:hidden;box-sizing:border-box}
  body #teamModal,body #playerModal{width:100%;max-width:100%;height:100%;max-height:100%;min-height:0;border-radius:16px 16px 0 0;display:flex;flex-direction:column;overflow:hidden;box-sizing:border-box}
  body #teamModalHdr{display:grid;grid-template-columns:42px minmax(0,1fr) 36px;gap:6px 10px;padding:12px!important;align-items:start}
  #teamModalHdr>.modal-av,#teamModalHdr>.modal-av-fb{grid-column:1;grid-row:1/3;width:42px;height:42px;font-size:14px;border-width:2px}
  #teamModalHdr .team-header-title{grid-column:2;grid-row:1;min-width:0}
  #teamModalHdr .modal-name{font-size:22px;line-height:1.1;overflow-wrap:anywhere}
  #teamModalHdr .modal-name>span{font-size:13px!important;white-space:nowrap}
  #teamModalHdr .modal-sub{font-size:10px;margin-top:4px}
  #teamModalHdr .team-header-actions{grid-column:2/4;grid-row:2;gap:7px;flex-wrap:wrap}
  body #teamModalHdr .team-header-actions button{min-height:30px;height:30px;margin:0!important;padding:0 10px!important;font-size:11px!important;border-radius:7px!important}
  body #teamModalHdr>.modal-close{position:static;grid-column:3;grid-row:1;min-width:36px;min-height:36px;width:36px;height:36px;font-size:16px}
  body #teamModal .team-modal-filters{display:grid!important;grid-template-columns:minmax(0,1fr) minmax(0,1.8fr);gap:4px 10px!important;padding:8px 12px!important;align-items:center}
  #teamModal .team-modal-filters label{font-size:9px!important;margin:0!important;grid-row:1}
  #teamModal .team-modal-filters label:nth-of-type(2){grid-column:2}
  #teamModal .team-modal-filters select{grid-row:2;width:100%;min-width:0!important;max-width:100%;min-height:36px;height:36px!important;font-size:16px!important;padding:0 24px 0 8px!important;appearance:none;-webkit-appearance:none;background-color:var(--nv2)!important;color:#fff!important;-webkit-text-fill-color:#fff;background-image:linear-gradient(45deg,transparent 50%,#fff 50%),linear-gradient(135deg,#fff 50%,transparent 50%);background-position:calc(100% - 13px) 15px,calc(100% - 9px) 15px;background-size:4px 4px;background-repeat:no-repeat}
  #teamCompFilter{grid-column:2}
  body #teamModalStats{grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:1px}
  #teamModalStats .mstat{min-width:0;padding:7px 3px}
  #teamModalStats .mstat-n{font-size:18px;line-height:1.2}
  #teamModalStats .mstat-l{font-size:8px;line-height:1.25;letter-spacing:0;margin-top:3px;overflow-wrap:anywhere}
  #teamModalStats #teamBestScorer{grid-column:1/-1;display:flex;align-items:center;justify-content:center;flex-direction:row-reverse;gap:7px;padding:5px 8px}
  #teamModalStats #teamBestScorer .mstat-n{font-size:11px!important}
  #teamModalStats #teamBestScorer .mstat-l{margin:0;font-size:8px}
  body #teamModal .modal-tabs .modal-tab{min-height:36px;padding:8px;font-size:12px}
  #teamModal .modal-tab-panel.active{flex:1 1 0;min-height:0;overflow-y:auto;overflow-x:hidden;touch-action:pan-y}
  #teamModalBody,#teamGamesBody{padding:0 10px 14px!important}
  #teamModalBody .roster-table{width:100%;table-layout:auto}
  #teamModalBody .roster-table thead th{padding:8px 5px;top:0!important;font-size:9px}
  #teamModalBody .roster-table td{padding:8px 5px}
  #teamModalBody .roster-table td:first-child{width:22px!important;font-size:10px!important}
  #teamModalBody .roster-table .pn{font-size:12px;line-height:1.35;overflow-wrap:anywhere}
  #teamModalBody .roster-table .pm{font-size:10px}
  #teamModalBody .roster-table .av,#teamModalBody .roster-table .av-fb{width:28px!important;height:30px!important;flex:0 0 28px}
  #teamModalBody .roster-table .roster-jersey{font-size:9px;margin-left:4px}
  /* Replace the conflicting mobile flex widths with a contained two-column grid. */
  body.kzs-design .view-panel>.fbar{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px!important;padding:12px!important;overflow:visible!important;align-items:end!important}
  body.kzs-design .view-panel>.fbar>.fg,body.kzs-design .view-panel>.fbar>.fg:first-child,body.kzs-design .view-panel>.fbar>.fg:has(.sort-ps){width:auto!important;min-width:0!important;max-width:100%;flex:none!important;grid-column:auto}
  body.kzs-design #panel-scorers>.fbar>.fg:first-child,body.kzs-design #panel-scorers>.fbar>.fg:has(.sort-ps){grid-column:1/-1}
  body.kzs-design .fbar .fg label{font-size:9px;letter-spacing:.06em}
  body.kzs-design .fbar input,body.kzs-design .fbar select,body.kzs-design .fbar #fYearBtn{width:100%;min-width:0!important;max-width:100%;box-sizing:border-box;font-size:16px!important;height:42px!important;min-height:42px!important}
  body.kzs-design .fbar .srch{width:100%;min-width:0}
  body.kzs-design .fbar .srch input{padding-left:32px}
  body.kzs-design .fbar .sort-ps{max-width:100%;min-width:0;display:flex;flex-wrap:wrap;gap:4px}
  body.kzs-design .fbar .sort-ps button{flex:1;min-width:0;font-size:11px;min-height:34px;padding:8px 5px}
  body.kzs-design .fbar>.reset-btn{justify-self:end;grid-column:2;min-height:34px;font-size:11px;padding:7px 10px}
  body.kzs-design #panel-scorers>.kzs-season-note{padding:8px 10px;font-size:11px;line-height:1.5;margin-bottom:10px}
  body.kzs-design #recordsWrap .tbl-scroll{max-height:65dvh}
  /* Native iOS focus zoom is avoided by keeping every editable control at 16px. */
  body #noteModalBg #noteModal{display:flex;flex-direction:column;width:100%!important;max-width:100%!important;max-height:100%!important;min-height:0;overflow:hidden!important;border-radius:16px 16px 0 0!important;box-sizing:border-box}
  #noteModal .kzs-note-header{flex:0 0 auto;padding:8px 12px 10px!important}
  #noteModal .kzs-note-header .mob-handle{margin-bottom:6px!important}
  #noteModal #noteModalName{font-size:21px!important;min-width:0;overflow-wrap:anywhere}
  #noteModal .kzs-note-header button{flex:0 0 32px;min-width:32px;min-height:32px}
  body #noteModalBg #noteModal>.kzs-note-form{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding:12px!important}
  #noteModal .kzs-note-form>label{font-size:10px!important;letter-spacing:.03em!important;margin-bottom:5px!important}
  body #noteModalBg #noteModalText,body #noteModalBg #noteModalTags{font-size:16px!important;max-width:100%;min-width:0;box-sizing:border-box}
  body #noteModalBg #noteModalText{display:block;min-height:80px;height:clamp(80px,calc(var(--kzs-visual-height,100dvh) * .25),170px);max-height:calc(var(--kzs-visual-height,100dvh) * .45);padding:10px;line-height:1.5;resize:vertical}
  body #noteModalBg #noteModalTags{height:42px}
  #noteModal .kzs-note-actions{position:sticky;bottom:-12px;display:flex;gap:8px;flex-shrink:0;background:var(--wh);margin:10px -1px -1px!important;padding:9px 0 calc(5px + env(safe-area-inset-bottom,0px));z-index:2}
  #noteModal .kzs-note-actions button{flex:1;min-width:0;min-height:42px;padding:8px!important;font-size:14px!important;white-space:normal}
  #noteModal #hubNotebookObservations{padding:12px 0!important;margin-top:14px}
}

@media(max-width:700px),(max-width:1000px) and (pointer:coarse){
  /* Override the inline inset:0: iOS may pan the visual viewport above its keyboard. */
  body #noteModalBg{top:var(--kzs-visual-top,0px)!important;bottom:auto!important;height:var(--kzs-visual-height,100dvh)!important;max-height:var(--kzs-visual-height,100dvh)!important}
}
