:root {
  --bg: #f3f4f6; --card: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #b45309; --accent-soft: #fef3c7; --ok: #15803d; --warn: #dc2626; --bar: #1f2937;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b0f17; --card: #161b26; --ink: #f3f4f6; --muted: #9ca3af; --line: #2a3140;
          --accent: #f59e0b; --accent-soft: #3b2a0a; --ok: #22c55e; --warn: #f87171; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

/* login */
.login { max-width: 320px; margin: 20vh auto 0; padding: 0 20px; display: grid; gap: 12px; text-align: center; }
.login input { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.error { color: var(--warn); min-height: 1.4em; margin: 0; }

.primary { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 600; }
.primary:disabled { opacity: .5; }
.link { background: none; border: 0; color: var(--accent); padding: 6px 8px; }

/* layout */
.tab { padding: 0 12px calc(140px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px; background: var(--bg); }
.bar h2 { font-size: 18px; min-width: 170px; text-align: center; }
.bar input[type=date] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.nav { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 24px; line-height: 1; }
.hint { color: var(--muted); font-size: 14px; margin: 0 4px 10px; }
.empty, .note { color: var(--muted); text-align: center; padding: 24px; list-style: none; }
.note { font-size: 13px; padding: 12px; }

/* score cards */
.card { background: var(--card); border-radius: 14px; padding: 12px; margin-bottom: 12px; border: 2px solid transparent; }
.card.done { border-color: var(--ok); }
.card.partial { border-color: var(--warn); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.card-head h3 { font-size: 18px; }
.card.done .card-head h3::after { content: " ✓"; color: var(--ok); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.label { font-size: 14px; color: var(--muted); flex: 1; }
.picks { display: flex; gap: 6px; }
.picks button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; }
.picks button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.savebar { position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-top: 1px solid var(--line); }
#save-status { color: var(--muted); font-size: 14px; }

/* leaderboard & history */
.board, .history, .staff { list-style: none; padding: 0; margin: 0; }
.board li:not(.empty):not(.note), .history li, .staff li { background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.board li.leader { background: var(--accent-soft); }
.line { display: flex; align-items: baseline; gap: 10px; }
.line .name { flex: 1; font-weight: 600; }
.days { color: var(--muted); font-size: 13px; }
.mean { font-weight: 700; font-variant-numeric: tabular-nums; }
.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.cats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.history li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.history .wk { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.history .name { font-weight: 600; }

/* staff */
.add { display: flex; gap: 8px; margin-bottom: 12px; }
.add input { flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink); }
.staff li { display: flex; align-items: center; gap: 4px; }
.staff .name { flex: 1; }
.staff li.inactive .name { color: var(--muted); text-decoration: line-through; }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; background: var(--bar);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; height: 60px; background: none; border: 0; color: #9ca3af; font-size: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tabs button span { font-size: 11px; margin-top: 2px; }
.tabs button.active { color: #fff; }
