/* turnierwand: light mode only. Tokens on :root, no dark variants. */
:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --text: #17201b;
  /* Secondary text, at least 4.5:1 on --bg and --surface. */
  --muted: #56605a;
  --line: #e1e5df;
  --line-strong: #c9cfc7;
  --accent: #1f6b45;
  --accent-hover: #17573a;
  --accent-soft: #e6f2eb;
  --live: #b42318;
  --live-soft: #fdecea;
  --warn: #8a5300;
  --warn-soft: #fff4e0;
  --ok: #1f6b45;
  --radius: 12px;
  --page-width: 1180px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgb(23 32 27 / 5%), 0 1px 1px rgb(23 32 27 / 4%);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.5 ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

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

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem);
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.05rem;
  margin-top: 1.2em;
}

h4 {
  font-size: 1rem;
  margin-top: 1em;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 16px;
  top: 8px;
  z-index: 10;
  background: var(--surface);
  padding: 8px 12px;
  border-radius: 8px;
}

:focus-visible {
  outline: 3px solid #2b59c3;
  outline-offset: 2px;
}

.page {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 24px var(--gutter) 48px;
}

.page.narrow {
  max-width: 560px;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 0.9rem;
}

small.hint {
  display: block;
}

.mono {
  font-family: var(--mono);
  font-size: 0.92rem;
}

.lead {
  font-size: 1.2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  margin-bottom: 16px;
}

.brand-mark {
  color: var(--accent);
}

.page-footer {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--gutter) 32px;
  font-size: 0.95rem;
}

/* Buttons and forms */

.button,
button.big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-hover);
  color: #fff;
}

.button.ghost {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--line-strong);
}

.button.ghost:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.button.small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.92rem;
}

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

.icon-button {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 44px;
  max-width: 100%;
}

textarea {
  width: 100%;
  min-height: 12rem;
}

input[type="checkbox"],
input[type="radio"] {
  min-height: auto;
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.form label,
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
  margin-bottom: 12px;
}

.field .label {
  font-weight: 600;
}

.form label.check,
label.check {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
}

.form-status {
  min-height: 1.5em;
  color: var(--muted);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

.grid-form.narrow-fields {
  grid-template-columns: repeat(auto-fit, minmax(140px, 220px));
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-top: 16px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 16px;
}

legend {
  font-weight: 700;
  padding: 0 4px;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.copy-row input {
  flex: 1 1 260px;
}

/* Badges, notices, issues */

.badge,
.tag,
.live-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  vertical-align: middle;
}

.badge.public {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.badge.draft {
  background: #eceeea;
  color: var(--muted);
}

.tag {
  background: #eceeea;
  color: var(--muted);
  margin-left: 8px;
}

.live-badge {
  background: var(--live);
  color: #fff;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.notice {
  border-radius: 10px;
  padding: 10px 14px;
  margin: 12px 0;
  background: var(--live-soft);
  color: #7a1a12;
  border: 1px solid #f3c4be;
}

.notice[data-kind="ok"] {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: #bcdcc9;
}

.issues {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.issues li {
  border-radius: 8px;
  padding: 6px 10px;
  margin: 4px 0;
  font-size: 0.92rem;
}

.issues li.error {
  background: var(--live-soft);
  color: #7a1a12;
}

.issues li.warning {
  background: var(--warn-soft);
  color: var(--warn);
}

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

.connection {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

.connection::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: #a7b0aa;
  vertical-align: 1px;
}

.connection[data-state="online"]::before {
  background: #2f9e5b;
}

.connection[data-state="offline"]::before,
.connection[data-state="linkRevoked"]::before,
.connection[data-state="notPublic"]::before {
  background: var(--live);
}

/* Tables */

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

tbody th {
  font-weight: 500;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pts {
  font-weight: 700;
}

.row-hint {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
}

tr.highlight {
  background: var(--accent-soft);
}

tr.live td {
  background: var(--live-soft);
}

tr.conflict td {
  background: var(--warn-soft);
}

.row-buttons {
  white-space: nowrap;
}

.row-buttons .button,
.row-buttons .icon-button {
  margin: 2px;
}

.visually-hidden-text {
  font-size: 0;
}

/* Organiser */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 8px var(--gutter);
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-inner .brand {
  margin: 0;
}

.topbar-user {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.92rem;
}

.crumbs {
  margin: 0 0 8px;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.steps ol {
  list-style: none;
  display: flex;
  gap: 6px;
  padding: 0;
  margin: 16px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.steps a {
  display: block;
  white-space: nowrap;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.steps a[aria-current="step"] {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.sortable-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  max-width: 560px;
}

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

tr.sortable {
  display: table-row;
}

.sortable.dragging {
  opacity: 0.5;
}

.drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.handle {
  color: var(--muted);
  cursor: grab;
}

.grow {
  flex: 1;
}

.group-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.group-box {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfa;
  min-height: 120px;
}

.group-box h3 {
  margin-top: 0;
}

.chips {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 8px;
  margin: 6px 0;
  cursor: grab;
}

.chip select {
  min-height: 36px;
  padding: 4px 6px;
  font-size: 0.92rem;
}

.link-list {
  list-style: none;
  padding: 0;
}

.link-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.link-list li.revoked {
  color: var(--muted);
}

.fresh-link {
  border: 1px solid #bcdcc9;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
}

.qr svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.score-inputs input {
  width: 4.2em;
  min-height: 36px;
  padding: 4px 6px;
}

.pen {
  display: block;
  margin-top: 4px;
  font-size: 0.9rem;
}

/* Public plan */

.plan-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-bottom: 16px;
}

.plan-title {
  flex: 1 1 260px;
}

.plan-name {
  margin: 0;
}

.plan-meta {
  margin: 4px 0 0;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.sponsor {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.sponsor-logo {
  max-height: 48px;
  max-width: 180px;
}

.sponsor-name {
  font-weight: 700;
  color: var(--text);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.filters label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 0.9rem;
  gap: 4px;
  flex: 1 1 160px;
  max-width: 280px;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.qr-block {
  margin-top: 16px;
  text-align: center;
}

.qr-block .qr {
  display: inline-block;
}

.qr-block .links {
  display: flex;
  justify-content: center;
  gap: 16px;
}

@media (width >= 900px) {
  .plan-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .plan-grid .wide,
  .plan-grid [data-section="tables"] {
    grid-column: 1 / -1;
  }
}

.matches {
  list-style: none;
  padding: 0;
  margin: 0;
}

.match {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.match:last-child {
  border-bottom: 0;
}

.match.live {
  background: var(--live-soft);
  border-radius: 8px;
  padding: 10px;
}

.match-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.match-time {
  font-weight: 700;
  color: var(--text);
}

.match-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.match-teams .home {
  text-align: right;
}

.match-teams .score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 3.2em;
  text-align: center;
}

.match-teams .score.empty {
  color: var(--muted);
  font-weight: 500;
}

.tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.group-table h3 {
  margin-top: 0;
}

.standings th,
.standings td {
  padding: 6px 6px;
}

.empty {
  margin: 0;
}

/* Helper page: phone first, big targets */

.helper-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.helper-bar h1 {
  font-size: 1.2rem;
  margin: 0;
}

.helper-name {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.offline-banner {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 10px var(--gutter);
  font-weight: 600;
}

.helper-main {
  max-width: 640px;
}

.field-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
  margin: 8px 0 16px;
}

.queue {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}

.stuck {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0 0 14px;
  /* A match card links here; keep the list clear of the sticky helper bar. */
  scroll-margin-top: 84px;
}

.stuck p {
  margin: 0 0 6px;
  font-weight: 600;
}

.stuck ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stuck li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 6px 0;
}

.stuck-actions {
  display: flex;
  gap: 8px;
}

.not-sent-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}

.not-sent-head p {
  margin: 0;
}

.tag.not-sent-tag {
  background: var(--warn-soft);
  color: var(--warn);
  text-decoration: underline;
}

.helper-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}

.helper-card.live {
  border-color: #f0b8b1;
}

.helper-card.done {
  opacity: 0.85;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.card-head strong {
  color: var(--text);
}

.big-score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
  font-weight: 600;
}

.big-score span:first-child {
  text-align: right;
}

.big-score strong {
  font-size: 2.6rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.teams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 600;
}

.goal-row {
  display: grid;
  grid-template-columns: 1fr 72px 96px;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}

.goal-label {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.goal-label span {
  color: var(--muted);
  font-size: 0.9rem;
}

button.big {
  min-height: 56px;
  font-size: 1.15rem;
  width: 100%;
}

button.big.minus {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line-strong);
}

button.big.plus {
  font-size: 1.4rem;
}

button.big.secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--line-strong);
  margin-top: 8px;
}

button.big.primary {
  margin-top: 8px;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.penalties-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.penalties-form label {
  display: flex;
  flex-direction: column;
  font-weight: 600;
  font-size: 0.92rem;
}

.penalties-form button {
  grid-column: 1 / -1;
}

/* Embed: compact */

body.embed {
  background: var(--surface);
}

.embed-main {
  padding: 8px 12px;
}

.embed-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.embed .tables {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

@media (width >= 700px) {
  .steps ol {
    flex-wrap: wrap;
  }
}

@media (width <= 480px) {
  .card,
  .block {
    padding: 14px;
  }

  /* Phones: field and group columns of the schedule and W/D/L of the tables go. */
  .schedule th:nth-child(3),
  .schedule td:nth-child(3),
  .schedule th:nth-child(4),
  .schedule td:nth-child(4),
  .standings .wdl {
    display: none;
  }

  .schedule th,
  .schedule td {
    padding: 6px 5px;
  }

  /* The row colour marks a live match; the badge would widen the score column. */
  .schedule .live-badge {
    display: none;
  }
}
