:root {
  --board: #0f4d2e;        /* scoreboard green */
  --board-deep: #0a3820;
  --board-line: #1d6640;
  --paper: #f5f7f3;
  --surface: #ffffff;
  --ink: #18231c;
  --ink-soft: #55635a;
  --rule: #d9e2dc;
  --red: #c8102e;          /* under par */
  --flag: #f2c230;         /* winner / bonus */
  --ok: #1f7a46;
  --warn: #b5560f;
  --radius-s: 6px;
  --radius-m: 10px;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Barlow', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0c1610;
    --surface: #13211a;
    --ink: #e8efe9;
    --ink-soft: #9db0a4;
    --rule: #24372c;
    --red: #ff5a6e;
    --board: #0b3a22;
    --board-deep: #082a18;
    --board-line: #1a5a37;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--flag); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.pad { padding: 16px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--board);
  color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
  flex-wrap: wrap;
}
.brand {
  font: 700 26px/1 var(--cond);
  letter-spacing: .02em;
  text-decoration: none;
  padding-bottom: 10px;
}
.brand span { color: var(--flag); }
.acct { margin-left: auto; font-size: 14px; opacity: .85; padding-bottom: 10px; text-decoration: none; }
.tabs {
  order: 3; flex-basis: 100%;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 12px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  font: 600 17px/1 var(--cond);
  text-decoration: none; white-space: nowrap;
  padding: 10px 10px 12px;
  color: rgba(255,255,255,.72);
  border-bottom: 3px solid transparent;
}
.tabs a.on { color: #fff; border-bottom-color: var(--flag); }
@media (min-width: 760px) {
  .top { flex-wrap: nowrap; padding-top: 0; }
  .brand, .acct { padding-bottom: 0; }
  .tabs { order: 0; flex-basis: auto; margin: 0; padding: 0; }
  .tabs a { padding: 18px 12px 15px; }
}

main { max-width: 760px; margin: 0 auto; padding: 0 0 80px; outline: none; }
section { padding: 16px; }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; line-height: 1.05; margin: 0 0 8px; }
h1 { font-size: 34px; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }
p { margin: 0 0 12px; }

/* ---------- event header: the scoreboard ---------- */
.board-head {
  background: var(--board);
  color: #fff;
  padding: 18px 16px 16px;
  border-bottom: 4px solid var(--board-deep);
}
.board-head h1 { font-size: 38px; letter-spacing: .01em; margin: 0; }
.board-head .sub { color: rgba(255,255,255,.75); font-size: 15px; margin-top: 6px; }
.board-head .pill { display: inline-block; margin-top: 10px; }
.pill {
  font: 600 14px/1 var(--cond); letter-spacing: .03em;
  padding: 5px 8px 4px; border-radius: 4px;
  background: rgba(255,255,255,.14); color: #fff;
}
.pill.flag { background: var(--flag); color: #1b1600; }
.pill.red { background: var(--red); color: #fff; }

/* ---------- leaderboard ---------- */
.lb { list-style: none; margin: 0; padding: 0; }
.lb > li { border-bottom: 1px solid var(--rule); background: var(--surface); }
.lb .row {
  display: grid; grid-template-columns: 44px 1fr auto 64px; align-items: center; gap: 8px;
  padding: 12px 16px; width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
}
.lb .pos { font: 600 20px/1 var(--cond); color: var(--ink-soft); }
.lb .who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .who small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 13px; }
.lb .tot { font: 700 30px/1 var(--cond); text-align: right; font-variant-numeric: tabular-nums; }
.lb .pts { font: 500 15px/1 var(--cond); color: var(--ink-soft); text-align: right; }
.lb li.me { box-shadow: inset 4px 0 0 var(--flag); }
.under { color: var(--red); }
.golfers { padding: 0 16px 12px 68px; display: none; }
.lb li.open .golfers { display: block; }
.g {
  display: grid; grid-template-columns: 1fr auto 52px; gap: 8px; align-items: baseline;
  padding: 5px 0; font-size: 15px; border-top: 1px dashed var(--rule);
}
.g .gp { font: 600 19px/1 var(--cond); text-align: right; font-variant-numeric: tabular-nums; }
.g .gs { font-size: 13px; color: var(--ink-soft); }
.g.dim { opacity: .5; }
.g .tag { font: 600 12px/1 var(--cond); padding: 3px 5px 2px; border-radius: 3px; background: var(--rule); margin-left: 6px; }
.g .tag.cut { background: var(--red); color: #fff; }
.g .tag.win { background: var(--flag); color: #1b1600; }

/* ---------- picks ---------- */
.capbar {
  position: sticky; top: var(--top-h, 96px); z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--rule);
  padding: 10px 16px;
}
.capline { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.capline .left { font: 700 26px/1 var(--cond); }
.capline .left.over { color: var(--red); }
.meter { height: 6px; background: var(--rule); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--board-line); }
.meter > i.over { background: var(--red); }
.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.slot {
  border: 1px dashed var(--rule); border-radius: var(--radius-s);
  padding: 6px 8px; min-height: 44px; font-size: 13px; line-height: 1.2;
  background: none; text-align: left; cursor: pointer;
}
.slot.full { border-style: solid; border-color: var(--board-line); background: color-mix(in srgb, var(--board) 8%, transparent); }
.slot b { display: block; font-weight: 600; }
.tools { display: flex; gap: 8px; padding: 12px 16px; }
.tools input { flex: 1; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-s);
  background: var(--surface);
}
.plist { list-style: none; margin: 0; padding: 0; }
.plist li {
  display: grid; grid-template-columns: 1fr auto 44px; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--surface);
}
.plist .nm { font-weight: 500; }
.plist .nm small { display: block; color: var(--ink-soft); font-size: 13px; }
.plist .sal { font: 600 18px/1 var(--cond); font-variant-numeric: tabular-nums; }
.plist li.picked { background: color-mix(in srgb, var(--board) 10%, var(--surface)); }
.plist li.cant .sal { color: var(--ink-soft); text-decoration: line-through; }
.add {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--board-line);
  background: none; font: 700 22px/1 var(--cond); cursor: pointer; color: var(--board-line);
}
@media (prefers-color-scheme: dark) { .add { color: #8fd3a8; border-color: #3d8f60; } }
.plist li.picked .add { background: var(--board-line); color: #fff; }
.add:disabled { opacity: .3; cursor: default; }

/* ---------- buttons, forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 16px; border-radius: var(--radius-s); border: 1px solid var(--board);
  background: var(--board); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: none; color: var(--ink); border-color: var(--rule); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.warn { background: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.wide { width: 100%; }
.form { max-width: 420px; margin: 24px auto; padding: 0 16px; }
.form label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.err { color: var(--red); font-weight: 600; }
.note {
  margin: 12px 16px; padding: 12px 14px; border-radius: var(--radius-m);
  background: var(--surface); border: 1px solid var(--rule);
}
.note.alert { border-color: var(--red); box-shadow: inset 4px 0 0 var(--red); }
.note.good { box-shadow: inset 4px 0 0 var(--ok); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 15px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: middle; }
.tbl th { font: 600 15px/1.1 var(--cond); color: var(--ink-soft); }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .big { font: 700 22px/1 var(--cond); }
.tbl tr.cutline td { border-bottom: 2px solid var(--red); }
.scroll { overflow-x: auto; }
.drop { text-decoration: line-through; color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 3px 8px; border-radius: 12px; background: var(--rule); }
.chip.in { background: color-mix(in srgb, var(--ok) 25%, transparent); }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: var(--radius-m);
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.bad { background: var(--red); color: #fff; }
details summary { cursor: pointer; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
