:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #ece7dc;
  --text: #1d1d1b;
  --muted: #6b675e;
  --border: #ddd6c7;
  --accent: #1f6f4a;
  --accent-text: #ffffff;
  --accent-soft: #dcefe4;
  --notrump: #6b4fa0;
  --extra: #b06a12;
  --pos: #1c7a45;
  --neg: #c0392b;
  --warn-bg: #fdecea;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121512;
    --surface: #1c201d;
    --surface-2: #262b27;
    --text: #ecebe6;
    --muted: #9c9a92;
    --border: #333a35;
    --accent: #3fae78;
    --accent-text: #0b1a12;
    --accent-soft: #1d3a2b;
    --notrump: #a58ad8;
    --extra: #e2a04d;
    --pos: #5fd394;
    --neg: #ff7b6e;
    --warn-bg: #3a1f1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation; /* geen dubbeltik-zoom, zodat snel tikken op − en + telt */
}

button {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}

a { color: var(--accent); }
h1, h2 { margin: 0; }

.muted, .hint, .legend, .empty { color: var(--muted); }
.hint { font-size: 15px; margin: 4px 0 16px; }
.legend { font-size: 13px; margin: 8px 0 0; }
.empty { text-align: center; padding: 16px 0; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 24px 0 8px;
}

/* ---------- knoppen ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--neg); margin-top: 32px; }
.btn.block { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }

.btn-row { display: flex; gap: 12px; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.btn-row .btn.primary { flex: 2; }

.icon, .chip {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.icon:disabled { opacity: .3; }
.chip { padding: 0 10px; font-size: 14px; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- topbalk ---------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
}
.topbar .back { text-decoration: none; font-weight: 500; }
.topbar .title { font-weight: 700; }
.topbar .right { text-align: right; }
.topbar .right a { text-decoration: none; font-weight: 600; }

/* ---------- start ---------- */

.hero { text-align: center; padding: 24px 0 16px; }
.hero h1 { font-size: 32px; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.logo {
  width: 72px; height: 72px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-text);
  font: 700 26px Georgia, serif;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.card h2 { font-size: 18px; }
.card p { margin: 4px 0 8px; }

.games { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.games a {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
}
.games .date { font-size: 13px; color: var(--muted); }
.games .result { font-weight: 600; }
.games .players { font-size: 14px; color: var(--muted); }

/* ---------- nieuw spel ---------- */

.setup { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.setup li { display: flex; align-items: center; gap: 6px; }
.setup .seat { width: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.setup input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;
}
.setup input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- ronde ---------- */

.round {
  border-radius: var(--radius);
  padding: 16px;
  background: var(--accent);
  color: #fff;
  text-align: center;
}
.round.notrump { background: var(--notrump); }
.round.extra, .round.winner-banner { background: var(--extra); }
@media (prefers-color-scheme: dark) { .round { color: #0d0f0d; } }
.round-no { font-size: 14px; opacity: .85; }
.round-cards { font-size: 30px; font-weight: 800; line-height: 1.2; }
.round-tag { font-weight: 600; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.round-meta { margin-top: 8px; font-size: 15px; }

.round + .entries { margin-top: 16px; }
.entries { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.entries li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 64px; }
.entries li + li { border-top: 1px solid var(--border); }
.entries .who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entries .name { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entries .sub { font-size: 13px; color: var(--muted); }
.entries.edit li { flex-direction: column; align-items: stretch; }
.entries.edit .who { flex-direction: row; justify-content: space-between; }
.pair { display: flex; gap: 12px; justify-content: space-between; }
.pair label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }

.tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.pts { font-weight: 700; min-width: 40px; text-align: right; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper output { color: var(--text); width: 40px; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.step {
  width: 48px; height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.step:active:not(:disabled) { background: var(--border); }
.step:disabled { opacity: .25; }

.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.segmented button {
  min-width: 72px; height: 42px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text);
  font: inherit; cursor: pointer;
}
.segmented button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }

.summary { margin: 12px 4px 0; font-size: 15px; color: var(--muted); }
.summary.ok { color: var(--pos); }
.summary.warn { color: var(--neg); }

.flash {
  background: var(--warn-bg);
  color: var(--neg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-weight: 600;
}

/* ---------- stand ---------- */

.standings { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.standings li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.standings li + li { border-top: 1px solid var(--border); }
.standings .rank { width: 24px; text-align: center; color: var(--muted); font-weight: 600; }
.standings .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standings .delta { font-size: 14px; }
.standings .total { font-weight: 800; font-size: 18px; min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.standings .winner .name { font-weight: 700; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scores { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.scores th, .scores td { padding: 6px 8px; text-align: center; white-space: nowrap; }
.scores thead th {
  font-size: 13px; font-weight: 700;
  max-width: 80px; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid var(--border);
}
.scores tbody tr + tr { border-top: 1px solid var(--border); }
.scores th[scope="row"], .scores thead th:first-child {
  position: sticky; left: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  width: 40px;
}
.scores .rc { font-weight: 700; }
.scores .rt { display: block; font-size: 10px; color: var(--notrump); text-transform: uppercase; font-weight: 700; }
.scores .cum { font-weight: 700; }
.scores .sub { font-size: 11px; }
.scores .bt { color: var(--muted); }
.scores .na { color: var(--muted); }
.scores .pending { color: var(--muted); opacity: .5; }
.scores .clickable { cursor: pointer; }
.scores .clickable:active { background: var(--surface-2); }
.scores tfoot td, .scores tfoot th { border-top: 2px solid var(--border); font-weight: 800; font-size: 17px; padding: 10px 8px; }
.scores tfoot .lead { color: var(--accent); }
