:root {
  --bg: #f4f6f1;
  --panel: #ffffff;
  --ink: #1d2a1f;
  --muted: #66735f;
  --line: #dde3d6;
  --brand: #1f5f3a;
  --brand-ink: #ffffff;
  --accent: #f2c14e;
  --warn-bg: #fff6dd;
  --err: #b3261e;
  --ok: #1f7a45;
  --chart-hl: #15803d;       /* validated pair (dataviz validator, light on #fff) */
  --chart-avg: #c2410c;
  --chart-context: #c9d1c4;
  --chart-grid: #e6eae2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121712;
    --panel: #1b221b;
    --ink: #e7ede3;
    --muted: #9aa894;
    --line: #2d382c;
    --brand: #3f9a63;
    --accent: #d9a92e;
    --warn-bg: #2e2a17;
    --err: #ff8a80;
    --ok: #74d39a;
    --chart-hl: #16a34a;     /* validated pair (dark, on #1b221b) */
    --chart-avg: #ea580c;
    --chart-context: #3a463a;
    --chart-grid: #273027;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
main { max-width: 960px; margin: 0 auto;
       padding: 16px calc(16px + env(safe-area-inset-right)) 16px calc(16px + env(safe-area-inset-left)); }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.muted { color: var(--muted); font-weight: normal; }
code { font-size: 1rem; letter-spacing: .1em; }

.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
       padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px
                calc(16px + env(safe-area-inset-left));
       background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 30; }
.top a, .top .link { color: var(--brand-ink); text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; }
/* Phones: a Menu button; the links open as a card inside the bar (in the page flow - nothing floats). */
.menu-toggle { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .12);
               color: var(--brand-ink); border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px;
               padding: 6px 14px 6px 10px; font-weight: 600; min-height: 40px; }
.menu-toggle[aria-expanded="true"] { background: rgba(255, 255, 255, .25); }
.burger { display: inline-flex; flex-direction: column; gap: 3px; width: 16px; }
.burger i { display: block; height: 2px; background: currentColor; border-radius: 2px; }
.site-nav { display: none; flex-basis: 100%; flex-direction: column; margin: 6px 0 2px;
            background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
            padding: 4px 0 6px; overflow: hidden; }
.site-nav.open { display: flex; }
.site-nav a, .site-nav .link { display: block; color: var(--ink); padding: 12px 18px; font-size: 1.05rem;
                               border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.site-nav a.here { font-weight: 700; color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }
.site-nav form { display: block; }
.site-nav .link { border-bottom: 0; color: var(--err); }
.nav-user { display: block; padding: 10px 18px 6px; font-size: .85rem; color: var(--muted);
            text-transform: uppercase; letter-spacing: .05em; }
/* Wide screens: the links sit in the bar as before. */
@media (min-width: 760px) {
  .menu-toggle, .nav-user { display: none; }
  .site-nav { display: flex; flex-basis: auto; flex-direction: row; flex-wrap: wrap; gap: 14px; align-items: center;
              background: none; color: var(--brand-ink); border: 0; margin: 0; padding: 0; overflow: visible; }
  .site-nav a, .site-nav .link { display: inline; color: var(--brand-ink); padding: 0; font-size: 1rem; border: 0;
                                 width: auto; }
  .site-nav a.here { color: var(--brand-ink); box-shadow: none; text-decoration: underline; text-underline-offset: 4px; }
  .site-nav .link { color: var(--brand-ink); }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 0 0 16px; overflow-x: auto; }
.panel.narrow { max-width: 380px; margin: 24px auto; }
.panel.attention { border-color: var(--accent); background: var(--warn-bg); }

label { display: block; margin: 0 0 12px; font-weight: 600; }
label input, label select { display: block; width: 100%; margin-top: 4px; font-weight: normal; }
input, select, button { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
input.short { width: 80px; }
button { cursor: pointer; background: var(--bg); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.danger { color: var(--err); }
button.link { border: 0; background: none; padding: 0; text-decoration: underline; }
form.inline { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.actions { display: flex; gap: 10px; margin: 12px 0 20px; }
.actions button { flex: 1; padding: 12px; }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--panel); }
.flash.error { border-color: var(--err); color: var(--err); }
.flash.ok { border-color: var(--ok); color: var(--ok); }
.note { margin-top: 6px; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--warn-bg); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.list .meta { color: var(--muted); font-size: .9rem; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.submitted { background: var(--accent); color: #2b2100; }
.badge.signed { background: var(--ok); color: #fff; }

.card-head p { margin: 4px 0; }
table { border-collapse: collapse; width: 100%; }
.scorecard { max-width: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 12px 0; }
.scorecard th, .scorecard td { padding: 6px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.scorecard th { background: var(--brand); color: var(--brand-ink); font-size: .85rem; }
.scorecard td.hole { font-weight: 700; }
.scorecard td.shots { color: var(--brand); letter-spacing: 2px; }
.scorecard td.pts { font-weight: 700; }
.scorecard input { width: 56px; text-align: center; font-size: 1.1rem; padding: 6px; }
.scorecard input.bad { border-color: var(--err); outline: 2px solid var(--err); }
.scorecard tr.sub td, .scorecard tr.total td { font-weight: 700; background: var(--bg); }

.board th, .board td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.board th { font-size: .85rem; color: var(--muted); }
.board td.num { text-align: right; }
.board tr.provisional td { color: var(--muted); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); text-decoration: none; white-space: nowrap; }
.tabs a.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: block; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); }
.tile strong { display: block; font-size: 1.8rem; color: var(--brand); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.gallery figcaption { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; font-size: .9rem; }
.gallery figcaption .meta { color: var(--muted); font-size: .8rem; }
.gallery .link.danger { font-size: .8rem; color: var(--err); }
#viewer { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
#viewer::backdrop { background: rgba(0, 0, 0, .85); }
#viewer img { display: block; max-width: 96vw; max-height: 88vh; border-radius: 6px; }
#viewer p { color: #fff; text-align: center; margin: 8px 0 0; }

.intro { background: var(--brand); color: var(--brand-ink); border-radius: 12px; padding: 20px 18px; margin: 4px 0 16px; }
.intro .eyebrow { margin: 0 0 4px; font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.intro h1 { margin: 0 0 10px; font-size: 1.7rem; line-height: 1.15; }
.intro h1 span { display: block; font-size: 1.05rem; font-weight: 500; color: var(--accent); }
.intro .lede { margin: 0 0 14px; font-size: 1.05rem; }
.intro .recap { background: rgba(255, 255, 255, .1); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.intro .recap h2 { font-size: 1rem; margin: 0 0 8px; }
.intro .recap p { margin: 8px 0 0; }
.intro dl { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; }
.intro dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
.intro dd { margin: 0; font-weight: 700; }
.intro .muted { color: var(--brand-ink); opacity: .8; margin: 0; font-size: .9rem; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: normal; }
label.check input { width: auto; margin: 0; }
.groups { margin: 0; padding-left: 1.4em; }
.groups li { padding: 4px 0; }
input.tiny { width: 56px; }
.flash.warn { border-color: var(--accent); background: var(--warn-bg); }
h3 { font-size: 1rem; margin: 14px 0 6px; }
.list li > .meta:last-child { flex-basis: 100%; }

.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.login-hero { text-align: center; margin: 20px 0 -8px; }
.login-hero img { width: 96px; height: 96px; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .25)); }
.login-hero p { margin: 4px 0 0; font-size: 1.4rem; font-weight: 700; color: var(--brand); }
.intro-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.intro .trophy { width: 72px; height: 72px; flex: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .3)); }
.nowrap { white-space: nowrap; }
.nick { color: var(--brand); font-style: italic; }
.card-photo { display: block; max-width: 100%; width: 320px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 10px; }
.photo-caption { margin: 0 0 10px; font-style: italic; }

.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 24px; }
.award { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.award h2 { margin-bottom: 2px; }
.award p { margin: 6px 0; }
.award .muted { font-size: .85rem; }
.award .leader { font-size: 1.05rem; font-weight: 600; }
.award .val { color: var(--muted); font-weight: normal; font-size: .9rem; }
.carry { margin: 10px 0; }
.carry-label { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .95rem; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

.leader-banner { display: flex; align-items: center; gap: 14px; background: var(--brand); color: var(--brand-ink);
                 border-radius: 12px; padding: 14px 16px; margin: 4px 0 18px; }
.leader-banner img { width: 64px; height: 64px; flex: none; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .3)); }
.leader-banner p { margin: 0; }
.leader-banner .eyebrow { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.leader-banner .leader-name { font-size: 1.4rem; font-weight: 700; }
.leader-banner .leader-name strong { color: var(--accent); }
.leader-banner .muted { color: var(--brand-ink); opacity: .85; }
.leader-row td { background: var(--warn-bg); }
.leader-row td:first-child, .leader-row td:nth-child(2) { font-weight: 700; }
.mini-churn { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; }
.form-table td, .form-table th { white-space: nowrap; }
.form-table tr > :first-child { position: sticky; left: 0; background: var(--panel); }
.form-table tr.leader-row > :first-child { background: var(--warn-bg); }
.trend { font-size: .75rem; margin-left: 4px; }
.trend.finisher { color: var(--ok); }
.trend.fader { color: var(--err); }

.trend-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.trend-head h2 { margin: 0; }
.legend { font-size: .85rem; color: var(--muted); margin: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.key { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.key.hl { background: var(--chart-hl); }
.key.avg { background: var(--chart-avg); }
.key.context { background: var(--chart-context); }
.trend-wrap { position: relative; }
.trend-svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.trend-svg .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.trend-svg .context { fill: none; stroke: var(--chart-context); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-svg .avg { fill: none; stroke: var(--chart-avg); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-svg .avg-dot { fill: var(--chart-avg); stroke: var(--panel); stroke-width: 2; }
.trend-svg .hl { fill: none; stroke: var(--chart-hl); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-svg .hl-dot { fill: var(--chart-hl); stroke: var(--panel); stroke-width: 2; }
.trend-svg .label { fill: var(--muted); font-size: 12px; }
.trend-svg .label.strong { fill: var(--ink); font-weight: 700; }
.trend-svg .cross { stroke: var(--muted); stroke-width: 1; }
.trend-tip { position: absolute; top: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
             padding: 6px 10px; font-size: .85rem; box-shadow: 0 4px 12px rgba(0, 0, 0, .15); pointer-events: none;
             white-space: nowrap; }

.install-banner { display: flex; align-items: center; gap: 8px; padding: 6px 12px;
                  background: var(--warn-bg); border-bottom: 1px solid var(--accent); font-size: .85rem; }
.install-banner[hidden] { display: none; }
.install-banner img { border-radius: 5px; flex: none; }
.install-banner p { margin: 0; flex: 1; line-height: 1.3; }
.install-banner .install-go { padding: 3px 12px; font-size: .85rem; font-weight: 600; border-radius: 999px;
                              background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.install-banner .install-close { font-size: 1rem; color: var(--muted); text-decoration: none; padding: 2px 4px; }

/* Venue map links */
.map-link { display: inline-block; font-size: .85rem; font-weight: 600; text-decoration: none; white-space: nowrap;
            padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); margin-left: 4px; }
h1 .map-link, h3 .map-link { vertical-align: middle; }

/* Touch screens: comfortable tap targets, no double-tap zoom on controls */
button, input, select, a { touch-action: manipulation; }
@media (pointer: coarse) {
  button, input:not([type="checkbox"]), select { min-height: 44px; }
  .scorecard input { width: 64px; min-height: 48px; font-size: 1.25rem; }
  .scorecard th, .scorecard td { padding: 4px 3px; }
  .list li { padding: 12px 0; }
  .tabs a { padding: 10px 16px; }
  .install-banner .install-go, .install-banner .install-close, .menu-toggle { min-height: 36px; }
}
/* Scorecard: keep Save / Submit within reach while scrolling the holes */
#scorecard .actions { position: sticky; bottom: 0; background: var(--bg);
                      padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
                      margin: 0 0 12px; border-top: 1px solid var(--line); }
#scorecard .actions button { min-height: 48px; }

/* Tables on phones: fit the screen instead of scrolling sideways */
.board .short { display: none; }
@media (max-width: 600px) {
  .panel { padding: 12px; }
  .board.fit th, .board.fit td { padding: 7px 4px; font-size: .9rem; }
  .board.fit th:first-child, .board.fit td:first-child { padding-left: 2px; }
  .board.fit .lo { display: none; }           /* lower-value columns: team, raw handicap, status badge */
  .board.fit .wrap { white-space: normal; }   /* long names wrap rather than widen the table */
  .board .short { display: inline; }
  .board .full { display: none; }
  /* Stacked tables: one card per row, labels from data-label */
  .board.stack, .board.stack tbody, .board.stack tr, .board.stack td { display: block; }
  .board.stack thead { display: none; }
  .board.stack tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
  .board.stack tr.leader-row { background: var(--warn-bg); }
  .board.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
                    border: 0; padding: 3px 0; white-space: normal; text-align: right; background: transparent; }
  .board.stack td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; text-align: left; }
  .board.stack td.name { display: block; text-align: left; font-size: 1.05rem; font-weight: 700;
                         padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .board.stack td.name::before { content: none; }
  .form-table.stack tr > :first-child { position: static; }
}

/* More phone fixes: pills wrap, uploads and form rows fit, admin tables stack into named cards */
h2.hi { margin-top: 4px; }
@media (max-width: 600px) {
  .tabs { flex-wrap: wrap; overflow: visible; }
  input, select, button, textarea { max-width: 100%; }
  input[type="file"] { min-width: 0; width: 100%; }
  .row > * { max-width: 100%; }
  .row > input:not(.short):not(.tiny):not([type="checkbox"]):not([type="file"]), .row > select { flex: 1 1 150px; min-width: 0; }
  .board.stack tr[data-name]::before { content: attr(data-name); display: block; font-size: 1.05rem; font-weight: 700;
                                       padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
  .board.stack td > form { flex: 1 1 100%; width: 100%; }
  .board.stack td[data-label] input, .board.stack td[data-label] select { text-align: center; }
  .board.stack td:not([data-label]):not(.name) { display: block; text-align: left; }
}
