:root {
  /* Zwart thema (op vraag, 19-11-2026): logo = biljartbal 11 met Napoleonhoed (logo.svg). */
  --navy: #000000;
  --navy-2: #161616;
  --gold: #c9a24a;
  --gold-soft: #2b2414;
  --paper: #000000;
  --card: #141414;
  --ink: #f2f2f2;
  --muted: #9b9b9b;
  --line: #2a2a2a;
  --win: #6cc28f;
  --loss: #e08a83;
  --mine-bg: #211c10;
  --shadow: none;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.4;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--navy);
  color: #f6f0e2;
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .logo { display: block; height: 46px; width: 46px; flex: none; }
.brand-title { font-family: var(--serif); font-weight: 700; font-size: 17px; letter-spacing: .2px; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-text { min-width: 0; }
@media (max-width: 380px) { .brand-title { font-size: 15px; } }
.team-chip {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 48vw;
  border: 1px solid rgba(201, 162, 74, .7);
  background: rgba(255, 255, 255, .06);
  color: #f6f0e2;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}
.team-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; }
.team-chip.empty .dot { background: transparent; border: 1px solid var(--gold); }

main { max-width: 720px; margin: 0 auto; padding: 16px 14px 24px; }
.view-title { font-family: var(--serif); font-size: 22px; margin: 4px 2px 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.footnote { color: var(--muted); font-size: 12.5px; margin: 12px 4px; }

/* Banners */
.banner {
  display: flex; align-items: center; gap: 10px;
  max-width: 720px; margin: 10px auto 0; padding: 10px 12px 10px 14px;
  background: var(--gold-soft); color: var(--ink);
  border-radius: 12px; font-size: 14px;
  width: calc(100% - 28px);
}
.banner span { flex: 1; }
.banner-muted { background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.icon-btn { background: none; border: 0; font-size: 22px; line-height: 1; padding: 0 4px; color: var(--muted); }

/* Buttons */
.btn, .btn-small {
  background: var(--gold); color: #000; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 600;
}
.btn-small { padding: 7px 12px; font-size: 13px; }
.btn-ghost { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; color: var(--muted); }
.btn:disabled { opacity: .5; }

/* Segmented */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--card); border: 1px solid var(--line);
  padding: 4px; border-radius: 12px; margin: 14px 0 6px;
}
.seg { border: 0; background: none; border-radius: 9px; padding: 8px; font-size: 14px; color: var(--muted); }
.seg.active { background: var(--gold); color: #000; font-weight: 600; }
.seg:disabled { opacity: .45; cursor: default; }

/* Next match card */
.card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 16px; }
.next-card {
  background: linear-gradient(160deg, var(--navy-2) 0%, #0a0a0a 100%);
  color: #f6f0e2; border: 1px solid var(--line); position: relative; overflow: hidden;
}
.next-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px;
  border: 2px solid rgba(201, 162, 74, .35); border-radius: 50%;
}
.next-label { font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.next-date { font-family: var(--serif); font-size: 21px; margin: 6px 0 10px; }
.next-teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.next-teams .t { font-weight: 600; font-size: 15px; }
.next-teams .t:last-child { text-align: right; }
.next-teams .t.me { color: var(--gold); }
.next-teams .vs { font-family: var(--serif); color: #c8cbd6; font-style: italic; }
.next-meta { display: flex; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; color: #c8cbd6; }
.next-meta strong { color: #fff; font-size: 16px; display: block; }

/* Calendar */
.month { margin: 22px 2px 8px; font-family: var(--serif); font-size: 17px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; }
.month::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.match {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow);
  scroll-margin-top: 90px;
}
.match.mine { background: var(--mine-bg); border-color: var(--gold); box-shadow: inset 4px 0 0 var(--gold), var(--shadow); }
.match.dim { opacity: .55; }
.match.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.date-box { text-align: center; border-right: 1px solid var(--line); padding-right: 10px; }
.date-box .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.date-box .day { font-family: var(--serif); font-size: 22px; font-weight: 700; line-height: 1.1; }
.lines { min-width: 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.line .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.line.me .name { font-weight: 700; }
.line .score { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 26px; text-align: right; font-size: 16px; }
.line.won .score { color: var(--win); }
.line.lost .name, .line.lost .score { color: var(--muted); font-weight: 500; }
.line.me.lost .name { font-weight: 700; }
.meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; }
.badge { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.badge.w { background: rgba(47, 122, 79, .12); color: var(--win); }
.badge.l { background: rgba(162, 64, 58, .12); color: var(--loss); }
.badge.today { background: var(--gold); color: var(--navy); }
.empty-note { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Standings */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; box-shadow: var(--shadow); }
.standings { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.standings th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.standings td { text-align: right; padding: 11px 8px; border-bottom: 1px solid var(--line); }
.standings tr:last-child td { border-bottom: 0; }
.standings th:nth-child(2), .standings td:nth-child(2) { text-align: left; }
.standings th:first-child, .standings td:first-child { text-align: center; width: 40px; padding-left: 12px; }
.standings td:last-child, .standings th:last-child { padding-right: 14px; }
.standings .pts { font-weight: 800; font-size: 15px; }
.standings .team { font-weight: 600; white-space: nowrap; }
/* vaste breedte voor de teamnaam; te lange namen schuiven (fitTeamNames in app.js) */
.name-clip { display: block; width: 150px; overflow: hidden; white-space: nowrap; }
.name-clip > span { display: inline-block; }
.name-clip.marquee { mask-image: linear-gradient(90deg, #000 88%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); }
.name-clip.marquee > span { animation: team-scroll var(--dur, 6s) ease-in-out infinite alternate; }
@keyframes team-scroll { 0%, 18% { transform: translateX(0); } 82%, 100% { transform: translateX(var(--shift, 0)); } }
@media (prefers-reduced-motion: reduce) {
  .name-clip.marquee { mask-image: none; -webkit-mask-image: none; }
  .name-clip.marquee > span { animation: none; display: block; overflow: hidden; text-overflow: ellipsis; }
}
.badge.d { background: rgba(155, 155, 155, .15); color: var(--muted); }
.standings tr.mine td { background: var(--mine-bg); }
.standings tr.mine td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.rank { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 700; font-size: 13px; }
.rank.r1 { background: var(--gold); color: var(--navy); }
.standings .opt { display: table-cell; }
@media (max-width: 420px) {
  .standings .opt { display: none; }
  .standings th, .standings td { padding-left: 5px; padding-right: 5px; }
  .name-clip { width: 112px; }
}

/* Admin */
.login-card form { display: flex; gap: 8px; margin-top: 12px; }
input[type=password], input[type=number], input[type=date], input[type=text], select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input[type=password] { flex: 1; min-width: 0; }
input:focus { outline: 2px solid var(--gold); outline-offset: 0; }
.error { color: var(--loss); font-size: 14px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; }
.admin-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.admin-row .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.admin-row .grid { display: grid; grid-template-columns: 1fr 64px; gap: 6px 10px; align-items: center; }
.admin-row .grid input { width: 64px; text-align: center; font-size: 17px; font-weight: 700; padding: 8px 4px; }
.admin-row .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.admin-row.saved { border-color: var(--win); }
.admin-row.dirty { border-color: var(--gold); }
.add-match { width: 100%; margin-bottom: 10px; }
.cal-row .cal-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; font-size: 14px; }
.cal-row .cal-grid label { color: var(--muted); }
.cal-row .cal-grid input, .cal-row .cal-grid select { width: 100%; min-width: 0; padding: 8px 10px; font-size: 15px; }
.cal-row .actions .btn-ghost.danger { color: var(--loss); border-color: var(--loss); }
.cal-row.new { border-color: var(--gold); border-width: 2px; }
.cal-row .past { color: var(--muted); font-size: 12px; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; color: var(--muted); }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--ink); font-weight: 700; }
.tab.active svg { stroke: var(--gold); stroke-width: 2; }

/* Dialog */
dialog {
  border: 0; border-radius: 20px; padding: 0; width: min(440px, calc(100% - 24px));
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dialog-inner { padding: 20px; }
.dialog-inner h2 { font-family: var(--serif); margin: 0 0 6px; }
.team-options { display: grid; gap: 8px; margin: 16px 0 12px; }
.team-options button {
  text-align: left; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; font-weight: 600;
}
.team-options button.active { border-color: var(--gold); background: var(--mine-bg); box-shadow: inset 4px 0 0 var(--gold); }
#teamNone { width: 100%; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: #222; color: #fff; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  transition: .2s ease; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--loss); }

@media (min-width: 760px) {
  .tabbar { max-width: 720px; margin: 0 auto 14px; border: 1px solid var(--line); border-radius: 18px; height: var(--tabbar-h); padding-bottom: 0; box-shadow: var(--shadow); }
}
