/* Base reset (what the page needs outside a host wrapper) */
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout: green-jacket masthead, sticky tab bar, one centered working column (max 1080px) */
:root {
  --bg: #f3f6f2;
  --surface: #ffffff;
  --surface-2: #e9efe9;
  --ink: #142019;
  --muted: #586860;
  --line: #d3dcd5;
  --jacket: #1c5034;
  --jacket-2: #2a6a47;
  --on-jacket: #f3f8f4;
  --flag: #dcaa1c;
  --flag-soft: #fbf1cf;
  --under: #c0261d;
  --warn: #9a5f00;
  --warn-soft: #fbefd9;
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-script: "Yellowtail", "Brush Script MT", cursive;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1511; --surface: #151f19; --surface-2: #1c2821; --ink: #e4ece6; --muted: #92a399; --line: #2b3a31;
    --jacket: #173f2a; --jacket-2: #4f9d71; --on-jacket: #eef6f0; --flag: #e9bd3e; --flag-soft: #3a3115;
    --under: #ff6f63; --warn: #f0b04a; --warn-soft: #3a2c12; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1511; --surface: #151f19; --surface-2: #1c2821; --ink: #e4ece6; --muted: #92a399; --line: #2b3a31;
  --jacket: #173f2a; --jacket-2: #4f9d71; --on-jacket: #eef6f0; --flag: #e9bd3e; --flag-soft: #3a3115;
  --under: #ff6f63; --warn: #f0b04a; --warn-soft: #3a2c12; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--jacket); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--flag); outline-offset: 2px; }
.num, table { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1080px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* masthead */
.mast { background: var(--jacket); color: var(--on-jacket); }
.mast .wrap { padding-block: 18px 14px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 20px; }
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.wordmark { font-family: var(--f-script); font-size: clamp(40px, 9vw, 56px); line-height: .9; letter-spacing: .5px; transform: rotate(-4deg); transform-origin: left bottom; display: inline-block; padding-right: 6px; }
.edition { font-family: var(--f-display); font-weight: 600; font-size: 18px; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.who select { font-size: 14px; font-weight: 600; background: color-mix(in srgb, var(--on-jacket) 12%, transparent); color: var(--on-jacket); border: 1px solid color-mix(in srgb, var(--on-jacket) 40%, transparent); border-radius: 999px; padding: 4px 10px; max-width: 46vw; }
.who option { color: var(--ink); background: var(--surface); }
.lang { display: inline-flex; border: 1px solid color-mix(in srgb, var(--on-jacket) 40%, transparent); border-radius: 999px; overflow: hidden; }
.lang button { background: none; border: 0; padding: 4px 12px; font-size: 13px; font-weight: 600; letter-spacing: .06em; cursor: pointer; color: var(--on-jacket); }
.lang button[aria-pressed="true"] { background: var(--on-jacket); color: var(--jacket); }

/* tabs */
.tabs { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs .wrap { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs .wrap::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 12px 9px; font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--flag); }

main.wrap { padding-block: 20px 60px; display: flex; flex-direction: column; gap: 22px; }
section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
h2 { font-family: var(--f-display); font-weight: 700; font-size: 26px; line-height: 1.1; letter-spacing: .02em; text-transform: uppercase; margin: 0; text-wrap: balance; }
h3 { font-family: var(--f-display); font-weight: 600; font-size: 19px; letter-spacing: .04em; text-transform: uppercase; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-family: var(--f-display); font-size: 14px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* practice tournament bar: dashed like a range divider */
.demo-bar { border: 2px dashed var(--flag); background: var(--flag-soft); border-radius: var(--r); padding: 12px 14px; gap: 10px; }
.demo-bar a { color: var(--jacket-2); font-weight: 600; }
a { color: var(--jacket-2); }

/* banners & notes */
.note { border-radius: var(--r); padding: 10px 14px; background: var(--surface-2); font-size: 14px; }
.note.warn { background: var(--warn-soft); color: var(--ink); border-left: 3px solid var(--warn); }
.note.flag { background: var(--flag-soft); border-left: 3px solid var(--flag); }

/* buttons & form controls */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; }
.btn:hover { border-color: var(--jacket-2); }
.btn.primary { background: var(--jacket); border-color: var(--jacket); color: var(--on-jacket); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); padding-inline: 8px; }
.btn.danger { color: var(--under); }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.field input, .field select, select.sel, input.txt { font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100%; }
select.sel { width: auto; max-width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--jacket-2); }

/* hero strip on the board */
.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.panel .big { font-family: var(--f-display); font-weight: 700; font-size: 26px; line-height: 1.1; }
.jacket-chip { display: inline-block; width: 12px; height: 14px; background: var(--jacket-2); clip-path: polygon(20% 0, 80% 0, 100% 25%, 100% 100%, 0 100%, 0 25%); margin-right: 6px; vertical-align: -1px; }
.prizes { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--f-display); font-size: 18px; font-weight: 600; }
.prizes span b { color: var(--muted); font-weight: 500; margin-right: 4px; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-family: var(--f-display); font-weight: 600; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface); }
tr:last-child td { border-bottom: 0; }
td.l, th.l { text-align: left; }
td.name { text-align: left; font-weight: 600; white-space: normal; min-width: 150px; }
td.pos { font-family: var(--f-display); font-weight: 700; font-size: 18px; width: 44px; text-align: center; }
td.total { font-family: var(--f-display); font-weight: 700; font-size: 20px; }
.board td.sticky, .board th.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.board td.sticky2, .board th.sticky2 { position: sticky; left: 44px; background: var(--surface); z-index: 1; }
.board tr.podium td.pos { color: var(--jacket-2); }
.board tr.leader td { background: var(--flag-soft); }
.cell-pts { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.cell-pts small { font-size: 11px; color: var(--muted); }
.prov { color: var(--muted); font-style: italic; }
.under { color: var(--under); }
.prize { display: inline-block; font-size: 11px; font-weight: 700; color: var(--jacket-2); margin-left: 6px; }

/* round chips */
.chips { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chip b { font-family: var(--f-display); font-size: 17px; letter-spacing: .04em; text-transform: uppercase; }
.chip span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip[aria-pressed="true"] { border-color: var(--jacket-2); box-shadow: inset 0 0 0 1px var(--jacket-2); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live { color: var(--under); background: color-mix(in srgb, var(--under) 12%, transparent); }
.pill.final { color: var(--jacket-2); background: color-mix(in srgb, var(--jacket-2) 14%, transparent); }
.pill.closed { color: var(--ink); background: var(--surface-2); }

.round-head { display: flex; flex-direction: column; gap: 6px; }
.round-head .title { font-family: var(--f-display); font-weight: 700; font-size: 30px; line-height: 1.05; text-transform: uppercase; letter-spacing: .02em; }

/* scorecards */
.cards { display: flex; flex-direction: column; gap: 10px; }
.group-label { font-family: var(--f-display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-size: 15px; padding-top: 6px; }
details.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
details.card[open] { border-color: color-mix(in srgb, var(--jacket-2) 55%, var(--line)); }
details.card > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 14px; }
details.card > summary::-webkit-details-marker { display: none; }
.sum-pos { font-family: var(--f-display); font-weight: 700; font-size: 22px; text-align: center; color: var(--muted); }
.sum-who { min-width: 0; }
.sum-who b { display: block; font-weight: 700; line-height: 1.25; }
.sum-who span { font-size: 12px; color: var(--muted); }
.sum-score { text-align: right; font-family: var(--f-display); font-weight: 700; font-size: 24px; line-height: 1; }
.sum-score small { display: block; font-family: var(--f-body); font-weight: 500; font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 12px; border-top: 1px dashed var(--line); }
.members { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.members .m { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.members input.rep { width: 64px; font-size: 16px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }

.sc { display: grid; grid-template-columns: 52px repeat(9, minmax(0, 1fr)) 40px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.sc > div { min-width: 0; display: flex; align-items: center; justify-content: center; height: 30px; font-size: 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sc > div:nth-child(11n) { border-right: 0; }
.sc .lbl { justify-content: flex-start; overflow: hidden; white-space: nowrap; padding-left: 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
.sc .hd { font-family: var(--f-display); font-weight: 700; font-size: 15px; background: var(--jacket); color: var(--on-jacket); border-color: color-mix(in srgb, var(--on-jacket) 20%, var(--jacket)); }
.sc .hd.lbl { color: var(--on-jacket); background: var(--jacket); }
.sc .sub { color: var(--muted); font-size: 12px; }
.sc .tot { font-weight: 700; background: var(--surface-2); }
.sc .in { height: 42px; position: relative; padding: 3px; }
.sc .last > div, .sc > div.lastrow { border-bottom: 0; }
.sc .in input { width: 100%; height: 100%; min-width: 0; text-align: center; font-size: 16px; font-weight: 700; border: 1.5px solid transparent; background: none; padding: 0; border-radius: 4px; }
.sc .in input:focus { background: var(--flag-soft); outline: none; border-color: var(--flag); }
.sc .in input:disabled { color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1; }
.sc .dots { position: absolute; top: 1px; right: 3px; font-size: 9px; letter-spacing: -1px; color: var(--jacket-2); line-height: 1; pointer-events: none; }
/* paper-scorecard marks: circle = under par, square = over par */
.sc .in.birdie input { border-color: var(--under); border-radius: 50%; color: var(--under); }
.sc .in.eagle input { border-color: var(--under); border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--under); color: var(--under); }
.sc .in.hio input { background: var(--under); color: var(--surface); border-radius: 50%; border-color: var(--under); }
.sc .in.bogey input { border-color: var(--muted); border-radius: 2px; }
.sc .in.dbl input { border-color: var(--muted); border-radius: 2px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--muted); }
.sc .in.bad input { background: var(--warn-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 5px; vertical-align: -3px; border: 1.5px solid var(--muted); }
.legend i.c { border-radius: 50%; border-color: var(--under); }
.legend i.cc { border-radius: 50%; border-color: var(--under); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--under); }
.legend i.s { border-radius: 1px; }
.legend i.ss { border-radius: 1px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--muted); }
.legend .dot { color: var(--jacket-2); margin-right: 4px; }

/* setup panels */
.setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.slot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.slot .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.slot select { width: 100%; }

/* admin forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mini-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.mini-grid input { width: 100%; min-width: 0; text-align: center; font-size: 16px; padding: 5px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.mini-grid .h { text-align: center; font-size: 11px; color: var(--muted); }
details.adm { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
details.adm > summary { cursor: pointer; padding: 12px 16px; font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
details.adm .body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.pts-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.pts-row label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); text-align: center; }
.pts-row input { width: 100%; text-align: center; font-size: 16px; padding: 5px 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.code { font-family: var(--f-display); font-weight: 700; font-size: 26px; letter-spacing: .2em; }

/* rules */
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.rules .panel p { max-width: 65ch; }
.rules ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty b { font-family: var(--f-display); font-size: 22px; color: var(--ink); text-transform: uppercase; letter-spacing: .04em; }

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 8px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }

@media (max-width: 520px) {
  .sc { grid-template-columns: 40px repeat(9, minmax(0, 1fr)) 34px; }
  .sc .lbl { padding-left: 5px; font-size: 10px; letter-spacing: .02em; }
  details.card > summary { grid-template-columns: 28px minmax(0, 1fr) auto; padding: 10px 12px; gap: 4px 10px; }
  .card-body { padding: 4px 10px 12px; }
  .round-head .title { font-size: 26px; }
  th, td { padding: 7px 8px; }
}
@media (prefers-reduced-motion: no-preference) {
  details.card > summary, .chip, .btn { transition: border-color .15s, background-color .15s; }
}
