/* ChessApp Results: the app's quiet monochrome look (white or near-black page,
   black text and buttons, soft grey lines), one colour only for live and results. */
:root {
  --bg: #ffffff;
  --surface: #f6f6f4;
  --ink: #1a1a1a;
  --muted: #6e6e6a;
  --line: #e6e6e3;
  --button: #1a1a1a;
  --button-ink: #ffffff;
  --live: #c2410c;
  --win: #2d6a4f;
  --loss: #a8322a;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --surface: #1d1d1c; --ink: #ececea; --muted: #9b9b97; --line: #2c2c2a;
    --button: #ececea; --button-ink: #141414; --live: #fb923c; --win: #7cc49b; --loss: #e08a8a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414; --surface: #1d1d1c; --ink: #ececea; --muted: #9b9b97; --line: #2c2c2a;
  --button: #ececea; --button-ink: #141414; --live: #fb923c; --win: #7cc49b; --loss: #e08a8a; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: inherit; text-underline-offset: 3px; text-decoration-color: var(--line); }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
main { max-width: 1040px; margin: 0 auto; padding: 8px 16px 40px; }
h1 { font-size: clamp(22px, 4vw, 30px); line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 6px; text-wrap: balance; }
h2 { font-size: 17px; margin: 0 0 10px; }
h2 small, h3 small { color: var(--muted); font-weight: 400; font-size: 13px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
small { color: var(--muted); }

/* header and footer */
header.site, footer.site {
  max-width: 1040px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
footer.site { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -0.01em; }
.brand img { border-radius: 6px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand img { filter: invert(1); } }
:root[data-theme="dark"] .brand img { filter: invert(1); }
.hright { display: flex; align-items: center; gap: 14px; }
.orglink { font-size: 13px; color: var(--muted); text-decoration: none; }
.orglink:hover { color: var(--ink); }
.langs { display: flex; gap: 2px; }
.langs a { text-decoration: none; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 7px; border-radius: 6px; }
.langs a[aria-current] { color: var(--ink); background: var(--surface); }

/* home */
.hero { padding: 18px 0 8px; }
.hero h1 { max-width: 22ch; }
.search { display: flex; gap: 8px; margin-top: 14px; max-width: 560px; }
.search input { flex: 1; min-width: 0; font: inherit; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.search button, .button { font: inherit; font-weight: 600; padding: 11px 18px; border-radius: var(--radius); border: 0; background: var(--button); color: var(--button-ink); cursor: pointer; }
.tlist { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tcard a { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; height: 100%; }
.tcard a:hover { background: var(--surface); }
.tname { font-weight: 650; }
.tmeta { color: var(--muted); font-size: 13px; margin: 0; }
.tfoot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 4px; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); vertical-align: 1px; }
.badge.live { color: var(--live); }
.badge.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .badge.live i { animation: none; } }

/* tabs and round chips */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 14px 0 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { text-decoration: none; color: var(--muted); padding: 10px 12px; white-space: nowrap; font-weight: 550; box-shadow: inset 0 -2px 0 transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.thead { padding-top: 10px; }
.thead .tmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 14px; }
.chips .lbl { color: var(--muted); font-size: 13px; margin-right: 4px; }
.chips a, .chips span:not(.lbl) { min-width: 34px; text-align: center; padding: 5px 9px; border-radius: 8px; border: 1px solid var(--line);
  text-decoration: none; font-size: 13px; font-variant-numeric: tabular-nums; }
.chips span:not(.lbl) { color: var(--muted); opacity: .5; }
.chips a[aria-current] { background: var(--button); color: var(--button-ink); border-color: var(--button); }
.sub { color: var(--muted); margin: -6px 0 12px; font-size: 14px; }

/* panels and facts */
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; min-width: 0; }
.panel.center { text-align: center; padding: 40px 16px; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid2 .panel { margin: 0; }
.grid2 { margin-bottom: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* tables */
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface) 70%, transparent); }
td.n, th.n { text-align: right; }
td.strong { font-weight: 700; }
td.name { white-space: normal; min-width: 150px; }
td.name a { text-decoration: none; }
td.name a:hover { text-decoration: underline; }
.title { font-size: 11px; font-weight: 700; color: var(--muted); }
tr.out td { color: var(--muted); text-decoration: line-through; }
tr.out td small { text-decoration: none; }
td.res, th.res { text-align: center; }
td.res b { font-weight: 700; min-width: 1.1em; display: inline-block; }
td.res span { color: var(--muted); padding: 0 4px; }
.pending { color: var(--muted); }
table.compact td { border: 0; padding: 3px 0; }
table.compact td:first-child { color: var(--muted); padding-right: 16px; }
table.cross td.x, table.cross th.x { text-align: center; font-size: 13px; padding: 8px 6px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink); vertical-align: -1px; }
.dot.w { background: var(--bg); }
.dot.b { background: var(--ink); }
.byes { margin: 0; padding-left: 18px; }
.legend, .note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.note { margin-top: 18px; }
.empty { color: var(--muted); padding: 24px 0; }

/* narrow screens: secondary columns go */
@media (max-width: 640px) {
  .opt { display: none; }
  th, td { padding: 8px 6px; }
  td.name { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  table.pairings td.name { width: 42%; }
  .title { display: block; line-height: 1.2; }
  .facts { gap: 4px 12px; }
}

/* embeds */
body.embed main, body.embed { padding: 0; }
body.embed { padding: 8px; background: var(--bg); }
.ehead, .efoot { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.ehead a { text-decoration: none; color: var(--ink); }
.efoot { margin: 8px 0 0; text-align: right; }

/* organiser pages */
.form { display: grid; gap: 12px; max-width: 420px; }
.form label { display: grid; gap: 4px; font-weight: 550; font-size: 14px; }
.form label small { font-weight: 400; }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=file], .form select, .inline input[type=text] {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; }
.button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button.small { padding: 6px 12px; font-size: 13px; }
.msg { padding: 10px 14px; border-radius: 10px; background: var(--surface); margin: 0 0 16px; }
.msg.err { color: var(--loss); }
.msg.ok { color: var(--win); }
.olist { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.orow { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.orow .top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.orow .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.orow form { margin: 0; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline input[type=text] { width: auto; flex: 1; min-width: 180px; }
.badge.public { color: var(--win); }
pre.code { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12.5px; white-space: pre; margin: 6px 0; }
.codebox { display: grid; gap: 4px; margin: 0 0 16px; }
.codebox .inline { justify-content: space-between; }
