/* Phone presentation only. Shared by the three research apps; no data, gates,
   scroll-row limits, calculations or desktop metrics are changed here. */
@media (max-width:600px) {
  body:is([data-sp-ui=mlb],[data-sp-ui=nfl],[data-sp-ui=nba]) :is(main,header,nav).ct,
  body:is([data-sp-ui=mlb],[data-sp-ui=nfl],[data-sp-ui=nba]) :is(header,nav)>.ct {
    min-width:0;max-width:100%;
  }
  /* Brand and account share a compact row. Additional admin tools wrap as a
     group; account menus retain their own containing block and click handler. */
  body[data-sp-ui] .sp-app-header {position:relative;top:auto}
  body[data-sp-ui] .sp-app-header>.ct {
    display:flex;flex-direction:row;align-items:center;gap:6px;
    padding:8px!important;
  }
  body[data-sp-ui] .sp-brand {padding-left:0!important;flex:none}
  body[data-sp-ui] .sp-brand .header-title {
    font-size:1.15rem!important;white-space:nowrap;line-height:1.2;
  }
  body[data-sp-ui] .sp-header-actions {
    width:auto;min-width:0;max-width:100%;flex:1 1 auto;
    justify-content:flex-end;gap:6px;flex-wrap:wrap;
  }
  body[data-sp-ui] .sp-header-actions>.flex {gap:6px;flex-wrap:wrap;justify-content:flex-end;min-width:0}
  body[data-sp-ui] .sp-header-actions .user-menu-btn {
    display:flex;align-items:center;min-height:40px;font:500 12px/1.3 'DM Sans',sans-serif;
    max-width:150px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  }
  body[data-sp-ui] .sp-header-actions :is(.btn,a.btn) {
    min-width:40px;min-height:40px;padding:5px 8px!important;white-space:nowrap;font-size:12px!important;
  }
  body[data-sp-ui] .user-dropdown {max-width:calc(100vw - 16px);right:0}
  body[data-sp-ui] .user-dropdown :is(a,button) {min-height:44px;display:flex;align-items:center}
  /* Keep the existing horizontal navigation, but make every destination readable. */
  body[data-sp-ui] .sp-app-nav>.ct {padding:4px 0!important;gap:0!important;flex-wrap:nowrap}
  body[data-sp-ui] .sp-app-nav .sp-nav-tabs {
    display:flex;flex:1 1 auto;width:100%;min-width:0;gap:4px!important;
    padding:2px 8px!important;overflow-x:auto;scrollbar-width:thin;
  }
  body[data-sp-ui] .sp-app-nav :is(.sp-nav-tabs>button,.nav-menu-wrap>button,.research-menu-wrap>button) {
    display:flex;flex-direction:column;justify-content:center;gap:2px;
    min-height:46px;height:auto;min-width:58px;flex-shrink:0;
    padding:5px 8px!important;white-space:nowrap;font-size:13px!important;line-height:1.1;
  }
  body[data-sp-ui] .sp-app-nav :is(.hd-mobile,.nfl-nav-label) {
    display:inline!important;font-family:'DM Sans',sans-serif;font-size:11px;line-height:1.2;
  }
  body[data-sp-ui] .sp-app-nav .sp-nav-rail {display:none}
  body[data-sp-ui] :is(.nav-dropdown,.research-dropdown) {max-height:70dvh;overflow-y:auto}
  body[data-sp-ui] :is(.nav-dropdown,.research-dropdown) button {min-height:44px}
  /* Keep scrolling local to each wide data table and preserve its columns. */
  body[data-sp-ui] .sp-app-main {padding:12px 8px 20px!important;min-width:0;max-width:100%}
  body[data-sp-ui] .sp-app-main :is(.fc,.mgrid2,.mgrid3,.gl,.gc,.ox) {min-width:0}
  body[data-sp-ui] .sp-app-main :is(.mgrid2,.mgrid3) {grid-template-columns:minmax(0,1fr)}
  body[data-sp-ui] .sp-app-main .ox {max-width:100%;overscroll-behavior-x:contain}
  body[data-sp-ui] .sp-app-main :is(.flex,.fc) > :is(.fc,.gl,.gc,.ox) {min-width:0;max-width:100%}
  body[data-sp-ui] .sp-app-main :is(.flex,.fc):has(> .sp-page-title) {flex-wrap:wrap;gap:8px}
  body[data-sp-ui] .sp-app-main .sp-page-title {line-height:1.2!important;margin-bottom:0}
  body[data-sp-ui] .sp-app-main :is(.btn,.toggle-btn) {min-height:40px;white-space:normal;line-height:1.25}
  body[data-sp-ui] .sp-app-main :is(select,input[type=text],input[type=password],input[type=email]) {
    max-width:100%;font-size:16px!important;min-height:40px;
  }
  body[data-sp-ui] .sp-app-main td input[type=number] {
    padding:4px 3px!important;font-size:16px!important;min-height:36px;
  }
  /* Slate controls are one unit. Long slate names fit the select, not the page. */
  body[data-sp-ui] :is(.mlb-page-slate-controls,.nfl-page-slate-controls) {
    width:100%;max-width:100%;margin-left:0!important;gap:6px!important;flex-wrap:nowrap!important;
  }
  body[data-sp-ui] :is(.mlb-page-slate-controls,.nfl-page-slate-controls)>:has(select) {flex:1;min-width:0}
  body[data-sp-ui] :is(.mlb-page-slate-controls,.nfl-page-slate-controls) select {width:100%!important;min-width:0;max-width:100%!important}
  body[data-sp-ui] :is(.mlb-page-slate-controls,.nfl-page-slate-controls) .nav-toggle {flex:none}
  /* One consistent rhythm: heading/help, model order, browse filters, file actions. */
  body[data-sp-ui] :is(.mlb-lineups-controls,.nfl-lineups-controls) {gap:6px;padding:0;align-items:center}
  body[data-sp-ui] :is(.mlb-lineups-controls,.nfl-lineups-controls)>h2 {flex:1;margin:0!important}
  body[data-sp-ui] :is(.mlb-lineups-controls,.nfl-lineups-controls) :is(button,a.btn,label.btn) {
    min-height:40px;padding:6px 8px!important;font-size:12px!important;
  }
  body[data-sp-ui] :is(.sp-lineup-lanes,.nfl-browse-lanes) {
    flex:1 0 100%;display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:3px!important;
    padding:3px!important;
  }
  body[data-sp-ui] :is(.sp-lineup-lanes,.nfl-browse-lanes)>button {min-width:0;white-space:normal!important;padding:5px 3px!important;line-height:1.15!important}
  body[data-sp-ui] :is(.sp-lineup-stacks,.nfl-lu-stacks) {flex-basis:100%;padding:6px 0;border-block:1px solid var(--sp-line);gap:4px!important}
  body[data-sp-ui] :is(.sp-lineup-stacks,.nfl-lu-stacks) select {min-width:0;flex:1;max-width:100%!important;font-size:14px!important;padding:4px!important;min-height:40px}
  body[data-sp-ui] .sp-toolbar-divider {display:none}
  body[data-sp-ui] :is(.sp-lineup-quick,.nfl-lu-show) {min-width:0}
  body[data-sp-ui] .sp-lineup-quick>div {left:0!important;right:auto!important;max-width:calc(100vw - 16px)}
  body[data-sp-ui] .sp-lineup-quick>div [style*="cursor: pointer"] {min-height:40px;display:flex;align-items:center}
  body[data-sp-ui] :is(.mlb-pool-strip,.nfl-pool-summary) {gap:5px!important;padding:8px!important;line-height:1.4}
  body[data-sp-ui] .mlb-pool-strip>span {font-family:'DM Sans',sans-serif;font-size:12px;line-height:1.45;margin-left:0!important}
  body[data-sp-ui] :is(.mlb-pool-strip,.nfl-pool-summary)>span {overflow-wrap:anywhere;min-width:0}
  body[data-sp-ui] .sp-app-main :is([role=status],[role=alert]) {overflow-wrap:anywhere;max-width:100%}
  /* Dialog shells already own vertical scrolling. Cap only their phone geometry. */
  body[data-sp-ui] .sp-mobile-dialog {max-width:calc(100vw - 16px)!important;max-height:calc(100dvh - 16px)!important;overflow:auto!important;padding:14px!important}
  body[data-sp-ui] .sp-mobile-dialog :is(input,select,textarea) {max-width:100%;font-size:16px!important}
  body[data-sp-ui] .sp-mobile-dialog .btn {min-height:40px;white-space:normal}
  body[data-sp-ui] .sp-mobile-dialog>.flex {flex-wrap:wrap;gap:8px}

  /* Flatten only the existing header wrappers so the account can sit beside
     the brand and the admin tools occupy one row below it. */
  body[data-sp-ui] .sp-header-actions,
  body[data-sp-ui] .sp-header-actions>.flex {display:contents}
  body[data-sp-ui] .sp-brand {flex:1 1 calc(100% - 156px)}
  body[data-sp-ui] .sp-header-actions .user-menu-wrap {margin-left:auto;flex:0 1 150px}
  body[data-sp-ui] .sp-header-actions .user-menu-btn {justify-content:flex-end}
  body[data-sp-ui] .sp-app-header>.ct {justify-content:flex-start}
  body[data-sp-ui] .sp-file-action {flex:1 1 28%;justify-content:center}
  body[data-sp-ui] .sp-mobile-controls {min-width:0;max-width:100%;flex-wrap:wrap;gap:6px}
  body[data-sp-ui] .sp-mobile-controls select {min-width:0;flex:1;max-width:100%!important}
  /* Matrix keeps its fixed card height and every column. One shared set of
     widths for header/body prevents squeezed names and drifting headings. */
  body[data-sp-ui] .sp-matrix-card>div:last-child {overflow:auto!important}
  body[data-sp-ui] .sp-matrix-card>div:last-child>.flex {width:max-content;min-width:100%;flex-wrap:nowrap}
  body[data-sp-ui] .sp-matrix-card>div:last-child>.flex>:first-child {
    flex:0 0 160px!important;width:160px!important;max-width:none;
    white-space:normal!important;overflow:visible!important;line-height:1.25;
  }
  body[data-sp-ui] .sp-matrix-card>div:last-child>.flex>:not(:first-child) {flex-shrink:0}

  body[data-sp-ui] .sp-app-header>.ct {gap:6px!important}
  body[data-sp-ui] .mlb-lineups-controls>input[type=number] {width:72px!important;padding:4px!important;min-height:40px}
  body[data-sp-ui] .nfl-pool-strip {flex-wrap:wrap;overflow:visible;gap:6px;padding:8px}
  body[data-sp-ui] .nfl-pool-summary {flex:1 0 100%;min-width:0;flex-wrap:wrap;white-space:normal;padding:0!important;font-size:12px}
  body[data-sp-ui] .nfl-pool-summary>span {overflow:visible;text-overflow:clip;white-space:normal}
  body[data-sp-ui] .nfl-pool-sort {display:block;flex-basis:100%}
  body[data-sp-ui] .nfl-pool-strip .nfl-page-slate-controls {flex:1 1 100%;width:100%}

  body[data-sp-ui] .toast {
    width:max-content;max-width:calc(100vw - 24px);max-height:40dvh;overflow:auto;
    padding:10px 12px;font:500 13px/1.45 'DM Sans',sans-serif;text-align:left;overflow-wrap:anywhere;
  }
  body[data-sp-ui] .toast button {min-width:40px;min-height:40px}
  body[data-sp-ui] :is(.sp-lineup-stacks,.nfl-lu-stacks) select {font-size:16px!important}
}

/* Uniform NFL/MLB phone navigation, including dropdown and locked tabs. */
@media (max-width:600px) {
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs {align-items:center}
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs>.nav-menu-wrap {flex:0 0 88px}
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs>button,
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs>.nav-menu-wrap>button {
    position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;
    box-sizing:border-box;flex:0 0 88px;width:88px;min-width:88px;max-width:88px;
    height:54px;min-height:54px;max-height:54px;padding:5px 3px!important;gap:3px;
  }
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs :is(.nfl-nav-icon,.sp-nav-icon) {
    display:block;font-size:18px;line-height:20px;height:20px;
    /* 9/25 (Chris: off-center tab emojis): the desktop rule fixes .nfl-nav-icon at 17px, so the 18px
       glyph (about 22px wide) overflowed right. Size the box to the glyph so the column centers it. */
    width:auto;min-width:0;text-align:center;
  }
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs :is(.nfl-nav-label,.hd-mobile) {
    display:block!important;font:500 11px/14px 'DM Sans',sans-serif;height:14px;white-space:nowrap;
  }
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-nav .sp-nav-tabs :is(button[aria-haspopup=menu]>span:last-child,.sp-nav-badge) {
    position:absolute;right:5px;top:4px;font-size:10px;line-height:12px;
  }
  /* NBA phone tabs: icon and label centered over each other; the lock and the Research caret
     move to the corner, as on NFL/MLB. Tab widths stay content-sized (unchanged). */
  body[data-sp-ui=nba] .sp-app-nav .sp-nav-tabs :is(.sp-nav-tabs>button,.research-menu-wrap>button) {position:relative;align-items:center}
  body[data-sp-ui=nba] .sp-app-nav .sp-nav-tabs :is(.sp-nav-badge,.sp-nav-caret) {position:absolute;right:5px;top:4px;font-size:10px;line-height:12px}
  /* Members: brand above, account + Refresh/Home together below. Admins keep
     their existing fuller action row. Upgrade remains beside the brand. */
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-header:not(:has(.sp-stream-toggle))>.ct {row-gap:4px!important}
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-header:not(:has(.sp-stream-toggle)) .sp-brand {flex:1 0 100%}
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-header:not(:has(.sp-stream-toggle)):has(.bjoin) .sp-brand {flex:1 1 auto}
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-header:not(:has(.sp-stream-toggle)) .user-menu-wrap {
    order:2;flex:1 1 calc(100% - 92px);margin-left:0;
  }
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-header:not(:has(.sp-stream-toggle)) .user-menu-btn {
    justify-content:flex-start;max-width:100%;
  }
  body:is([data-sp-ui=nfl],[data-sp-ui=mlb]) .sp-app-header:not(:has(.sp-stream-toggle)) .sp-header-actions>.flex>.btn {order:3}
}
