/* The round console and its starting order screen (07-14, UI-SPEC section 3): court ladder, points
   shootout and king of the court. Existing tokens only, the 8-point spacing scale, 44px targets, a
   visible focus ring. Nothing is color alone: every state has a word or a glyph. The page is light. */

.rounds-page {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

.rounds-division {
  margin: 0 0 var(--space-md);
  color: var(--muted);
}

.round-print-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin: 0 0 var(--space-md);
}

.round-print-links:empty {
  display: none;
}

.round-print-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: 0 var(--space-sm);
}

.rounds-error {
  margin: 0 0 var(--space-md);
}

.rounds-banner-slot:empty {
  display: none;
}

.rounds-banner-slot {
  margin-bottom: var(--space-md);
}

/* ---- starting order ---- */

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

.round-start-heading,
.round-start-court {
  margin: 0;
}

.round-start-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.round-start-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.round-start .seed-row {
  grid-template-columns: 3ch minmax(0, 1fr) auto auto auto;
}

.round-start .seed-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* A phone has no room for the name, DUPR, place and arrows in one line: the name takes the row and
   the rating and place stack under it, with the arrows on the right at full size. */
@media (max-width: 480px) {
  .round-start .seed-row {
    grid-template-columns: 3ch minmax(0, 1fr) auto;
    row-gap: 0;
  }

  .round-start .seed-number {
    grid-column: 1;
    grid-row: 1;
  }

  .round-start .seed-name {
    grid-column: 2;
    grid-row: 1;
  }

  .round-start .seed-rating {
    grid-column: 2;
    grid-row: 2;
  }

  .round-start .round-start-place {
    grid-column: 2;
    grid-row: 3;
    min-width: 0;
  }

  .round-start .seed-arrows {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
  }
}

.round-standings-wrap .round-rule {
  margin-bottom: var(--space-sm);
}

.round-start-place {
  min-width: 96px;
  font-size: 14px;
  color: var(--muted);
}

.round-start-pairing {
  margin: 0;
  font-size: 16px;
}

.round-start-rule {
  color: var(--muted);
  font-size: 14px;
}

.round-start-group-players {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.round-start-problem {
  margin: 0;
}

.round-start-plan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-md);
  margin: 0;
}

.round-start-notin {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.round-start-notin-list {
  margin: 0;
  padding-left: var(--space-lg);
}

.round-start-order-heading {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.round-start-actions .btnp:disabled,
.round-start-actions .btnp[aria-disabled='true'] {
  opacity: 1;
  color: var(--muted);
  border: 2px solid var(--muted);
  background: var(--tint);
  cursor: not-allowed;
}

.round-start-actions {
  display: flex;
  gap: var(--space-sm);
}

.round-start-actions .btnp {
  min-height: 44px;
}

/* ---- tabs (the Phase 6 tab pattern) ---- */

.round-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.round-tab {
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-sm) var(--space-md);
  font: inherit;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--line);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
}

.round-tab:hover {
  background: var(--tint);
}

.round-tab[aria-selected="true"] {
  background: var(--tint);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.round-tab:focus-visible,
.round-swap-button:focus-visible,
.round-played summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- the round panel ---- */

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

.round-heading {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
}

.round-meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.round-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 768px) {
  .round-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.round-card {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 96px;
  padding: var(--space-md);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.round-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.round-card-court {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 600;
}

.round-card-state {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--muted);
}

.round-side {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-sm);
}

.round-side-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 16px;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.round-side.bm-winner .round-side-name {
  font-weight: 600;
}

.round-side-name svg {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--accent);
}

.round-side-score {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  display: inline-flex;
  gap: var(--space-sm);
}

.round-markers {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  margin: 0;
  padding: 0;
  list-style: none;
}

.movement-marker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}

.movement-marker svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.movement-marker-who {
  color: var(--muted);
}

.round-card-marks {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  font-size: 14px;
  line-height: 1.45;
}

.round-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-sm);
}

.round-swap-button {
  min-height: 44px;
  min-width: 44px;
}

.round-swap-slot:empty {
  display: none;
}

.round-swap {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tint);
}

.round-swap select {
  min-height: 44px;
  font: inherit;
}

/* ---- a court of games (court groups and the river formats) ---- */

.round-court-card {
  min-height: 0;
}

.round-games {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.round-game {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
}

.round-game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.round-game-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.round-game-sits {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---- planned rounds ---- */

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

.round-plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-md);
}

.round-plan-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.round-plan-round {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.round-plan-round summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  cursor: pointer;
}

.round-plan-round summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.round-plan-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0;
  padding: 0 var(--space-md) var(--space-md) var(--space-lg);
}

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

.round-waiting h3,
.round-sitting h3 {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.round-waiting h3 svg {
  width: 16px;
  height: 16px;
}

.round-waiting ol {
  margin: 0;
  padding-left: var(--space-lg);
  color: var(--muted);
}

.round-sitting {
  margin: 0;
  color: var(--ink);
}

.round-notice {
  margin: 0 0 var(--space-md);
}

/* ---- standings ---- */

.round-standings-wrap {
  /* Containing block for the .sr-only spans in the rows: static, they sit past the scroll edge and widen the page. */
  position: relative;
  overflow-x: auto;
}

.round-standings-wrap:focus-visible,
.round-panel-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.round-standings .num,
.round-standings .rank {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.round-standings thead th {
  background: var(--tint);
}

.round-standings .round-bye,
.round-standings .round-out {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

.round-out-button {
  min-height: 44px;
  min-width: 44px;
  white-space: nowrap;
}

.round-out-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.round-standings .round-out {
  font-weight: 600;
  color: var(--ink);
}

.round-standings-actions {
  text-align: right;
}

.round-players-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.round-players-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  cursor: pointer;
}

.round-players-details summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.round-players-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0;
  padding: 0 var(--space-md) var(--space-md);
  list-style: none;
}

.round-player {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-md);
}

.round-player-name {
  flex: 1 1 140px;
  overflow-wrap: anywhere;
}

.round-player-status {
  min-width: 96px;
  font-size: 14px;
  color: var(--muted);
}

.round-players .round-out-slot {
  padding: 0 var(--space-md) var(--space-md);
}

.round-out-slot:empty {
  display: none;
}

.round-out-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* The chevron marks a collapsed section; it turns when the section is open, with no transition. */
.round-summary-chevron {
  flex: none;
  width: 20px;
  height: 20px;
}

.round-plan-round[open] > summary .round-summary-chevron,
.round-players-details[open] > summary .round-summary-chevron,
.round-played[open] > summary .round-summary-chevron {
  transform: rotate(90deg);
}

/* ---- rounds played ---- */

.round-played {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.round-played summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  cursor: pointer;
}

.round-played-list {
  margin: 0;
  padding: 0 var(--space-md) var(--space-md);
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.round-played-match {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-md);
}

.round-played-court {
  min-width: 72px;
  color: var(--muted);
  font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
  .round-tab,
  .round-card {
    transition: none;
  }
}

/* ---- the plan of every round, undo and reset (25-20) ---- */

.round-plan-controls,
.round-reset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.round-plan-action,
.round-plan-swap-button,
.round-reset-button {
  min-height: 44px;
  min-width: 44px;
}

.round-plan-action:focus-visible,
.round-plan-swap-button:focus-visible,
.round-reset-button:focus-visible,
.round-plan-swap select:focus-visible,
.round-plan-error:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.round-plan-round .round-plan-swap-button {
  margin: 0 var(--space-md) var(--space-md);
}

.round-plan-swap-slot:empty,
.round-reset-slot:empty {
  display: none;
}

.round-plan-swap {
  margin: 0 var(--space-md) var(--space-md);
}

.round-plan-swap .field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.round-plan-stale,
.round-score-driven,
.round-plan-none,
.round-start-plan-none,
.round-penalty-line {
  margin: 0;
}

.round-reset {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.bm-timed {
  font-weight: 600;
}

/* 26-23: movement and fallback lines, the Bracket section and final places */
.round-standings-wrap .round-movement,
.round-standings-wrap .round-fallback {
  margin: 0 0 var(--space-2, 8px);
}
.round-bracket {
  margin-top: var(--space-5, 24px);
}
.round-bracket-seeds,
.round-places {
  margin: 0 0 var(--space-3, 12px);
  padding-left: var(--space-5, 24px);
}
.round-places {
  list-style: none;
  padding-left: 0;
}
.round-bracket-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.round-bracket-link:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 2px;
}

/* ---- ties board (27-23): the console for a team division. Light only, 44px targets, every state in words. ---- */
.ties-board .ties-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.ties-seeds,
.ties-short,
.ties-group,
.ties-standings {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.ties-short-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.ties-short-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  color: var(--warn);
  font-weight: 600;
}

.ties-draw {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: flex-start;
}

.ties-draw-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
}

.tie-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}

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

.tie-title {
  margin: 0;
  font-size: var(--fs-22);
}

.tie-title:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tie-meta {
  color: var(--muted);
  font-weight: 600;
}

.tie-score {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tie-status,
.tie-flag {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
  font-weight: 600;
}

.tie-flag {
  color: var(--warn);
}

.tie-lines {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.tie-line,
.tie-dreambreaker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-md);
  min-height: 44px;
  padding: var(--space-xs) 0;
  border-top: 1px solid var(--line);
}

.tie-line-name {
  min-width: min(11rem, 100%);
  overflow-wrap: anywhere;
}

.tie-line-pairs {
  color: var(--ink);
}

.tie-line-state {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 600;
}

.tie-line-score {
  font-variant-numeric: tabular-nums;
}

.tie-line-winner {
  font-weight: 700;
}

.tie-line-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
}

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

.tie-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: 0 var(--space-md);
  text-decoration: none;
}

.tie-action:focus-visible,
.ties-draw-button:focus-visible,
.tie-select:focus-visible,
.tie-form .forfeit-option input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.tie-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
}

.tie-form .reason-panel {
  position: static;
  width: auto;
  max-width: none;
  margin: 0;
}

.tie-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.tie-line-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--r-ctl);
}

.tie-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.tie-select {
  min-height: 44px;
  min-width: 14rem;
  padding: 0 var(--space-sm);
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--control);
  border-radius: var(--r-ctl);
}

.ties-standings {
  /* Five columns do not fit a phone at 200% text: the section scrolls instead of the page. */
  min-width: 0;
  overflow-x: auto;
}

.ties-standings:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ties-standings-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.ties-board .page-title {
  margin-bottom: var(--space-md);
}

/* A team name is a row header: it reads as a body cell in bold, not as a second column header. */
.ties-standings-table tbody th {
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.ties-standings-table th,
.ties-standings-table td {
  min-height: 44px;
  padding: var(--space-sm);
  border-top: 1px solid var(--line);
}
