/* ── Self-hosted fonts ──────────────────────────── */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/fraunces-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/hanken-grotesk.woff2') format('woff2');
}

/* ── Variables ─────────────────────────────────── */
:root {
  --bg:          #eceee7;
  --surface:     #ffffff;
  --paper:       #ffffff;
  --cream:       #f7f5ee;
  --dark:        #1f4d2e;
  --green-deep:  #163823;
  --mid:         #2a6b35;
  --green-soft:  #e7efe8;
  --green-line:  #cbdccf;
  --light:       #a3d4aa;
  --muted:       #8a9486;
  --border:      #e4e9e0;
  --ink:         #23291f;
  --gold:        #b08d3e;
  --gold-dark:   #8f6f2c;
  --net:         #255a94;
  --danger:      #c0392b;
  --shadow-sm:   0 1px 4px rgba(22,56,35,0.08);
  --shadow:      0 6px 18px -8px rgba(22,56,35,0.25);
  --shadow-lg:   0 18px 50px -22px rgba(22,56,35,0.45);
  --radius:      14px;
  --radius-sm:   8px;
  --serif:       'Fraunces', Georgia, 'Times New Roman', serif;
  --sans:        'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 20% -10%, #eef3ec 0%, transparent 60%),
    radial-gradient(1000px 700px at 110% 110%, #e9efe6 0%, transparent 55%),
    var(--bg);
  font-family: var(--sans);
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button { cursor: pointer; font-family: inherit; font-size: inherit; border: none; background: none; color: inherit; }
input, select  { font-family: inherit; font-size: inherit; }

/* ── View switching ─────────────────────────────── */
.view { display: none; flex-direction: column; min-height: calc(100dvh - 60px); overflow-y: auto; }
.view.active { display: flex; }
body[data-view="scorecard"] .bottom-nav { display: none; }
body[data-view="scorecard"] #view-scorecard { min-height: 100dvh; }
[hidden] { display: none !important; }

/* ── App header (gradient + gold underline) ─────── */
.app-header {
  position: relative;
  background: linear-gradient(135deg, var(--dark) 0%, var(--green-deep) 100%);
  padding: 20px 18px 16px;
}
.app-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}
.app-header__title {
  color: #fff; font-family: var(--serif); font-weight: 600;
  font-size: 24px; letter-spacing: -0.01em; line-height: 1.05;
}
.app-header__sub {
  color: #bcd4c2; font-size: 10px; letter-spacing: 0.32em;
  text-transform: uppercase; margin-top: 4px; font-weight: 600;
}

/* ── Bottom nav ─────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 60px; background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
}
.tab-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-family: var(--serif);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.28em; text-transform: uppercase;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab-btn.active { color: var(--dark); font-weight: 700; }

/* ── PWA "update available" banner ──────────────── */
.update-banner {
  position: fixed; z-index: 200;
  left: 50%; transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100% - 32px);
  padding: 11px 12px 11px 18px;
  background: var(--dark); color: #fff;
  border-radius: 999px; box-shadow: var(--shadow-lg);
  animation: update-banner-in 0.25s ease;
}
body[data-view="scorecard"] .update-banner {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.update-banner__msg {
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.update-banner__btn {
  flex: 0 0 auto;
  background: var(--gold); color: #1a1305;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px; padding: 7px 14px;
}
.update-banner__btn:disabled { opacity: 0.6; }
@keyframes update-banner-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── FAB ────────────────────────────────────────── */
.fab {
  position: fixed; bottom: 76px; right: 16px;
  width: 54px; height: 54px; border-radius: 27px;
  background: linear-gradient(135deg, var(--dark), var(--green-deep));
  color: #fff; padding: 0;
  box-shadow: 0 8px 22px -6px rgba(31,77,46,0.55);
  display: grid; place-items: center; z-index: 50;
}
.fab svg { display: block; }

/* ── List container ─────────────────────────────── */
.list-container { flex: 1; padding: 18px 16px 90px; display: flex; flex-direction: column; gap: 12px; }

/* ── Round card ─────────────────────────────────── */
.round-card {
  background: var(--paper); border-radius: var(--radius);
  padding: 16px 14px 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.round-card:active { transform: scale(0.99); box-shadow: var(--shadow-sm); }
.round-card__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.round-card__date   { font-family: var(--serif); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.round-card__meta   { font-size: 11px; color: var(--muted); margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; }
.round-card__meta--blue  { color: #4b7fb8; }
.round-card__meta--white { color: var(--muted); }
.round-card__actions { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 6px; color: var(--muted); font-size: 14px; display: flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--green-soft); color: var(--dark); }
.icon-btn--danger:hover { background: rgba(192,57,43,0.08); color: var(--danger); }

.round-card__players {
  padding-top: 10px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.round-card__player {
  display: grid; grid-template-columns: 1fr 32px 32px 56px;
  align-items: center; font-size: 13px; column-gap: 8px;
}
.round-card__player-name { font-weight: 600; color: var(--ink); }
.round-card__player-stat { text-align: center; color: var(--muted); font-weight: 500; }
.round-card__player-pts {
  background: var(--dark); color: #fff;
  padding: 3px 8px; border-radius: 11px;
  text-align: center; font-weight: 700; font-size: 12px;
  box-shadow: 0 2px 6px -2px rgba(31,77,46,0.4);
}
.round-card__player-labels {
  display: grid; grid-template-columns: 1fr 32px 32px 56px;
  column-gap: 8px;
  font-size: 9px; color: var(--muted); letter-spacing: 0.1em;
  border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 6px;
  font-weight: 700;
}
.round-card__player-labels span:first-child { visibility: hidden; }
.round-card__player-labels span { text-align: center; }

/* ── Empty state ────────────────────────────────── */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; gap: 10px; padding: 40px; }
.empty-state__text { font-size: 14px; line-height: 1.55; }

/* ── Scorecard header ───────────────────────────── */
.sc-header {
  position: relative;
  background: linear-gradient(135deg, var(--dark) 0%, var(--green-deep) 100%);
  display: flex; align-items: center; padding: 16px 12px; gap: 8px;
}
.sc-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}
.sc-header__back  { color: #fff; font-size: 20px; padding: 4px 8px; border-radius: 6px; }
.sc-header__title { flex: 1; color: #fff; font-size: 16px; font-weight: 600; letter-spacing: 0.01em; }

/* ── Scorecard steps ────────────────────────────── */
.sc-step { padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }

/* ── Fields ─────────────────────────────────────── */
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.tee-select { cursor: pointer; font-weight: 600; text-align: left; display: flex; align-items: center; gap: 8px; }
.tee-select::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid; flex: none; }
.tee-select--white { color: var(--ink); }
.tee-select--white::before { background: #fff; border-color: #b7c3b7; }
.tee-select--blue  { color: #2f6db0; border-color: #2f6db0; }
.tee-select--blue::before { background: #2f6db0; border-color: #2f6db0; }
.field__label { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.field__input { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 12px; font-size: 16px; color: var(--ink); width: 100%; }
.field__input--short { max-width: 160px; }
.field__input:focus { outline: none; border-color: var(--dark); }

/* ── Buttons ────────────────────────────────────── */
.btn { padding: 13px 22px; border-radius: 26px; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; letter-spacing: 0.01em; }
.btn--primary  { background: linear-gradient(135deg, var(--dark), var(--green-deep)); color: #fff; box-shadow: 0 6px 16px -6px rgba(31,77,46,0.5); }
.btn--ghost    { background: var(--surface); border: 1.5px solid var(--border); color: var(--dark); }
.btn--full     { width: 100%; }
.btn:disabled  { opacity: 0.4; pointer-events: none; box-shadow: none; }

/* ── Hole pill ──────────────────────────────────── */
.hole-pill { background: linear-gradient(135deg, var(--dark), var(--green-deep)); color: var(--light); font-size: 11px; font-weight: 700; letter-spacing: 0.15em; padding: 7px 16px; border-radius: 14px; text-align: center; align-self: center; }

/* ── Player rows (hole stepper) ─────────────────── */
.player-rows { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
.player-row  { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.player-row:last-child { border-bottom: none; }
.player-row__name    { flex: 1; font-size: 14px; font-weight: 600; display: flex; flex-direction: column; gap: 1px; }
.player-row__stepper { display: flex; align-items: center; gap: 14px; }
.stepper-btn { width: 36px; height: 36px; border-radius: 18px; padding: 0; display: grid; place-items: center; transition: transform 0.1s; }
.stepper-btn svg { display: block; }
.stepper-btn:active { transform: scale(0.92); }
.stepper-btn--minus { background: var(--green-soft); border: 1.5px solid var(--dark); color: var(--dark); }
.stepper-btn--plus  { background: linear-gradient(135deg, var(--dark), var(--green-deep)); color: #fff; border: none; }
.player-row__score  { width: 28px; text-align: center; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.player-row__strokes {
  font-size: 10px; color: var(--gold); font-weight: 700; letter-spacing: 0.05em;
}

/* ── Progress bar ───────────────────────────────── */
.hole-progress { display: flex; gap: 6px; justify-content: center; }
.hole-chip {
  flex: 1; max-width: 38px; height: 32px;
  border: 1px solid var(--green-line);
  background: var(--paper); color: var(--green-deep);
  font-family: inherit; font-weight: 700; font-size: 13px;
  font-variant-numeric: tabular-nums;
  border-radius: 8px; padding: 0;
  display: grid; place-items: center;
  cursor: pointer; transition: background 0.15s, color 0.15s, transform 0.1s;
}
.hole-chip--current {
  background: var(--dark); color: #fff; border-color: var(--dark);
}
.hole-chip:active { transform: scale(0.95); }

/* ── Scorecard nav ──────────────────────────────── */
.sc-nav { display: flex; gap: 10px; }
.sc-nav .btn { flex: 1; }
.sc-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── Hole pill row (with Edit players link) ─────── */
.hole-pill-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link-btn {
  font-size: 12px; color: var(--dark); font-weight: 600;
  text-decoration: underline; padding: 4px 6px;
}

/* ── Player cards (setup) ───────────────────────── */
.players-container { display: flex; flex-direction: column; gap: 8px; }
.player-card {
  background: var(--paper); border-radius: var(--radius-sm);
  padding: 10px; display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.player-card__name {
  flex: 1; background: transparent; border: 1.5px solid var(--border);
  border-radius: 7px; padding: 9px 10px; font-size: 14px; color: var(--ink);
}
.player-card__name:focus { outline: none; border-color: var(--dark); }
.player-card__hdcp {
  width: 64px; background: transparent; border: 1.5px solid var(--border);
  border-radius: 7px; padding: 9px; font-size: 14px; text-align: center; color: var(--ink);
}
.player-card__hdcp:focus { outline: none; border-color: var(--dark); }
.player-card__x {
  width: 28px; height: 28px; border-radius: 14px;
  background: var(--bg); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
}
.player-card__x:disabled { opacity: 0.3; pointer-events: none; }
.btn-add-player {
  background: var(--surface); border: 1.5px dashed var(--green-line);
  color: var(--dark); padding: 11px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 13px; margin-top: 6px;
}
.btn-add-player:disabled { opacity: 0.4; pointer-events: none; }

/* ── Scorecard summary table ────────────────────── */
.scorecard {
  background: var(--paper);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.scorecard__head {
  position: relative;
  background: linear-gradient(135deg, var(--dark) 0%, var(--green-deep) 100%);
  color: #fff;
  padding: 20px 22px 18px;
}
.scorecard__head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
}
.scorecard__crest {
  font-family: var(--serif); font-weight: 600;
  font-size: 10px; letter-spacing: 0.32em;
  text-transform: uppercase; color: #bcd4c2;
}
.scorecard__title {
  font-family: var(--serif); font-weight: 600;
  font-size: 24px; line-height: 1.05; margin-top: 4px;
  letter-spacing: -0.01em;
}
.scorecard__meta {
  display: flex; gap: 14px; margin-top: 10px;
  font-size: 12px; color: #cfe0d2; flex-wrap: wrap;
}
.scorecard__meta b { color: #fff; font-weight: 600; }

/* Column header (Hole / Par labels appear once, above all players) */
.scorecard__colhead { padding: 12px 16px 8px; }
.scorecard__collbl {
  display: flex; justify-content: space-between;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.sc-strip {
  display: grid; grid-template-columns: repeat(9, 1fr); column-gap: 2px;
  font-variant-numeric: tabular-nums;
}
.sc-strip--holes .c {
  font-size: 11px; font-weight: 700; color: var(--green-deep); text-align: center;
}
.sc-strip--pars { margin-top: 3px; }
.sc-strip--pars .c {
  font-size: 11px; color: var(--muted); text-align: center;
}

/* Player blocks — one stacked card per player */
.scorecard__players { padding: 2px 0 6px; }
.sc-player {
  padding: 11px 16px 12px;
  border-top: 1px solid var(--border);
}
.sc-player__line {
  display: flex; align-items: center; gap: 11px; margin-bottom: 9px;
}
.sc-player__info {
  flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2;
}
.sc-player__name {
  font-weight: 600; font-size: 15px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sc-player__meta {
  font-size: 11px; color: var(--muted); margin-top: 1px; letter-spacing: 0.02em;
}
.sc-player__totals {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
}
.sc-player__pill {
  display: inline-flex; align-items: baseline; gap: 3px;
  border-radius: 999px; border: 1.5px solid transparent; font: inherit;
}
.sc-player__pill b {
  font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
}
.sc-player__pill span {
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; opacity: 0.85;
}
/* Points — the league metric — leads as a filled pill. */
.sc-player__pill--pts {
  background: var(--dark); color: #fff; padding: 6px 13px;
  box-shadow: 0 4px 10px -4px rgba(31,77,46,0.5);
}
.sc-player__pill--pts b { font-size: 18px; }
/* Gross & net — secondary — read as smaller outlined chips. */
.sc-player__pill--gross,
.sc-player__pill--net {
  background: var(--paper); padding: 5px 10px;
}
.sc-player__pill--gross { border-color: var(--gold-dark); color: var(--gold-dark); }
.sc-player__pill--net   { border-color: var(--net);       color: var(--net); }
.sc-player__pill--gross b,
.sc-player__pill--net b { font-size: 16px; }

.sc-player .cell {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.sc-player .cell .dots {
  height: 9px; line-height: 9px;
  color: var(--gold); font-size: 10px; letter-spacing: 1.5px;
  margin-bottom: 4px;
}
.sc {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; box-sizing: border-box;
  /* line-height matches the 18px inner box (20px − 1px border × 2) so the
     glyph centers on a whole pixel instead of rounding ±1px badge to badge. */
  font-size: 16px; font-weight: 600; color: var(--ink); line-height: 18px;
  font-variant-numeric: tabular-nums;
}
/* Classic notation: red circles under par, dark squares over par.
   Kept thin/small so the double-ring never bleeds into neighbours. */
.sc--birdie,
.sc--eagle {
  color: var(--danger); border: 1px solid var(--danger); border-radius: 50%;
}
.sc--bogey,
.sc--dbogey {
  color: var(--ink); border: 1px solid var(--ink); border-radius: 2px;
}
.sc--eagle  { box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--danger); }
.sc--dbogey { box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--ink); }

.sc-player .cell .pt {
  font-size: 9.5px; font-weight: 700; color: var(--dark); line-height: 1;
  margin-top: 6px; opacity: 0.85;
}

.scorecard__foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 16px; background: var(--cream);
  border-top: 1px solid var(--green-line);
  font-size: 10px; color: var(--muted); letter-spacing: 0.02em;
  flex-wrap: wrap; gap: 6px;
}
.scorecard__foot .legdot { color: var(--gold); font-weight: 700; }

/* ── Stats cards ────────────────────────────────── */
.card { background: var(--paper); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.card__title   { font-family: var(--serif); font-size: 17px; font-weight: 600; margin-bottom: 4px; letter-spacing: -0.01em; }
.card__sub     { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.chart-canvas  { width: 100% !important; height: 180px !important; display: block; }
.chart-canvas--tall { height: 210px !important; }
.empty-text    { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 0; }
.build-stamp   { color: var(--muted); opacity: 0.7; font-size: 11px; text-align: center; letter-spacing: 0.06em; padding: 6px 0 2px; font-variant-numeric: tabular-nums; }

/* ── Stats selector ─────────────────────────────── */
.stats-selector { display: flex; flex-direction: column; gap: 6px; }
.stats-select {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px;
  font-size: 14px; color: var(--ink);
}
.stats-select:focus { outline: none; border-color: var(--dark); }
.stats-select:disabled { opacity: 0.5; }
