:root {
  --bg: #fafaf7;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --line: #deded8;
  --card: #ffffff;
  --accent: #2f5fd0;
  --accent-fg: #ffffff;
  --win: #e6f4e4;
  --lose: #fbeaea;
  --danger: #b3261e;
  --flash: #fff6d6;
  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;
  }
}

* { 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;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
}
.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); }
