:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #1d1b18;
  --muted: #6b665d;
  --line: #e2ddd3;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --gold: #b7791f;
  --gold-bg: #fdf3dc;
  --silver: #64748b;
  --silver-bg: #eef1f5;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #92400e;
  --warn-bg: #fff4d6;
  --err: #b91c1c;
  --err-bg: #fde8e8;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1e1c19;
    --ink: #f1ede6;
    --muted: #a39d92;
    --line: #34312c;
    --accent: #f97316;
    --accent-ink: #1a1007;
    --gold: #f2b84b;
    --gold-bg: #3a2c10;
    --silver: #b4c0d0;
    --silver-bg: #262b33;
    --ok: #4ade80;
    --ok-bg: #12301d;
    --warn: #fbbf24;
    --warn-bg: #3a2c0c;
    --err: #f87171;
    --err-bg: #3b1515;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 980px; margin: 0 auto; padding: 16px 16px 64px; }
h1 { font-size: 1.5rem; margin: 4px 0 2px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 0.95rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
button, .btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--err); }
button.small { min-height: 32px; padding: 4px 10px; font-size: 0.9rem; }
button:disabled { opacity: 0.5; cursor: default; }
input[type=text], input[type=password], input.score {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 40px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.msg { border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.err { background: var(--err-bg); color: var(--err); }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Sonuç tablosu */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
td.total, th.total { font-weight: 700; }
td.empty { color: var(--muted); }
tr.f1 td { background: var(--gold-bg); }
tr.f2 td { background: var(--silver-bg); }
.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.final { background: var(--accent); color: var(--accent-ink); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge.open { background: var(--warn-bg); color: var(--warn); }

.finalists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.finalist { border-radius: var(--radius); padding: 14px; }
.finalist.f1 { background: var(--gold-bg); }
.finalist.f2 { background: var(--silver-bg); }
.finalist .lbl { font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.finalist .name { font-size: 1.3rem; font-weight: 700; overflow-wrap: anywhere; }
.finalist .pts { font-variant-numeric: tabular-nums; color: var(--muted); }

/* Liste (takımlar, oyunlar) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.list .name { flex: 1; min-width: 120px; font-weight: 600; overflow-wrap: anywhere; }
.link { font-size: 0.85rem; color: var(--muted); word-break: break-all; }
.qr { width: 180px; height: 180px; background: #fff; border-radius: 8px; padding: 6px; }

/* Hakem ekranı */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.team-pick { flex-direction: column; align-items: flex-start; justify-content: center; min-height: 72px; padding: 12px 14px; text-align: left; }
.team-pick .nm { font-size: 1.1rem; font-weight: 700; overflow-wrap: anywhere; }
.team-pick .tick { font-size: 0.85rem; color: var(--ok); min-height: 1.2em; }
.team-pick.saved { border-color: var(--ok); }
.entry-team { font-size: 1.8rem; margin: 2px 0 0; overflow-wrap: anywhere; }
input.entry-score { width: 100%; font-size: 2rem; text-align: center; min-height: 64px; }
.bar { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; display: flex; gap: 8px; }
.bar button { flex: 1; min-height: 52px; font-size: 1.05rem; justify-content: center; }

nav.tabs { display: flex; gap: 4px; margin: 8px 0 16px; overflow-x: auto; }
nav.tabs button { border-radius: 99px; white-space: nowrap; flex-shrink: 0; }
nav.tabs button[aria-selected=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

td.total, th.total { border-right: 1px solid var(--line); }
@media (max-width: 520px) {
  .finalists { gap: 8px; }
  .finalist { padding: 10px 12px; }
  .finalist .name { font-size: 1.1rem; }
}
