:root {
  --bg: #fafaf7;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --line: #deded8;
  --card: #ffffff;
  --accent: #2f5fd0;
  --accent-fg: #ffffff;
  --win: #e6f4e4;
  --lose: #fbeaea;
  --danger: #b3261e;
  --flash: #fff6d6;
  --notice: #edf2fd;
  --notice-line: #c5d4f5;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #18181a;
    --fg: #e8e8e3;
    --muted: #9a9a94;
    --line: #34343a;
    --card: #222226;
    --accent: #7a9cf0;
    --accent-fg: #101014;
    --win: #1f3321;
    --lose: #3a2224;
    --danger: #f08a82;
    --flash: #3a3420;
    --notice: #1d2436;
    --notice-line: #34436c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, sans-serif;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
}
header .brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; color: inherit; text-decoration: none; }
header .brand img { width: 2rem; height: 2rem; }
header .user { color: var(--muted); font-size: 0.9rem; }
main { max-width: 52rem; margin: 0 auto; padding: 1rem 1rem 3rem; }
h1 { font-size: 1.6rem; margin: 0.5rem 0 0.5rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
.card h2 { margin-top: 0; }
a { color: var(--accent); }
.muted, .meta { color: var(--muted); }
.meta strong { color: var(--fg); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
}
.flash { background: var(--flash); padding: 0.5rem 0.8rem; border-radius: 6px; }
.flash.error { color: var(--danger); }

input, select, button, .button { font: inherit; }
input, select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
}
input[type=checkbox], input[type=radio] { width: 1.2rem; height: 1.2rem; }
button, .button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.link { border: none; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
.buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.stack { display: flex; flex-direction: column; gap: 0.8rem; }
.stack label { display: flex; flex-direction: column; gap: 0.2rem; }
.narrow { max-width: 20rem; }
label.inline { display: flex; align-items: center; gap: 0.5rem; margin: 0.8rem 0; flex-wrap: wrap; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.setup tr.off td:not(:first-child) label,
table.setup tr.off td:not(:first-child) input,
table.setup tr.off td:not(:first-child) select { opacity: 0.5; }
/* Fit phone screens: names may wrap and the joker choice shrinks. */
table.setup td { white-space: normal; }
table.setup td:last-child { width: 100%; }
table.setup select { width: 100%; min-width: 6rem; text-overflow: ellipsis; }
table.setup button.hide { margin-left: 0.4rem; text-decoration: none; color: var(--muted); }
table.setup button.hide:hover { color: var(--danger); }
table.scores .total { font-weight: 700; }
table.scores td.doubled { font-weight: 600; }
tr.winner { background: var(--win); }
tr.loser { background: var(--lose); }

.round .score {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}
.round .score label { flex: 1; }

/* Dragging teams into order (see browser.ffi.mjs). */
.handle {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  margin-right: 0.2rem;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
}
button.handle { border: none; background: none; cursor: grab; touch-action: none; }
button.handle:hover, button.handle:focus-visible { color: var(--fg); }
span.handle { visibility: hidden; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
.dragged { background: var(--flash); }
.round input { width: 6rem; text-align: right; font-size: 1.1rem; }
form.inline { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.8rem 0; }
.offline { color: var(--danger); }
.badge { font-size: 0.85rem; padding: 0.05rem 0.4rem; border-radius: 4px; background: var(--flash); }

ol.podium { padding-left: 2rem; font-size: 1.1rem; }
ol.podium li { padding: 0.3rem 0.5rem; border-radius: 6px; }
ol.podium .total { font-weight: 700; font-variant-numeric: tabular-nums; }
ol.podium .note { color: var(--muted); font-size: 0.9rem; margin-left: 0.5rem; }
ol.podium li.winner { background: var(--win); }
ol.podium li.loser { background: var(--lose); }
ul.facts { padding-left: 1.2rem; color: var(--muted); }
ul.facts strong { color: var(--fg); }

/* The notice on the home page; its HTML comes from Markdown. */
textarea {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  width: 100%;
  resize: vertical;
}
.hint { font-size: 0.85rem; margin: 0; }
.card.notice {
  background: var(--notice);
  border-color: var(--notice-line);
  border-left: 5px solid var(--accent);
}
.notice .label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.notice .text { overflow-wrap: anywhere; }
.notice .text > :first-child { margin-top: 0; }
.notice .text h1, .notice .text h2, .notice .text h3 { font-size: 1.2rem; margin: 1rem 0 0.5rem; }
.notice .text img { max-width: 100%; }
.notice .hint { margin-top: 0.8rem; }
.notice-add { margin: 0.5rem 0; text-align: right; font-size: 0.9rem; }
