.match {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-width: 960px;
  margin: 0 auto;
}

.match__header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
}

.match__title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.match__actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.match__teams {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.match__team {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.match__team--winner {
  border-color: var(--color-accent);
}

.match__team-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.match__team-result {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.match__team-summary {
  margin: calc(-1 * var(--space-sm)) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.match__team--winner .match__team-result {
  color: var(--color-accent);
}

/* Horizontal-scroll guard so the table never wraps on narrow screens. */
.match__roster-scroll {
  overflow-x: auto;
}

.match__roster {
  display: grid;
  grid-template-columns:
    minmax(150px, 1.7fr)
    repeat(2, minmax(56px, 0.9fr))
    repeat(2, minmax(54px, 0.8fr))
    repeat(2, minmax(70px, 0.9fr));
  min-width: 520px;
  column-gap: var(--space-md);
}

/* Header + each player row span all columns and inherit the parent's tracks
   (subgrid), so every cell lines up regardless of content width. */
.match__roster-head,
.match__roster-item {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  column-gap: var(--space-md);
}

.match__roster-item {
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border);
}

.match__roster-item:hover {
  background: var(--color-bg);
}

.match__col {
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: right;
  padding-bottom: var(--space-xs);
}

.match__player {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
}

.match__player-pos {
  font-size: 12px;
  color: var(--color-muted);
  flex-shrink: 0;
}

.match__cell {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

/* The two ELO cells stack their value + signed delta and right-align together. */
.match__elo-cell {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: var(--space-xs);
}

.match__stat {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-xs);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  white-space: nowrap;
}

.match__stat-label {
  color: var(--color-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.match__stat-value {
  font-weight: 500;
  color: var(--color-fg);
}

.match__elo {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--color-muted);
  font-size: 14px;
  min-width: 36px;
  text-align: right;
}

.match__elo-change {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  min-width: 36px;
  text-align: right;
}

.match__elo-change--gain {
  color: var(--color-flash-notice);
}

.match__elo-change--loss {
  color: var(--color-flash-alert);
}

.match__diff {
  font-variant-numeric: tabular-nums;
}

.match__diff--gain {
  color: var(--color-flash-notice);
}

.match__diff--loss {
  color: var(--color-flash-alert);
}

.match__roster-item:last-child {
  border-bottom: none;
}

.match__nickname {
  color: var(--color-fg);
  text-decoration: none;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.match__nickname:hover {
  text-decoration: underline;
}

.match-form {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.match-form__title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.match-form__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.match-form__date {
  width: max-content;
  min-width: 220px;
}

.match-form__lineup {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.match-form__toolbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

.match-form__sides {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

@media (min-width: 768px) {
  .match-form__sides {
    grid-template-columns: 1fr 1fr;
  }
}

.match-form__side {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.match-form__side-title {
  margin: 0 0 var(--space-sm);
  font-size: 16px;
  font-weight: 600;
}

.match-form__winner {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.match-form__winner-option {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.match__finish {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.match__finish-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.match__finish-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
