/* ==========================================================
   v179.9.31 — PHASE 9 DESKTOP FOUNDATION
   Desktop-only structural adaptation of the frozen v179.9.30
   mobile scorebook. Theme tokens remain visual-only.
   Breakpoint begins above the existing compact-laptop rules so
   phone/tablet behavior is unchanged.
   ========================================================== */

@media (min-width:1101px){
  :root{
    --v179931-desktop-live-h:72px;
    --v179931-desktop-tabs-h:62px;
    --v179931-desktop-team-top:134px;
    --v179931-desktop-team-h:60px;
    --v179931-inspector-w:clamp(476px,36vw,520px);
  }

  /* ---------- Shared desktop canvas ---------- */
  body:not(.home-page) #main{
    width:100%!important;
    max-width:1580px!important;
    margin:0 auto!important;
    padding:18px 22px 48px!important;
  }
  body:not(.home-page) .mode-page-shell{
    width:100%!important;
    max-width:1536px!important;
    margin-left:auto!important;
    margin-right:auto!important;
  }

  /* Game information uses desktop width instead of retaining the
     mobile/tablet 3 × 2 tile matrix. */
  body:not(.home-page)[data-theme-family] #main .game-info.with-extras{
    grid-template-columns:repeat(6,minmax(0,1fr))!important;
  }
  body:not(.home-page)[data-theme-family] #main .game-info.with-extras .game-field{
    min-height:82px!important;
    height:82px!important;
    padding:10px 12px!important;
    border-right:1px solid var(--line)!important;
    border-bottom:0!important;
  }
  body:not(.home-page)[data-theme-family] #main .game-info.with-extras .game-field:last-child{
    border-right:0!important;
  }
  body:not(.home-page)[data-theme-family] #main .game-info.with-extras .game-field-copy label{
    font-size:8px!important;
  }
  body:not(.home-page)[data-theme-family] #main .game-info.with-extras .game-field-copy input,
  body:not(.home-page)[data-theme-family] #main .game-info.with-extras .game-field-copy textarea{
    font-size:14px!important;
  }

  /* Keep the matchup readable and intentional instead of stretching its
     controls across the full monitor. */
  body:not(.home-page) #main .matchup-selector{
    width:min(920px,100%)!important;
    margin:0 auto 12px!important;
    min-height:70px!important;
    padding:9px 14px!important;
    grid-template-columns:minmax(0,1fr) 70px minmax(0,1fr)!important;
  }
  body:not(.home-page) #main .matchup-team{
    grid-template-columns:52px minmax(0,1fr)!important;
    column-gap:10px!important;
  }
  body:not(.home-page) #main .matchup-team img{
    width:50px!important;
    height:50px!important;
    padding:3px!important;
  }
  body:not(.home-page) #main .matchup-team select{
    height:42px!important;
    font-size:13px!important;
  }
  body:not(.home-page) #main .versus-mark{font-size:13px!important;}

  /* ---------- Persistent desktop scorekeeping chrome ---------- */
  body:not(.home-page) #main .live-game-bar{
    position:sticky!important;
    top:0!important;
    z-index:104!important;
    min-height:var(--v179931-desktop-live-h)!important;
    height:var(--v179931-desktop-live-h)!important;
    margin-bottom:0!important;
    border-radius:18px 18px 0 0!important;
    box-shadow:0 7px 22px rgba(15,23,42,.13)!important;
  }
  body:not(.home-page) #main .mode-workspace-tabs{
    position:sticky!important;
    top:var(--v179931-desktop-live-h)!important;
    z-index:103!important;
    height:var(--v179931-desktop-tabs-h)!important;
    min-height:var(--v179931-desktop-tabs-h)!important;
    margin:0 0 14px!important;
    padding:5px!important;
    border-radius:0 0 16px 16px!important;
    box-shadow:0 6px 16px rgba(15,23,42,.10)!important;
  }
  body:not(.home-page) #main .mode-workspace-tabs button{
    min-height:50px!important;
    font-size:11px!important;
  }

  body:not(.home-page) #main .team-scorebook{
    overflow:visible!important;
    margin-bottom:18px!important;
    scroll-margin-top:calc(var(--v179931-desktop-team-top) + var(--v179931-desktop-team-h) + 12px)!important;
  }
  body:not(.home-page) #main .team-scorebook .team-scorebook-head{
    position:sticky!important;
    top:var(--v179931-desktop-team-top)!important;
    inset-block-start:var(--v179931-desktop-team-top)!important;
    z-index:102!important;
    min-height:var(--v179931-desktop-team-h)!important;
    height:var(--v179931-desktop-team-h)!important;
    padding:7px 16px!important;
    overflow:visible!important;
    border-radius:18px 18px 0 0!important;
    box-shadow:0 5px 14px rgba(15,23,42,.10)!important;
  }
  body:not(.home-page) #main .team-scorebook-body{
    overflow:hidden!important;
    border-radius:0 0 18px 18px!important;
  }
  body:not(.home-page) #main .team-scorebook-name{
    overflow:visible!important;
    gap:10px!important;
  }
  body:not(.home-page) #main .team-scorebook img.team-logo{
    width:46px!important;
    height:46px!important;
    flex:0 0 46px!important;
    max-width:46px!important;
    max-height:46px!important;
    padding:2px!important;
    object-fit:contain!important;
    overflow:visible!important;
  }
  body:not(.home-page) #main .team-header-name{
    font-size:14px!important;
    letter-spacing:.025em!important;
  }
  body:not(.home-page) #main .section-collapse{
    width:40px!important;
    height:40px!important;
    min-width:40px!important;
    min-height:40px!important;
    flex:0 0 40px!important;
  }

  /* The desktop table fits a regulation scorebook comfortably while still
     retaining horizontal overflow for narrower desktop windows / extras. */
  body:not(.home-page) #main .team-scorebook-scroll{
    overflow-x:auto!important;
    overflow-y:hidden!important;
    scrollbar-width:thin!important;
    scroll-snap-type:none!important;
    scroll-behavior:auto!important;
  }
  body:not(.home-page) #main .unified-score-table{
    --ord-w:32px;
    --player-w:190px;
    --pos-w:46px;
    --inning-w:62px;
    --stat-w:54px;
    --head1-h:36px;
    --head2-h:32px;
    --row-h:60px;
    --total-h:38px;
    width:100%!important;
    min-width:1282px!important;
  }
  body:not(.home-page) #main .unified-score-table .score-head-primary th{font-size:10px!important;}
  body:not(.home-page) #main .unified-score-table .score-head-secondary th{font-size:9px!important;}
  body:not(.home-page) #main .unified-score-table .sticky-lineup-banner{font-size:11px!important;}
  body:not(.home-page) #main .unified-score-table .player-main{font-size:12px!important;line-height:1.08!important;}
  body:not(.home-page) #main .unified-score-table .player-subs{font-size:9px!important;}
  body:not(.home-page) #main .unified-score-table .sticky-ord,
  body:not(.home-page) #main .unified-score-table .sticky-pos,
  body:not(.home-page) #main .unified-score-table .stat-cell{font-size:10px!important;}
  body:not(.home-page) #main .unified-score-table .batter-row{
    scroll-margin-top:calc(var(--v179931-desktop-team-top) + var(--v179931-desktop-team-h) + 12px)!important;
  }
  body:not(.home-page) #main .unified-score-table .play-code{font-size:11px!important;}
  body:not(.home-page) #main .unified-score-table .standalone-out{font-size:21px!important;}
  body:not(.home-page) #main .unified-score-table .rbi-code{font-size:8px!important;}

  /* Full-width desktop pitching. */
  body:not(.home-page) #main .team-scorebook-canvas>.pitch-pane .pitch-table,
  body:not(.home-page) #main .full-width-pitch .pitch-table{
    width:100%!important;
    min-width:1040px!important;
  }
  body:not(.home-page) #main .pitch-table .pitcher-name{width:320px!important;}
  body:not(.home-page) #main .pitch-table th{height:38px!important;font-size:10px!important;}
  body:not(.home-page) #main .pitch-table td{height:48px!important;}
  body:not(.home-page) #main .pitch-table input{height:44px!important;font-size:13px!important;}
  body:not(.home-page) #main .pane-title{height:42px!important;font-size:11px!important;}

  /* Defensive field gets useful desktop breathing room without changing the
     position model or any scoring interaction. */
  body:not(.home-page) #main .team-defense-field{
    height:360px!important;
    min-height:360px!important;
  }
  body:not(.home-page) #main .team-defense-pos{
    width:104px!important;
    min-width:104px!important;
    max-width:124px!important;
  }

  /* ---------- Desktop modal geometry ---------- */
  .modal{padding:28px!important;place-items:center!important;}
  .v102-manager-card{
    width:min(880px,calc(100vw - 80px))!important;
    max-height:min(88vh,900px)!important;
    border-radius:22px!important;
    padding:18px!important;
  }
  .v102-info-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important;}
  .v102-info-tile{min-height:108px!important;}

  /* The score editor remains a right-side inspector on desktop. This is
     intentionally different from the phone bottom-sheet: the scorecard stays
     visible while the scorer works, and opening the editor never creates a
     full-screen overlay over the desktop workspace. */
  body.has-play-inspector:not(.home-page) #main,
  body.has-play-inspector:not(.home-page) main{
    padding-right:calc(var(--v179931-inspector-w) + 20px)!important;
    transition:padding-right .18s ease!important;
  }
  body.editor-basic-v110 #playModal:not(.hidden),
  body.editor-advanced-v110 #playModal:not(.hidden),
  body.editor-pitch-v110 #playModal:not(.hidden){
    display:block!important;
    position:fixed!important;
    inset:0 0 0 auto!important;
    width:var(--v179931-inspector-w,520px)!important;
    height:100dvh!important;
    padding:0!important;
    margin:0!important;
    background:transparent!important;
    backdrop-filter:none!important;
    pointer-events:none!important;
    z-index:999!important;
  }
  body.editor-basic-v110[data-theme-family] #playModal:not(.hidden)>.play-card,
  body.editor-advanced-v110[data-theme-family] #playModal:not(.hidden)>.play-card,
  body.editor-pitch-v110[data-theme-family] #playModal:not(.hidden)>.play-card{
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    height:100dvh!important;
    max-height:100dvh!important;
    min-height:100dvh!important;
    margin:0!important;
    padding:0 18px 28px!important;
    border-radius:22px 0 0 22px!important;
    background:var(--panel)!important;
    box-shadow:-18px 0 46px rgba(0,0,0,.30)!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    scrollbar-gutter:stable!important;
    pointer-events:auto!important;
  }
  body.editor-basic-v110 #playModal .modal-head,
  body.editor-advanced-v110 #playModal .modal-head,
  body.editor-pitch-v110 #playModal .modal-head{
    position:sticky!important;
    top:0!important;
    z-index:30!important;
    margin:0 -18px 8px!important;
    padding:18px 18px 12px!important;
    border-radius:22px 0 0 0!important;
    background:color-mix(in srgb,var(--panel) 97%,transparent)!important;
    border-bottom:1px solid color-mix(in srgb,var(--line) 68%,transparent)!important;
    backdrop-filter:blur(16px)!important;
  }
  body.editor-basic-v110 #playModal .modal-actions,
  body.editor-advanced-v110 #playModal .modal-actions,
  body.editor-pitch-v110 #playModal .modal-actions{
    position:sticky!important;
    bottom:-28px!important;
    z-index:32!important;
    margin:16px -18px -28px!important;
    padding:12px 18px 18px!important;
    background:color-mix(in srgb,var(--panel) 97%,#000 3%)!important;
    border-top:1px solid color-mix(in srgb,var(--line) 68%,transparent)!important;
    box-shadow:0 -10px 24px rgba(0,0,0,.14)!important;
  }
  #pitchHistoryModal>.pitch-history-card{
    width:min(760px,calc(100vw - 80px))!important;
    max-width:760px!important;
    height:min(82vh,780px)!important;
    max-height:min(82vh,780px)!important;
    margin:auto!important;
    border-radius:22px!important;
  }

  /* ---------- Home becomes a true desktop dashboard ---------- */
  body.home-page[data-theme-family] .v97-home-inner{
    width:min(1180px,calc(100% - 72px))!important;
    max-width:1180px!important;
    margin:0 auto!important;
    padding:32px 0 28px!important;
    display:grid!important;
    grid-template-columns:minmax(0,1.18fr) minmax(380px,.82fr)!important;
    grid-template-areas:
      "brand brand"
      "current actions"
      "center actions"
      "continue actions"
      "postgame actions"
      "footer footer"!important;
    column-gap:22px!important;
    row-gap:14px!important;
    align-items:start!important;
  }
  body.home-page[data-theme-family] .v97-home-brand{grid-area:brand!important;}
  body.home-page[data-theme-family] .v97-current-game{grid-area:current!important;}
  body.home-page[data-theme-family] .v97-game-center{grid-area:center!important;}
  body.home-page[data-theme-family] .v97-continue{grid-area:continue!important;}
  body.home-page[data-theme-family] .v97-postgame{grid-area:postgame!important;}
  body.home-page[data-theme-family] .v97-home-actions{
    grid-area:actions!important;
    grid-template-columns:1fr!important;
    grid-auto-rows:minmax(82px,auto)!important;
    gap:12px!important;
    align-self:stretch!important;
  }
  body.home-page[data-theme-family] .v97-home-actions button{
    min-height:82px!important;
  }
  body.home-page[data-theme-family] .v97-home-footer{grid-area:footer!important;}
  body.home-page[data-theme-family] .v97-settings-button{right:6px!important;}

  /* Desktop-only hover feedback, without changing touch semantics. */
  @media (hover:hover) and (pointer:fine){
    body.home-page[data-theme-family] .v97-home-actions button:hover,
    body.home-page[data-theme-family] .v97-current-game:hover,
    body:not(.home-page) #main .matchup-selector:hover{
      transform:translateY(-1px);
    }
  }
}

/* Narrow desktop / browser zoom safety. Keep the wide scorebook usable
   without falling back to the tablet typography. */
@media (min-width:1101px) and (max-width:1280px){
  body:not(.home-page) #main{padding-left:14px!important;padding-right:14px!important;}
  body:not(.home-page) #main .unified-score-table{
    --player-w:176px;
    --inning-w:58px;
    --stat-w:52px;
    min-width:1210px!important;
  }
  body.home-page[data-theme-family] .v97-home-inner{
    width:min(1080px,calc(100% - 48px))!important;
    grid-template-columns:minmax(0,1.1fr) minmax(350px,.9fr)!important;
  }
}

@media (min-width:1101px){
  /* Final desktop dashboard balance: matchup and quick actions share the
     primary row; Game Center and Continue use the full working width. */
  body.home-page[data-theme-family] .v97-home-inner{
    grid-template-areas:
      "brand brand"
      "current actions"
      "center center"
      "continue continue"
      "postgame postgame"
      "footer footer"!important;
  }
  body.home-page[data-theme-family] .v97-home-actions{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    grid-auto-rows:minmax(94px,1fr)!important;
    gap:12px!important;
    align-self:stretch!important;
  }
  body.home-page[data-theme-family] .v97-home-actions button{min-height:94px!important;}

  /* Desktop workspace tabs occupy the same scorecard width as the live bar. */
  body:not(.home-page) #main .mode-workspace-tabs{
    width:100%!important;
    max-width:none!important;
  }
}
