:root {
  --accent: #2446c9;
  --accent-dark: #1a3494;
  --ink: #101828;
  --muted: #5b6474;
  --border: #e3e6ec;
  --bg: #f5f6f8;
  --nav-bg: #0e1726;
  --nav-ink: #c9d1de;
  --nav-muted: #9aa6b8;
  --nav-active: #1f2c44;
  --danger-bg: #fdf0e3;
  --danger-ink: #8a3b06;
  --ok-bg: #e8edfc;
  --ok-ink: #1a3494;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-dark);
}

.num {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.btn-primary {
  border: none;
  background: var(--accent);
  color: #fff;
}

.btn:disabled {
  background: #c9d0dc;
  color: #344054;
  border: none;
  cursor: not-allowed;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}

.input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f3;
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}

.badge-warn {
  background: var(--danger-bg);
  color: var(--danger-ink);
}

.badge-muted {
  background: var(--border);
  color: var(--muted);
}

.error-banner {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid #f3d8bb;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* Dashboard shell: dark sidebar + main content, matching docs/design/td-console-mockup */
.shell {
  display: flex;
  flex-wrap: wrap;
  min-height: 100vh;
}

.sidebar {
  flex: 1 1 240px;
  max-width: 100%;
  background: var(--nav-bg);
  color: var(--nav-ink);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-sizing: border-box;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}

.sidebar .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.sidebar .brand-name {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.sidebar .brand-sub {
  font-size: 12px;
  color: var(--nav-muted);
}

.navlink {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--nav-ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.navlink:hover {
  background: #1a2538;
  color: #fff;
}

.navlink.active {
  background: var(--nav-active);
  color: #fff;
}

.navlink-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.main {
  flex: 999 1 560px;
  min-width: 0;
  padding: 28px 36px 48px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--ink);
  border-bottom: 2px solid var(--accent);
}

.result-btn {
  min-width: 52px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: #344054;
}

.result-btn.selected {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

/* Branding: the real logo file (docs/design/assets/logo.png, copied to web/img/logo.png) is a
   wide horizontal lockup with built-in whitespace padding around the mark -- rather than risk
   cropping it blind (no image-processing tool available in this environment to verify exact
   content bounds), it's constrained to a fixed height everywhere it appears; its 2079:756 aspect
   ratio means a small height naturally keeps the rendered width small too, so this looks right at
   both header scale and the dashboard sidebar's narrower column without separate treatment. */
.logo-img {
  height: 36px;
  width: auto;
  display: block;
}

/* The logo PNG has a solid white (non-transparent) background baked in -- confirmed via
   `sips --getProperty hasAlpha` (no alpha channel) -- so on the dark sidebar/footer it needs an
   explicit light "plate" behind it rather than sitting directly on the dark surface. A CSS color
   filter can't fix this either: brightness(0) then invert(1) would turn the whole image (mark AND
   its white background alike) solid white, erasing the logo's shape rather than recoloring it. */
.logo-plate {
  display: inline-flex;
  background: #fff;
  border-radius: 8px;
  padding: 4px 10px;
}

.sidebar .logo-img {
  height: 22px;
}

/* Homepage specific */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-wrap: wrap;
}

.site-header .main-nav {
  display: flex;
  gap: 24px;
  font-size: 14px;
  font-weight: 600;
  flex-wrap: wrap;
}

.site-header .main-nav a {
  color: var(--ink);
  text-decoration: none;
}

.site-header .main-nav a:hover,
.site-header .main-nav a.active {
  color: var(--accent);
}

.site-header .auth-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero {
  position: relative;
  padding: 56px 32px 64px;
  overflow: hidden;
  /* No real event photo available in this environment -- a dark gradient over a faint CSS-only
     checkered texture approximates the mockup's blurred chess-board photo without depending on an
     external image URL that might not load. Swapping in a real photo asset later only means
     changing this one background rule. */
  background:
    linear-gradient(180deg, rgba(14, 23, 38, 0.86), rgba(14, 23, 38, 0.92)),
    repeating-conic-gradient(#1b2740 0% 25%, #141d30 0% 50%) 50% / 46px 46px;
  color: #fff;
}

.hero h1 {
  font-size: 40px;
  margin: 0 0 12px;
  max-width: 640px;
}

.hero .annotation {
  position: absolute;
  top: 26px;
  right: 40px;
  max-width: 260px;
  font-family: 'Caveat', cursive;
  font-size: 26px;
  line-height: 1.3;
  color: #9db8f5;
  transform: rotate(-5deg);
  text-align: right;
}

.search-bar {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 24px;
  color: var(--ink);
  position: relative;
}

.search-bar label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  flex: 1 1 180px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 16px 32px 0;
  font-size: 13px;
}

.chip-row .chip-label {
  color: var(--muted);
  font-weight: 600;
}

.chip {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 13px;
  font-weight: 600;
  border: none;
}

.chip:hover {
  background: #d6def8;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  padding: 32px;
  margin-top: 16px;
  background: #eef2fb;
}

.feature-row .feature {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feature-row .feature .icon {
  font-size: 26px;
  line-height: 1;
}

.feature-row .feature strong {
  font-size: 15px;
}

.feature-row .feature span {
  font-size: 13px;
  color: var(--muted);
}

.tournament-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 0 32px 32px;
}

.tournament-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tournament-card .media {
  position: relative;
}

.tournament-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: #eee;
  display: block;
}

.tournament-card .date-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  text-align: center;
  line-height: 1.15;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.25);
}

.tournament-card .date-badge .month {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
}

.tournament-card .date-badge .day {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.tournament-card .date-badge .weekday {
  font-size: 11px;
  color: var(--muted);
}

.tournament-card .body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-pill {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 11px;
  font-weight: 600;
}

.split-cta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 32px;
}

.split-cta .col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.split-cta .col .icon {
  font-size: 22px;
}

.split-cta .col .actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.site-footer {
  background: var(--nav-bg);
  color: var(--nav-muted);
  padding: 28px 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.site-footer .footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}


.site-footer .footer-links {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.site-footer .footer-links a {
  color: var(--nav-ink);
  text-decoration: none;
}

.site-footer .footer-links a:hover {
  color: #fff;
}

.signin-wrap {
  max-width: 480px;
  margin: 64px auto;
  padding: 0 20px;
}

.signin-wrap .card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: 28px;
  }
  .main {
    padding: 20px;
  }
}

/* Confirmation modal (showConfirmDialog in js/shared.js). */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, 0.5);
  z-index: 1000;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: min(480px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.25);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 18px;
}

.modal-message {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.45;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-danger {
  background: #b42318;
}

/* Pairing tables: points before the round, and colors played so far. */
.pts {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.color-history {
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  letter-spacing: 1px;
}

/* Wallchart */
.wc-legend {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.wc-scroll {
  overflow-x: auto;
}

.wc-table td,
.wc-table th {
  white-space: nowrap;
}

.wc-table td.wc-round {
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.wc-table td.wc-proposed {
  font-style: italic;
  color: var(--muted);
}

.wc-chip {
  display: inline-block;
  min-width: 18px;
  padding: 0 4px;
  margin-left: 4px;
  border: 1px solid #98a2b3;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.wc-white {
  background: #fff;
  color: var(--ink);
}

.wc-black {
  background: #1d2433;
  border-color: #1d2433;
  color: #fff;
}

.wc-withdrawn td {
  color: var(--muted);
}

/* Entries / Rounds tabs inside a section */
.subtabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.subtab {
  min-height: 34px;
  padding: 0 18px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.subtab.active {
  background: var(--accent);
  color: #fff;
}

/* Rounds list: each row expands in place */
.round-row {
  cursor: pointer;
}

.round-row:hover td {
  background: #f9fafb;
}

.round-row.expanded td {
  background: var(--ok-bg);
  border-bottom-color: transparent;
}

.chevron {
  display: inline-block;
  width: 16px;
  color: var(--muted);
}

.round-detail-row > td {
  padding: 0 0 20px;
  background: var(--ok-bg);
}

.round-detail {
  margin: 0 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  min-width: 0;
}

.round-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.round-tab {
  padding: 8px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.round-tab.active {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

.round-pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.wc-table .wc-current {
  background: #eef2ff;
}

/* Fixed layout so a wide wallchart inside an expanded round scrolls in its own box instead of
   stretching the rounds table (and the page) sideways. */
#roundsTable {
  table-layout: fixed;
}

#roundsTable > thead > tr > th:nth-child(1) { width: 18%; }
#roundsTable > thead > tr > th:nth-child(2) { width: 34%; }
#roundsTable > thead > tr > th:nth-child(3) { width: 22%; }
#roundsTable > thead > tr > th:nth-child(4) { width: 26%; }

/* Pairing and results tables: board/points columns shrink to their content, names get the
   room, and the three result buttons stay on one line as a single segmented control. */
.pairing-table th.col-narrow,
.pairing-table td.num:first-child,
.pairing-table td.pts {
  width: 1%;
  white-space: nowrap;
  padding-right: 20px;
}

.pairing-table th.col-result,
.pairing-table td.result-cell {
  width: 1%;
  white-space: nowrap;
}

.result-cell .result-btn {
  min-width: 48px;
  margin: 0;
  border-radius: 0;
}

.result-cell .result-btn + .result-btn {
  margin-left: -1px;
}

.result-cell .result-btn:first-child {
  border-radius: 8px 0 0 8px;
}

.result-cell .result-btn:last-child {
  border-radius: 0 8px 8px 0;
}

.result-cell .result-btn.selected {
  position: relative;
  z-index: 1;
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.pairing-table td {
  white-space: nowrap;
}

.round-status {
  margin: -6px 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 14px;
}

/* What this TD may do (dashboard applyAccess): hide what the server would refuse. */
body[data-access='results'] .needs-manage,
body[data-access='view'] .needs-manage {
  display: none !important;
}

body[data-access='view'] .result-btn {
  pointer-events: none;
  opacity: 0.6;
}

.access-notice {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 14px;
}

/* Standings: a cell per round, written as on the wallchart. */
.sr-cell {
  white-space: nowrap;
}

/* Entries: sortable headings, with an arrow on the sorted one; withdrawn players dimmed. */
th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable::after {
  content: attr(data-arrow);
  margin-left: 6px;
  font-size: 10px;
}

th.sortable:hover {
  color: var(--accent);
}

tr.entry-withdrawn td {
  color: var(--muted);
}

/* Edit pairings: a player's points before the round, at the front of their card. */
.slot-pts {
  display: inline-block;
  min-width: 26px;
  margin-right: 8px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  text-align: center;
}

/* Edit pairings: a board whose two players already met. */
.pairing-edit tr.repeat-board td {
  background: var(--danger-bg);
}

.repeat-warning {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger-ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* A board number the organizer or chief TD can click to move; everyone else sees plain text. */
.board-num-btn {
  font: inherit;
  padding: 2px 6px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.board-num-btn:hover {
  border-color: var(--accent);
}

.board-num-text {
  display: none;
}

body[data-access='results'] .board-num-text,
body[data-access='view'] .board-num-text {
  display: inline;
}

.result-btn-forfeit {
  min-width: 72px;
}

.round-start-board {
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
  font-size: 14px;
}

/* Printing (print-view.js): only the print area, as plain black-on-white tables. */
#printArea {
  display: none;
}

.round-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: -4px 0 14px;
}

.round-info,
.live-schedule {
  color: var(--muted);
  font-size: 14px;
}

.live-schedule {
  margin: -6px 0 12px;
}

@media print {
  html.printing body > *:not(#printArea) {
    display: none !important;
  }

  html.printing body {
    background: #fff;
  }

  html.printing #printArea {
    display: block;
    color: #000;
    font-size: 11pt;
  }

  #printArea h1 {
    margin: 0 0 4px;
    font-size: 18pt;
  }

  #printArea .print-line {
    margin: 0 0 2px;
  }

  #printArea h2 {
    margin: 10px 0 8px;
    font-size: 14pt;
  }

  #printArea table {
    width: 100%;
    border-collapse: collapse;
  }

  #printArea th,
  #printArea td {
    padding: 4px 6px;
    border-bottom: 1px solid #999;
    color: #000;
    background: none !important;
  }

  #printArea tr {
    break-inside: avoid;
  }

  #printArea thead {
    display: table-header-group;
  }

  /* The posted pairing sheet (printPairingSheet). */
  #printArea .pairing-sheet .ps-header {
    text-align: center;
    margin-bottom: 14px;
  }

  #printArea .pairing-sheet .ps-header h1 {
    font-size: 18pt;
    margin: 0 0 4px;
  }

  #printArea .pairing-sheet .ps-header p {
    margin: 0 0 4px;
    font-size: 14pt;
  }

  #printArea .ps-table,
  #printArea .ps-table th,
  #printArea .ps-table td {
    border: 1.5px solid #000;
  }

  #printArea .ps-table th {
    background: #d9d9d9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 2px 8px;
    font-size: 10.5pt;
  }

  #printArea .ps-table td {
    height: 30pt;
    padding: 0 8px;
    font-size: 10.5pt;
  }

  #printArea .ps-board {
    width: 9%;
    text-align: left;
  }

  #printArea .ps-box {
    width: 10%;
    text-align: center;
    font-weight: 600;
  }

  #printArea .ps-white {
    text-align: left;
  }

  #printArea .ps-black {
    text-align: right;
  }
}

/* Why the engine paired a round this way -- TDs only, never the public page. */
.pairing-notes {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
}

.pairing-notes summary {
  cursor: pointer;
  font-weight: 600;
}

.pairing-notes .pairing-notes-who {
  font-weight: 400;
  color: var(--muted);
}

.pairing-notes .pairing-notes-group {
  margin: 12px 0 0;
  font-weight: 600;
  color: var(--muted);
}

.pairing-notes ul {
  margin: 10px 0 2px;
  padding-left: 20px;
}

.pairing-notes li + li {
  margin-top: 6px;
}

@keyframes row-changed-flash {
  from { background: #fff4c2; }
  to { background: transparent; }
}

.pairing-table tr.row-changed td {
  animation: row-changed-flash 2.5s ease-out;
}

/* Public pages: Live Result and the pre-launch coming-soon page */
.public-page .site-header .logo-img {
  height: 28px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fdecec;
  color: #b42318;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d92d20;
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

.live-badge.is-final {
  background: #e7f6ec;
  color: #1a7f37;
}

.live-badge.is-final .live-dot {
  background: #1a7f37;
  animation: none;
}

.live-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.live-title {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
}

.live-updated {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.live-message {
  color: var(--muted);
  font-size: 15px;
}

#liveContent {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#liveContent[hidden] {
  display: none;
}

.live-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.round-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.round-picker[hidden] {
  display: none;
}

.round-chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.round-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.live-view-heading {
  margin: 0 0 12px;
  font-size: 18px;
}

.live-view-heading:empty {
  display: none;
}

.live-result {
  text-align: center;
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-weight: 600;
  white-space: nowrap;
}

.live-pending {
  color: var(--muted);
  font-weight: 400;
}


.coming-soon {
  max-width: 640px;
  margin: 0 auto;
  padding: 72px 16px;
  text-align: center;
}

.coming-soon h1 {
  font-size: clamp(26px, 5vw, 38px);
  margin: 0 0 16px;
}

.coming-soon p {
  color: var(--muted);
  line-height: 1.6;
}

.coming-soon-td {
  margin-top: 32px;
  font-size: 14px;
}

@media (max-width: 600px) {
  .site-header {
    padding: 12px 16px;
  }
}

/* A small form inside the confirmation modal (e.g. Add bye) */
.modal-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  white-space: normal;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.modal-form .input {
  width: 100%;
}

/* Byes on the Entries tab */
.byes-cell {
  white-space: nowrap;
}

.bye-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--danger-bg);
  color: var(--danger-ink);
  font-size: 12px;
  font-weight: 600;
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

.btn-small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

.bye-editor {
  gap: 8px;
}

.bye-editor-row {
  display: grid;
  grid-template-columns: 1fr 140px 92px;
  gap: 10px;
  align-items: center;
}

.bye-editor-row.is-locked {
  color: var(--muted);
}

.bye-editor-round {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.bye-editor-note {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

/* A result shown on the players: 1 / ½ / 0 badge, winner bold, loser dimmed */
.outcome-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  margin-right: 8px;
  padding: 0 4px;
  border-radius: 6px;
  font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  vertical-align: middle;
}

.outcome-win {
  background: #dcfae6;
  color: #067647;
}

.outcome-draw {
  background: #fef0c7;
  color: #93370d;
}

.outcome-loss {
  background: #f2f4f7;
  color: #667085;
}

.player-win {
  font-weight: 700;
}

.player-loss {
  color: var(--muted);
}

/* TD results table: a board still waiting for its result stands out */
.pairing-table tr.awaiting-result td {
  background: #fffaeb;
}

.pairing-table tr.awaiting-result td:first-child {
  box-shadow: inset 3px 0 0 #f79009;
}

/* Tie-break editor */
.tiebreak-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.tiebreak-row label {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.wc-heading {
  display: block;
  margin-bottom: 6px;
}

.wc-heading:empty {
  display: none;
}

/* Live page: a newly published round */
.new-round-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: #dcfae6;
  color: #067647;
  font-weight: 600;
}

.new-round-notice[hidden] {
  display: none;
}

@keyframes round-chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(36, 70, 201, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(36, 70, 201, 0); }
}

.round-chip-new {
  animation: round-chip-pulse 1.2s ease-out 4;
}

@media (prefers-reduced-motion: reduce) {
  .round-chip-new { animation: none; }
}

.rating-delta {
  color: var(--muted);
  font-size: 12px;
}

.provisional-mark {
  margin-left: 2px;
  color: var(--danger-ink);
  font-weight: 700;
  cursor: help;
}

/* Public pairings, mirrored around the result: after the board number, every column has its twin
   on the other side at the same width (Pts | White | Result | Black | Pts), so the result is
   centered. Fixed layout makes the widths exact rather than content-driven. */
.live-pairings {
  table-layout: fixed;
  min-width: 640px;
}

.live-pairings th:nth-child(1) { width: 6%; }
.live-pairings th:nth-child(2),
.live-pairings th:nth-child(6) { width: 8%; }
.live-pairings th:nth-child(3),
.live-pairings th:nth-child(5) { width: 34%; }
.live-pairings th:nth-child(4) { width: 10%; }

.live-pairings td.live-side {
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-pairings .live-side-black,
.live-pairings .pts-black {
  text-align: right;
}

.live-pairings th.live-result {
  text-align: center;
}

.live-pairings .live-side-black .outcome-badge {
  margin-right: 0;
  margin-left: 8px;
}

.live-pairings td.pts-black {
  padding-left: 20px;
}

.black-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.black-cell select {
  flex: 1;
  min-width: 0;
}

/* Pairing editor: player cards you swap by drag-and-drop or two clicks */
.edit-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.slot {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: grab;
}

.slot:hover {
  border-color: var(--accent);
}

.slot-empty {
  border-style: dashed;
  color: var(--muted);
  cursor: pointer;
}

.slot-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(36, 70, 201, 0.25);
  background: var(--ok-bg);
}

.slot-over {
  border-color: var(--accent);
  background: #f0f4ff;
}

/* Public standings: 14 columns (rounds, tie-breaks, Perf., Est. post) in one view without a
   scroll bar on a laptop -- tight padding, headers that wrap, a name column that wraps. A phone
   still scrolls sideways, with the place and name held in view. */
.live-main:has(.standings-table) {
  max-width: 1280px;
}

.standings-table {
  font-size: 13px;
}

.tbl.standings-table th,
.tbl.standings-table td {
  padding: 8px 6px;
}

.tbl.standings-table th {
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.25;
}

.tbl.standings-table th:first-child,
.tbl.standings-table td:first-child {
  padding-left: 10px;
}

.pairing-table.standings-table th.col-narrow,
.pairing-table.standings-table td.num:first-child,
.pairing-table.standings-table td.pts {
  padding-right: 6px;
}

/* Name shrinks to its content like every other column, so spare width is shared across the row
   instead of all landing between the name and the rating. */
.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  width: 1%;
  min-width: 8.5em;
}

.standings-table td.num {
  white-space: nowrap;
}

.standings-table .sr-cell .outcome-badge {
  min-width: 20px;
  height: 20px;
  margin-right: 3px;
  font-size: 12px;
}

.standings-table .sr-cell .wc-chip {
  margin-left: 3px;
  min-width: 16px;
  padding: 0 2px;
  font-size: 10px;
  line-height: 15px;
}

@media (max-width: 760px) {
  .standings-table th:nth-child(-n + 2),
  .standings-table td:nth-child(-n + 2) {
    position: sticky;
    background: #fff;
    z-index: 1;
  }
  .standings-table th:nth-child(-n + 2) {
    background: #fafbfc;
  }
  .standings-table th:first-child,
  .standings-table td:first-child {
    left: 0;
    min-width: 30px;
  }
  .standings-table th:nth-child(2),
  .standings-table td:nth-child(2) {
    left: 30px;
    min-width: 7.5em;
    box-shadow: 1px 0 0 var(--border);
  }
}

/* Perf. / Est. post: the change from the current rating goes under the number, not beside it. */
.standings-table .rating-delta {
  display: block;
  font-size: 11px;
  line-height: 1.2;
}
