:root {
  --felt: #0b6b3a;
  --felt-dark: #084f2b;
  --felt-deep: #063d21;
  --ink: #0d1a12;
  --cream: #f4efe2;
  --gold: #e8b23a;
  --gold-soft: #f0c96a;
  --wood: #6b3f1d;
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(0, 0, 0, 0.22);
  --win: #6ee787;
  --danger: #ff8a80;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--cream);
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--felt) 0%, var(--felt-dark) 45%, var(--felt-deep) 100%),
    var(--felt-deep);
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.1));
  border-bottom: 3px solid var(--wood);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; letter-spacing: 0.3px; }
.logo { width: 46px; height: 46px; flex: none; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { color: var(--gold); font-size: 1.35rem; letter-spacing: 1px; }
.brand-text small { color: rgba(244,239,226,0.75); font-size: 0.72rem; letter-spacing: 0.4px; }
.ball {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 60%, #b8801f);
  color: #241a05;
  font-weight: 800;
  border: 2px solid #241a05;
  box-shadow: inset -2px -3px 6px rgba(0,0,0,0.35);
}
nav { display: flex; gap: 8px; }
.nav-btn {
  background: transparent;
  color: var(--cream);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.92rem;
  transition: all 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); }
.nav-btn.active { background: var(--gold); color: var(--ink); border-color: var(--gold); font-weight: 700; }

/* ---------- Layout ---------- */
main { max-width: 1000px; margin: 0 auto; padding: 26px 20px 60px; }
.view { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h1 { margin: 0 0 8px; font-size: 1.7rem; }
.lead { color: rgba(244,239,226,0.82); max-width: 60ch; line-height: 1.5; margin-top: 0; }
.hint { color: rgba(244,239,226,0.55); font-weight: 400; font-size: 0.8em; }

/* ---------- Formulier ---------- */
form { margin-top: 22px; }
.players-setup { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; }
.vs { font-size: 1.4rem; font-weight: 800; color: var(--gold); text-align: center; }
.player-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.player-card legend { padding: 0 8px; font-weight: 700; color: var(--gold-soft); }
label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 0.9rem; }
input, select {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--cream);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 1rem;
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
select option { background: var(--felt-deep); }
.options-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--ink);
  border: none;
  font-weight: 800;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px 20px;
  font-size: 1rem;
  transition: transform 0.08s, filter 0.15s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-large { width: 100%; padding: 15px; font-size: 1.1rem; margin-top: 22px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--cream);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); }

/* ---------- Scorebord ---------- */
.score-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.pill {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.player-score {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.player-score.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,178,58,0.25), var(--shadow);
}
.player-score.done { border-color: var(--win); }
.ps-name { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ps-badge { font-size: 0.7rem; background: var(--gold); color: var(--ink); padding: 2px 8px; border-radius: 999px; font-weight: 800; }
.ps-total { font-size: 4rem; font-weight: 800; line-height: 1; margin: 8px 0 2px; }
.ps-total .target { font-size: 1.5rem; color: rgba(244,239,226,0.6); font-weight: 600; }
.progress { height: 8px; background: rgba(0,0,0,0.3); border-radius: 999px; overflow: hidden; margin: 10px 0 16px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-soft)); transition: width 0.3s; }
.player-score.done .progress > span { background: var(--win); }
.ps-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat { background: rgba(0,0,0,0.22); border-radius: 10px; padding: 8px 4px; }
.stat .v { font-size: 1.35rem; font-weight: 800; color: var(--gold-soft); }
.stat .k { font-size: 0.72rem; color: rgba(244,239,226,0.65); text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Beurt-paneel ---------- */
.turn-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 18px;
  text-align: center;
}
.turn-active { font-size: 1.05rem; margin-bottom: 12px; }
.turn-active strong { color: var(--gold); }
.carom-input { display: flex; justify-content: center; align-items: center; gap: 12px; }
.carom-input input {
  width: 130px; text-align: center; font-size: 2.4rem; font-weight: 800; padding: 6px;
}
.step {
  width: 54px; height: 54px; border-radius: 50%; font-size: 1.8rem; line-height: 1;
  background: rgba(0,0,0,0.3); color: var(--cream); border: 1px solid var(--line); cursor: pointer;
}
.step:hover { background: rgba(255,255,255,0.1); }
.quick { display: flex; justify-content: center; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.q {
  background: rgba(0,0,0,0.28); color: var(--cream); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 700; min-width: 52px;
}
.q:hover { background: var(--gold); color: var(--ink); border-color: var(--gold); }

.score-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

.banner {
  background: linear-gradient(180deg, rgba(110,231,135,0.2), rgba(110,231,135,0.08));
  border: 1px solid var(--win);
  color: var(--win);
  padding: 14px 18px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---------- Geschiedenis ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.history-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.hi-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.hi-date { color: rgba(244,239,226,0.6); font-size: 0.82rem; }
.hi-players { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 10px; }
.hi-p { background: rgba(0,0,0,0.2); border-radius: 10px; padding: 10px 12px; }
.hi-p.winner { border: 1px solid var(--win); }
.hi-p .n { font-weight: 700; }
.hi-p .m { color: var(--gold-soft); font-size: 0.86rem; margin-top: 3px; }
.hi-vs { color: var(--gold); font-weight: 800; }
.hi-actions { display: flex; gap: 8px; }
.hi-actions button { font-size: 0.8rem; padding: 6px 12px; }
.tag-live { color: var(--gold); font-weight: 800; }
.empty { color: rgba(244,239,226,0.6); text-align: center; padding: 40px; }

/* ---------- Spelers ---------- */
.player-add {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 18px;
}
.player-add label { margin-bottom: 0; }
.player-add button { height: 44px; }
.players-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.pr-name { font-weight: 700; font-size: 1.05rem; flex: 1; }
.pr-edit { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 0; font-size: 0.8rem; color: rgba(244,239,226,0.7); }
.pr-target-input { width: 84px; padding: 7px 8px; font-size: 0.95rem; text-align: center; }
.pr-del { font-size: 0.8rem; padding: 6px 12px; }
.hi-date-inline { color: rgba(244,239,226,0.6); font-size: 0.82rem; margin-left: 6px; }

@media (max-width: 720px) {
  .player-add { grid-template-columns: 1fr; }
}

/* ---------- Competitie ---------- */
h2.sub { margin: 28px 0 6px; font-size: 1.15rem; color: var(--gold-soft); }
.comp-players { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.chk { flex-direction: row; align-items: center; gap: 8px; margin-bottom: 0; font-size: 0.92rem; cursor: pointer; }
.chk input { width: auto; }
.comp-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.comp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.ci-info strong { font-size: 1.05rem; }
.ci-sub { color: rgba(244,239,226,0.6); font-size: 0.82rem; margin-top: 3px; }
.ci-actions { display: flex; gap: 8px; }
.ci-actions button { font-size: 0.85rem; padding: 8px 14px; }

.table-wrap { overflow-x: auto; }
.standings { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.9rem; }
.standings th, .standings td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.standings th { color: rgba(244,239,226,0.7); font-weight: 600; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.4px; }
.standings td.st-name { text-align: left; font-weight: 700; }
.standings td.st-pts { font-weight: 800; color: var(--gold-soft); }
.standings tr.leader td { background: rgba(232,178,58,0.12); }
#comp-nextlevel { margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--line); }
.standings tfoot tr.totals td { border-top: 2px solid var(--line); font-weight: 700; background: rgba(0,0,0,0.18); }
.standings tfoot tr.totals td.st-pts { color: var(--gold); font-weight: 800; }
.pill-accent { background: rgba(232,178,58,0.18); border-color: var(--gold); color: var(--gold-soft); font-weight: 700; }

.fixtures { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fx-row {
  display: grid; grid-template-columns: 34px 1fr auto auto auto; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.fx-num { color: rgba(244,239,226,0.5); font-size: 0.85rem; text-align: center; }
.fx-players { font-weight: 600; }
.fx-vs { color: var(--gold); font-weight: 800; margin: 0 4px; }
.fx-date { color: rgba(244,239,226,0.6); font-size: 0.8rem; white-space: nowrap; }
.fx-res { color: var(--win); font-size: 0.85rem; }
.fx-busy { color: var(--gold); font-size: 0.85rem; }
.fx-todo { color: rgba(244,239,226,0.5); font-size: 0.85rem; }
.fx-btn { font-size: 0.82rem; padding: 7px 14px; }

@media (max-width: 720px) {
  .fx-row { grid-template-columns: 26px 1fr; }
  .fx-date, .fx-res, .fx-busy, .fx-todo { grid-column: 2; }
}

.detail-actions { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.print-only { display: none; }

.evening-controls {
  display: flex; align-items: end; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin: 20px 0 4px;
}
.evening-controls label { margin-bottom: 0; }
.evening-controls input { width: 90px; }
.evening-controls button { height: 44px; }
.evening-progress { font-size: 0.8rem; color: rgba(244,239,226,0.6); font-weight: 400; }
#comp-evening-list .fx-row { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(232,178,58,0.15); }

.evening-absent { margin: 4px 0 0; }
.ea-label { display: block; font-size: 0.9rem; margin-bottom: 8px; color: rgba(244,239,226,0.85); }
.ea-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.evening-absent-note { color: var(--danger); font-size: 0.85rem; margin: 2px 0 10px; }

/* ---------- Afdrukken ---------- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff !important; color: #000 !important; }
  .topbar, nav, .no-print, .detail-actions, .fx-btn, #toast, #comp-overview { display: none !important; }
  .view { display: none !important; }
  #view-competitie { display: block !important; }
  #comp-detail { display: block !important; }
  main { max-width: none; margin: 0; padding: 0; }
  .print-only { display: block; }
  #print-header { font-size: 1.25rem; font-weight: 800; margin-bottom: 10px; border-bottom: 2px solid #000; padding-bottom: 6px; }
  #print-header .ph-sub { display: block; font-size: 0.8rem; font-weight: 400; color: #333; margin-top: 3px; }
  .print-note { font-size: 0.85rem; color: #555; margin: 4px 0; }
  h1, h2.sub { color: #000 !important; }
  h1 { font-size: 1.4rem; margin: 6px 0; }
  .pill { background: #fff; color: #000; border: 1px solid #999; }
  .banner { background: #fff !important; color: #000 !important; border: 1px solid #000; }
  .standings th, .standings td { color: #000 !important; border-color: #999 !important; }
  .standings td.st-name, .standings td.st-pts { color: #000 !important; }
  .standings tr.leader td { background: #eee !important; }
  .standings tfoot tr.totals td { background: #f0f0f0 !important; color: #000 !important; border-top: 2px solid #000 !important; }
  .fx-row { background: #fff !important; color: #000 !important; border: 1px solid #999; page-break-inside: avoid; }
  .fx-row:not(.is-played) { display: none !important; }
  .fx-vs, .fx-res, .fx-date { color: #000 !important; }
  a[href]:after { content: ""; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--cream); padding: 12px 20px; border-radius: 10px;
  border: 1px solid var(--gold); box-shadow: var(--shadow); z-index: 50; font-size: 0.9rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .players-setup { grid-template-columns: 1fr; }
  .vs { display: none; }
  .options-row { grid-template-columns: 1fr; }
  .ps-total { font-size: 3rem; }
  .logo { width: 38px; height: 38px; }
  .brand-text strong { font-size: 1.1rem; }
}
