
/* FC27 V8.7 — FINAL MOBILE LAYER
   Targets:
   - iPhone 16 Pro Max (~430–440 CSS px)
   - Samsung Galaxy S23 (~360 CSS px)
   - iOS Home Screen / Android installed PWA
   Loaded LAST so old mobile files cannot override it.
*/

:root{
  --ll-mobile-side:10px;
  --ll-touch:44px;
}

@media(max-width:700px){
  html{
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
    scroll-behavior:smooth;
    scroll-padding-top:58px;
  }
  html,body{
    width:100%;
    max-width:100%;
    overflow-x:hidden;
  }
  body{
    margin:0;
    padding-left:env(safe-area-inset-left);
    padding-right:env(safe-area-inset-right);
    padding-bottom:env(safe-area-inset-bottom);
  }
  *{box-sizing:border-box}
  img,svg,video{max-width:100%}
  button,select,input,textarea{
    touch-action:manipulation;
  }
  input,select,textarea{
    font-size:16px !important; /* prevents Safari zoom */
  }

  /* ---------- GLOBAL HEADER ---------- */
  .topbar{
    min-height:218px !important;
    background-position:50% 52% !important;
    overflow:visible !important;
  }
  .top-inner{
    min-height:218px !important;
    padding:
      max(14px,env(safe-area-inset-top))
      10px
      64px !important;
    align-items:flex-start !important;
    flex-direction:row !important;
    justify-content:space-between !important;
    gap:8px !important;
  }
  .brand{
    min-width:0 !important;
    min-height:58px !important;
    gap:9px !important;
    align-items:center !important;
  }
  .badge.losers-badge,
  .home-logo-link{
    width:58px !important;
    height:58px !important;
    min-width:58px !important;
    min-height:58px !important;
    max-width:58px !important;
    max-height:58px !important;
    flex:0 0 58px !important;
    border-radius:15px !important;
  }
  .badge.losers-badge img,
  .home-logo-link img{
    width:58px !important;
    height:58px !important;
    object-fit:cover !important;
    border-radius:15px !important;
  }
  .brand-title{
    min-height:0 !important;
    max-width:none !important;
    font-size:clamp(23px,6.5vw,29px) !important;
    line-height:.96 !important;
    letter-spacing:-.04em !important;
    white-space:normal !important;
    overflow-wrap:anywhere;
  }
  .top-actions{
    width:auto !important;
    margin-top:2px !important;
    padding:4px !important;
    gap:5px !important;
    border-radius:12px !important;
  }
  .status{
    display:inline-flex !important;
    width:10px !important;
    min-width:10px !important;
    height:10px !important;
    margin:0 3px 0 2px !important;
  }
  .status .dot{
    width:9px !important;
    height:9px !important;
  }

  .competition-nav{
    position:sticky !important;
    top:0 !important;
    z-index:140 !important;
    margin-top:-52px !important;
    padding:0 !important;
    background:rgba(13,0,22,.94) !important;
    backdrop-filter:blur(15px) !important;
    -webkit-backdrop-filter:blur(15px) !important;
  }
  .competition-nav-inner{
    max-width:100% !important;
    padding:0 8px !important;
    gap:4px !important;
    overflow-x:auto !important;
    scrollbar-width:none;
    -webkit-overflow-scrolling:touch;
  }
  .competition-nav-inner::-webkit-scrollbar{display:none}
  .competition-nav button{
    min-height:48px !important;
    padding:0 10px !important;
    font-size:9px !important;
    border-bottom-width:3px !important;
    letter-spacing:.02em !important;
  }

  /* EPL secondary nav */
  #plSubnav{
    position:sticky !important;
    top:48px !important;
    z-index:135 !important;
    margin:0 !important;
    background:rgba(28,7,36,.96) !important;
    backdrop-filter:blur(14px) !important;
    -webkit-backdrop-filter:blur(14px) !important;
  }
  #plSubnav button{
    min-height:43px !important;
    padding:0 !important;
    font-size:9px !important;
    white-space:nowrap;
  }

  /* ---------- GLOBAL CONTENT ---------- */
  .wrap{
    width:100% !important;
    max-width:100% !important;
    padding:16px var(--ll-mobile-side) calc(38px + env(safe-area-inset-bottom)) !important;
  }
  .competition-panel{
    width:100%;
    min-width:0;
  }
  .competition-hero{
    padding:13px 2px 14px !important;
  }
  .competition-hero h1{
    margin:4px 0 8px !important;
    font-size:clamp(34px,10vw,42px) !important;
    line-height:.96 !important;
  }
  .competition-hero p{
    max-width:100% !important;
    font-size:12px !important;
    line-height:1.42 !important;
  }
  .comp-kicker,.stage-kicker,.kicker{
    font-size:9px !important;
  }
  .section-head{
    gap:7px !important;
    margin-bottom:9px !important;
  }
  .section-head h2{
    font-size:29px !important;
    line-height:.98 !important;
  }
  .card,.comp-card,.history-global-card,.history-backup-card{
    border-radius:16px !important;
  }

  /* ---------- HOME ---------- */
  .ll-home{padding:0 0 14px !important}
  .ll-home-intro{
    grid-template-columns:1fr !important;
    gap:9px !important;
    margin-bottom:11px !important;
  }
  .ll-home-intro h1{
    margin:3px 0 5px !important;
    font-size:36px !important;
  }
  .ll-home-intro p{
    font-size:12px !important;
    line-height:1.35 !important;
  }
  .ll-home-layout-v52{gap:9px !important}
  .ll-result-row{
    grid-template-columns:31px minmax(0,1fr) 30px minmax(0,1fr) !important;
    gap:5px !important;
    padding:9px 0 !important;
  }
  .ll-result-row b{
    font-size:10px !important;
    line-height:1.1 !important;
  }
  .ll-result-row small{font-size:7px !important}
  .ll-result-row strong{font-size:16px !important}
  .ll-tag{
    height:23px !important;
    min-width:29px !important;
    font-size:7px !important;
  }
  .ll-duel-score{
    grid-template-columns:1fr 44px 1fr !important;
    padding:5px 0 9px !important;
  }
  .ll-duel-score b{font-size:38px !important}
  .ll-duel-score em{
    width:40px !important;
    height:40px !important;
  }
  .ll-duel-meta{
    gap:5px !important;
  }
  .ll-duel-meta span{
    padding:7px !important;
    font-size:8px !important;
  }

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

  /* ---------- WORLD CUP ---------- */
  .wc-subnav{
    gap:5px !important;
    margin:0 0 10px !important;
    overflow-x:auto !important;
    scrollbar-width:none;
  }
  .wc-subnav::-webkit-scrollbar{display:none}
  .wc-subnav button{
    min-height:42px !important;
    padding:0 11px !important;
    font-size:9px !important;
    border-radius:10px !important;
  }
  .wc-group-tabs{
    grid-template-columns:repeat(12,42px) !important;
    gap:0 !important;
    margin-bottom:12px !important;
    overflow-x:auto !important;
  }
  .wc-group-tabs button{
    min-height:43px !important;
    padding:0 !important;
    font-size:14px !important;
  }
  .wc-group-title{margin-bottom:9px !important}
  .wc-group-title h2{font-size:25px !important}
  .wc-group-grid{
    grid-template-columns:1fr !important;
    gap:10px !important;
  }
  .wc-card-head{
    padding:11px 12px 8px !important;
  }
  .wc-card-head h2{font-size:24px !important}
  .wc-card-head h3{font-size:19px !important}

  .wc-table{
    min-width:570px !important;
    font-size:10px !important;
  }
  .wc-table th,.wc-table td{
    padding:8px 6px !important;
  }
  .wc-table th:first-child,.wc-table td:first-child{
    position:sticky;
    left:0;
    z-index:4;
  }
  .wc-table th:nth-child(2),.wc-table td:nth-child(2){
    position:sticky;
    left:36px;
    z-index:3;
    min-width:150px;
  }
  .wc-table th:first-child,.wc-table td:first-child,
  .wc-table th:nth-child(2),.wc-table td:nth-child(2){
    background:#fbfaf7;
  }
  .wc-qualified td:first-child,.wc-qualified td:nth-child(2){background:#eff8ee}
  .wc-team{
    gap:5px !important;
    font-size:10px !important;
  }
  .wc-flag{font-size:16px !important}

  .wc-match{
    grid-template-columns:minmax(0,1fr) 54px minmax(0,1fr) !important;
    gap:5px !important;
    padding:9px 7px !important;
  }
  .wc-score{font-size:16px !important}
  .wc-group-controller{
    min-height:34px !important;
    font-size:8px !important;
  }

  .wc-bracket-wrap{padding:7px !important}
  .wc-ko-help{
    margin-bottom:8px !important;
    padding:9px !important;
    font-size:9px !important;
  }
  .wc-ko-bracket-scroll{
    margin:0 -2px;
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
  }
  .wc-ko-bracket{
    min-width:1140px !important;
    grid-template-columns:repeat(5,minmax(205px,1fr)) !important;
    gap:18px !important;
  }
  .wc-ko-name{font-size:9px !important}
  .wc-ko-row{
    grid-template-columns:minmax(0,1fr) 37px !important;
    min-height:36px !important;
  }
  .wc-ko-score-input{
    width:37px !important;
    height:36px !important;
    font-size:15px !important;
  }
  .wc-ko-teamname{gap:4px !important}
  .wc-ko-flag{font-size:15px !important}
  .wc-controller{
    min-height:34px !important;
    font-size:8px !important;
  }

  /* ---------- PREMIER LEAGUE ---------- */
  #comp-pl .headline{
    gap:7px !important;
    margin-bottom:10px !important;
  }
  #comp-pl .hero h1{
    font-size:33px !important;
    margin:3px 0 6px !important;
  }
  #comp-pl .hero p{font-size:11px !important}
  .owner-select{
    height:36px !important;
    min-height:36px !important;
    padding:0 4px !important;
    font-size:10px !important;
  }

  #tableBox .table{
    min-width:670px !important;
  }
  #tableBox .table th,#tableBox .table td{
    padding:8px 6px !important;
  }
  #tableBox .table th:first-child,
  #tableBox .table td:first-child{
    left:0 !important;
  }
  #tableBox .table th:nth-child(2),
  #tableBox .table td:nth-child(2){
    left:38px !important;
    min-width:150px !important;
  }
  #tableBox .table td.team .club-mark{
    width:34px !important;
    height:34px !important;
    flex-basis:34px !important;
  }
  #tableBox .table td.team{font-size:10px !important}
  .record-card{padding:10px !important}
  .recap-card{border-radius:15px !important}
  .recap-hero{padding:11px !important}
  .recap-hero h3{font-size:22px !important}
  .recap-results{padding:6px 8px !important}

  /* ---------- CHAMPIONS LEAGUE ---------- */

  .ucl-table{
    min-width:650px !important;
  }
  .ucl-table th,.ucl-table td{
    height:auto !important;
    padding:7px 5px !important;
  }
  .ucl-table th:first-child,.ucl-table td:first-child{
    width:32px !important;
    min-width:32px !important;
  }
  .ucl-table th:nth-child(2),.ucl-table td:nth-child(2){
    left:32px !important;
    min-width:150px !important;
    max-width:150px !important;
  }
  .ucl-table td:nth-child(2) .ucl-real-crest{--ucl-badge-size:28px !important}
  .ucl-table td:nth-child(2) .ucl-team-line b{font-size:9px !important}
  .ucl-table td:nth-child(2) .ucl-form{margin-left:35px !important}
  .ucl-recap-results{padding:6px !important}
  .ucl-recap-results>div{
    grid-template-columns:minmax(0,1fr) 36px minmax(0,1fr) !important;
    gap:3px !important;
  }
  .ucl-recap-bottom{grid-template-columns:1fr !important;padding:0 7px 7px !important}

  /* ---------- HISTORY + BACKUPS ---------- */
  .history-hero{padding-bottom:12px !important}
  .history-global-head{
    padding:11px !important;
    gap:8px !important;
    flex-direction:column !important;
  }
  .history-global-head h2{font-size:22px !important}
  .history-undo{
    width:100% !important;
    min-height:43px !important;
  }
  .history-status{
    padding:8px 10px !important;
    font-size:9px !important;
  }
  .history-global-list{padding:0 10px !important}
  .history-item{
    grid-template-columns:minmax(0,1fr) auto !important;
    gap:5px 8px !important;
    padding:10px 0 !important;
  }
  .history-time{font-size:8px !important}
  .history-editor{font-size:10px !important}
  .history-main{
    grid-column:1/-1 !important;
  }
  .history-main b{font-size:11px !important}
  .history-main small{font-size:8px !important}
  .history-scope{font-size:7px !important}

  /* ---------- NHL PLACEHOLDER ---------- */
  #comp-nhl .comp-card{
    min-height:82px !important;
    padding:12px !important;
  }
  #comp-nhl .comp-card b{font-size:15px !important}
  #comp-nhl .comp-card span{font-size:10px !important}

  /* ---------- MODALS / MOBILE APP BOTTOM SHEETS ---------- */
  .matchcard-modal,
  .team-history-modal{
    overscroll-behavior:contain;
  }
  .matchcard-sheet,
  .team-history-sheet{
    left:0 !important;
    right:0 !important;
    top:auto !important;
    bottom:0 !important;
    width:100% !important;
    max-width:none !important;
    max-height:calc(93dvh - env(safe-area-inset-top)) !important;
    border-radius:18px 18px 0 0 !important;
    padding:
      17px
      10px
      calc(14px + env(safe-area-inset-bottom)) !important;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch;
  }
  .matchcard-close,.team-history-close{
    width:42px !important;
    height:42px !important;
    top:5px !important;
    right:6px !important;
    font-size:27px !important;
  }
  .mc-scoreline{
    grid-template-columns:minmax(0,1fr) 50px minmax(0,1fr) !important;
    gap:5px !important;
    padding:9px 5px !important;
  }
  .mc-scoreline strong{font-size:20px !important}
  .mc-section{padding:10px 0 !important}
  .mc-event-row,
  .ucl-proto-row{
    grid-template-columns:1fr !important;
    gap:5px !important;
  }
  .ucl-proto-row .minute{max-width:none !important}

  /* ---------- SCROLLABLE TABLES ---------- */
  .table-scroll,.wc-bracket-scroll,.wc-ko-bracket-scroll{
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
    overscroll-behavior-x:contain;
  }

  /* ---------- FOOTER ---------- */
  footer{
    padding-bottom:calc(14px + env(safe-area-inset-bottom)) !important;
  }
}

/* Galaxy S23 / compact Android */
@media(min-width:340px) and (max-width:390px){
  :root{--ll-mobile-side:8px}
  .topbar,.top-inner{min-height:204px !important}
  .top-inner{padding-left:8px !important;padding-right:8px !important}
  .badge.losers-badge,.home-logo-link,
  .badge.losers-badge img,.home-logo-link img{
    width:52px !important;height:52px !important;min-width:52px !important;min-height:52px !important;max-width:52px !important;max-height:52px !important;flex-basis:52px !important;
  }
  .brand-title{font-size:21px !important}
  .ll-home-intro h1{font-size:33px !important}
  .ucl-table{min-width:625px !important}
}

/* iPhone 16 Pro Max / roomier iOS */
@media(min-width:420px) and (max-width:480px){
  :root{--ll-mobile-side:11px}
  .topbar,.top-inner{min-height:224px !important}
  .brand-title{font-size:28px !important}
  .ll-home-intro h1{font-size:39px !important}
}

/* Installed PWA / Home Screen mode */
@media(max-width:700px) and (display-mode:standalone){
  html{scroll-padding-top:58px}
  .topbar{
    padding-top:env(safe-area-inset-top) !important;
  }
  .top-inner{
    padding-top:10px !important;
  }
  .competition-nav{
    top:env(safe-area-inset-top) !important;
  }
  #plSubnav{
    top:calc(env(safe-area-inset-top) + 48px) !important;
  }
  .matchcard-sheet,.team-history-sheet{
    padding-bottom:calc(18px + env(safe-area-inset-bottom)) !important;
  }
}

/* Android PWA without notch variables still keeps touch-safe bottom space */
@media(max-width:700px) and (display-mode:standalone) and (max-width:390px){
  body{padding-bottom:max(8px,env(safe-area-inset-bottom))}
}
