:root {
  --paper: #f3f5f2;
  --card: #ffffff;
  --ink: #0e1a14;
  --muted: #4f5d55;
  --line: #cdd5cf;
  --green: #0f4d32;
  --green-soft: #e1ece5;
  --warn-bg: #fff1cf;
  --warn-ink: #5c3d00;
  --warn-line: #a86f00;
  --bad: #a3231a;
  --red: #c8352b; --blue: #1f56c2; --black: #141618; --white: #ffffff;
  --num: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 500 17px/1.45 var(--body);
  padding-top: calc(56px + var(--safe-t));
  padding-bottom: calc(72px + var(--safe-b));
  -webkit-text-size-adjust: 100%;
}
a { color: var(--green); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #f2a900; outline-offset: 2px; }
main:focus, main:focus-visible { outline: none; }
h1, h2, h3 { margin: 0; font-family: var(--num); font-weight: 800; line-height: 1.05; }
h1 { font-size: 34px; }
h2 { font-size: 24px; margin-top: 28px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* top bar and tabs */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: var(--safe-t) 16px 0; height: calc(56px + var(--safe-t));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--green); color: #fff;
}
.brand { color: #fff; text-decoration: none; font: 800 24px var(--num); letter-spacing: .01em; }
.sync { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.14); white-space: nowrap; }
.sync.off { background: #f2a900; color: #1d1400; }
.sync.wait { background: #fff; color: var(--green); }
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs[hidden] { display: none; }
.tabs a { text-align: center; padding: 14px 2px 16px; font-weight: 600; font-size: 14px; color: var(--muted); text-decoration: none; min-height: 56px; }
.tabs a[aria-current="page"] { color: var(--green); box-shadow: inset 0 3px 0 var(--green); }
main { max-width: 600px; margin: 0 auto; padding: 18px 16px 24px; outline: none; }

/* leaderboard: the team colour rows */
.board { display: grid; gap: 8px; margin-top: 14px; }
.team {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 14px; color: var(--ink);
}
.team.white { border: 2px solid var(--ink); }
.team .pos { font: 800 26px var(--num); opacity: .85; }
.team .nm { font: 800 30px/1 var(--num); text-transform: none; }
.team .det { font-size: 14px; margin-top: 4px; opacity: .9; }
.team .pts { text-align: right; }
.team .pts b { display: block; font: 800 46px/0.9 var(--num); font-variant-numeric: tabular-nums; }
.team .pts span { font-size: 13px; opacity: .9; }
.progress { margin-top: 12px; font-size: 14px; color: var(--muted); }

/* tables */
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--line); font-size: 15px; }
th { font-weight: 600; color: var(--muted); font-size: 13px; }
td:first-child, th:first-child { text-align: left; padding-left: 12px; }
tr:last-child td { border-bottom: 0; }
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); vertical-align: -2px; margin-right: 6px; }

/* match list */
.match { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.match .sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-weight: 600; }
.match .sides .b { text-align: right; }
.match .vs { color: var(--muted); font-size: 13px; }
.match .st { margin-top: 8px; display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 15px; }
.strip { display: flex; gap: 3px; }
.strip i { width: 18px; height: 18px; border-radius: 4px; background: var(--line); display: block; border: 1px solid transparent; }
.strip i.h { background: #fff; border-color: var(--muted); }
.strip i.q { background: repeating-linear-gradient(45deg, var(--warn-line) 0 3px, var(--warn-bg) 3px 6px); }
.flag { color: var(--warn-ink); background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 6px; padding: 1px 6px; font-size: 13px; font-weight: 600; }

/* segmented control on the card page */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--green-soft); padding: 4px; border-radius: 12px; margin: 14px 0 6px; }
.seg button { border: 0; background: transparent; padding: 10px 4px; border-radius: 9px; font-weight: 600; font-size: 15px; min-height: 48px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.15); color: var(--green); }
.seg small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }

.status { font: 800 30px/1.1 var(--num); margin: 14px 0 4px; }
.vsline { font-weight: 600; }

/* hole picker */
.holes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 16px 0 6px; }
.holes button {
  border: 2px solid var(--line); background: var(--card); border-radius: 10px; min-height: 58px; padding: 4px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05;
}
.holes button small { font-size: 12px; color: var(--muted); font-weight: 600; }
.holes button b { font: 800 22px var(--num); min-height: 22px; }
.holes button.done { background: var(--green-soft); border-color: var(--green-soft); }
.holes button.q { background: var(--warn-bg); border-color: var(--warn-line); }
.holes button[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* score entry */
.entry { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-top: 10px; }
.entry h3 { font-size: 26px; text-align: center; }
.entry .who { text-align: center; color: var(--muted); font-size: 15px; margin-top: 2px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 14px 0; }
.stepper button { width: 72px; height: 72px; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); font: 700 34px var(--num); cursor: pointer; touch-action: manipulation; }
.stepper output { font: 800 80px/1 var(--num); width: 110px; text-align: center; font-variant-numeric: tabular-nums; }
.btn { display: block; width: 100%; min-height: 54px; border-radius: 12px; border: 2px solid var(--green); background: var(--green); color: #fff; font-weight: 700; font-size: 18px; cursor: pointer; padding: 0 14px; }
.btn.ghost { background: var(--card); color: var(--green); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn + .btn { margin-top: 10px; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 10px 0; cursor: pointer; font-size: 15px; display: block; margin: 6px auto 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.compare div { border: 2px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.compare b { display: block; font: 800 44px/1 var(--num); }
.warn { background: var(--warn-bg); border: 2px solid var(--warn-line); color: var(--warn-ink); border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.warn b { display: block; font-size: 18px; }
.note { background: var(--green-soft); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 15px; }

/* login */
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.pick button { min-height: 60px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: 18px; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 0 14px; text-align: left; }
.pin { display: flex; justify-content: center; gap: 10px; margin: 18px 0; }
.pin span { width: 46px; height: 58px; border: 2px solid var(--line); border-radius: 10px; display: grid; place-items: center; font: 800 32px var(--num); background: var(--card); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 0 auto; }
.keypad button { min-height: 62px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font: 700 28px var(--num); cursor: pointer; touch-action: manipulation; }
.err { color: var(--bad); font-weight: 600; text-align: center; min-height: 24px; }

/* admin */
.form { display: grid; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.form label { font-weight: 600; font-size: 14px; display: grid; gap: 4px; }
.form select, .form input { font: inherit; min-height: 46px; border: 1px solid var(--muted); border-radius: 8px; padding: 0 10px; background: #fff; color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; list-style: none; }
.log { padding: 0; margin: 0; max-height: 360px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
code { font-size: 13px; word-break: break-all; }

.toast { position: fixed; left: 16px; right: 16px; top: calc(64px + var(--safe-t)); z-index: 30; max-width: 560px; margin: 0 auto; background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 12px; font-weight: 600; }

/* clubhouse screen */
body.tv { padding: 0; background: var(--green); }
body.tv .bar, body.tv .tabs { display: none; }
body.tv main { max-width: 1400px; padding: 4vh 4vw; }
body.tv h1 { color: #fff; font-size: 7vh; }
body.tv .progress { color: #d7e6dc; font-size: 2.6vh; }
body.tv .board { gap: 1.6vh; }
body.tv .team { padding: 2.2vh 3vw; border-radius: 2vh; grid-template-columns: 6vh 1fr auto; }
body.tv .team .pos { font-size: 6vh; }
body.tv .team .nm { font-size: 8vh; }
body.tv .team .det { font-size: 2.6vh; }
body.tv .team .pts b { font-size: 11vh; }
body.tv .team .pts span { font-size: 2.4vh; }

@media (min-width: 700px) { main { padding-top: 28px; } }
@media (prefers-reduced-motion: no-preference) { .team { transition: transform .3s; } }

/* ---------- Christmas Eve: login and home ---------- */
body.xmas {
  --night: #0b1f33; --night-2: #12304b; --snow: #f4f7fa; --gold: #f2c14e; --frost: #b9cad8;
  background: var(--night); color: var(--snow);
}
body.xmas .bar { background: var(--night); }
body.xmas .muted { color: var(--frost); }
body.xmas a { color: var(--gold); }
body.xmas h2 { color: var(--snow); }
body.xmas .tabs { background: var(--night-2); border-top-color: #24476a; }
body.xmas .tabs a { color: var(--frost); }
body.xmas .tabs a[aria-current="page"] { color: var(--gold); box-shadow: inset 0 3px 0 var(--gold); }
body.xmas .btn { display: grid; place-items: center; text-decoration: none; background: var(--gold); border-color: var(--gold); color: #1d1400; margin-top: 12px; }
body.xmas .btn.ghost { background: transparent; color: var(--snow); border-color: rgba(244,247,250,.5); }
body.xmas .linkbtn { color: var(--frost); }
body.xmas .err { color: #ff9a8f; }
body.xmas :focus-visible { outline-color: var(--gold); }

.scene { position: relative; margin: -18px -16px 0; height: 210px; overflow: hidden; }
.scene svg { display: block; width: 100%; height: 100%; }
.scene .bulb { animation: twinkle 2.4s ease-in-out infinite alternate; }
.snow { position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%), radial-gradient(2px 2px at 90px 80px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 160px 40px, #fff 50%, transparent 51%), radial-gradient(2.5px 2.5px at 230px 110px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 300px 60px, #fff 50%, transparent 51%), radial-gradient(2px 2px at 350px 140px, #fff 50%, transparent 51%);
  background-size: 380px 200px; opacity: .8; }
@keyframes twinkle { from { opacity: .35; } to { opacity: 1; } }
@keyframes fall { from { background-position: 0 -200px, 0 -200px, 0 -200px, 0 -200px, 0 -200px, 0 -200px; } to { background-position: 30px 0, -20px 0, 15px 0, -30px 0, 20px 0, -10px 0; } }
@media (prefers-reduced-motion: no-preference) { .snow { animation: fall 9s linear infinite; } }
@media (prefers-reduced-motion: reduce) { .scene .bulb { animation: none; } }

.xtitle { font-size: 46px; margin-top: 18px; letter-spacing: .005em; }
.xdate { margin: 4px 0 0; color: var(--gold); font: 700 20px var(--num); letter-spacing: .02em; }
.hello { font-size: 20px; margin: 16px 0 0; font-weight: 600; }
.xcard { background: var(--night-2); border: 1px solid #24476a; border-radius: 16px; padding: 16px; margin-top: 14px; }
.xcard h2 { margin: 0 0 10px; font-size: 22px; }
.count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.count div { background: var(--night); border-radius: 12px; padding: 10px 0 8px; text-align: center; border: 1px solid #24476a; }
.count b { display: block; font-size: 44px; line-height: 1; color: var(--snow); }
.count span { font-size: 13px; color: var(--frost); }
.xcard p { margin: 10px 0 0; }
.colour { display: grid; grid-template-columns: 64px 1fr 48px; align-items: center; gap: 14px; }
.swatch { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--snow); box-shadow: 0 0 0 3px var(--night-2), 0 0 0 5px rgba(244,247,250,.35); }
.ctext b { display: block; font: 800 38px/1 var(--num); }
.info { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--gold); background: transparent; color: var(--gold); font: italic 700 22px Georgia, serif; cursor: pointer; }
.info[aria-expanded="true"] { background: var(--gold); color: #1d1400; }
.infobox { grid-column: 1 / -1; background: var(--night); border-radius: 12px; padding: 12px 14px; border: 1px solid var(--gold); font-size: 16px; }
.infobox b { display: block; font-size: 18px; color: var(--gold); margin-bottom: 2px; }
.mates { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 18px; font-weight: 600; }

.login h2 { margin-top: 24px; }
.pick.names { grid-template-columns: 1fr 1fr; }
body.xmas .pick button { background: var(--night-2); border-color: #24476a; color: var(--snow); justify-content: center; text-align: center; }
body.xmas .pin span { background: var(--night-2); border-color: #24476a; color: var(--snow); }
body.xmas .keypad button { background: var(--night-2); border-color: #24476a; color: var(--snow); }

/* course */
.holeline { text-align: center; font: 700 18px var(--num); letter-spacing: .02em; color: var(--green); margin-top: 2px; }
.topar { font-size: 22px; color: var(--muted); }
.parrow td { color: var(--muted); font-size: 13px; background: var(--green-soft); }
.course h2 { margin: 2px 0 4px; font-size: 28px; }
.cstats { color: var(--gold); font-size: 20px; font-weight: 700; margin: 0 !important; }
.facts { margin: 10px 0 0; padding-left: 18px; }
.facts li { margin: 3px 0; }
.addr { font-weight: 600; }
.clinks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.clinks .btn { margin-top: 12px; }
.course .btn + .btn { margin-top: 12px; }
.guide { margin-top: 12px; }
.guide table { background: var(--night); border-radius: 12px; overflow: hidden; }
.guide th, .guide td { border-bottom-color: #24476a; color: var(--snow); font-size: 15px; padding: 7px 6px; }
.guide th { color: var(--frost); }
.guide tr.split td { border-top: 2px solid var(--gold); }
.course > a.small { display: inline-block; margin-top: 12px; }

/* scorecard marks: circles under par, squares over */
.sc { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 4px; box-sizing: border-box; line-height: 1; font-variant-numeric: tabular-nums; }
.sc-birdie, .sc-eagle, .sc-ace { border: 2px solid #b3261e; border-radius: 50%; color: #b3261e; }
.sc-eagle, .sc-ace { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #b3261e; }
.sc-ace { background: #b3261e; color: #fff; }
.sc-bogey, .sc-double { border: 2px solid #33557e; border-radius: 3px; color: #1e3a5f; }
.sc-double { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px #33557e; }
.holes button.done { --card: var(--green-soft); }
.holes button b .sc { min-width: 28px; height: 28px; font-size: 18px; }
td .sc { min-width: 28px; height: 28px; }
.sname { text-align: center; font: 800 22px var(--num); letter-spacing: .02em; margin: -6px 0 12px; color: var(--muted); }
.sname.birdie, .sname.eagle, .sname.ace { color: #b3261e; }
.sname.bogey, .sname.double { color: #33557e; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 10px; }
.legend .sc { min-width: 24px; height: 24px; font-size: 13px; margin-left: 6px; }
/* tee times */
.tee .teetime { display: block; font-size: 56px; line-height: 1; margin: 4px 0 2px; color: var(--gold); }
.tee #teeoff { margin-top: 12px; }
.tees { list-style: none; margin: 0; padding: 0; }
.tees li { display: flex; align-items: center; gap: 4px; padding: 9px 0; border-bottom: 1px solid #24476a; font-size: 18px; font-weight: 600; }
.tees li:last-child { border-bottom: 0; }
.tees li b { margin-left: auto; font-size: 22px; }
.tees li.mine b { color: var(--gold); }
body.xmas .dot { border-color: var(--snow); }
/* keep the 6-hole scramble table on one screen */
td:first-child { white-space: nowrap; }
.tablewrap th, .tablewrap td { padding-left: 3px; padding-right: 3px; }
.tablewrap td:first-child, .tablewrap th:first-child { padding-left: 10px; }
.tablewrap td .sc { min-width: 26px; height: 26px; font-size: 15px; padding: 0 3px; }
