/* Responsive mobile layout for the main Västeråsserien site and player profile. */
@media (max-width: 700px) {
  html,
  body {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
  }

  body {
    margin: 0 !important;
    padding: 0 !important;
  }

  body > .container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 10px 8px 18px !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  body > .card {
    width: calc(100% - 12px) !important;
    max-width: calc(100% - 12px) !important;
    min-width: 0 !important;
    margin: 6px auto 18px !important;
    padding: 18px 12px !important;
    border-radius: 14px !important;
  }

  .logo-container,
  .logo-link,
  .league-logo,
  .table-layout,
  .table-left,
  .section,
  .league-division,
  #ranking-container,
  .players-section,
  #schedule,
  .schedule-division,
  #sched-div1-table,
  #sched-div2-table,
  #sched-div3-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .logo-container,
  .league-division,
  #ranking-container,
  .players-section,
  .schedule-division,
  #sched-div1-table,
  #sched-div2-table,
  #sched-div3-table {
    overflow-x: visible !important;
  }

  .league-logo {
    height: auto !important;
    object-fit: contain !important;
  }

  /* Turn wide desktop tables into readable mobile cards. */
  .league-division table,
  #ranking-container table,
  .players-section table,
  #schedule .schedule-table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
    border: 0 !important;
    background: transparent !important;
    overflow: visible !important;
  }

  .league-division thead,
  #ranking-container thead,
  .players-section thead,
  #schedule .schedule-table thead {
    display: none !important;
  }

  .league-division tbody,
  #ranking-container tbody,
  .players-section tbody,
  #schedule .schedule-table tbody {
    display: grid !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .league-division tbody tr,
  #ranking-container tbody tr,
  .players-section tbody tr,
  #schedule .schedule-table tbody tr {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 2px 10px !important;
    padding: 9px 10px !important;
    border: 1px solid #dfe6ee !important;
    border-radius: 12px !important;
    background: #fff !important;
    box-shadow: 0 3px 10px rgba(20, 45, 72, .06) !important;
  }

  .league-division tbody td,
  #ranking-container tbody td,
  .players-section tbody td,
  #schedule .schedule-table tbody td {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    padding: 6px 2px !important;
    border: 0 !important;
    background: transparent !important;
    text-align: right !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    font-size: .82rem !important;
  }

  .league-division tbody td::before,
  #ranking-container tbody td::before,
  .players-section tbody td::before,
  #schedule .schedule-table tbody td::before {
    flex: 0 0 auto;
    color: #6b7785;
    font-size: .69rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    text-align: left;
  }

  /* League table labels. */
  .league-division tbody td:nth-child(1)::before { content: "Pos"; }
  .league-division tbody td:nth-child(2)::before { content: "Lag"; }
  .league-division tbody td:nth-child(3)::before { content: "Spelade"; }
  .league-division tbody td:nth-child(4)::before { content: "Vunna"; }
  .league-division tbody td:nth-child(5)::before { content: "Oavgjorda"; }
  .league-division tbody td:nth-child(6)::before { content: "Förlorade"; }
  .league-division tbody td:nth-child(7)::before { content: "Poäng"; }
  .league-division tbody td:nth-child(8)::before { content: "V / F"; }
  .league-division tbody td:nth-child(2) {
    grid-column: 1 / -1 !important;
    font-weight: 700 !important;
    color: #1f3a5f !important;
    font-size: .94rem !important;
  }

  /* Ranking table labels. */
  #ranking-container tbody td:nth-child(1)::before { content: "Pos"; }
  #ranking-container tbody td:nth-child(2)::before { content: "Spelare"; }
  #ranking-container tbody td:nth-child(3)::before { content: "Värde"; }
  #ranking-container tbody td:nth-child(2) {
    grid-column: 1 / -1 !important;
    font-weight: 700 !important;
    color: #1f3a5f !important;
  }

  /* Team player list labels. */
  .players-section tbody td:nth-child(1)::before { content: "Pos"; }
  .players-section tbody td:nth-child(2)::before { content: "Spelare"; }
  .players-section tbody td:nth-child(3)::before { content: "Spelade"; }
  .players-section tbody td:nth-child(4)::before { content: "Snitt"; }
  .players-section tbody td:nth-child(2) {
    grid-column: 1 / -1 !important;
    font-weight: 700 !important;
  }

  /* Normal schedule: 7 cells. */
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(1)::before { content: "Match"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(2)::before { content: "Datum"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(3)::before { content: "Tid"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(4)::before { content: "Hemma"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(5)::before { content: "Resultat"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(6)::before { content: "Lagpoäng"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(7)::before { content: "Borta"; }
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(4),
  #schedule .schedule-table tbody tr:not(:has(td:nth-child(8))) td:nth-child(7) {
    grid-column: 1 / -1 !important;
    font-weight: 700 !important;
    color: #1f3a5f !important;
  }

  /* Semi/final schedule: 8 cells. */
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(1)::before { content: "Omgång"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(2)::before { content: "Datum"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(3)::before { content: "Tid"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(4)::before { content: "Spelare 1"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(5)::before { content: "Spelare 2"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(6)::before { content: "Spelare 3"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(7)::before { content: "Spelare 4"; }
  #schedule .schedule-table tbody tr:has(td:nth-child(8)) td:nth-child(8)::before { content: "Trasseltjänst"; }

  .tabs,
  .division-tabs {
    max-width: 100% !important;
  }

  .week-selector,
  .week-selector select,
  #rankingMetric,
  #teamFilter {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  /* Player profile */
  body > .card h1 {
    font-size: 1.65rem !important;
    line-height: 1.2 !important;
  }

  body > .card .avatar img {
    width: 112px !important;
    height: 112px !important;
  }

  body > .card .section-title {
    font-size: .98rem !important;
    margin-top: 20px !important;
  }

  body > .card .stats-grid {
    width: 100% !important;
    min-width: 0 !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  body > .card .stat {
    min-width: 0 !important;
    padding: 11px 10px !important;
    gap: 7px !important;
    font-size: .82rem !important;
    overflow-wrap: anywhere !important;
  }

  body > .card .stat strong {
    flex: 0 0 auto;
    font-size: .95rem !important;
  }

  .trend-panel,
  .trend-chart-wrap,
  #trendChart {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .trend-chart-wrap {
    overflow-x: hidden !important;
  }

  #trendChart {
    height: auto !important;
  }
}

@media (max-width: 420px) {
  body > .card .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .league-division tbody tr,
  #ranking-container tbody tr,
  .players-section tbody tr,
  #schedule .schedule-table tbody tr {
    grid-template-columns: 1fr !important;
  }

  .league-division tbody td:nth-child(2),
  #ranking-container tbody td:nth-child(2),
  .players-section tbody td:nth-child(2),
  #schedule .schedule-table tbody td {
    grid-column: 1 !important;
  }
}
