/* Shared phone cleanup for 9pintabell.se main + SM/Elit pages. */
@media (max-width: 700px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    font-size: 14px !important;
  }

  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  /* ---------- Main Västeråsserien page ---------- */
  body > .container {
    width: calc(100% - 12px) !important;
    max-width: none !important;
    margin: 6px auto 18px !important;
    padding: 12px 8px 16px !important;
    border-radius: 12px !important;
    box-shadow: 0 5px 18px rgba(0, 0, 0, .07) !important;
  }

  #siteTitle {
    font-size: 1.45rem !important;
    margin: 2px 0 6px !important;
  }

  .logo-container {
    width: 100% !important;
    margin: 0 auto 8px !important;
    overflow: hidden;
  }

  .logo-link {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .league-logo {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 190px;
    object-fit: contain;
  }

  .tabs,
  .division-tabs {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px !important;
    padding: 5px !important;
    margin: 10px 0 14px !important;
    border-radius: 13px !important;
  }

  .tabs button,
  .division-tabs button {
    width: 100%;
    min-width: 0;
    padding: 9px 4px !important;
    font-size: .78rem !important;
    line-height: 1.2;
    border-radius: 9px !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .table-layout,
  .table-left,
  .main-content,
  .layout {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .league-division,
  #ranking-container,
  .players-section,
  #sched-div1-table,
  #sched-div2-table,
  #sched-div3-table {
    width: 100%;
    max-width: 100%;
  }

  .league-division,
  #ranking-container,
  .players-section,
  #sched-div1-table,
  #sched-div2-table,
  #sched-div3-table {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .league-division table,
  #ranking-container table,
  .players-section table {
    min-width: 650px;
    width: 650px;
    margin-bottom: 8px;
  }

  th,
  td {
    padding: 8px 7px !important;
    font-size: .76rem !important;
  }

  td.team,
  .player-link {
    font-size: .8rem !important;
  }

  .week-selector {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 7px !important;
    margin-bottom: 12px !important;
  }

  .week-selector label {
    font-size: .8rem;
  }

  .week-selector select,
  #rankingMetric,
  #teamFilter {
    max-width: 100%;
    min-height: 38px;
    padding: 7px 9px !important;
    font-size: .85rem;
  }

  #schedule h2,
  #ranking h2 {
    font-size: 1.2rem;
    margin: 8px 0 12px;
  }

  .players-section {
    padding: 10px !important;
    margin-top: 14px !important;
  }

  #excelBlock {
    padding: 10px !important;
    margin-bottom: 14px !important;
    overflow: hidden;
  }

  #excelBlock input,
  #excelBlock select {
    max-width: 100%;
    margin: 3px 0;
  }

  #logoutBtn {
    top: 8px !important;
    right: 8px !important;
    padding: 6px 9px !important;
    font-size: .75rem !important;
  }

  /* Keep schedule data readable, but scroll only the table instead of the page. */
  #schedule .schedule-division {
    width: 100%;
    max-width: 100%;
    overflow: visible !important;
  }

  #schedule .schedule-table {
    min-width: 720px !important;
    width: 720px !important;
    table-layout: auto !important;
  }

  #schedule .schedule-table th,
  #schedule .schedule-table td {
    padding: 8px 7px !important;
    font-size: .75rem !important;
    white-space: nowrap !important;
  }

  #schedule .schedule-table th:nth-child(2),
  #schedule .schedule-table td:nth-child(2) {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
  }

  #schedule .schedule-table th:nth-child(3),
  #schedule .schedule-table td:nth-child(3) {
    width: 62px !important;
    min-width: 62px !important;
    max-width: 62px !important;
  }

  #schedule .schedule-table th:nth-child(4),
  #schedule .schedule-table td:nth-child(4),
  #schedule .schedule-table th:nth-child(7),
  #schedule .schedule-table td:nth-child(7) {
    min-width: 115px !important;
  }

  #about9pin {
    margin: 22px auto 8px !important;
    padding: 12px 8px !important;
    font-size: .72rem !important;
    line-height: 1.45 !important;
  }

  #about9pin h2 {
    font-size: .82rem !important;
  }

  .site-legal-footer {
    gap: 7px 10px !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    text-align: center;
    font-size: .72rem !important;
    padding: 10px 4px !important;
  }

  .site-legal-footer a {
    margin-top: 0 !important;
  }

  /* ---------- Shared SM / Elit page ---------- */
  .page-shell {
    width: calc(100% - 10px) !important;
    margin: 5px auto 18px !important;
    padding: 12px 8px 16px !important;
    border-radius: 14px !important;
    overflow: hidden;
  }

  .hero {
    min-height: 0 !important;
    padding: 8px 0 2px !important;
    gap: 5px !important;
  }

  .series-logo {
    width: min(165px, 58vw) !important;
    max-height: 95px !important;
  }

  .hero h1 {
    font-size: 1.65rem !important;
  }

  .season-line {
    margin-top: 2px !important;
    font-size: .82rem;
  }

  .series-switch,
  .category-tabs,
  .main-tabs {
    gap: 5px !important;
  }

  .series-switch {
    margin: 8px 0 10px !important;
  }

  .series-switch button {
    min-width: 0 !important;
    flex: 1 1 0;
    padding: 9px 12px !important;
    font-size: .9rem !important;
  }

  .category-tabs {
    margin-bottom: 14px !important;
  }

  .category-tabs button {
    padding: 8px 10px !important;
    font-size: .74rem !important;
  }

  .main-tabs {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    width: 100% !important;
    margin: 15px auto 17px !important;
    padding: 5px !important;
    border-radius: 13px !important;
  }

  .main-tabs button {
    min-width: 0;
    padding: 9px 3px !important;
    font-size: .76rem !important;
    line-height: 1.18;
    border-radius: 9px !important;
    overflow-wrap: anywhere;
  }

  .section-heading,
  .ranking-heading {
    gap: 8px !important;
    margin-bottom: 10px !important;
  }

  .section-heading h2 {
    font-size: 1.25rem !important;
  }

  .filter-row,
  .admin-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100%;
  }

  .filter-row label,
  .admin-grid label,
  .metric-picker {
    width: 100%;
  }

  .filter-row select,
  .admin-grid select,
  .admin-grid input,
  .metric-picker select {
    width: 100%;
    max-width: 100%;
  }

  .table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px !important;
  }

  .table-scroll table {
    min-width: 650px !important;
  }

  .players-panel {
    padding: 10px !important;
    margin-top: 14px !important;
    overflow-x: auto;
  }

  .admin-dock {
    top: 6px !important;
    right: 6px !important;
  }

  .admin-toggle,
  .logout-btn {
    min-width: 36px !important;
    min-height: 36px !important;
    padding: 6px 9px !important;
    font-size: .78rem;
  }

  .admin-login-panel {
    width: min(240px, calc(100vw - 54px)) !important;
  }
}

@media (max-width: 390px) {
  .tabs button,
  .division-tabs button,
  .main-tabs button {
    font-size: .7rem !important;
  }

  .league-division table,
  #ranking-container table,
  .players-section table,
  .table-scroll table {
    min-width: 610px !important;
  }
}
