:root {
  /* Sprightly-huisstijl: blauw is de hoofdkleur, roze het ene accent per
     scherm (de opslaan-knop), paars voor een 1-1. Licht of donker volgt de
     telefoon. */
  --bg: #f3f6f9;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --line: #d5dfe8;
  --text: #3d3d3d;
  --muted: #6b7680;
  --accent: #448ba8;
  --on-accent: #ffffff;
  --hot: #ee438b;
  --accent-2: #624173;
  --win: #2a9d6a;
  --loss: #d0475a;
  --pending: #c98a1e;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191d;
    --panel: #1e242a;
    --panel-2: #262d34;
    --line: #2f3943;
    --text: #e8ecef;
    --muted: #9aa7b2;
    --accent: #6fb1cc;
    --on-accent: #0d1f27;
    --hot: #f472a8;
    --accent-2: #c1a2d4;
    --win: #4cc38a;
    --loss: #f07a86;
    --pending: #e8b04b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 "Work Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent);
  color: var(--on-accent);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 18px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .02em; }
.ball {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #fff, #c9c4d6 35%, #6d6680 75%, #2b2638);
  box-shadow: 0 0 10px color-mix(in srgb, var(--hot) 55%, transparent);
}
.sync { width: 8px; height: 8px; border-radius: 50%; background: var(--win); flex: none; }
.sync.offline { background: var(--loss); }
.sync.pending { background: var(--pending); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top .chip, .top .icon-btn { background: color-mix(in srgb, #fff 18%, transparent); border-color: color-mix(in srgb, #fff 45%, transparent); color: var(--on-accent); }
.top .sync { box-shadow: 0 0 0 2px var(--accent); }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); }
.icon-btn.on { color: var(--accent-2); border-color: var(--accent-2); }

/* layout */
.view { padding: 4px 16px 24px; max-width: 720px; margin: 0 auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.hint { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.hint b { color: var(--text); }

/* bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--panel) 96%, transparent); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); backdrop-filter: blur(8px);
}
.tabs button {
  border: 0; background: none; color: var(--muted); padding: 8px 0 10px; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs button span { font-size: 18px; line-height: 1.2; }
.tabs button.active { color: var(--accent); }

/* buttons & inputs */
.btn {
  border: 0; border-radius: 12px; padding: 14px 16px; font-weight: 600; width: 100%;
  background: var(--hot); color: #fff; font-size: 17px;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); font-weight: 500; }
.btn.small { padding: 8px 12px; font-size: 14px; width: auto; }
.btn.danger { background: transparent; border: 1px solid var(--loss); color: var(--loss); }
input[type=text], input[type=password], input[type=search] {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); font-size: 17px; outline: none;
}
input:focus { border-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.pick {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 12px 8px;
  text-align: center; min-height: 56px; display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.pick .sub { font-size: 12px; color: var(--muted); }
.pick.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.pick.done { opacity: .35; }
.pick.half .sub { color: var(--accent-2); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg .pick { min-height: 64px; font-weight: 600; }
.seg .pick.win.sel { border-color: var(--win); background: color-mix(in srgb, var(--win) 15%, transparent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 6px 11px; font-size: 14px; }

/* standings */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
th:nth-child(2), td:nth-child(2) { text-align: left; }
td:first-child, th:first-child { text-align: center; width: 30px; color: var(--muted); }
tr.me td { background: color-mix(in srgb, var(--hot) 10%, transparent); }
td.pts { font-weight: 700; font-size: 18px; color: var(--accent-2); }
.bar { height: 4px; background: var(--panel-2); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.podium-1 td:first-child { color: #c9a227; font-weight: 700; }
.podium-2 td:first-child { color: #8a96a3; font-weight: 700; }
.podium-3 td:first-child { color: #b9733a; font-weight: 700; }

/* matrix */
.matrix-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.matrix { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.matrix th, .matrix td { border: 0; padding: 0; text-align: center; }
.matrix th.rowh { text-align: left; padding-right: 4px; white-space: nowrap; color: var(--text); font-size: 12px; text-transform: none; letter-spacing: 0; position: sticky; left: 0; background: var(--panel); z-index: 1; }
.matrix th.colh { writing-mode: vertical-rl; transform: rotate(180deg); height: 62px; padding-bottom: 4px; font-size: 12px; color: var(--text); text-transform: none; letter-spacing: 0; font-weight: 500; }
.matrix td div { width: 25px; height: 26px; font-size: 11px; border-radius: 6px; display: grid; place-items: center; background: var(--panel-2); color: var(--muted); font-weight: 600; }
.matrix td.self div { background: transparent; }
.matrix td.w div { background: color-mix(in srgb, var(--win) 22%, transparent); color: var(--win); }
.matrix td.l div { background: color-mix(in srgb, var(--loss) 18%, transparent); color: var(--loss); }
.matrix td.d div { background: color-mix(in srgb, var(--accent-2) 18%, transparent); color: var(--accent-2); }
.matrix td.p div { outline: 1px dashed var(--muted); }
.matrix tr.me th.rowh { color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.feed li:last-child { border-bottom: 0; }
.feed .what { flex: 1; min-width: 0; }
.feed .what b.w { color: var(--win); }
.feed .meta { font-size: 13px; color: var(--muted); }
.feed .tag { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--pending); color: var(--pending); margin-left: 6px; }
.feed .del { border: 0; background: none; color: var(--muted); font-size: 20px; padding: 0 4px; }

/* stats */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

/* toast & modal */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 30; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: var(--loss); }
dialog {
  border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 18px;
  padding: 20px; width: min(420px, calc(100% - 32px)); max-height: 85dvh;
}
dialog::backdrop { background: rgba(10, 20, 28, .55); }
dialog h3 { margin: 0 0 12px; }
.stack > * + * { margin-top: 10px; }
.summary { font-size: 18px; line-height: 1.5; }
.summary b { color: var(--accent-2); }
.list-admin li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list-admin { list-style: none; padding: 0; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
