/* Self-hosted fonts: Geist and JetBrains Mono (SIL Open Font License), variable weight, latin and latin-ext
   (Polish needs the second). Files taken from Google Fonts. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* tabelki.online design system. Tokens follow the design handoff (DESIGN.md): neutral canvas/surface/border,
   one blue primary, amber for live, 8px radius, 4px for badges and score cells, 1px borders, no heavy shadows.
   Light is the default; dark follows the system, and the toggle in the header overrides both
   (html[data-theme="light" | "dark"]). */

:root {
  color-scheme: light;
  --canvas: #f7f9ff;
  --surface: #ffffff;
  --hover: #f1f4fa;
  --border: #d9dbe0;
  /* The Stitch screens (organiser_tournament_page_light) are the exact design; where DESIGN.md differs, they win. */
  --divider: #ebeef4;
  --card-border: transparent;
  --card-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --field-bg: #f1f4fa;
  --field-border: rgba(194, 198, 215, 0.5);
  --primary-ink: #0055ce;
  --primary-fixed: #dae2ff;
  --on-primary-fixed: #001847;
  --secondary-fixed: #ffddb8;
  --on-secondary-fixed: #2a1700;
  --secondary-container: #fea619;
  --container-high: #e5e8ee;
  --on-variant: #424654;
  --text: #2b2d31;
  --muted: #5f6368;
  --primary: #2f6fed;
  --on-primary: #ffffff;
  --primary-bg: rgba(47, 111, 237, 0.12);
  --live: #f59e0b;
  --published: #10b981;
  --finished: #64748b;
  --danger: #ba1a1a;
  --danger-bg: rgba(186, 26, 26, 0.08);
  --focus: 0 0 0 2px rgba(47, 111, 237, 0.25);
  --float: 0 4px 12px rgba(0, 0, 0, 0.06);
  --font-ui: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #1e1f22;
  --surface: #26282c;
  --hover: #2f3237;
  --border: #3d4046;
  --text: #e6e7ea;
  --muted: #a3a7ad;
  --danger: #ff8a80;
  --danger-bg: rgba(255, 138, 128, 0.1);
  --float: 0 4px 16px rgba(0, 0, 0, 0.35);
  --divider: #3d4046;
  --card-border: #3d4046;
  --card-shadow: none;
  --field-bg: #1e1f22;
  --field-border: #3d4046;
  --primary-ink: #2f6fed;
  --primary-fixed: rgba(47, 111, 237, 0.2);
  --on-primary-fixed: #b1c5ff;
  --secondary-fixed: rgba(245, 158, 11, 0.16);
  --on-secondary-fixed: #f59e0b;
  --container-high: #2f3237;
  --on-variant: #a3a7ad;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #1e1f22;
    --surface: #26282c;
    --hover: #2f3237;
    --border: #3d4046;
    --text: #e6e7ea;
    --muted: #a3a7ad;
    --danger: #ff8a80;
    --danger-bg: rgba(255, 138, 128, 0.1);
    --float: 0 4px 16px rgba(0, 0, 0, 0.35);
    --divider: #3d4046;
    --card-border: #3d4046;
    --card-shadow: none;
    --field-bg: #1e1f22;
    --field-border: #3d4046;
    --primary-ink: #2f6fed;
    --primary-fixed: rgba(47, 111, 237, 0.2);
    --on-primary-fixed: #b1c5ff;
    --secondary-fixed: rgba(245, 158, 11, 0.16);
    --on-secondary-fixed: #f59e0b;
    --container-high: #2f3237;
    --on-variant: #a3a7ad;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 24px;
  line-height: 32px;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
}

h3 {
  font-size: 20px;
  line-height: 28px;
  margin: 1.5rem 0 0.5rem;
}

h4 {
  font-size: 16px;
  line-height: 24px;
  margin: 1rem 0 0.25rem;
}

p {
  margin: 0.5rem 0;
}

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

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- the shell: header, main, footer ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1440px;
  height: 64px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.brand span {
  color: var(--primary);
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topnav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.topnav-link:hover {
  background: var(--hover);
}

/* A button that opens a small menu: the language and the account. */
.dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.dropdown-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
}

.dropdown-button:hover,
.icon-button:hover {
  border-color: var(--primary);
  background: var(--hover);
}

.chevron {
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}

.flag {
  width: 22px;
  height: 15px;
  border-radius: 2px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 0 0 1px var(--border);
}

.flag-en {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40'%3E%3Crect width='60' height='40' fill='%23012169'/%3E%3Cpath d='M0 0l60 40M60 0L0 40' stroke='%23fff' stroke-width='8'/%3E%3Cpath d='M0 0l60 40M60 0L0 40' stroke='%23C8102E' stroke-width='3'/%3E%3Cpath d='M30 0v40M0 20h60' stroke='%23fff' stroke-width='13'/%3E%3Cpath d='M30 0v40M0 20h60' stroke='%23C8102E' stroke-width='8'/%3E%3C/svg%3E");
}

.flag-pl {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 40'%3E%3Crect width='60' height='20' fill='%23fff'/%3E%3Crect y='20' width='60' height='20' fill='%23DC143C'/%3E%3C/svg%3E");
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7z'/%3E%3C/svg%3E");
  background-position: center;
  background-size: 18px;
  background-repeat: no-repeat;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 12rem;
  padding: 0.375rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--float);
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-head {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 0 0.75rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.dropdown-item:hover:not(:disabled) {
  background: var(--hover);
}

.dropdown-item[aria-pressed="true"] {
  color: var(--primary);
  font-weight: 600;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem;
}

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem;
}

/* ---- buttons ---- */

button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button[type="submit"],
.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

button[type="submit"]:hover:not(:disabled),
.button-primary:hover {
  background: var(--primary);
  filter: brightness(0.92);
}

a.button-primary,
a.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}

a.button-primary {
  color: var(--on-primary);
}

a.button-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

a.button-secondary:hover {
  border-color: var(--primary);
  background: var(--hover);
}

button.danger {
  margin-top: 0.75rem;
  color: var(--danger);
}

button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* ---- forms ---- */

fieldset {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.form-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  column-gap: 1rem;
  align-content: start;
}

.form-panel > .check,
.form-panel > .actions,
.form-panel > .kind-row,
.form-panel > fieldset {
  grid-column: 1 / -1;
}

.categories-section {
  margin-top: 1.5rem;
}

.categories-section > h2 {
  margin: 0 0 0.5rem;
}

.categories-section > button {
  margin-bottom: 0.5rem;
}

fieldset.nested {
  margin: 0.75rem 0;
  background: var(--canvas);
}

legend {
  padding: 0 0.5rem;
  font-weight: 600;
}

.category {
  background: var(--surface);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0.75rem 0;
}

.field .label {
  font-size: 13px;
  font-weight: 500;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

.field[hidden] {
  display: none;
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0;
}

.check input {
  accent-color: var(--primary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="datetime-local"],
select {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.kind-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.player-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr 1.5fr auto;
  gap: 0.5rem;
}

.registration-form {
  max-width: 28rem;
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.registration-form h3 {
  margin-top: 0;
}

.tournament-form {
  max-width: 56rem;
}

.link-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.link-row .field {
  flex: 1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 2rem;
}

.override .actions {
  margin: 0.25rem 0 0.5rem;
}

/* ---- status line and messages ---- */

.meta {
  color: var(--muted);
}

.warning {
  font-weight: 600;
  color: var(--live);
}

#status:empty {
  display: none;
}

#status {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

#status.error {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 600;
}

#status ul {
  margin: 0.25rem 0 0;
}

/* ---- panels ---- */

.links,
.state-panel,
.signup-panel,
.tables-panel,
.play-mode-panel,
.table-board-panel,
.table-settings-panel,
.draw,
.locked-players {
  margin: 1rem 0;
}

.state-panel,
.signup-panel,
.tables-panel,
.play-mode-panel,
.table-board-panel,
.table-settings-panel,
.locked-players,
.category-view {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.state-panel h3,
.signup-panel h3,
.tables-panel h3,
.play-mode-panel h3,
.table-board-panel h3,
.table-settings-panel h3,
.locked-players h3,
.category-view h3 {
  margin-top: 0;
  font-size: 16px;
  line-height: 24px;
}

.state-panel .warning {
  font-weight: 700;
}

.draw h4 {
  margin: 1rem 0 0.25rem;
}

.draw ul,
.locked-players ol {
  margin: 0.25rem 0;
}

.locked-players li button {
  margin-left: 0.5rem;
}

.draw .match {
  margin: 0.25rem 0;
}

.draw .match button {
  margin-left: 0.5rem;
}

.draw .match-score,
.match-score {
  font-family: var(--font-mono);
  font-weight: 600;
  font-feature-settings: "tnum" 1;
}

.match-table,
.match-referee {
  color: var(--muted);
}

.match-winner {
  font-weight: 700;
}

.match-void {
  color: var(--muted);
  text-decoration: line-through;
}

.result-form {
  max-width: 32rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--float);
}

.result-form .actions {
  margin: 0.5rem 0 0;
}

.draw .ranking {
  list-style: none;
  padding-left: 0;
  font-weight: 600;
}

/* ---- tables: dense header row, 1px rules, tabular figures for every number ---- */

.draw .standings {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem;
  background: var(--surface);
  font-feature-settings: "tnum" 1;
}

.draw .standings th,
.draw .standings td {
  padding: 8px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.draw .standings th:nth-child(2),
.draw .standings td:nth-child(2) {
  text-align: left;
}

.draw .standings th {
  height: 32px;
  padding-top: 4px;
  padding-bottom: 4px;
  background: var(--hover);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.draw .standings td {
  height: 40px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.draw .standings td:nth-child(2) {
  font-family: var(--font-ui);
  font-size: 14px;
}

.draw .standings tbody tr:hover {
  background: var(--hover);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-wrap: normal;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-scroll .standings {
  margin: 0;
}

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

.table-scroll td:nth-child(2) {
  min-width: 9rem;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ---- status badges (the state a tournament is in) ---- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 20px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-drawn {
  border-color: rgba(47, 111, 237, 0.3);
  background: rgba(47, 111, 237, 0.07);
  color: var(--primary);
}

.badge-published {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.07);
  color: var(--published);
}

.badge-started {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.07);
  color: var(--live);
}

.badge-started::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--live);
  animation: live-pulse 1.6s ease-in-out infinite;
}

.badge-finished {
  background: rgba(100, 116, 139, 0.1);
  color: var(--finished);
}

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

@media (prefers-reduced-motion: reduce) {
  .badge-started::before {
    animation: none;
  }
}

/* ---- public page ---- */

.public {
  max-width: 56rem;
  margin: 0 auto;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.page-head h2 {
  margin: 0;
}

.page-head .button-primary {
  margin-left: auto;
}

.empty-state {
  margin-top: 1.5rem;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
}

.refresh-row {
  margin: 0.5rem 0;
}

.registration-note {
  margin: 0.5rem 0;
  color: var(--muted);
}

.category-view {
  margin: 1rem 0;
}

.category-view ol {
  margin: 0.5rem 0 0;
  padding-left: 1.5rem;
}

.public .draw,
.public .category-view {
  overflow-wrap: anywhere;
}

/* ---- landing page ---- */

.hero {
  padding: 3rem 0 2rem;
  max-width: 44rem;
}

.hero h1 {
  font-size: 32px;
  line-height: 40px;
  letter-spacing: -0.02em;
}

.hero h1 span {
  color: var(--primary);
}

.hero p {
  margin: 1rem 0 1.5rem;
  font-size: 16px;
  line-height: 24px;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.feature {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.feature:hover {
  border-color: var(--primary);
}

.feature h3 {
  margin: 0 0 0.25rem;
  font-size: 16px;
  line-height: 24px;
}

.feature p {
  margin: 0;
  color: var(--muted);
}

/* ---- sign-in page: a centred card ---- */

.auth-card {
  width: 100%;
  max-width: 26rem;
  margin: 2rem auto;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--float);
}

.auth-card h2 {
  font-size: 20px;
  line-height: 28px;
}

.auth-card .actions {
  margin: 1rem 0 0;
}

.auth-card button[type="submit"] {
  width: 100%;
  height: 40px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 2px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--hover);
}

.auth-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.auth-tabs button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--border);
}

/* ---- narrow screens: single column, 16px margins ---- */

@media (max-width: 767px) {
  .hero {
    padding-top: 1.5rem;
  }

  .hero h1 {
    font-size: 26px;
    line-height: 32px;
    letter-spacing: -0.01em;
  }

}

@media (max-width: 36rem) {
  .player-row {
    grid-template-columns: 1fr 1fr;
  }

  .link-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ---- the public page: category pills, stage tabs, progress, match cards ---- */

[hidden] {
  display: none !important;
}

.pills {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding-bottom: 2px;
  overflow-x: auto;
}

.pills button {
  flex: none;
  border-radius: 9999px;
  padding: 0 14px;
  color: var(--muted);
  white-space: nowrap;
}

.pills button[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.tab-bar {
  display: flex;
  gap: 2px;
  margin: 0.75rem 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.tab-bar button {
  flex: 1;
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.tab-bar button[aria-pressed="true"] {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.tab-bar button[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--primary);
}

/* The stage a category shows: only the parts of that stage (a category with no data-stage shows everything). */
[data-stage="standings"] .stage-matches,
[data-stage="standings"] .stage-knockout,
[data-stage="matches"] .stage-standings,
[data-stage="matches"] .stage-knockout,
[data-stage="knockout"] .group-block,
[data-stage="knockout"] .stage-standings,
[data-stage="knockout"] .stage-matches {
  display: none;
}

.progress {
  margin: 0.75rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.progress-count {
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: 600;
  font-feature-settings: "tnum" 1;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 9999px;
  background: var(--hover);
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: var(--primary);
}

/* The position in a standings table: a circle, the first place filled. */
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  background: var(--hover);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rank-1 {
  background: var(--primary);
  color: var(--on-primary);
}

.draw .standings td:first-child,
.draw .standings th:first-child {
  width: 40px;
  text-align: center;
}

/* A group: its standings and its matches in one card. */
.group-block {
  margin: 1rem 0;
}

.group-block h4 {
  margin-top: 0;
}

.group-block h5,
.draw h5 {
  margin: 0.75rem 0 0.25rem;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Matches: one card each, the score in tabular figures, the winner in bold. */
.draw ul {
  list-style: none;
  padding: 0;
}

.draw ul.ranking,
.draw ul.group-players {
  margin: 0.25rem 0;
}

.draw li.match {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin: 6px 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.draw li.match:hover {
  border-color: var(--primary);
}

.draw li.match > span:first-child {
  flex: 1 1 14rem;
}

.draw li:not(.match) {
  padding: 4px 0;
}

details > summary {
  cursor: pointer;
  font-weight: 600;
}

details[open] > summary {
  margin-bottom: 0.5rem;
}

@media (max-width: 767px) {
  .public {
    margin: 0 -0.25rem;
  }

  .progress {
    margin: 0.5rem 0;
  }
}

.public .draw > h2 {
  display: none;
}

/* ---- the organiser page: lifecycle stepper, section navigation, cards ---- */

/* The sub-header: the name, its state and the lifecycle. */
.org-head {
  margin: -1rem -1rem 0;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.back-button::before {
  content: "\2190";
  font-size: 16px;
}

.back-button:hover {
  border-color: var(--primary);
  color: var(--text);
}

.org-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 1rem;
  margin: 1rem 0;
}

.org-title h1 {
  margin: 0;
  font-size: 32px;
  line-height: 40px;
  letter-spacing: -0.02em;
}

.lifecycle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 1rem;
}

.lifecycle-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.step-pill {
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.stepper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.step + .step::before {
  content: "";
  width: 28px;
  height: 2px;
  margin: 0 8px;
  background: var(--border);
}

.step-done + .step::before,
.step-done + .step-current::before {
  background: var(--primary);
}

.step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.step-done .step-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.step-current {
  color: var(--text);
  font-weight: 600;
}

.step-current .step-dot {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}

/* The body: the sections menu at the left, the open section beside it. */
.org-body {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  margin: 0 -1rem -1rem;
  min-height: 60vh;
}

.org-side {
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.org-side-title {
  margin: 0 0 1rem 0.5rem;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.org-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.org-menu button {
  justify-content: flex-start;
  min-height: 36px;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.org-menu button:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}

.org-menu button[aria-current="page"] {
  background: var(--primary);
  color: var(--on-primary);
}

.org-main {
  padding: 1.5rem;
}

.org-pane[hidden] {
  display: none;
}

.org-pane > * + * {
  margin-top: 1rem;
}

.pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pane-head h2 {
  margin: 0;
}

.categories-section > button {
  margin-top: 0.5rem;
}

/* A section already has its name in the head of the pane. */
.org-pane .draw > h2,
.org-pane .locked-players > h2 {
  display: none;
}

@media (max-width: 767px) {
  .org-head {
    padding: 1rem;
  }

  .org-title h1 {
    font-size: 24px;
    line-height: 32px;
  }

  .org-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .org-side {
    padding: 0.5rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .org-side-title {
    display: none;
  }

  .org-menu {
    flex-direction: row;
    overflow-x: auto;
  }

  .org-menu button {
    flex: none;
    white-space: nowrap;
  }

  .org-main {
    padding: 1rem;
  }
}

/* The state card shows no card inside a card: the panels beside it are cards of their own. */
.state-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 16px;
  line-height: 24px;
}

.state-panel .actions {
  margin: 0.5rem 0;
}

.links h2,
.draw > h2,
.locked-players > h2 {
  font-size: 16px;
  line-height: 24px;
}

.links {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.draw {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.public .draw {
  padding: 0;
  border: 0;
  background: transparent;
}

/* The table board: one card for each table, a busy one marked with the live colour. */
.table-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

.table-board li {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.table-board li.table-busy {
  border-left: 3px solid var(--live);
}

.table-board li.table-free {
  border-left: 3px solid var(--published);
  color: var(--muted);
}

.table-board .override {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.table-board .override .field {
  margin: 0.25rem 0;
}

.queue {
  padding-left: 1.5rem;
}

.queue li {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* The players: a dense list, the controls on the right. */
.locked-players ol {
  margin: 0.25rem 0;
  padding: 0;
  list-style: none;
  counter-reset: player;
}

.locked-players li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  counter-increment: player;
}

.locked-players li::before {
  content: counter(player);
  min-width: 24px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 13px;
}

.locked-players li > span {
  flex: 1 1 12rem;
}

.locked-players li button {
  min-height: 28px;
  margin-left: 0;
  font-size: 13px;
}

.locked-players .category-view {
  padding: 0;
  border: 0;
  background: transparent;
}

.override .actions {
  align-items: flex-end;
}

/* ---- group pills, call-to-action band ---- */

.group-pills {
  margin: 0 0 0.5rem;
}

[data-stage="knockout"] .group-pills {
  display: none;
}

.group-pills button {
  min-height: 32px;
  font-size: 13px;
}

.cta-band {
  margin: 2rem 0;
  padding: 2rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.cta-band h2 {
  margin: 0;
}

.cta-band p {
  margin: 0.5rem auto 1.25rem;
  max-width: 32rem;
  color: var(--muted);
}

/* ---- phones: the result form is a sheet at the bottom ---- */

@media (max-width: 767px) {
  .result-form {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    max-width: none;
    max-height: 85vh;
    margin: 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    border-width: 1px 0 0;
    border-radius: 12px 12px 0 0;
  }

  .result-form .actions button {
    flex: 1;
    min-height: 44px;
  }
}

.form-error {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 500;
}

/* ---- inside a section of the tournament page: cards, labels and inputs as in the design ---- */

.org-pane > * + *,
.org-pane .tournament-form > * + *,
.org-pane .categories-section > * + * {
  margin-top: 24px;
}

.org-pane .tournament-form {
  max-width: none;
}

.pane-head h2 {
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.pane-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.org-pane .links,
.org-pane .state-panel,
.org-pane .signup-panel,
.org-pane .tables-panel,
.org-pane .play-mode-panel,
.org-pane .table-board-panel,
.org-pane .table-settings-panel,
.org-pane .draw,
.org-pane .locked-players,
.org-pane .card {
  margin: 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.org-pane .links > h2,
.org-pane .links > h3,
.org-pane .state-panel > h2,
.org-pane .state-panel > h3,
.org-pane .signup-panel > h2,
.org-pane .signup-panel > h3,
.org-pane .tables-panel > h2,
.org-pane .tables-panel > h3,
.org-pane .play-mode-panel > h2,
.org-pane .play-mode-panel > h3,
.org-pane .table-board-panel > h2,
.org-pane .table-board-panel > h3,
.org-pane .table-settings-panel > h2,
.org-pane .table-settings-panel > h3,
.org-pane .draw > h2,
.org-pane .draw > h3,
.org-pane .locked-players > h2,
.org-pane .locked-players > h3,
.org-pane .card > h3 {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
}

.org-pane .card.form-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 16px;
}

.org-pane .card.form-panel > h3,
.org-pane .card.form-panel > .check,
.org-pane .card.form-panel > .kind-row,
.org-pane .card.form-panel > .actions {
  grid-column: 1 / -1;
  margin: 0;
}

.org-pane .nested {
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--canvas);
}

.org-pane .nested {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 16px;
}

.org-pane .nested > h4 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.org-pane .field {
  margin: 0;
  gap: 6px;
}

.org-pane .field .label {
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.org-pane input[type="text"],
.org-pane input[type="email"],
.org-pane input[type="date"],
.org-pane input[type="number"],
.org-pane select {
  height: 38px;
  padding: 8px 12px;
  background: var(--canvas);
  font-size: 14px;
}

.org-pane button.button-primary {
  font-weight: 600;
  padding: 8px 16px;
}

.org-pane .actions {
  margin: 0;
}

/* ---- the sections that list things: tables, chips, category cards, table cards ---- */

.pane-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pane-actions:empty {
  display: none;
}

.org-pane .table-card {
  padding: 0;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: var(--hover);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  justify-content: flex-end;
}

.row-actions button {
  min-height: 28px;
  font-size: 12px;
}

.score {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.score-live {
  color: var(--live);
}

.score-final {
  color: var(--primary);
}

.score-scheduled {
  color: var(--muted);
  font-family: var(--font-ui);
  font-weight: 500;
}

.matches-table td:last-child,
.matches-table th:last-child {
  text-align: right;
}

.chip-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.chip-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chip {
  min-height: 28px;
  padding: 0 12px;
  border-color: transparent;
  border-radius: 9999px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
}

.chip[aria-pressed="true"] {
  background: var(--primary-bg);
  color: var(--primary);
}

.category-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 16px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  min-height: 84px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.category-card[aria-pressed="true"] {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.category-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.filter-row {
  display: flex;
  justify-content: flex-end;
}

.inline-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-filter .label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.org-pane .inline-filter select {
  width: auto;
  min-width: 12rem;
}

.empty-card {
  text-align: center;
  color: var(--muted);
}

.empty-card h3 {
  margin: 0 0 0.25rem;
  color: var(--text);
}

.empty-card p {
  margin: 0;
}

/* The tables: one card for each, as in the design. */
.org-pane .table-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 16px;
  margin: 0;
}

.org-pane .table-board li {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.org-pane .table-board li.table-busy,
.org-pane .table-board li.table-free {
  border-left: 1px solid var(--border);
}

.org-pane .table-board li.table-free {
  border-style: dashed;
}

.table-card-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-card-top .badge {
  margin-left: auto;
}

.table-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--hover);
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 700;
}

.table-busy .table-number {
  background: var(--primary);
  color: var(--on-primary);
}

.table-board li > p {
  margin: 0.75rem 0 0;
}

.table-board li > p.meta {
  margin-top: 0.5rem;
}

/* ---- the organiser page as the Stitch screens draw it (light values; dark keeps its own tokens) ---- */

a {
  color: var(--primary-ink);
}

.org-head {
  border-bottom: 1px solid var(--divider);
}

.back-button {
  border: 0;
  background: var(--hover);
  color: var(--on-variant);
}

.back-button:hover {
  background: var(--divider);
  color: var(--text);
}

/* The lifecycle: a small label and pill, then the five steps joined by a line. */
.step-pill {
  border-radius: 4px;
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
  font-weight: 600;
}

.stepper {
  flex-wrap: nowrap;
  overflow-x: auto;
}

.step {
  gap: 6px;
  color: var(--on-variant);
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
}

.step + .step::before {
  width: 24px;
  margin: 0 8px;
  border-radius: 9999px;
  background: var(--container-high);
}

.step-done + .step::before,
.step-done + .step-current::before {
  background: var(--primary);
}

.step-dot {
  width: 20px;
  height: 20px;
  border: 0;
  background: var(--container-high);
  color: var(--on-variant);
  font-family: var(--font-ui);
  font-size: 10px;
}

.step-done {
  color: var(--text);
}

.step-done .step-dot {
  background: var(--primary);
  color: var(--on-primary);
  font-size: 12px;
}

.step-body {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.step-current {
  color: var(--primary-ink);
  font-weight: 700;
}

.step-current .step-body {
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--primary-fixed);
}

.step-current .step-dot {
  width: 8px;
  height: 8px;
  background: var(--primary-ink);
  font-size: 0;
  animation: live-pulse 1.6s ease-in-out infinite;
}

.step:not(.step-done):not(.step-current) {
  opacity: 0.6;
}

/* The sections menu. */
.org-side {
  border-right: 1px solid var(--divider);
}

.org-menu button {
  color: var(--on-variant);
}

.org-menu button[aria-current="page"] {
  background: var(--primary);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 600;
}

/* Cards: white, no border, a soft shadow. */
.org-pane .links,
.org-pane .state-panel,
.org-pane .signup-panel,
.org-pane .tables-panel,
.org-pane .play-mode-panel,
.org-pane .table-board-panel,
.org-pane .table-settings-panel,
.org-pane .draw,
.org-pane .locked-players,
.org-pane .card,
.org-pane .table-board li,
.category-card,
.chip-bar {
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.org-pane .table-board li.table-busy,
.org-pane .table-board li.table-free {
  border-left: 1px solid var(--card-border);
}

.org-pane .table-board li.table-free {
  border: 2px dashed var(--field-border);
}

.category-card[aria-pressed="true"] {
  border-color: var(--primary);
}

/* Fields: a pale fill with a soft outline. */
.org-pane input[type="text"],
.org-pane input[type="email"],
.org-pane input[type="date"],
.org-pane input[type="number"],
.org-pane input[type="datetime-local"],
.org-pane select {
  height: 38px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
}

.org-pane .field .label {
  color: var(--on-variant);
}

/* Buttons: the primary is the lighter blue, bold; the others are plain white or pale. */
.org-pane button {
  border-color: var(--field-border);
}

.org-pane button.button-primary,
.org-pane button[type="submit"] {
  border-color: var(--primary);
  box-shadow: var(--card-shadow);
  font-size: 16px;
  line-height: 24px;
}

/* Tables: a pale header band of small capitals, rows ruled lightly. */
.org-pane .standings,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-feature-settings: "tnum" 1;
}

.org-pane .standings th,
.data-table th {
  padding: 10px 12px;
  border-bottom: 0;
  background: var(--hover);
  color: var(--on-variant);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.org-pane .standings th:first-child,
.data-table th:first-child {
  border-radius: 4px 0 0 4px;
}

.org-pane .standings th:last-child,
.data-table th:last-child {
  border-radius: 0 4px 4px 0;
  text-align: right;
}

.org-pane .standings td,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--divider);
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  text-align: left;
}

.org-pane .standings tbody tr:last-child td,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.org-pane .standings td:nth-child(2),
.data-table td:first-child {
  font-weight: 500;
}

.org-pane .standings td:first-child {
  color: var(--primary-ink);
  font-weight: 700;
}

.org-pane .standings td:last-child {
  font-family: var(--font-mono);
  font-weight: 700;
  text-align: right;
}

.org-pane .table-scroll {
  border: 0;
  border-radius: 0;
}

.org-pane .table-card {
  padding: 24px;
}

/* The status pills: filled, rounded, the live one with its pulsing dot. */
.badge {
  height: auto;
  padding: 2px 10px;
  border: 0;
  border-radius: 9999px;
  background: var(--container-high);
  color: var(--on-variant);
}

.badge-drawn,
.badge-published {
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
}

.badge-started {
  background: var(--secondary-fixed);
  color: var(--on-secondary-fixed);
}

.badge-started::before {
  width: 8px;
  height: 8px;
  background: var(--secondary-container);
}

.badge-finished {
  background: var(--container-high);
  color: var(--on-variant);
}

/* The category filter: a white chip in the corner of the header of its section. */
.org-pane .inline-filter {
  padding: 8px 12px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.org-pane .inline-filter select {
  min-width: 0;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

@media (min-width: 1024px) {
  .org-body {
    grid-template-columns: 288px minmax(0, 1fr);
  }
}

/* The position is a bold number, the first place in blue, not a circle. */
.org-pane .standings td:first-child,
.org-pane .standings th:first-child {
  width: auto;
  text-align: left;
}

.org-pane .rank {
  display: inline;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  color: var(--text);
  font-size: 12px;
}

.org-pane .rank-1 {
  background: none;
  color: var(--primary-ink);
}

.org-pane .standings td {
  height: auto;
}

.org-pane .pane-actions {
  align-items: center;
}

/* General: the tournament card at the left, the links and the state at the right (one column on a narrow screen). */
.general-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.general-grid > * {
  margin-top: 0 !important;
}

.general-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

/* The tables board: each table a card with a pale header band, as in the design. */
.org-pane .table-board li {
  padding: 0;
  overflow: hidden;
}

.org-pane .table-board .table-card-top {
  gap: 8px;
  padding: 16px;
  background: color-mix(in srgb, var(--hover) 60%, transparent);
}

.org-pane .table-board .table-card-top strong {
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
}

.org-pane .table-number,
.org-pane .table-busy .table-number {
  border-radius: 4px;
  background: var(--container-high);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
}

.org-pane .table-board li > p {
  margin: 16px 16px 0;
}

.org-pane .table-board li > p.meta {
  margin: 16px;
}

.org-pane .table-board .override {
  margin: 16px 0 0;
  padding: 16px;
  border-top: 0;
  background: color-mix(in srgb, var(--hover) 40%, transparent);
}

/* Rows that are lists (the queue, the matches of a draw): a pale rounded row, no outline. */
.org-pane .queue li,
.org-pane .draw .match {
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: var(--hover);
}

/* The chips that sort a list: rounded 8px, the chosen one pale blue. */
.chip {
  border-radius: 8px;
  background: var(--hover);
  color: var(--on-variant);
  font-size: 13px;
}

.chip[aria-pressed="true"] {
  background: var(--primary-fixed);
  color: var(--on-primary-fixed);
  font-weight: 600;
}

.chip-bar {
  border-radius: 12px;
}

/* A status in the last column sits at the right edge, under its heading. */
.data-table td:last-child {
  text-align: right;
}

/* General, as the design draws it: the cards hold their fields one under the other, the dates side by side. */
.org-pane .card.general-card {
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.field-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--hover);
  cursor: pointer;
}

.toggle-row p {
  margin: 0;
}

.toggle-title {
  font-size: 13px;
  line-height: 16px;
  font-weight: 600;
}

.toggle-hint {
  color: var(--on-variant);
  font-size: 12px;
  line-height: 16px;
}

.toggle-row input[type="checkbox"] {
  flex: none;
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.org-pane input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* The limits of a category: three groups of radio buttons side by side, "no limit" or a small number field. */
.limits {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 16px;
  margin: 12px 0;
}

.radio-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.radio-group legend {
  padding: 0;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.radio-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radio-options .check {
  margin: 0;
}

.radio-options input[type="radio"] {
  accent-color: var(--primary);
}

.radio-options input.limit-number {
  width: 4.5rem;
  padding: 4px 8px;
}

.org-pane .nested > .meta {
  grid-column: 1 / -1;
  margin: 0;
}
