html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  padding: 0 !important;
}

.layout-app {
  width: min(1450px, 100%);
  margin: 0 auto;
  padding: 10px;
  box-sizing: border-box;
}

:root {
  --desktop-sidebar-width: 260px;
  --desktop-tabs-top-gap: 50px;
  --desktop-main-panel-gap: 60px;
}

.layout-app,
.sidebar-left,
.main-panel,
.contenido,
.seccion-tabla,
.seccion-partidos,
#partidos-container,
.fixture-header,
.match-card,
.match-teams-col,
.team-home,
.team-away,
.team-name-cell,
.league-banner,
.league-banner-center {
  min-width: 0;
}

/* Prevent standings table from overflowing viewport */
.seccion-tabla {
  overflow-x: hidden;
  max-width: 100%;
}

.standings-table {
  max-width: 100%;
}

.menu-ligas {
  width: 100%;
  box-sizing: border-box;
}

.site-header {
  min-height: var(--desktop-tabs-top-gap);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-title-link {
  color: inherit;
  text-decoration: none;
}

.home-title-link:hover,
.home-title-link:focus-visible {
  text-decoration: underline;
}

.tab-btn {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.league-title {
  text-wrap: balance;
}

.section-heading {
  margin-bottom: 10px;
}

.standings-table {
  width: 100%;
  table-layout: fixed;
}

.standings-table th,
.standings-table td {
  padding: 5px 3px;
}

.standings-table th:nth-child(1),
.standings-table td:nth-child(1) {
  width: 28px;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  width: auto;
}

.standings-table th:nth-child(n + 3),
.standings-table td:nth-child(n + 3) {
  width: 38px;
}

.team-name-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  text-align: left;
}

.team-name-text,
.team-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standings-group-row td {
  text-align: center;
  font-weight: bold;
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--accent-color);
  padding: 6px;
}

.standings-rank-cell {
  width: 28px;
  padding-right: 8px !important;
}

.standings-points-cell strong {
  color: var(--accent-color);
}

#partidos-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-group {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
}

/* <details> reset */
.match-group[open] > .match-group-list {
  display: flex;
}

.match-group-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--accent-color);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

/* Hide default browser marker */
.match-group-title::-webkit-details-marker { display: none; }
.match-group-title::marker { display: none; }

/* Chevron indicator */
.match-group-title::after {
  content: ' ▾';
  font-size: 0.85em;
  transition: transform 0.2s;
  display: inline-block;
}

details.match-group:not([open]) > .match-group-title::after {
  transform: rotate(-90deg);
}

.match-group-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-group .match-card {
  background-color: var(--bg-color);
  margin-bottom: 0;
}

.match-card {
  gap: 10px;
  padding: 10px 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.match-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 10px;
}

.match-scorers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 2px 0 0 0;
  border-top: 1px solid var(--border-color);
}

.scorers-home {
  text-align: right;
  padding-right: 4px;
}

.scorers-away {
  text-align: left;
  padding-left: 4px;
}

.scorer-item {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scorer-min {
  color: var(--text-color);
  font-size: 0.6rem;
}

.match-date-col {
  flex: 0 0 78px;
  min-width: 0;
  text-align: center;
  border-right: 1px solid var(--border-color);
  padding-right: 10px;
}

.match-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.match-time {
  font-weight: bold;
  color: var(--text-color);
  font-size: 0.95rem;
}

.match-league-label {
  margin-top: 2px;
  font-size: 0.65rem;
  color: var(--accent-color);
}

.match-teams-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.team-home,
.team-away {
  display: flex;
  align-items: center;
  gap: 6px;
}

.team-home {
  justify-content: flex-end;
  text-align: right;
}

.team-away {
  justify-content: flex-start;
  text-align: left;
}

.team-badge {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.match-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 58px;
}

.vs-text {
  font-weight: bold;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.score-box {
  font-weight: bold;
  background-color: var(--bg-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.match-status-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
}

.match-center .match-status-note {
  color: #fff;
  font-weight: bold;
}

.badge-live {
  color: var(--live-color);
  font-weight: bold;
  font-size: 0.6rem;
  animation: pulse 1.5s infinite;
}

.fixture-header {
  flex-wrap: wrap;
}

.fixture-select {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 900px) {
  .site-header {
    min-height: auto;
  }

  .layout-app {
    grid-template-columns: 1fr !important;
  }

  .sidebar-left {
    position: relative !important;
    top: 0 !important;
  }

  .menu-ligas {
    margin-top: 0 !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    justify-content: center;
    gap: 6px !important;
  }

  .tab-btn {
    width: auto !important;
    flex: 1 1 150px;
    justify-content: center;
    text-align: center;
  }

  .league-banner {
    display: flex !important;
    justify-content: center;
  }

  .contenido.liga-view {
    flex-direction: column !important;
  }
}

@media (min-width: 901px) {
  .layout-app {
    grid-template-columns: var(--desktop-sidebar-width) minmax(0, 1fr);
    column-gap: var(--desktop-main-panel-gap);
  }

  .sidebar-left {
    gap: 0;
  }

  .site-header h1 {
    font-size: calc(1.5rem + 2pt);
    margin-bottom: 4px;
  }

  .site-header {
    height: var(--desktop-tabs-top-gap);
    min-height: 0;
  }

  .site-header .subtitle {
    font-size: calc(0.8rem + 2pt);
  }

  .menu-ligas {
    margin-top: 49px;
  }

  .main-panel {
    padding-top: var(--desktop-tabs-top-gap);
    margin-top: 0;
  }

  .league-banner {
    margin-bottom: 15px;
  }

  .contenido.liga-view {
    flex-direction: row;
    column-gap: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.7fr);
    padding-left: 0;
    box-sizing: border-box;
  }

  .contenido.liga-view .seccion-tabla,
  .contenido.liga-view .seccion-partidos {
    min-width: 0;
  }

  .contenido.liga-view .seccion-tabla,
  .contenido.liga-view .seccion-partidos {
    margin-top: 0;
  }
}

@media (min-width: 1200px) {
  /*
   * The home fixture is centered against the viewport rather than only the
   * space to the right of the sidebar. The fixture's max-width leaves room
   * between it and the sidebar after this visual shift.
   */
  .main-panel.home-view .league-banner,
  .main-panel.home-view #contenedor-principal {
    transform: translateX(
      calc((var(--desktop-sidebar-width) + var(--desktop-main-panel-gap)) / -2)
    );
  }
}

@media (max-width: 640px) {
  .layout-app {
    padding: 8px 12px !important;
  }

  .menu-ligas {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    flex-wrap: unset !important;
    overflow: visible !important;
    overflow-x: unset !important;
    justify-content: unset !important;
    padding: 6px !important;
    gap: 4px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .tab-btn {
    flex: unset !important;
    width: 100% !important;
    white-space: normal !important;
    min-height: 32px;
    padding: 5px 8px !important;
    font-size: 0.68rem !important;
    justify-content: center;
    text-align: center;
  }

  .league-title {
    font-size: 1rem !important;
  }

  .fixture-header {
    gap: 6px;
    padding: 6px 8px !important;
  }

  .fixture-btn {
    flex: 1 1 110px;
    min-width: 0;
    font-size: 0.68rem !important;
  }

  .fixture-select {
    order: 2;
    flex: 1 1 100%;
    font-size: 0.7rem !important;
  }

  .standings-table {
    font-size: 0.68rem !important;
  }

  .standings-table th,
  .standings-table td {
    padding: 4px 2px;
  }

  .standings-table th {
    font-size: 0.62rem !important;
  }

  .standings-table th:nth-child(1),
  .standings-table td:nth-child(1) {
    width: 20px;
  }

  .standings-table th:nth-child(2),
  .standings-table td:nth-child(2) {
    width: 96px;
  }

  .standings-table th:nth-child(n + 3),
  .standings-table td:nth-child(n + 3) {
    width: 28px;
  }

  .team-name-cell {
    gap: 4px;
  }

  .team-badge {
    width: 16px;
    height: 16px;
  }

  .team-name-text,
  .team-name {
    font-size: 0.68rem;
  }

  .team-name-text {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.15;
  }

  .team-name {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.15;
  }

  .match-group {
    padding: 10px;
  }

  .match-group-title {
    font-size: 0.88rem;
  }

  .match-card {
    gap: 8px;
    padding: 8px;
  }

  .match-date-col {
    flex-basis: 64px;
    padding-right: 8px;
  }

  .match-date {
    font-size: 0.62rem;
  }

  .match-time {
    font-size: 0.82rem;
  }

  .match-teams-col {
    gap: 6px;
  }

  .match-body {
    padding-left: 8px;
  }

  .team-home,
  .team-away {
    gap: 4px;
  }

  .match-center {
    min-width: 48px;
  }

  .match-scorers {
    font-size: 0.58rem;
    gap: 2px;
  }

  .scorer-item {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.15;
  }

  .vs-text {
    font-size: 0.62rem;
  }

  .score-box {
    font-size: 0.72rem;
    padding: 2px 4px;
  }

  .match-status-note,
  .badge-live,
  .match-league-label {
    font-size: 0.54rem;
  }
}
