/* Club Ledger: warm paper, forest ink, and ruled scorecards. */
:root {
  --bg: #f6f2e8;
  --surface: #fffcf4;
  --text: #173c30;
  --muted: #657267;
  --line: #d4d5c4;
  --accent: #234d39;
  --accent-text: #fffdf4;
  --under: #a33e2e;
  --warn-bg: #f5e8c9;
  --warn-text: #674a15;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
/* manipulation: quick taps on − and + never zoom the page. */
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
a { color: var(--accent); text-decoration: none; }

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  /* Equal sides, so the title sits at the true center whatever the links' widths. */
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--surface);
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
}
.bar h1 { margin: 0; font: 400 21px/1.2 Georgia, "Times New Roman", serif; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
.bar > :first-child { justify-self: start; }
.bar > :last-child { justify-self: end; }
.bar:has(> h1:only-child) { grid-template-columns: 1fr; }
.bar h1:only-child { justify-self: center; }
.actions { display: flex; gap: 14px; }

/* A round's name gets a line of its own under the links, and may wrap. */
.round-bar { grid-template-columns: 1fr auto; grid-template-areas: "back actions" "title title"; row-gap: 6px; }
.round-bar > a { grid-area: back; }
.round-bar > .actions { grid-area: actions; }
.round-bar h1 { grid-area: title; justify-self: center; max-width: none; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.round-bar h1 small { display: block; margin-top: 2px; font: 14px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--muted); }

.page { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 32px); }

h2 { font-size: 15px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 28px 0 8px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 10px; }

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 0;
  padding: 14px 18px;
  font-size: 13px;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-weight: 600;
}
.quiet { color: var(--accent); padding: 8px 4px; }
.wide { display: block; width: 100%; margin-top: 16px; text-align: center; }
.big { font-size: 34px; line-height: 1; padding: 4px 16px; }

input, select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.field input { font-size: 17px; color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 0; border: 1px solid var(--line); }
.list li + li { border-top: 1px solid var(--line); }
.list li { display: flex; align-items: center; }
.list a { flex: 1; padding: 14px 16px; color: var(--text); }
.list .remove { padding: 8px 16px; }
.danger { color: var(--under); padding: 14px; }

.errors { background: var(--warn-bg); color: var(--warn-text); border-radius: 0; padding: 12px 12px 12px 30px; margin: 0 0 16px; font-size: 15px; }

/* Setup */
.course { width: 100%; border-collapse: collapse; margin-bottom: 12px; table-layout: fixed; }
.course th { font-size: 12px; font-weight: 500; color: var(--muted); padding: 2px 0; }
.course th:first-child { width: 36px; text-align: left; }
.course td { padding: 2px; }
.course input { width: 100%; padding: 8px 0; text-align: center; font-size: 16px; }
.course .par-entry input { background: #e8ecdf; border-color: #bfc9b6; font-weight: 600; }
.course .par-entry th { color: var(--text); font-weight: 600; }
.course .rank-entry input { background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.course .rank-entry td { padding-top: 6px; }

.tee-row { display: grid; grid-template-columns: 1fr 72px 64px 32px; gap: 6px; margin-bottom: 8px; }
.tee-row.labels { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tee-row input:not(:first-child) { text-align: center; }

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px;
  grid-template-areas: "name name remove" "index prior ." "ch group ." "tee tee .";
  align-items: center;
  gap: 6px 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.player-row .name { grid-area: name; }
.player-row .remove { grid-area: remove; }
.player-row .ruled-field.index { grid-area: index; }
.player-row .ruled-field.prior { grid-area: prior; }
.ruled-field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; min-width: 0; }
.ruled-field input {
  width: 100%; min-height: 56px; padding: 8px 0;
  border: 0; border-bottom: 1px solid var(--text);
  background: transparent; color: var(--text);
  font: 28px/1.4 Georgia, "Times New Roman", serif;
  font-variant-numeric: tabular-nums;
}
.ruled-field input:focus { outline: 2px solid var(--accent); outline-offset: 3px; }
.player-row [name^="tee"] { grid-area: tee; }
.player-row [name^="group"] { grid-area: group; }
.player-row .ch { grid-area: ch; margin: 0; }
.player-row .ch:empty { display: none; }
.remove { font-size: 22px; color: var(--muted); }
.add { display: block; width: 100%; padding: 12px; margin-top: 4px; border: 1.5px dashed var(--line); border-radius: 0; color: var(--accent); font-weight: 500; }

/* Round */
.tabs { display: flex; gap: 4px; margin: 12px 16px 0; padding: 0; border-bottom: 1px solid var(--line); max-width: 528px; }
@media (min-width: 560px) { .tabs { margin: 12px auto 0; } }
.tabs button { flex: 1; padding: 14px 7px; border-bottom: 2px solid transparent; border-radius: 0; font-size: 15px; font-weight: 500; color: var(--muted); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

.status { margin: 10px 16px 0; padding: 8px 12px; border-radius: 0; font-size: 14px; color: var(--muted); text-align: center; }
.status.warn { background: var(--warn-bg); color: var(--warn-text); }

.group-pick { display: grid; gap: 2px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 14px 16px; margin-bottom: 10px; }
.group-pick span { color: var(--muted); font-size: 15px; }

.hole-nav { display: flex; align-items: center; justify-content: space-between; text-align: center; margin: 12px 0 24px; }
.hole-number { font: 400 40px/1.2 Georgia, "Times New Roman", serif; margin-bottom: 6px; }
.hole-nav .hint { margin: 0; }

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 15px 4px;
  margin-bottom: 0;
}
.who { display: grid; min-width: 0; }
.who .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .sub { color: var(--muted); font-size: 14px; }
.strokes { color: var(--accent); font-size: 13px; letter-spacing: 1px; margin-left: 2px; vertical-align: 2px; }

.stepper { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.stepper button { width: 46px; height: 46px; border-radius: 0; background: transparent; font-size: 24px; color: var(--accent); }
.stepper .value { width: 52px; height: 52px; font-size: 24px; font-weight: 700; color: var(--text); background: none; border: 2px solid transparent; }
.stepper .value.empty { color: var(--muted); font-weight: 400; }

/* Score marks: circles under par, squares over. */
:is(.stepper .value, .card .mark):is(.birdie, .eagle) { border-color: var(--under); color: var(--under); border-radius: 50%; }
:is(.stepper .value, .card .mark):is(.bogey, .double) { border-color: var(--muted); border-radius: 4px; }
:is(.stepper .value, .card .mark).eagle { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--under); }
:is(.stepper .value, .card .mark).double { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--muted); }

.board { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 0; overflow: hidden; border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.board th { font-size: 12px; font-weight: 500; color: var(--muted); padding: 10px 6px 6px; text-align: center; }
.board td { padding: 12px 6px; text-align: center; border-top: 1px solid var(--line); }
.board .left { text-align: left; }
.board .pos { width: 36px; color: var(--muted); font-size: 15px; }
.board tr[data-action] { cursor: pointer; }
.board tr.open td { background: var(--bg); }
.board .under { color: var(--under); }
.board .card-row > td { padding: 8px 4px 12px; background: var(--bg); border-top: 0; }

.card { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; margin-bottom: 6px; }
.card caption { text-align: left; padding: 4px 0 10px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; }
.card + .card { margin-top: 20px; }
.card + .card caption { border-top: 1px solid var(--line); padding-top: 14px; }
.nine-heading, .round-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-total { display: grid; gap: 2px; text-align: right; text-transform: none; letter-spacing: normal; color: var(--text); }
.card-total strong { font: 400 28px/1.1 Georgia, "Times New Roman", serif; font-variant-numeric: tabular-nums; }
.card-total small, .round-total > span > small { display: block; font: 400 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--muted); }
.round-total { border-top: 2px solid var(--accent); margin-top: 20px; padding: 14px 0 4px; text-align: left; font-weight: 600; }
.round-total .card-total strong { font-size: 32px; font-weight: 700; }
.card th, .card td { padding: 3px 0; text-align: center; border: 0; }
.card th { color: var(--muted); font-weight: 500; }
.card th:first-child { width: 44px; text-align: left; }
.card tr > :last-child { width: 32px; font-weight: 600; }
.card .mark { display: inline-block; min-width: 20px; line-height: 18px; border: 1.5px solid transparent; }
/* Double score outlines extend 4px beyond the mark; keep dots clear of them. */
.card .strokes { display: block; font-size: 12px; line-height: 12px; margin: 0 0 6px; }

/* Course finder */
.finder { display: grid; grid-template-columns: 1fr auto; gap: 6px; margin-bottom: 10px; }
.choices { display: grid; gap: 6px; margin-bottom: 8px; }
.choice { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 12px 14px; }
.choice > span:first-of-type { flex: 1; }
.choice .hint { margin: 0; }
.small { font-size: 12px; }

/* Quotes */
.quote { margin: 40px 8px 0; text-align: center; color: var(--muted); }
.quote blockquote { margin: 0; font: italic 16px/1.5 Georgia, "Times New Roman", serif; }
.quote blockquote::before { content: "\201C"; }
.quote blockquote::after { content: "\201D"; }
.quote figcaption { margin-top: 6px; font-size: 13px; letter-spacing: .02em; }
.quote figcaption::before { content: "\2014\2009"; }

/* Sign-in and members */
.sign-in { display: grid; justify-items: center; gap: 12px; padding: 20px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 0; text-align: center; }
.sign-in p { margin: 0; }
.sign-in-entry {
  justify-items: start;
  gap: 16px;
  padding: 24px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.sign-in-entry h2 {
  margin: 0;
  color: var(--text);
  font: 400 28px/1.2 Georgia, "Times New Roman", serif;
  letter-spacing: normal;
  text-transform: none;
}
.sign-in-entry p { max-width: 36ch; color: var(--muted); font-size: 15px; }
.sign-in-button { display: flex; align-items: center; justify-content: space-between; gap: 32px; width: min(100%, 320px); min-height: 48px; margin-top: 4px; text-align: left; }
.sign-in-button span { font-size: 20px; line-height: 1; font-weight: 400; }
.sign-in-entry .sign-in-provider { margin-top: -8px; font-size: 12px; }
.sign-in-button:hover { background: #173c30; }

/* One centered column for the welcome screen, with a single closing rule. */
.home.welcome { max-width: 432px; }
.home.welcome .sign-in-entry {
  justify-items: center;
  text-align: center;
  padding-top: 28px;
  padding-bottom: 0;
  border-bottom: 0;
}
.home.welcome .sign-in-button { width: 100%; }
.home.welcome > .quote { margin: 28px 0 0; }
.account { margin-top: 24px; text-align: center; }
.account .quiet { padding: 4px 2px; font-size: 14px; }
/* At 16px and up, iPhone doesn't zoom in when a field is tapped. */
textarea { width: 100%; font: 16px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 0; padding: 10px; }

/* Joining */
.sign-in.join { justify-items: stretch; text-align: left; }
.sign-in.join .field { color: var(--muted); }
.sign-in.join textarea { font: inherit; }
.request { background: var(--surface); border: 1px solid var(--line); border-radius: 0; padding: 12px 14px; margin-bottom: 10px; }
.request .note { margin: 6px 0 0; font-size: 15px; }
.request .decide { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.request .decide .primary { padding: 8px 16px; }

.member { flex: 1; padding: 14px 16px; overflow-wrap: anywhere; }
.add-member { margin-top: 12px; }

/* Terms and privacy: plain reading pages. */
.legal-links { margin: 32px 0 0; text-align: center; font-size: 13px; color: var(--muted); }
.legal-links a { color: var(--muted); }
.sign-in-provider a { color: inherit; text-decoration: underline; }
.legal h1 { margin: 12px 0 4px; font: 400 28px/1.2 Georgia, "Times New Roman", serif; }
.legal p, .legal li { font-size: 16px; line-height: 1.55; }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 8px; }
.legal a { text-decoration: underline; }
.legal .hint a { text-decoration: none; }

/* Consistent keyboard and touch affordances across every screen. */
button:focus-visible, a:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.quiet, .remove, .primary, .add, .hole-nav button { min-height: 44px; }
.hole-nav button { min-width: 44px; border: 1px solid var(--line); }
.stepper, .course { font-variant-numeric: tabular-nums; }
.board > thead > tr > th { text-transform: uppercase; letter-spacing: .06em; }
.quote { border-top: 1px solid var(--line); padding-top: 24px; }
.bar .quiet { font-size: 14px; }
@media (max-width: 380px) {
  .actions { gap: 6px; }
  .bar { gap: 4px; padding-left: 12px; padding-right: 12px; }
  .bar h1 { font-size: 18px; }
  .stepper { gap: 2px; }
  .stepper .value { width: 44px; height: 44px; }
  .score-row { gap: 6px; }
}

/* Mobile round header: a compact utility row above an editorial title. */
@media (max-width: 559px) {
  .bar.round-bar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 12px;
    padding: calc(env(safe-area-inset-top) + 4px) 16px 0;
  }
  .round-bar .quiet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 8px;
    line-height: 1;
  }
  .round-bar > a.quiet { justify-content: flex-start; padding-left: 0; }
  .round-bar > .actions { align-items: center; gap: 4px; }
  .round-bar > .actions > :last-child { padding-right: 0; }
  .bar.round-bar h1 {
    justify-self: stretch;
    min-width: 0;
    max-width: none;
    padding: 6px 0 14px;
    font-size: 24px;
    line-height: 1.2;
    text-align: left;
    text-wrap: pretty;
  }
  .round-bar h1 small { margin-top: 6px; }
  .round-bar + .tabs { margin-top: 0; }
  .round-bar + .tabs button { padding-block: 12px; min-height: 44px; }
}

.field.allowance { max-width: 140px; margin-bottom: 12px; }
