/* PuttKeep: app styles (plain CSS, no framework). */
:root {
  --brand: #12855a;
  --on-brand: #ffffff;
  --brand-ink: #0e6e4a;
  --brand-soft: #e2f1ea;
  --brand-softer: #f0f8f4;
  --brand-line: #b8dccb;
  --bg: #eef7f1;
  --bg-deep: #dcefe4;
  --on-bg: #0f172a;
  --on-bg-muted: #475569;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #566176;   /* 4.5:1 or better on white and on the light brand-tinted panels */
  --line: #e5e9f0;
  --surface: #ffffff;
  --good: #0f8a4b;
  --good-bg: #e3f6eb;
  --bad: #c2410c;
  --bad-bg: #fdeee4;
  --ace: #a16207;
  --ace-bg: #fff3c4;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 30px -12px rgba(15, 23, 42, .18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 100% -10%, var(--glow, var(--brand-soft)), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, var(--bg-deep), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* No double-tap zoom on fast repeated taps. "manipulation" = pan + pinch-zoom, so scrolling and
   pinch zoom still work (the viewport tag never sets maximum-scale or user-scalable). touch-action
   is not inherited and scroll containers start a new chain, so it is set on the page, on every
   container and on every control. assets/tap-guard.js covers browsers that still zoom. */
html, body, main, header, nav, footer, section, form, dialog, .topbar, .card, .hero, .hole-card, .scores, .score-row,
.stepper, .mini-stepper, .action-bar, .action-bar-inner, .sheet-inner, .sheet-head, .sheet-body, .sheet-body *, .sheet-actions,
.menu-list, .player-list, .player-item, .add-player, .par-grid, .par-strip, .par-cell, .btn-row, .row2, .swatches,
.setting, .switch, .table-wrap, .table-wrap *, .board, .final-rank, .toast, .challenge, .challenge-slim,
button, a, input, select, textarea, label, summary, [data-action], [data-sheet], [role="button"] { touch-action: manipulation; }
/* Controls: no text selection or grey tap flash when tapped fast. Text fields keep selection. */
button, summary, [data-action], [data-sheet], [role="button"], .btn, .step, .icon-btn, .switch, .swatch, .chip,
.stepper, .mini-stepper, .action-bar, input[type="checkbox"], input[type="radio"] {
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-ink); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px calc(112px + env(safe-area-inset-bottom));
}
.app.no-bar { padding-bottom: 32px; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(4px + env(safe-area-inset-top)) 0 10px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; text-decoration: none; color: var(--on-bg); }
.brand-logo {
  width: 46px; height: 46px; border-radius: 14px; object-fit: contain; flex: none;
  background: var(--surface); box-shadow: var(--shadow); padding: 3px;
}
.brand-mark { width: 46px; height: 46px; border-radius: 14px; flex: none; box-shadow: var(--shadow); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.brand-sub { font-size: 13px; color: var(--on-bg-muted); font-weight: 600; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(.96); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 14px;
}
.card-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 12px; font-family: var(--font-display); font-size: 18px; font-weight: 800; letter-spacing: -.01em;
}
.card-title .count { font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- hero ---------- */
.hero { padding: 8px 2px 18px; color: var(--on-bg); }
.hero h1 { margin: 0 0 6px; font-family: var(--font-display); font-size: clamp(28px, 8vw, 36px); line-height: 1.08; letter-spacing: -.025em; font-weight: 850; }
.hero p { margin: 0; color: var(--on-bg-muted); font-size: 16px; }
/* A course name that is one very long word (24+ letters, no spaces) wraps instead of pushing the page sideways. */
.hero, .notice, .result-hero, .footer { min-width: 0; }
.hero h1, .hero p, .cap-hint, .notice h1, .notice p, .footer, .result-hero h1, .result-hero p, .brand-sub { overflow-wrap: anywhere; }
.resume-note { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--on-bg-muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 0; font-weight: 750; font-size: 16px; letter-spacing: -.005em; text-decoration: none;
  transition: transform .08s ease, background-color .15s ease, box-shadow .15s ease, opacity .15s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
/* Disabled buttons (Prev on hole 1, Start before anyone is added) stay readable on any page
   color, dark course themes included: solid grey with 4.5:1 text instead of a faded brand color. */
.btn-ghost[disabled], .btn-primary[disabled], .btn-soft[disabled] { opacity: 1; background: #e9edf2; color: #4b5567; box-shadow: inset 0 0 0 1.5px #d5dbe3; filter: none; }
.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 8px 20px -10px var(--brand); }
.btn-primary:hover:not([disabled]) { filter: brightness(1.05); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-danger { background: #fde8e8; color: #b42318; }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.link-btn { background: none; border: 0; padding: 0; min-height: 44px; color: var(--brand-ink); font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.link-btn svg { width: 16px; height: 16px; transition: transform .2s; }
.link-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, rgba(255,255,255,0));
}
.action-bar-inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }
.action-bar-inner .btn { flex: 1; }
.action-bar-inner .btn-ghost { flex: 0 0 auto; min-width: 104px; }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: #fbfcfd; font-size: 17px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px var(--brand-soft); }
.input::placeholder { color: #94a3b8; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; padding-top: 2px; }
.setting-label { font-weight: 700; }
.setting-help { font-size: 13px; color: var(--muted); }

.mini-stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-softer); border-radius: 999px; padding: 4px; }
.mini-stepper button {
  width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--surface); color: var(--brand-ink);
  font-size: 22px; font-weight: 700; line-height: 1; display: grid; place-items: center; box-shadow: 0 1px 2px rgba(15,23,42,.08);
}
.mini-stepper button[disabled] { opacity: .35; }
.mini-stepper output { min-width: 44px; text-align: center; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }

.par-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 10px; }
.par-cell { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 14px; background: #f8fafc; }
.par-cell .h { font-weight: 700; font-size: 14px; color: var(--ink-2); }
.par-cell .mini-stepper { background: transparent; padding: 0; }
.par-cell .mini-stepper button { width: 44px; height: 44px; font-size: 20px; }
.par-cell .mini-stepper output { min-width: 26px; font-size: 16px; }

.locked {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--brand-softer); color: var(--ink-2); font-weight: 650;
}
.locked svg { width: 20px; height: 20px; color: var(--brand-ink); flex: none; }
.locked .grow { flex: 1; }
.par-strip { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-top: 10px; }
.par-strip span { display: grid; place-items: center; padding: 6px 0; border-radius: 9px; background: #f8fafc; font-size: 12px; color: var(--muted); line-height: 1.15; text-align: center; }
.par-strip b { color: var(--ink); font-size: 15px; }

.add-player { display: flex; gap: 8px; }
.add-player .input { flex: 1; min-width: 0; }
.add-player .btn { flex: none; padding: 0 20px; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; align-items: center; }
.swatch {
  position: relative; width: 44px; height: 44px; border-radius: 999px; border: 0; padding: 0;
  background: var(--c); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
  transition: transform .12s;
}
.swatch[aria-checked="true"] { transform: scale(1.08); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c); }
.swatch[aria-checked="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 7px;
  border: solid #fff; border-width: 0 0 3px 3px; transform: translateY(-2px) rotate(-45deg);
}
.swatch.taken { opacity: .25; }
.swatch-custom { position: relative; width: 44px; height: 44px; border-radius: 999px; overflow: hidden; box-shadow: inset 0 0 0 2px var(--line); background: conic-gradient(#f87171, #facc15, #34d399, #60a5fa, #a78bfa, #f472b6, #f87171); }
.swatch-custom input { position: absolute; inset: -8px; width: 60px; height: 60px; opacity: 0; cursor: pointer; border: 0; padding: 0; }

.recent { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.recent-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.recent .forget-names { font-size: 13px; margin-left: auto; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1.5px dashed var(--brand-line); background: var(--brand-softer); color: var(--brand-ink); font-weight: 700; font-size: 14px;
}
.chip::before { content: "+"; font-weight: 800; }

.player-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }  /* long one-word names shrink, never widen the page */
.player-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px; border-radius: 14px; background: #f8fafc; }
.player-item .name { flex: 1; font-weight: 700; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-btn { width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.remove-btn:hover { background: #fee2e2; color: #b42318; }
.remove-btn svg { width: 18px; height: 18px; }
.empty { margin: 14px 0 0; padding: 16px; text-align: center; color: var(--muted); border-radius: 14px; background: #f8fafc; font-size: 15px; }
.hint { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.cap-hint { color: var(--on-bg-muted); }   /* sits on the page, not on a card */

.ball {
  width: 22px; height: 22px; border-radius: 999px; flex: none; background: var(--c, #60a5fa);
  background-image: radial-gradient(circle at 32% 30%, rgba(255,255,255,.75) 0 18%, transparent 19%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.14);
}
.ball.lg { width: 30px; height: 30px; }

/* 56x44 tap target around a 52x32 track */
.switch { position: relative; width: 56px; height: 44px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; left: 2px; right: 2px; top: 6px; bottom: 6px; border-radius: 999px; background: #cbd5e1; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- play ---------- */
.hole-card { position: relative; overflow: hidden; background: var(--brand); color: var(--on-brand); padding: 12px 14px 12px 18px; margin-bottom: 10px; }
.hole-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 999px;
  background: rgba(0,0,0,.07); pointer-events: none;
}
.hole-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.hole-title { margin: 0; display: flex; align-items: baseline; gap: 8px; font: inherit; min-width: 0; }
.hole-label { font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.hole-num { font-family: var(--font-display); font-size: 46px; line-height: 1; font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.hole-of { font-size: 17px; font-weight: 700; margin-left: 2px; letter-spacing: 0; }
.par-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 3px 3px 14px; border-radius: 999px;
  background: rgba(0,0,0,.16); font-weight: 800; font-size: 17px; white-space: nowrap;
}
.par-badge.locked-par { padding: 8px 16px; }
.par-badge button {
  width: 44px; height: 44px; border-radius: 999px; border: 0; background: rgba(0,0,0,.14); color: inherit;
  font-size: 20px; font-weight: 800; line-height: 1; display: grid; place-items: center;
}
.progress { position: relative; z-index: 1; height: 6px; margin-top: 10px; border-radius: 999px; background: rgba(255,255,255,.22); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--on-brand); opacity: .95; transition: width .3s ease; }
.sponsor { position: relative; z-index: 1; margin: 8px 0 0; font-size: 13px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.challenge { background: linear-gradient(135deg, #fff8e6, #fff); border: 1.5px solid #fde7a7; padding: 10px 14px; margin-bottom: 8px; }
.challenge-text::before { content: "\1F3B2  "; }
.challenge-text { margin: 0 0 4px; font-family: var(--font-display); font-size: 17px; line-height: 1.2; font-weight: 800; color: #451a03; letter-spacing: -.01em; }
.challenge-slim { margin: 0 0 10px; }
.challenge-slim .btn { min-height: 46px; font-size: 16px; }
/* Play-safe note: only inside the open challenge card, as one small line (keeps 4 players above the
   action bar on an iPhone 14). */
.play-safe { margin: 0 0 6px; font-size: 12px; line-height: 1.25; font-weight: 600; color: #78350f; }
.challenge-text.pop { animation: pop .35s ease; }
.challenge .btn-row { display: flex; gap: 8px; }
.challenge .btn-row .btn { flex: 1; min-height: 44px; }
.btn-challenge { background: #f59e0b; color: #1f1300; box-shadow: 0 8px 18px -10px #b45309; }
.btn-challenge-soft { background: #fff; color: #92400e; box-shadow: inset 0 0 0 1.5px #fcd34d; }
@keyframes pop { 0% { transform: scale(.94); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.scores { padding: 2px 14px; margin-bottom: 8px; }
.score-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.score-row:first-child { border-top: 0; }
.score-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.score-who .meta { min-width: 0; }
.score-who .name { display: block; font-weight: 800; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-who .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; }
.step {
  width: 48px; height: 48px; border-radius: 16px; border: 0; display: grid; place-items: center;
  font-size: 26px; font-weight: 700; line-height: 1;
}
.step.minus { background: #f1f5f9; color: var(--ink-2); }
.step.plus { background: var(--brand); color: var(--on-brand); }
.step[disabled] { opacity: .35; }
.step:active:not([disabled]) { transform: scale(.94); }
.strokes { width: 54px; text-align: center; position: relative; }
.strokes .n { display: block; font-family: var(--font-display); font-size: 32px; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.strokes .n.blank { color: #cbd5e1; }
.strokes .rel { display: block; margin-top: 3px; font-size: 11px; font-weight: 800; letter-spacing: .02em; color: var(--muted); min-height: 14px; }
.rel.under { color: var(--good); }
.rel.over { color: var(--bad); }
.rel.ace { color: var(--ace); }
.cap-hint { margin: 0 4px 14px; }

.board ol { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.board li:first-child { border-top: 0; }
.board .rank { width: 24px; font-weight: 800; color: var(--muted); text-align: center; }
.board .nm { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .thru { font-size: 12px; color: var(--muted); font-weight: 600; }
.topar { min-width: 44px; text-align: center; padding: 3px 8px; border-radius: 999px; font-size: 13px; font-weight: 800; background: #f1f5f9; color: var(--ink-2); }
.topar.under { background: var(--good-bg); color: var(--good); }
.topar.over { background: var(--bad-bg); color: var(--bad); }
.board .tot { width: 34px; text-align: right; font-weight: 900; font-size: 18px; }

/* ---------- scorecard table ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
table.sc { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 15px; }
.sc th, .sc td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.sc thead th { position: sticky; top: 0; background: var(--surface); font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; z-index: 1; }
.sc thead th .ball { width: 14px; height: 14px; margin: 0 auto 4px; }
.sc thead th .pn { display: block; max-width: 72px; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.sc th:nth-child(-n+2), .sc td:nth-child(-n+2) { position: sticky; background: var(--surface); z-index: 1; }
.sc th:nth-child(1), .sc td:nth-child(1) { left: 0; width: 44px; min-width: 44px; }
.sc th:nth-child(2), .sc td:nth-child(2) { left: 44px; width: 40px; min-width: 40px; box-shadow: 6px 0 6px -6px rgba(15,23,42,.18); }
.sc thead th:nth-child(-n+2) { z-index: 2; }
.sc td.h { font-weight: 800; color: var(--ink-2); }
.sc td.p { color: var(--muted); }
.sc td .cell { display: inline-grid; place-items: center; min-width: 32px; height: 30px; padding: 0 4px; border-radius: 9px; font-weight: 700; }
.cell.under { background: var(--good-bg); color: var(--good); }
.cell.over { background: var(--bad-bg); color: var(--bad); }
.cell.ace { background: var(--ace-bg); color: var(--ace); box-shadow: inset 0 0 0 1.5px #facc15; }
.cell.blank { color: #cbd5e1; }
.sc tr.current td { background: var(--brand-softer); }
.sc tbody tr.jump:hover td:nth-child(-n+2) { background: #f8fafc; }
.sc tbody tr.jump { cursor: pointer; }
.sc tbody tr.jump:hover td { background: #f8fafc; }
.sc tfoot td { font-weight: 900; border-bottom: 0; padding-top: 10px; font-size: 16px; }
.sc tfoot tr.sub td { font-weight: 800; font-size: 13px; padding-top: 2px; color: var(--muted); }

/* ---------- end screen ---------- */
.result-hero { text-align: center; padding: 26px 18px 22px; position: relative; overflow: hidden; background: var(--brand); color: var(--on-brand); }
.result-hero .trophy { font-size: 54px; line-height: 1; margin-bottom: 10px; filter: drop-shadow(0 8px 12px rgba(0,0,0,.2)); }
.result-hero h1 { margin: 0; font-family: var(--font-display); font-size: clamp(28px, 8vw, 36px); font-weight: 900; letter-spacing: -.025em; line-height: 1.1; }
.result-hero p { margin: 8px 0 0; font-weight: 700; }
/* hole-in-ones on the end screen: one compact line, never more than 2 */
.result-hero .aces-line { position: relative; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; opacity: .9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(260px) rotate(540deg); opacity: 0; } }

.final-rank { list-style: none; margin: 0; padding: 0; }
.final-rank li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.final-rank li:first-child { border-top: 0; padding-top: 4px; }
.final-rank .medal { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; font-weight: 900; font-size: 15px; background: #f1f5f9; color: var(--ink-2); flex: none; }
.final-rank .m1 { background: #fde68a; color: #78350f; }
.final-rank .m2 { background: #e2e8f0; color: #334155; }
.final-rank .m3 { background: #fed7aa; color: #7c2d12; }
.final-rank .who { flex: 1; min-width: 0; }
.final-rank .who b { display: block; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-rank .who small { color: var(--muted); font-weight: 600; font-size: 13px; }
.final-rank .tot { font-family: var(--font-display); font-weight: 900; font-size: 26px; min-width: 40px; text-align: right; }
.final-rank li.incomplete .tot { color: var(--muted); }
.final-rank li.incomplete .who small { color: var(--bad); font-weight: 700; }

.stack { display: grid; gap: 10px; margin: 4px 0 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.notice { text-align: center; padding: 30px 22px; }
.notice .big { font-size: 46px; margin-bottom: 8px; }
.notice h1 { font-family: var(--font-display); font-size: 26px; margin: 0 0 8px; letter-spacing: -.02em; }
.notice p { margin: 0 0 10px; color: var(--ink-2); }

.footer { text-align: center; padding: 10px 0 0; font-size: 13px; color: var(--on-bg-muted); }
.footer p { margin: 6px 0; }
.footer a { color: inherit; font-weight: 700; display: inline-block; min-height: 44px; box-sizing: border-box; padding: 12px 4px; margin: -12px 0; }
.privacy { font-size: 12px; }

/* ---------- dialog + toast ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh;
  border-radius: 24px 24px 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.sheet::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog.sheet[open] { animation: up .22s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-inner { padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; max-height: inherit; }
.sheet-grip { width: 42px; height: 5px; border-radius: 9px; background: #e2e8f0; margin: 2px auto 12px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex: none; }
.sheet-head h2 { margin: 0; font-family: var(--font-display); font-size: 21px; letter-spacing: -.015em; }
.sheet-body { overflow: auto; flex: 1; min-height: 0; color: var(--ink-2); }
.sheet-body p { margin: 0 0 10px; }
.sheet-actions { display: grid; gap: 10px; margin-top: 16px; flex: none; }
.menu-list { display: grid; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border: 0; border-radius: 16px; background: #f8fafc; text-align: left; font-weight: 700; font-size: 16px; color: var(--ink); }
.menu-item svg { width: 22px; height: 22px; color: var(--brand-ink); flex: none; }
.menu-item small { display: block; font-weight: 600; color: var(--muted); font-size: 13px; }
.menu-item.danger svg { color: #b42318; }

.toast {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); z-index: 60;
  transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  box-shadow: var(--shadow-lg); transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
  line-height: 1.3; display: flex; align-items: center; justify-content: center; box-sizing: border-box;
}
/* Over the header's logo and name (placed by app.js), clear of the header buttons. */
.toast.anchored { transform: translateY(-8px); max-width: none; padding: 6px 12px; font-size: 14px; line-height: 1.25; border-radius: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.anchored.show { transform: none; }
/* The clamp lives on the text, not on the padded box, so the third line never shows half-cut. */
.toast-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; min-width: 0; }
.fit-measure { display: block !important; -webkit-line-clamp: none !important; overflow: visible !important; }

.loading { display: grid; place-items: center; min-height: 50vh; color: var(--on-bg-muted); font-weight: 700; }
.spinner { width: 34px; height: 34px; border-radius: 999px; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* very narrow phones (320-359 px): keep each player on one compact row */
@media (max-width: 359px) {
  .scores { padding: 2px 10px; }
  .score-row { gap: 6px; }
  .score-who { gap: 8px; }
  .score-who .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  .stepper { gap: 4px; }
  .strokes { width: 44px; }
  .score-who .ball.lg { width: 24px; height: 24px; }
}
@media (min-width: 720px) {
  .app { padding-top: 28px; }
  dialog.sheet { margin: auto; border-radius: 24px; }
  .hole-num { font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
