/* R8.166 — BETA mobile portrait regression fixes.
   Keep the approved desktop/tablet work intact. On phones, restore the compact
   transfer-card rhythm used earlier in the day and normalise Builder name weight. */

@media(max-width:620px){
  /* Transfers > Full squad view: phone cards use the earlier compact five-column
     scan pattern. Provisional remains a desktop/tablet detail; Total Pts becomes Pts. */
  html body #view-windows .tp-yot-squad-head.squad-head,
  html body #view-windows .tp-yot-player.squad-row{
    display:grid!important;
    grid-template-columns:36px minmax(0,1fr) 40px 52px 42px!important;
    column-gap:4px!important;
    align-items:center!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    box-sizing:border-box!important;
  }

  html body #view-windows .tp-yot-squad-head.squad-head{
    min-height:24px!important;
    margin:0 0 3px!important;
    padding:4px 6px!important;
    color:#70838f!important;
    font-size:8.5px!important;
    line-height:1!important;
    font-weight:900!important;
    text-transform:uppercase!important;
  }
  html body #view-windows .tp-yot-squad-head.squad-head>span{
    min-width:0!important;
    margin:0!important;
    padding:0!important;
    white-space:nowrap!important;
  }
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(1){grid-column:1!important;text-align:left!important}
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(2){grid-column:2!important;text-align:left!important}
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(3){grid-column:3!important;text-align:left!important}
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(4){grid-column:4!important;text-align:right!important}
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(5){display:none!important}
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(6){
    grid-column:5!important;
    text-align:right!important;
    font-size:0!important;
  }
  html body #view-windows .tp-yot-squad-head.squad-head>span:nth-child(6)::after{
    content:'Pts';
    font-size:8.5px!important;
  }

  html body #view-windows .tp-yot-stack.squad-list{
    display:grid!important;
    gap:3px!important;
  }
  html body #view-windows .tp-yot-player.squad-row{
    min-height:35px!important;
    height:auto!important;
    margin:0!important;
    padding:4px 6px!important;
    overflow:hidden!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-pos{
    grid-column:1!important;
    justify-self:start!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-name,
  html body #view-windows .tp-yot-player.squad-row>.pa-name-inline{
    grid-column:2!important;
    justify-self:start!important;
    min-width:0!important;
    max-width:100%!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.pa-name-inline{
    display:inline-flex!important;
    align-items:center!important;
    gap:3px!important;
    width:max-content!important;
    overflow:hidden!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-name,
  html body #view-windows .tp-yot-player.squad-row>.pa-name-inline>.tp-yot-name{
    appearance:none!important;
    -webkit-appearance:none!important;
    display:block!important;
    width:auto!important;
    min-width:0!important;
    max-width:100%!important;
    min-height:0!important;
    height:auto!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    background:transparent!important;
    box-shadow:none!important;
    color:#173f5a!important;
    font-family:inherit!important;
    font-size:12.5px!important;
    line-height:1.1!important;
    font-weight:750!important;
    text-align:left!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.pa-name-inline>.pa-badge{
    flex:0 0 auto!important;
    margin:0!important;
    padding:1px 4px!important;
    font-size:8px!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-club{
    grid-column:3!important;
    justify-self:start!important;
    min-width:0!important;
    font-size:9.5px!important;
    white-space:nowrap!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-price{
    grid-column:4!important;
    justify-self:end!important;
    min-width:0!important;
    font-size:10px!important;
    white-space:nowrap!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-prov{
    display:none!important;
  }
  html body #view-windows .tp-yot-player.squad-row>.tp-yot-points{
    grid-column:5!important;
    justify-self:end!important;
    min-width:0!important;
    margin:0!important;
    font-size:10px!important;
    font-weight:850!important;
    white-space:nowrap!important;
  }

  /* Team Builder: status-wrapped names and ordinary names must use the same
     type weight. Availability badges stay bold; player names do not jump weight. */
  html body #view-team-builder .tb-player-name>b,
  html body #view-team-builder .tb-player-name>.pa-name-inline>b{
    font-family:inherit!important;
    font-size:11.5px!important;
    line-height:1.1!important;
    font-weight:750!important;
    letter-spacing:0!important;
  }
}

/* R8.166b — iPhone portrait Player Pool density/alignment.
   Reclaim horizontal space for PLAYER without increasing row height. Keep every
   name/status combination on one line; long names ellipsize before the status pill. */
@media(max-width:520px){
  html body #view-team-builder .r830-player-head,
  html body #view-team-builder .tb-player{
    display:grid!important;
    grid-template-columns:30px minmax(0,1fr) 36px 44px 44px 58px!important;
    grid-template-rows:48px!important;
    column-gap:2px!important;
    align-items:center!important;
    width:100%!important;
    max-width:100%!important;
    min-width:0!important;
    box-sizing:border-box!important;
    padding:0 3px!important;
    overflow:hidden!important;
  }

  html body #view-team-builder .r830-player-head{
    grid-template-rows:40px!important;
    min-height:40px!important;
    height:40px!important;
  }
  html body #view-team-builder .tb-player{
    min-height:48px!important;
    height:48px!important;
  }

  html body #view-team-builder .r830-player-head>span,
  html body #view-team-builder .tb-player>*{
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    box-sizing:border-box!important;
  }

  html body #view-team-builder .r830-player-head>span:nth-child(1),
  html body #view-team-builder .tb-player>.tb-pos{grid-column:1!important;grid-row:1!important}
  html body #view-team-builder .r830-player-head>span:nth-child(2),
  html body #view-team-builder .tb-player>.tb-player-name{grid-column:2!important;grid-row:1!important}
  html body #view-team-builder .r830-player-head>span:nth-child(3),
  html body #view-team-builder .tb-player>.r833-team-cell{grid-column:3!important;grid-row:1!important}
  html body #view-team-builder .r830-player-head>span:nth-child(4),
  html body #view-team-builder .tb-player>.r830-prev-points{grid-column:4!important;grid-row:1!important}
  html body #view-team-builder .r830-player-head>span:nth-child(5),
  html body #view-team-builder .tb-player>strong{grid-column:5!important;grid-row:1!important}
  html body #view-team-builder .r830-player-head>.r847-add-only-cell,
  html body #view-team-builder .tb-player>[data-tb-add]{grid-column:6!important;grid-row:1!important}

  /* PLAYER: one line whether or not a status badge is present. */
  html body #view-team-builder .tb-player-name{
    display:flex!important;
    align-items:center!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    overflow:hidden!important;
    white-space:nowrap!important;
    padding:0!important;
  }
  html body #view-team-builder .tb-player-name>b{
    display:block!important;
    flex:1 1 auto!important;
    min-width:0!important;
    max-width:100%!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
    font-size:11.5px!important;
    line-height:1!important;
    font-weight:750!important;
  }
  html body #view-team-builder .tb-player-name>.pa-name-inline{
    display:flex!important;
    align-items:center!important;
    gap:3px!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    overflow:hidden!important;
    white-space:nowrap!important;
  }
  html body #view-team-builder .tb-player-name>.pa-name-inline>b{
    display:block!important;
    flex:1 1 auto!important;
    min-width:0!important;
    max-width:100%!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
    font-size:11.5px!important;
    line-height:1!important;
    font-weight:750!important;
  }
  html body #view-team-builder .tb-player-name>.pa-name-inline>.pa-badge{
    flex:0 0 auto!important;
    max-width:44px!important;
    min-width:18px!important;
    height:18px!important;
    min-height:18px!important;
    padding:0 4px!important;
    margin:0!important;
    font-size:8px!important;
    line-height:16px!important;
    white-space:nowrap!important;
  }

  /* Header sort controls and data use the same six tracks. */
  html body #view-team-builder .r830-player-head>span{
    height:30px!important;
    display:flex!important;
    align-items:center!important;
    overflow:hidden!important;
  }
  html body #view-team-builder .r830-player-head>span:nth-child(1),
  html body #view-team-builder .r830-player-head>span:nth-child(2),
  html body #view-team-builder .r830-player-head>span:nth-child(3){justify-content:flex-start!important}
  html body #view-team-builder .r830-player-head>span:nth-child(4),
  html body #view-team-builder .r830-player-head>span:nth-child(5){justify-content:center!important}

  html body #view-team-builder .r830-player-head .r833-sort{
    all:unset!important;
    box-sizing:border-box!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    gap:1px!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    height:30px!important;
    padding:0!important;
    border:0!important;
    border-radius:6px!important;
    background:transparent!important;
    color:#314e60!important;
    font-family:inherit!important;
    font-size:8px!important;
    line-height:1!important;
    font-weight:900!important;
    letter-spacing:0!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    cursor:pointer!important;
  }
  html body #view-team-builder .r830-player-head .r833-sort.r833-sort-active{
    background:#eef8f3!important;
    color:#087656!important;
    box-shadow:inset 0 0 0 1px #8fc1ac!important;
  }
  html body #view-team-builder .r830-player-head .r833-sort::after{
    display:inline-block!important;
    width:auto!important;
    min-width:0!important;
    height:auto!important;
    padding:0!important;
    border:0!important;
    background:transparent!important;
    font-size:7px!important;
    line-height:1!important;
    flex:0 0 auto!important;
  }

  html body #view-team-builder .r830-player-head>.r847-add-only-cell{
    display:flex!important;
    width:58px!important;
    min-width:58px!important;
    max-width:58px!important;
    height:30px!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:hidden!important;
  }
  html body #view-team-builder .r847-add-only{
    width:58px!important;
    min-width:58px!important;
    max-width:58px!important;
    height:30px!important;
    min-height:30px!important;
    padding:0 2px!important;
    font-size:7.2px!important;
    line-height:1!important;
    white-space:nowrap!important;
  }

  html body #view-team-builder .tb-pos{
    min-width:28px!important;
    max-width:28px!important;
    justify-self:start!important;
    font-size:9px!important;
    line-height:1!important;
  }
  html body #view-team-builder .r833-team-cell{
    justify-self:start!important;
    justify-content:flex-start!important;
    overflow:hidden!important;
  }
  html body #view-team-builder .r833-team-cell::after{
    font-size:9px!important;
    line-height:1!important;
    white-space:nowrap!important;
  }
  html body #view-team-builder .r830-prev-points{
    justify-self:end!important;
    text-align:right!important;
    font-size:9px!important;
    line-height:1!important;
    white-space:nowrap!important;
  }
  html body #view-team-builder .tb-player>strong{
    justify-self:end!important;
    text-align:right!important;
    font-size:11px!important;
    line-height:1!important;
    white-space:nowrap!important;
  }
  html body #view-team-builder .tb-player>[data-tb-add]{
    width:58px!important;
    min-width:58px!important;
    max-width:58px!important;
    height:36px!important;
    min-height:36px!important;
    padding:0 2px!important;
    font-size:9px!important;
    line-height:1!important;
    white-space:nowrap!important;
    overflow:hidden!important;
  }
}
