.collapsible-header,
.standings__group-header {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  border-radius: 8px;
  font-family: "Mali", "IBM Plex Sans", sans-serif;
}
.standings__group-header-icons {
  position: relative;
  float: right;
}
.season-finished-true {
  background: #eef2f7;
  color: #6b7280;
}
[data-theme="dark"] .season-finished-true {
  background: #1f2937;
  color: #9ca3af;
}
.collapsible-content {
  display: none;
}
.collapsible-header.is-open + .collapsible-content {
  display: block;
}
.standings__group-content {
  display: none;
}
.standings__group-header.is-open + .standings__group-content {
  display: block;
}

.rank-badge {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--brand);
  color: #053b39;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.rank-1 .rank-badge {
  background: var(--gold);
}
.rank-2 .rank-badge {
  background: var(--silver);
}
.rank-3 .rank-badge {
  background: var(--bronze);
}

.rank-1 .player-name::before,
.rank-1 td.name-col::before {
  content: "🥇 ";
}
.rank-2 .player-name::before,
.rank-2 td.name-col::before {
  content: "🥈 ";
}
.rank-3 .player-name::before,
.rank-3 td.name-col::before {
  content: "🥉 ";
}

.player-name {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
th.name-col,
td.name-col {
  width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0.75rem 0;
}

td.games.incomplete-true {
  outline: none;
  color: var(--warn);
  font-weight: bold;
}

.standings-container {
  width: 500px;
}

.flexcontainer,
.standings__groups {
  display: flex;
  flex-wrap: wrap;
  column-gap: 30px;
  justify-content: center;
}
.standings__group {
  min-width: 240px;
}

.player-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin: 1rem 0;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}
[data-theme="dark"] .player-card {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}
.player-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.player-card__eyebrow {
  margin: 0 0 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
}
.player-card__name {
  margin: 0;
  letter-spacing: 0.3px;
}
.player-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--brand);
  color: var(--brand-ink);
  border: 1px solid transparent;
  font-weight: 700;
  white-space: nowrap;
}
.player-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.player-card__item {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.player-card__label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}
.player-card__value {
  font-weight: 700;
  letter-spacing: 0.2px;
}
.player-card__tables {
  margin-top: 1rem;
}

#gamestable tr.session-row > td[data-title]::before {
  content: attr(data-title);
  display: block;
  color: var(--fg);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

#gamestable tr.session-row > td[data-title] {
  color: var(--muted);
}

/* Mobile: stack table rows into cards */
@media (max-width: 720px) {
  #gamestable thead {
    display: none;
  }

  #gamestable > table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  #gamestable > table > tbody {
    display: block;
  }

  #gamestable tr.session-row {
    display: block;
    margin: 0.5rem 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg);
  }

  #gamestable tr.session-row > td {
    display: block;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
  }

  #gamestable tr.session-row > td:last-child {
    border-bottom: 0;
  }

  /* Session header cell as a section header */
  #gamestable td.cell[colspan] {
    background: var(--card);
    color: var(--fg);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
  }
}

.game-details {
  text-align: left;
}

.game-details-container {
  background: transparent;
  border: 0;
}

tr.game-details-container {
  background: transparent;
}

td.game-details-container {
  padding: 0;
  border: 0;
  text-align: center;
}

td.game-details-container > .game-details {
  display: inline-block;
  max-width: min(100%, 60rem);
  margin: 1.5rem auto;
  padding: 1.5rem;
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  line-height: 1.5;
}

.game-details table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.game-details th,
.game-details td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.game-details th + th,
.game-details td + td {
  border-left: 1px solid var(--border);
}

.game-details thead th {
  background: var(--card);
  color: var(--fg);
}

.game-details tbody tr:last-child td {
  border-bottom: 0;
}

[data-theme="dark"] td.game-details-container > .game-details {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.65);
}

td.game-details-container > .game-details:empty {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.session-header,
.session-table__header {
  font-weight: bold;
  text-align: center;
  background: var(--brand);
  color: var(--brand-ink);
  font-family: "Mali", "IBM Plex Sans", sans-serif;
}

tbody > tr:nth-child(odd of .session-row) {
  background: var(--row-odd, transparent);
}
tbody > tr:nth-child(even of .session-row) {
  background: var(--row-even, rgba(0, 0, 0, 0.02));
}
#gamestable table {
  border-collapse: collapse;
}

#gamestable th,
#gamestable td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

#gamestable th + th,
#gamestable td + td {
  border-left: 1px solid var(--border);
}
#gamestable thead th {
  background: var(--card);
  color: var(--fg);
}
#gamestable tbody tr:last-child td {
  border-bottom: 0;
}

#tables-table td {
  padding: 0.4rem 0.8rem;
}

#tables-table .game-details-container td {
  padding: 0;
}

#tables-table .game-details-container .game-details td {
  padding: 0.4rem 0.8rem;
}

#tables-table .game-details-container .game-details table {
  border: 1px solid var(--border);
}

/* Tabs */
#gamestable .tabs,
.standings__tabs {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  margin: 3rem 0 1.5rem;
  padding: 0 0.5rem;
  background: #fdf0c1;
  border-top: 0.25rem solid #e8d48f;
}

[data-theme="dark"] #gamestable .tabs,
[data-theme="dark"] .standings__tabs {
  background: #8b6a28;
  border-top-color: #6f5420;
}

#gamestable .tab,
.standings__tab {
  display: block;
  line-height: 2.75em;
  height: 3em;
  padding: 0 1.5em;
  background: #fdf0c1;
  cursor: pointer;
  position: relative;
  top: 0;
  transition: all 0.25s;
  font-weight: 700;
  text-decoration: none;
}

[data-theme="dark"] #gamestable .tab,
[data-theme="dark"] .standings__tab {
  background: #8b6a28;
  border-right-color: #6f5420;
  color: #e5e7eb;
}

#gamestable .tab:hover,
.standings__tab:hover {
  text-decoration: underline dashed currentColor;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.5em;
}

#gamestable .tab-active,
.standings__tab--active {
  background: var(--bg);
  color: #2c3e50;
  border-bottom: 0;
  z-index: 1;
}

[data-theme="dark"] #gamestable .tab-active,
[data-theme="dark"] .standings__tab--active {
  background: var(--bg);
  color: #e5e7eb;
  border-right-color: #111827;
}
