/* V11.6 — phone composition layer
   Loaded LAST. Tuned for large iPhone (~430–440 CSS px) and compact Android (~360 CSS px).
   Goal: one-thumb navigation, minimal header, no accidental horizontal page overflow,
   readable score inputs, compact tables, bottom-sheet editing surfaces. */

@media (max-width: 700px) {
  :root{
    --ll-phone-side: 10px;
    --ll-phone-nav-h: 48px;
  }

  html{
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
    scroll-padding-top:52px;
    background:var(--ll-bg,#efeee9);
  }
  html,body{
    width:100%;
    max-width:100%;
    overflow-x:hidden!important;
  }
  body{
    padding-left:env(safe-area-inset-left)!important;
    padding-right:env(safe-area-inset-right)!important;
    padding-bottom:env(safe-area-inset-bottom)!important;
  }
  img,svg,video{max-width:100%;height:auto}
  button,input,select,textarea{touch-action:manipulation}
  input,select,textarea{font-size:16px!important}

  /* ---------- HEADER: phone, not billboard ---------- */
  .topbar{
    min-height:112px!important;
    height:112px!important;
    overflow:hidden!important;
    background:
      linear-gradient(90deg,rgba(9,0,16,.93),rgba(9,0,16,.72)),
      url("losersleague_header_scene.jpg?v=20260824-2055") 50% 45%/cover no-repeat!important;
  }
  .topbar::after{opacity:.12!important}
  .top-inner{
    position:relative!important;
    min-height:112px!important;
    height:112px!important;
    padding:max(10px,env(safe-area-inset-top)) 10px 10px!important;
    display:flex!important;
    align-items:flex-start!important;
    justify-content:space-between!important;
    gap:8px!important;
  }
  .brand{
    min-width:0!important;
    gap:8px!important;
    align-items:center!important;
  }
  .badge.losers-badge,.home-logo-link{
    width:46px!important;height:46px!important;
    min-width:46px!important;min-height:46px!important;
    max-width:46px!important;max-height:46px!important;
    flex:0 0 46px!important;
    border-radius:12px!important;
  }
  .badge.losers-badge img,.home-logo-link img{
    width:46px!important;height:46px!important;border-radius:12px!important;object-fit:cover!important;
  }
  .brand-title{
    min-height:0!important;
    max-width:190px!important;
    font-size:21px!important;
    line-height:.96!important;
    letter-spacing:-.04em!important;
    white-space:normal!important;
    overflow-wrap:normal!important;
  }
  .ll-header-slogan-art{display:none!important}
  .top-actions{
    position:absolute!important;
    top:max(10px,env(safe-area-inset-top))!important;
    right:10px!important;
    width:auto!important;
    margin:0!important;
    padding:3px!important;
    gap:4px!important;
    border-radius:11px!important;
  }
  #statusText{display:none!important}
  .status{
    width:24px!important;min-width:24px!important;height:34px!important;
    margin:0!important;padding:0!important;display:grid!important;place-items:center!important;
  }
  .status .dot{width:9px!important;height:9px!important;margin:0!important}

  .competition-nav{
    position:sticky!important;
    top:0!important;
    z-index:150!important;
    min-height:var(--ll-phone-nav-h)!important;
    margin:0!important;
    padding:0!important;
    background:rgba(13,0,22,.97)!important;
    backdrop-filter:blur(14px)!important;
    -webkit-backdrop-filter:blur(14px)!important;
    border-top:0!important;
  }
  .competition-nav-inner{
    width:100%!important;
    max-width:100%!important;
    min-height:var(--ll-phone-nav-h)!important;
    padding:0 8px!important;
    gap:4px!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  .competition-nav-inner::-webkit-scrollbar{display:none}
  .competition-nav button{
    flex:0 0 auto!important;
    min-height:48px!important;
    height:48px!important;
    padding:0 10px!important;
    font-size:9px!important;
    line-height:1!important;
    white-space:nowrap!important;
    border-bottom-width:3px!important;
  }

  /* secondary navigation */
  #plSubnav{
    position:sticky!important;
    top:48px!important;
    z-index:142!important;
  }

  /* ---------- GLOBAL CONTENT ---------- */
  .wrap{
    width:100%!important;
    max-width:100%!important;
    padding:14px var(--ll-phone-side) calc(34px + env(safe-area-inset-bottom))!important;
  }
  .competition-panel,.ll-home,.panel,.card{min-width:0!important;max-width:100%!important}
  .competition-panel>*+*{margin-top:14px!important}
  .competition-hero,.hero{
    padding:8px 1px 10px!important;
  }
  .competition-hero h1,.hero h1{
    margin:3px 0 5px!important;
    font-size:32px!important;
    line-height:.96!important;
  }
  .competition-hero p,.hero p{font-size:11px!important;line-height:1.34!important}
  .section-head{margin-bottom:8px!important;gap:6px!important;align-items:flex-end!important}
  .section-head h2,.wc-group-title h2,.wc-card-head h2{font-size:25px!important;line-height:.98!important}
  .card,.recap-card,.history-global-card,.history-backup-card,.comp-card,.wc-group-card,.wc-match-card{
    border-radius:14px!important;
  }

  /* ---------- HOME ---------- */
  .ll-home-intro{margin-bottom:14px!important}
  .ll-home-intro h1{font-size:34px!important;margin:3px 0 0!important}
  .ll-home-layout-v52{gap:8px!important}
  .ll-result-row{
    grid-template-columns:30px minmax(0,1fr) 28px minmax(0,1fr)!important;
    gap:5px!important;
    padding:8px 0!important;
  }
  .ll-result-row b{font-size:10px!important;line-height:1.08!important}
  .ll-result-row small{font-size:7px!important}
  .ll-result-row strong{font-size:16px!important}
  .ll-tag{min-width:28px!important;height:22px!important;font-size:7px!important}
  .ll-duel-score{grid-template-columns:1fr 42px 1fr!important;padding:4px 0 8px!important}
  .ll-duel-score b{font-size:37px!important}
  .ll-duel-score em{width:40px!important;height:40px!important}
  .ll-rivalry-split-grid{grid-template-columns:1fr!important;gap:7px!important}

  /* next match input card */
  #nextMatchSaveBtn{width:100%!important;min-height:44px!important}

  /* ---------- WORLD CUP ---------- */
  .wc-subnav{
    display:flex!important;gap:5px!important;margin:0 0 9px!important;
    overflow-x:auto!important;-webkit-overflow-scrolling:touch;scrollbar-width:none;
  }
  .wc-subnav::-webkit-scrollbar{display:none}
  .wc-subnav button{flex:0 0 auto!important;min-height:40px!important;padding:0 10px!important;font-size:9px!important;border-radius:9px!important}
  .wc-group-tabs{
    display:flex!important;gap:0!important;margin:0 -2px 10px!important;
    overflow-x:auto!important;-webkit-overflow-scrolling:touch;scrollbar-width:none;
  }
  .wc-group-tabs::-webkit-scrollbar{display:none}
  .wc-group-tabs button{flex:0 0 42px!important;min-height:40px!important;padding:0!important;font-size:13px!important}
  .wc-group-title{display:block!important;margin-bottom:8px!important}
  .wc-group-title h2{font-size:20px!important;line-height:1.08!important;margin-top:3px!important}
  .wc-group-edit-hint{margin-top:6px!important;text-align:left!important;font-size:8px!important;line-height:1.3!important}
  .wc-group-grid{grid-template-columns:1fr!important;gap:8px!important}
  .wc-card-head{padding:10px 10px 7px!important}
  .wc-card-head h3{font-size:18px!important}

  /* Group standings: full 10-column table, scrolls horizontally on phone */
  .wc-group-grid .wc-table{
    width:100%!important;min-width:480px!important;table-layout:fixed!important;font-size:10px!important;
  }
  .wc-group-grid .wc-table th,.wc-group-grid .wc-table td{padding:8px 5px!important}
  .wc-group-grid .wc-table th:first-child,.wc-group-grid .wc-table td:first-child{width:30px!important;position:static!important}
  .wc-group-grid .wc-table th:nth-child(2),.wc-group-grid .wc-table td:nth-child(2){width:96px!important;min-width:0!important;position:static!important}
  .wc-group-grid .wc-table th:nth-child(3),.wc-group-grid .wc-table td:nth-child(3){width:36px!important}
  .wc-group-grid .wc-table th:nth-child(n+4):nth-child(-n+9),
  .wc-group-grid .wc-table td:nth-child(n+4):nth-child(-n+9){width:30px!important}
  .wc-group-grid .wc-table th:nth-child(10),.wc-group-grid .wc-table td:nth-child(10){width:38px!important;display:table-cell!important}
  .wc-group-grid .wc-table th:first-child,.wc-group-grid .wc-table td:first-child,
  .wc-group-grid .wc-table th:nth-child(2),.wc-group-grid .wc-table td:nth-child(2){background:inherit!important}
  .wc-team{gap:5px!important;font-size:10px!important;min-width:0!important}
  .wc-team-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap!important;max-width:155px!important}
  .wc-flag-image{width:27px!important;height:18px!important;flex:0 0 27px!important}

  /* Third-place table: full 11-column table, scrolls horizontally on phone */
  .wc-thirds{width:100%!important;min-width:440px!important;table-layout:fixed!important;font-size:9px!important}
  .wc-thirds th,.wc-thirds td{padding:7px 4px!important}
  .wc-thirds th:first-child,.wc-thirds td:first-child{width:62px!important}
  .wc-thirds th:nth-child(2),.wc-thirds td:nth-child(2){width:34px!important}
  .wc-thirds th:nth-child(3),.wc-thirds td:nth-child(3){width:78px!important}
  .wc-thirds th:nth-child(4),.wc-thirds td:nth-child(4){width:38px!important}
  .wc-thirds th:nth-child(n+5):nth-child(-n+10),
  .wc-thirds td:nth-child(n+5):nth-child(-n+10){width:28px!important}
  .wc-thirds th:nth-child(11),.wc-thirds td:nth-child(11){display:table-cell!important;width:40px!important}
  .wc-thirds .wc-qualify{padding:4px 5px!important;font-size:7px!important;border-radius:7px!important}
  .wc-thirds .wc-team-text{max-width:120px!important}

  /* Editable group match cards */
  .wc-match-editable{
    grid-template-columns:minmax(0,1fr) 92px minmax(0,1fr)!important;
    gap:4px!important;padding:9px 6px!important;min-height:74px!important;
  }
  .wc-group-side{min-width:0!important;gap:4px!important}
  .wc-group-side .wc-team{font-size:9px!important;gap:4px!important}
  .wc-group-side .wc-team-text{max-width:78px!important;white-space:normal!important;line-height:1.05!important}
  .wc-group-side .wc-flag-image{width:24px!important;height:16px!important;flex-basis:24px!important}
  .wc-group-controller{min-width:32px!important;min-height:32px!important;height:32px!important;font-size:8px!important;border-radius:8px!important}
  .wc-score-editor{width:92px!important;min-width:92px!important}
  .wc-score-inputs{grid-template-columns:34px 8px 34px!important;gap:3px!important}
  .wc-group-score-input{width:34px!important;height:36px!important;min-height:36px!important;font-size:17px!important;padding:0!important}
  .wc-score-actions{gap:3px!important;margin-top:4px!important}
  .wc-group-score-save{min-height:30px!important;padding:0 5px!important;font-size:7px!important}
  .wc-group-score-clear{width:30px!important;height:30px!important;min-height:30px!important;font-size:16px!important}


  /* ---------- PREMIER LEAGUE ---------- */
  #comp-pl .headline{grid-template-columns:1fr!important;gap:8px!important}
  #comp-pl .hero h1{font-size:31px!important}
  .owner-select{height:35px!important;min-height:35px!important;font-size:9px!important;padding:0 3px!important}
  #tableBox .table{min-width:590px!important}

  /* ---------- UCL ---------- */
  .ucl-table{min-width:580px!important}

  /* ---------- HISTORY / MODALS ---------- */
  .history-global-head{padding:13px 11px!important}
  .history-global-head h2{font-size:23px!important}
  .history-global-list{padding:0 11px!important}
  .history-item{grid-template-columns:1fr auto!important;gap:5px 8px!important;padding:11px 0!important}
  .history-main{grid-column:1/-1!important}
  .matchcard-sheet,.team-history-sheet{
    position:fixed!important;left:0!important;right:0!important;bottom:0!important;top:auto!important;
    width:100%!important;max-width:none!important;max-height:calc(91dvh - env(safe-area-inset-top))!important;
    transform:none!important;border-radius:20px 20px 0 0!important;
    padding:17px 11px calc(14px + env(safe-area-inset-bottom))!important;
    overflow-y:auto!important;
  }
  .matchcard-close,.team-history-close{width:42px!important;height:42px!important;right:7px!important;top:6px!important}
  .mc-event-row{grid-template-columns:1fr!important;gap:5px!important}
  .mc-event-row input,.mc-event-row select{width:100%!important;min-height:44px!important}
}

/* Galaxy S23 / compact Android */
@media (min-width:340px) and (max-width:390px){
  :root{--ll-phone-side:9px}
  .topbar,.top-inner{min-height:104px!important;height:104px!important}
  .brand-title{font-size:19px!important;max-width:158px!important}
  .badge.losers-badge,.home-logo-link,.badge.losers-badge img,.home-logo-link img{
    width:42px!important;height:42px!important;min-width:42px!important;min-height:42px!important;max-width:42px!important;max-height:42px!important;flex-basis:42px!important;
  }
  .competition-nav button{padding:0 9px!important;font-size:8px!important}
  .ll-home-intro h1{font-size:31px!important}
  .wc-match-editable{grid-template-columns:minmax(0,1fr) 88px minmax(0,1fr)!important;padding:8px 5px!important}
  .wc-score-editor{width:88px!important;min-width:88px!important}
  .wc-group-side .wc-team-text{max-width:66px!important}
  .wc-team-text{max-width:128px!important}
  .wc-thirds .wc-team-text{max-width:94px!important}
}

/* iPhone 16 Pro Max / large iPhone portrait */
@media (min-width:420px) and (max-width:480px){
  :root{--ll-phone-side:12px}
  .brand-title{font-size:22px!important;max-width:205px!important}
  .ll-home-intro h1{font-size:36px!important}
  .wc-group-side .wc-team-text{max-width:96px!important}
  .wc-team-text{max-width:180px!important}
  .wc-thirds .wc-team-text{max-width:140px!important}
}
