/* VCD Golf Platform, shared styles */

:root {
  --bg: #0c1410;
  --surface: #131e18;
  --surface-2: #1a2920;
  --surface-3: #22352a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #edf3ee;
  --muted: rgba(237, 243, 238, 0.64);
  --faint: rgba(237, 243, 238, 0.38);
  --accent: #2a8a50;
  --accent-hover: #34a35f;
  --accent-soft: rgba(42, 138, 80, 0.16);
  --accent-text: #5fd08c;
  --on-accent: #fff;
  --gold: #d9b44a;
  --silver: #b4b6ba;
  --bronze: #c0824a;
  --danger: #e25a5a;
  --danger-soft: rgba(226, 90, 90, 0.14);
  --live: #ef4444;
  --ladies: #e86a8a;
  --radius: 10px;
  --font-head: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --surface-3: #e2eae4;
  --border: rgba(16, 32, 22, 0.1);
  --border-strong: rgba(16, 32, 22, 0.2);
  --text: #13201a;
  --muted: rgba(19, 32, 26, 0.68);
  --faint: rgba(19, 32, 26, 0.42);
  --accent: #1e6b3d;
  --accent-hover: #154d2b;
  --accent-soft: rgba(30, 107, 61, 0.1);
  --accent-text: #1e6b3d;
  --gold: #b08a1e;
  --silver: #7d8085;
  --bronze: #a0622c;
  --danger: #c43c3c;
  --danger-soft: rgba(196, 60, 60, 0.1);
  --ladies: #c8456a;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent-text); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.01em; line-height: 1.1; margin: 0 0 0.5rem; }
h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); text-transform: uppercase; }
h2 { font-size: 1.5rem; text-transform: uppercase; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 0.75rem; }
code { font-size: 0.85em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.mt { margin-top: 1rem; }
.mt-lg { margin-top: 2rem; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar__inner { display: flex; align-items: center; gap: 1rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; color: var(--text); font-family: var(--font-head); font-weight: 800; font-size: 1.2rem; letter-spacing: 0.04em; text-transform: uppercase; }
.brand__mark { width: 44px; height: 44px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex-shrink: 0; overflow: hidden; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15); }
.brand__mark img { width: 86%; height: 86%; object-fit: contain; }
.topbar__nav { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.stripe { display: flex; height: 3px; }
.stripe span { flex: 1; }
.stripe span:nth-child(1) { background: #1e6b3d; }
.stripe span:nth-child(2) { background: #fff; }
.stripe span:nth-child(3) { background: #2a8a50; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font: 600 0.9rem/1 var(--font-body); padding: 0.65rem 1rem; border-radius: 8px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--sm { padding: 0.4rem 0.65rem; font-size: 0.8rem; }
.btn--block { width: 100%; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card__head h2, .card__head h3 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat { background: var(--surface-2); border-radius: 8px; padding: 0.9rem 1rem; }
.stat__val { font-family: var(--font-head); font-size: 2rem; font-weight: 800; line-height: 1; }
.stat__label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-top: 0.3rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; font: 700 0.7rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; padding: 0.35rem 0.55rem; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.badge--live { background: rgba(239, 68, 68, 0.15); color: var(--live); }
.badge--live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
.badge--finished { background: var(--accent-soft); color: var(--accent-text); }
.badge--draft { background: var(--surface-3); color: var(--faint); }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .badge--live::before { animation: none; } }

/* Tabs & chips */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: 700 0.95rem/1 var(--font-head); text-transform: uppercase; letter-spacing: 0.06em; padding: 0.9rem 0.9rem; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: transparent; color: var(--muted); font: 600 0.8rem/1 var(--font-body); padding: 0.45rem 0.75rem; border-radius: 999px; cursor: pointer; }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); font: 600 0.85rem/1 var(--font-body); padding: 0.55rem 0.9rem; cursor: pointer; }
.seg button.active { background: var(--accent); color: var(--on-accent); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label, .label { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.field .hint { font-size: 0.8rem; color: var(--faint); }
input, select, textarea {
  font: 400 0.95rem var(--font-body); color: var(--text); background: var(--bg);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 0.6rem 0.75rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 160px; font-family: ui-monospace, Menlo, monospace; font-size: 0.82rem; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 0.25rem; }
.check strong { display: block; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.search { position: relative; flex: 1; min-width: 180px; }
.search input { padding-left: 2.1rem; }
.search::before { content: '⌕'; position: absolute; left: 0.75rem; top: 50%; transform: translateY(-52%); color: var(--faint); font-size: 1.1rem; pointer-events: none; }
.error { color: var(--danger); background: var(--danger-soft); padding: 0.6rem 0.8rem; border-radius: 8px; font-size: 0.9rem; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.data th { text-align: left; font: 700 0.72rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); padding: 0.75rem 0.75rem; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.data td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .center { text-align: center; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--surface-2); }
.player-name { font-weight: 600; }
.pos { font-family: var(--font-head); font-weight: 800; font-size: 1.05rem; width: 3rem; }
.score-big { font-family: var(--font-head); font-weight: 800; font-size: 1.2rem; }
.under { color: #ef6b6b; }
.empty { text-align: center; color: var(--faint); font-style: italic; padding: 2.5rem 1rem; }
.div-tag { font-family: var(--font-head); font-weight: 700; color: var(--accent-text); white-space: nowrap; }

/* Scorecard */
.scorecard { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.scorecard th, .scorecard td { border: 1px solid var(--border); padding: 0.35rem 0.2rem; text-align: center; min-width: 1.9rem; }
.scorecard th { color: var(--faint); font-weight: 600; background: var(--surface-2); }
.scorecard .lbl { text-align: left; padding-left: 0.5rem; color: var(--muted); min-width: 3.5rem; }
.sc-birdie { color: #ef6b6b; font-weight: 700; }
.sc-eagle { color: #ef6b6b; font-weight: 800; text-decoration: underline; }
.sc-bogey { color: var(--muted); }

/* Podium / results */
.podium { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.podium__head { background: var(--surface-2); padding: 0.7rem 1rem; font: 700 0.85rem/1 var(--font-head); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.podium__row { display: flex; align-items: center; gap: 0.8rem; padding: 0.7rem 1rem; border-top: 1px solid var(--border); }
.medal { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 800 0.9rem/1 var(--font-head); color: #1a1a1a; flex-shrink: 0; background: var(--surface-3); }
.medal--1 { background: var(--gold); }
.medal--2 { background: var(--silver); }
.medal--3 { background: var(--bronze); }
.podium__info { flex: 1; min-width: 0; }
.podium__name { font-weight: 600; }
.podium__meta { font-size: 0.75rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.podium__score { font: 800 1.35rem/1 var(--font-head); }
.champion { background: linear-gradient(135deg, var(--accent-soft), transparent); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.champion__label { font: 700 0.78rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); }
.champion__name { font: 800 1.6rem/1.15 var(--font-head); text-transform: uppercase; margin: 0.5rem 0 0.25rem; }
.champion__score { font: 800 2.4rem/1 var(--font-head); color: var(--accent-text); }

/* Hero */
.hero { padding: 2.5rem 0 1.5rem; }
.hero__meta { display: flex; gap: 0.5rem 1.25rem; flex-wrap: wrap; color: var(--muted); font-size: 0.92rem; align-items: center; }
.eyebrow { font: 700 0.78rem/1 var(--font-body); text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent-text); margin-bottom: 0.75rem; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal.open { display: flex; }
.modal__box { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; width: 100%; max-width: 560px; padding: 1.5rem; }
.modal__box--wide { max-width: 760px; }

/* Toast */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(150%); background: var(--text); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 8px; font-weight: 600; font-size: 0.9rem; z-index: 100; transition: transform 0.25s; max-width: calc(100% - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); }
/* Fully gone when not showing (also when it sits higher up, above the phone's bottom bar) */
.toast:not(.show) { opacity: 0; visibility: hidden; transition: transform 0.25s, opacity 0.25s, visibility 0s 0.25s; }
.toast--error { background: var(--danger); color: #fff; }

/* Admin score grid */
.grid-input { width: 2.6rem; padding: 0.35rem 0.1rem; text-align: center; font-variant-numeric: tabular-nums; border-radius: 6px; }
.grid-input.saving { border-color: var(--gold); }
.grid-input.saved { border-color: var(--accent); }
.grid-input.err { border-color: var(--danger); }
.code-box { display: flex; gap: 0.5rem; align-items: stretch; }
.code-box input, .code-box textarea { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; min-height: 0; }

.footer { color: var(--faint); font-size: 0.82rem; padding: 2rem 0; text-align: center; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  table.data th, table.data td { padding: 0.55rem 0.5rem; }
  .card { padding: 1rem; }
}

@media print {
  .topbar, .tabs, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Tournament logo beside the title */
.t-head { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.t-head__text { min-width: 0; }
.t-logo { width: 76px; height: 76px; object-fit: contain; border-radius: 12px; background: #fff; padding: 5px; flex-shrink: 0; border: 1px solid var(--border); }
.t-logo--sm { width: 44px; height: 44px; border-radius: 8px; padding: 3px; }
.t-logo--md { width: 56px; height: 56px; border-radius: 10px; padding: 4px; }
@media (max-width: 640px) {
  /* Big header logo shrinks on phones; the small card logo keeps its size */
  .t-logo:not(.t-logo--sm):not(.t-logo--md) { width: 56px; height: 56px; border-radius: 10px; padding: 4px; }
  .t-logo--md { width: 48px; height: 48px; border-radius: 9px; padding: 3px; }
  /* Tournament header on phones: club name on its own line, then the logo centred beside
     the tournament title, then the badge / course / date across the full width. */
  .t-head:has(> .t-head__text) { display: grid; grid-template-columns: auto 1fr; column-gap: 0.75rem; row-gap: 0.4rem; align-items: center; }
  .t-head:has(> .t-head__text) > .t-head__text { display: contents; }
  .t-head__text > * { grid-column: 1 / -1; margin-top: 0 !important; }
  .t-head__text > :not(:has(h1, h3)):not(h1):first-child { order: -1; }
  /* The title row (title + Live/Final badge) opens up: title beside the logo, badge on the next line */
  .t-head__text > :has(h1) { display: contents; }
  .t-head__text h1 { grid-column: 2; align-self: center; margin: 0 !important; }
  .t-head__text > :has(h1) > :not(h1) { grid-column: 1 / -1; justify-self: start; }
  .t-head:has(> .t-head__text) > .t-logo { grid-column: 1; align-self: center; }
}

.modal__box { position: relative; }
.modal__x { position: absolute; top: .75rem; right: .75rem; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--muted); font-size: 1rem; cursor: pointer; display: grid; place-items: center; }
.modal__x:hover { color: var(--text); background: var(--surface-3); }

/* Scores tab: view-only cells until a row is in Edit mode */
.grid-input.locked { border-color: transparent; background: transparent; cursor: default; color: var(--text); }
.grid-input.locked:focus { outline: none; }
.scores-table tr.editing td, table.data tr.editing td { background: var(--accent-soft); }

/* "Install app" card (tournaments page) */
.install-card { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin-top: 1.5rem; padding: .9rem 1rem; max-width: 640px; background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); }
.install-card__icon { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.install-card__text { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: .1rem; }

/* Phones and touch screens: comfortable tap targets, and 16px form text so
   iPhones don't zoom the page when a box is tapped. Desktop layout is unchanged. */
@media (max-width: 760px), (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
  .grid-input { font-size: 16px; }
  .btn { min-height: 44px; }
  .btn--sm { min-height: 40px; padding: 0.5rem 0.8rem; font-size: 0.85rem; }
  .topbar__nav .btn--sm { min-height: 40px; }
  .chip { min-height: 40px; padding: 0.55rem 0.9rem; font-size: 0.85rem; display: inline-flex; align-items: center; }
  .chips { gap: 0.5rem; }
  .seg button { min-height: 42px; padding: 0.6rem 1rem; }
  .tab { padding: 1rem 0.9rem; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; flex-shrink: 0; }
  .check input { margin-top: 0.1rem; }
  .modal__x { width: 42px; height: 42px; }
}
.topbar__nav { flex-wrap: nowrap; }
.brand__text { white-space: nowrap; }
@media (max-width: 480px) {
  .topbar__nav { gap: 0.4rem; }
  .topbar__inner { gap: 0.6rem; }
  .brand { gap: 0.45rem; font-size: 1.1rem; }
}
@media (max-width: 640px) {
  /* Show every tab instead of hiding some off-screen */
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .tab { padding: 0.85rem 0.7rem; }
}

/* Show / hide password eye button */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 3rem; }
.pw-eye { position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; background: none; border: 0; border-radius: 6px; color: var(--muted); cursor: pointer; padding: 0; }
.pw-eye:hover, .pw-eye[aria-pressed="true"] { color: var(--text); }
.pw-eye:focus-visible { outline: 2px solid var(--accent); }

/* "‹ Back" button above the page title */
.back-row { padding-top: 1rem; }
.back-btn { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 40px; padding: 0.45rem 0.9rem 0.45rem 0.6rem; background: transparent; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text); font: 600 0.9rem/1 var(--font-body); cursor: pointer; }
.back-btn:hover { background: var(--surface-2); }
.back-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
/* Pull the first section up a little so the page doesn't get a big gap under the button */
.back-row + main .hero, .back-row + main > .hero, .back-row + #viewer .hero { padding-top: 1.25rem; }
.back-row + main.container[style*="padding-top"] { padding-top: 1.25rem !important; }

/* Row under the top bar: Back (left) and Help (right) */
.back-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.help-link { margin-left: auto; display: inline-flex; align-items: center; gap: 0.35rem; min-height: 40px; padding: 0.45rem 0.85rem; border-radius: 999px; color: var(--muted); text-decoration: none; font: 600 0.9rem/1 var(--font-body); border: 1px solid transparent; }
.help-link:hover { color: var(--text); border-color: var(--border-strong); }

/* Floating Help button (bottom-right, floats over the page) */
.help-fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 45; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); transition: transform 0.15s, background 0.15s; }
.help-fab:hover { background: var(--accent-hover); transform: translateY(-1px); }
.help-fab:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.modal.open ~ .help-fab, body:has(.modal.open) .help-fab { display: none; }
@media print { .help-fab { display: none; } }

/* Help pop-up (same text styles as the help page) */
.help-pop { display: flex; flex-direction: column; max-height: 88vh; }
.help-pop__topics { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.6rem; margin-bottom: 0.4rem; border-bottom: 1px solid var(--border); scrollbar-width: thin; flex-shrink: 0; }
.help-pop__topics .chip { white-space: nowrap; flex-shrink: 0; }
.help-pop__body { overflow-y: auto; padding-right: 0.25rem; -webkit-overflow-scrolling: touch; }
.help-pop__body h2 { font-size: 1.4rem; margin: 0.6rem 0 0.6rem; }
.help-pop__body h1 { font-size: 1.5rem; }
.help-pop__body h3 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }
.help-pop__body .eyebrow { display: none; }
.help-pop__body p, .help-pop__body li { color: var(--muted); line-height: 1.6; }
.help-pop__body strong { color: var(--text); }
.help-pop__body ol, .help-pop__body ul { padding-left: 1.3rem; margin: 0 0 1rem; }
.help-pop__body li { margin-bottom: 0.3rem; }
.help-pop__body .who { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 1rem 0; }
.help-pop__body .who a { display: block; text-decoration: none; color: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem; }
.help-pop__body .who a:hover { border-color: var(--accent); }
.help-pop__body .who strong { display: block; font-family: var(--font-head); font-size: 1.05rem; text-transform: uppercase; margin: 0.3rem 0 0.15rem; }
.help-pop__body .who span { font-size: 0.82rem; color: var(--muted); }
.help-pop__body .tip { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 0.7rem 0.9rem; margin: 0.9rem 0; color: var(--text); font-size: 0.9rem; }
.help-pop__body .warn { background: rgba(217, 180, 74, 0.1); border-left: 3px solid var(--gold); border-radius: 6px; padding: 0.7rem 0.9rem; margin: 0.9rem 0; color: var(--text); font-size: 0.9rem; }
.help-pop__body .kbd { display: inline-block; border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 0.4rem; font-size: 0.85em; background: var(--surface-2); color: var(--text); }
.help-pop__body table.data td { color: var(--muted); }
.help-pop__body.faq details { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 0.9rem; margin-bottom: 0.5rem; }
.help-pop__body.faq summary { cursor: pointer; font-weight: 600; color: var(--text); }
.help-pop__body.faq details p { margin: 0.5rem 0 0; }
@media (max-width: 640px) {
  #helpModal { padding: 2vh 10px; }
  .help-pop { max-height: 94vh; padding: 1.1rem; }
}
/* Room at the very bottom so the floating Help button never hides the last thing on the page */
body:has(.help-fab) { padding-bottom: 84px; }

/* Share button + share pop-up */
.share-btn { gap: 0.4rem; }
.share-btn--icon { width: 40px; min-width: 40px; padding: 0; border-radius: 50%; }
.share-apps { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.t-card { position: relative; }
.t-card__link { position: absolute; inset: 0; border-radius: var(--radius); z-index: 1; }
.t-card .share-btn { position: relative; z-index: 2; }

/* Floating Share button: stacked above the floating Help button */
.share-fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 45; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); transition: transform 0.15s, background 0.15s; }
.share-fab:hover { background: var(--surface-2); transform: translateY(-1px); }
.share-fab:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
body:has(.modal.open) .share-fab { display: none; }
@media print { .share-fab { display: none; } }
/* Room at the bottom for both floating buttons */
body:has(.share-fab) { padding-bottom: 152px; }

/* Players › Quick edit */
.qe-table td { padding-top: 0.45rem; padding-bottom: 0.45rem; }
.qe-table .player-name { white-space: nowrap; }
.qe-tee { display: flex; align-items: center; gap: 0.4rem; }
.qe-tee + .qe-tee { margin-top: 0.35rem; }
.qe-input { padding: 0.4rem 0.55rem; }
.qe-time { width: 6.5rem; }
.qe-hole { width: 5.75rem; }
.qe-hcp { width: 4.5rem; }
.qe-div { width: auto; min-width: 8.5rem; }
.qe-input.qe-changed { border-color: var(--gold); }

/* Per-class pop-up */
.div-tag--btn { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; font-size: inherit; }
.div-tag--btn:hover { text-decoration-color: currentColor; }
.class-pop__chips { margin: 1rem 0 1.1rem; }
.class-pop__chips + .row { margin-bottom: 1rem; }
.class-pop__chips .chip.active .faint { color: inherit; opacity: 0.75; }
.class-pop__list { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
@media (pointer: coarse) { .div-tag--btn { min-height: 36px; } }
@media print {
  body:has(#classModal.open) > *:not(#classModal) { display: none !important; }
  #classModal.open { position: static; background: none; padding: 0; }
  #classModal .class-pop__list { max-height: none; overflow: visible; }
  #classModal .row, #classModal .modal__x, #classModal .chips { display: none; }
}
.class-pop__n { margin-left: 0.4em; }
.class-pop .seg { flex-wrap: wrap; }
/* Bottom bar of the By class / By tee time pop-ups: pinned to the bottom edge while scrolling (Edit, Done, Print, Copy, Close). */
.class-pop__foot { justify-content: flex-end; position: sticky; bottom: 0; z-index: 3; background: var(--surface); margin: 0 -1.5rem -1.5rem; padding: .85rem 1.5rem; border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; box-shadow: 0 -10px 18px -12px rgba(0,0,0,.45); }
@media (max-width: 640px) {
  /* Phones: four compact buttons on one line (the pop-up's own bottom space already keeps it above the phone menu bar) */
  .class-pop__foot { flex-wrap: nowrap; gap: .4rem; padding: .65rem 1rem; }
  .class-pop__foot .btn { flex: 1 1 auto; padding: .55rem .5rem; font-size: .82rem; white-space: nowrap; }
}
tr.qe-saved td { background: color-mix(in srgb, var(--accent) 22%, transparent); transition: background .3s; }
.qe-table .qe-save, .qe-table [data-cp-save] { min-width: 4.5rem; }
/* Quick edit on phones: each player becomes a small card so every box and Save fit on screen. */
@media (max-width: 640px) {
  .qe-table, .qe-table tbody { display: block; width: 100%; }
  .qe-table thead { display: none; }
  .qe-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; padding: 0.75rem 0.75rem 0.9rem; border-bottom: 1px solid var(--border); }
  table.data.qe-table td { display: block; padding: 0; border: 0; background: none; }
  .qe-table td.player-name { grid-column: 1 / -1; white-space: normal; }
  .qe-table td:last-child { grid-column: 1 / -1; }
  .qe-table td:last-child .btn { width: 100%; min-height: 44px; }
  .qe-table .qe-time, .qe-table .qe-hole, .qe-table .qe-hcp, .qe-table .qe-div { width: 100%; min-width: 0; }
  .qe-table .qe-tee { flex: 1; }
  .qe-table td:has(.qe-tee) { grid-column: 1 / -1; }
  .qe-table .qe-tee input { flex: 1; }
  .qe-table td::before { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin-bottom: 0.25rem; }
  .qe-table td:has(.qe-tee)::before { content: "Tee time · Hole"; }
  .qe-table td:has(.qe-hcp)::before { content: "HCP"; }
  .qe-table td:has(.qe-div)::before { content: "Class"; }
  .qe-table td:has([data-f="tee_time"]:not(.qe-tee *))::before { content: "Tee time"; }
  .qe-table td:has([data-f="start_hole"]:not(.qe-tee *))::before { content: "Hole"; }
}

/* Instant-search box (golf courses) */
.ss { position: relative; }
.ss__native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; overflow: hidden; clip: rect(0 0 0 0); }
.ss__input { padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.ss__list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; max-height: 300px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45); padding: 0.3rem 0; }
.ss__group { font: 700 0.7rem/1 var(--font-body); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); padding: 0.7rem 0.85rem 0.35rem; }
.ss__group:empty { padding: 0; margin: 0.3rem 0; border-top: 1px solid var(--border); }
.ss__opt { padding: 0.55rem 0.85rem; cursor: pointer; font-size: 0.92rem; }
.ss__opt:hover, .ss__opt.active { background: var(--accent-soft); }
.ss__opt.selected { color: var(--accent-text); font-weight: 600; }
.ss__empty { padding: 0.6rem 0.85rem; color: var(--muted); font-size: 0.88rem; }
@media (pointer: coarse) { .ss__opt { padding: 0.75rem 0.85rem; } .ss__list { max-height: 50vh; } }
.ss__region { display: block; font-size: 0.75rem; color: var(--faint); margin-top: 0.1rem; }
table.data tr.class-pop__flight td { background: var(--surface-2); font: 700 0.8rem/1.2 var(--font-body); letter-spacing: 0.04em; color: var(--accent-text); padding-top: 0.55rem; padding-bottom: 0.55rem; }
.class-pop .chips { max-height: 7.5rem; overflow-y: auto; }
/* Wider class / tee time pop-up so every column fits without squeezing */
.modal__box.class-pop { max-width: min(1120px, 100%); }
.class-pop .class-pop__list { max-height: 64vh; }
.class-pop .class-pop__list table.data td.player-name { white-space: nowrap; }
.class-pop .qe-table .qe-time { width: 7.5rem; }
.class-pop .qe-table .qe-hole { width: 7rem; }
.class-pop .qe-table .qe-div { min-width: 11rem; }
@media (max-width: 640px) { .class-pop .class-pop__list table.data td.player-name { white-space: normal; } }
/* Tournament with handicaps switched off */
.no-hcp .hcp-col, .no-hcp .net-col { display: none !important; }
.print-row { gap: 0.5rem; margin: 0 0 1rem; }
.card .print-row { margin: 1rem 0 0; }

/* Player, club and tournament names always display in capitals (the saved names are unchanged) */
.player-name, .pcard__name, .podium__name, .t-head h3, #clubName, .uc { text-transform: uppercase; }

/* Toggle switch (subscription mode) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 52px; height: 30px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; flex-shrink: 0; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(22px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan-row { display: grid; grid-template-columns: 170px minmax(0, 320px); gap: 0.75rem; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.plan-row:last-of-type { border-bottom: 0; }
.money { display: flex; align-items: center; gap: 0.4rem; }
.money span { color: var(--muted); font-weight: 600; white-space: nowrap; }
.money input { max-width: 150px; }
#payHow { font: 400 0.95rem/1.45 var(--font-body); }
.sub-status { font-weight: 600; }
.sub-status.ok { color: var(--accent-text); }
.sub-status.warn { color: var(--gold); }
.hist { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.hist li { padding: 0.55rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.hist li:last-child { border-bottom: 0; }
.plan-offer { display: flex; justify-content: space-between; align-items: baseline; padding: 0.7rem 0.9rem; border: 1px solid var(--border-strong); border-radius: 10px; }
.plan-offer + .plan-offer { margin-top: 0.5rem; }
.plan-offer strong { font-family: var(--font-head); font-size: 1.1rem; text-transform: uppercase; }
.pay-how { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 0.8rem 1rem; font-size: 0.92rem; }
@media (max-width: 640px) { .plan-row { grid-template-columns: 1fr; } }
.plan-warn { border-color: var(--gold); }

/* Light / dark mode floating button (above Help, and above Share when there is one) */
.theme-fab { position: fixed; right: 20px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 45; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); transition: transform 0.15s, background 0.15s; }
.theme-fab:hover { background: var(--surface-2); transform: translateY(-1px); }
.theme-fab:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
body:has(.help-fab) .theme-fab { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
body:has(.help-fab):has(.share-fab) .theme-fab { bottom: calc(152px + env(safe-area-inset-bottom, 0px)); }
body:has(.modal.open) .theme-fab { display: none; }
body:has(.theme-fab) { padding-bottom: 76px; }
body:has(.help-fab):has(.theme-fab) { padding-bottom: 144px; }
body:has(.share-fab):has(.theme-fab) { padding-bottom: 212px; }
@media print { .theme-fab { display: none; } }
.install-card--flash { animation: installFlash 1.2s ease 2; }
@keyframes installFlash { 50% { box-shadow: 0 0 0 4px var(--accent); } }
.co-list { list-style: none; margin: 0; padding: 0; }
.co-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.co-list li:last-child { border-bottom: 0; }

/* Bottom bar (phones only) */
.bnav { display: none; }
@media (max-width: 760px) {
  .bnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; /* above pop-ups: always there */
    background: var(--surface); border-top: 1px solid var(--border-strong);
    padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.25);
  }
  .bnav__btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
    min-height: 54px; padding: 0.25rem 0.1rem; border: 0; background: none; color: var(--muted);
    font: 600 0.7rem/1.1 var(--font-body); text-decoration: none; cursor: pointer; border-radius: 10px;
  }
  .bnav__btn.active { color: var(--accent-text); }
  .bnav__btn:active { background: var(--accent-soft); }
  .bnav__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  /* the bar replaces the floating buttons on phones */
  body.has-bnav .help-fab, body.has-bnav .share-fab, body.has-bnav .theme-fab { display: none !important; }
  body.has-bnav, body.has-bnav:has(.help-fab), body.has-bnav:has(.share-fab), body.has-bnav:has(.theme-fab) { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important; }
  body.has-bnav .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  /* Pop-ups stop above the bar so nothing hides behind it */
  body.has-bnav .modal { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  body.has-bnav .help-pop { max-height: calc(100dvh - 110px - env(safe-area-inset-bottom, 0px)); }
  /* "More" and pick lists slide up from the bottom */
  body.has-bnav .modal--sheet, .modal--sheet { align-items: flex-end; padding: 0 0 calc(66px + env(safe-area-inset-bottom, 0px)); }
  .modal--sheet .modal__box { border-radius: 16px 16px 0 0; max-width: none; }
}
.bnav-item { display: flex; flex-direction: column; padding: 0.85rem 0.25rem; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; }
.bnav-item:last-child { border-bottom: 0; }
.bnav-item small { color: var(--muted); font-weight: 400; font-size: 0.82rem; margin-top: 0.1rem; }
@media print { .bnav { display: none !important; } }
/* Phones: Account and Log out live in the bottom bar's More, not the top bar */
@media (max-width: 760px) {
  body.has-bnav .topbar #accountBtn, body.has-bnav .topbar #logout { display: none !important; }
}
.class-pop__tools { gap: 0.5rem; margin: 0.75rem 0 0; }
.card__head + .print-row { margin: 0 0 1rem; }
/* Handicaps off but "Show handicaps" on: HCP column back (Net stays hidden) */
.no-hcp.show-hcp .hcp-col { display: revert !important; }
@media (max-width: 640px) { .no-hcp.show-hcp .hcp-col.hide-sm { display: none !important; } }
.back-btn--scoring { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.back-btn--scoring:hover { background: var(--accent-hover); }
.badge--fun { background: rgba(217, 180, 74, 0.16); color: var(--gold); }
.kind-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.kind-pick label { display: block; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .65rem .75rem; cursor: pointer; }
.kind-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.kind-pick input { margin-right: .4rem; }
.kind-pick small { display: block; color: var(--muted); margin-top: .2rem; line-height: 1.35; }
.hero > .container, .embed-head > div { position: relative; }
/* "Finished" stamp. Sized in em so the whole stamp (border, padding, text) scales from one font-size. */
.done-stamp { --stamp: clamp(1.5rem, 6.5vw, 3.1rem); font-size: var(--stamp); display: inline-flex; flex-direction: column; align-items: center; margin: .8em 0 .2em; padding: .22em .5em .26em; border: .1em double var(--accent-text); border-radius: .25em; color: var(--accent-text); transform: rotate(-5deg); transform-origin: left center; opacity: .92; pointer-events: none; user-select: none; text-transform: uppercase; line-height: 1; box-shadow: inset 0 0 0 .03em color-mix(in srgb, var(--accent-text) 25%, transparent); }
.done-stamp__big { font: 800 1em/1 var(--font-head); letter-spacing: .14em; }
.done-stamp__sub { font: 700 .34em/1 var(--font-body); letter-spacing: .16em; margin-top: .45em; white-space: nowrap; }
.done-stamp--sm { --stamp: clamp(1.3rem, 4.5vw, 2rem); }
@media (min-width: 760px) {
  .hero .container { --page-stamp: clamp(1.9rem, 2.5vw, 2.6rem); }
  .hero .done-stamp { --stamp: var(--page-stamp); position: absolute; right: 1.25rem; top: 50%; margin: 0; transform: translateY(-50%) rotate(-8deg); transform-origin: center; }
  .hero .container:has(> .done-stamp) .t-head { padding-right: calc(var(--page-stamp) * 9.5); } /* keep the title clear of the stamp */
}
@media print { .done-stamp { display: none; } }

/* Tournament cards: the stamp grows with the card's own width (cqi = 1% of the card). */
.t-card { container-type: inline-size; }
.t-card__foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 2.6rem; margin-top: .3rem; }
/* Same placement on every card and screen: right end of the players line, raised a little so the card doesn't grow taller.
   Small tilt so no corner dips toward the card edge. Size follows the screen width, so every stamp on a screen matches. */
.done-stamp--card { --stamp: clamp(1.35rem, 2.2vw + .6rem, 2rem); margin: 6px .15em 0 auto; position: relative; top: calc(-5px + (1em - 1.35rem) * .3); transform: rotate(-4deg); transform-origin: center; opacity: .88; flex-shrink: 0; }
/* Phones: equal empty space above and below the tournament page stamp */
@media (max-width: 759px) {
  .hero .done-stamp { transform-origin: center; margin: 26px 0 -8px; /* measured: the gap to the details above equals the gap to the tab labels below */ }
}
/* Dashboard cards: full-width stamp below the buttons, straight (no tilt). */
.done-stamp--wide { --stamp: clamp(1.5rem, 1.4vw + .9rem, 2.1rem); display: flex; width: 100%; box-sizing: border-box; margin: 1rem 0 .15rem; transform: none; }
/* Computer screens: lift the card stamp further into the empty space beside the date, away from the bottom edge
   (the details are on the left, so it never reaches the text). */
@media (min-width: 760px) {
  .done-stamp--card { top: calc(-27px + (1em - 1.35rem) * .3); }
}
/* Tournaments page: cards glow green on mouse hover (and when focused with the keyboard). Mouse devices only, so taps on phones don't leave a glow behind. */
.t-card { transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
@media (hover: hover) {
  .t-card:hover { border-color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent-text), 0 0 24px color-mix(in srgb, var(--accent-text) 35%, transparent); transform: translateY(-2px); }
}
.t-card:has(.t-card__link:focus-visible) { border-color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent-text), 0 0 24px color-mix(in srgb, var(--accent-text) 35%, transparent); }
@media (prefers-reduced-motion: reduce) { .t-card { transition: none; } .t-card:hover { transform: none; } }
/* By tee time pop-up: search box, and the matching player(s) highlighted among their flight mates */
.class-pop__search { max-width: 420px; margin-bottom: .35rem; }
.class-pop__hit td { background: var(--accent-soft); }
.class-pop__hit .player-name { color: var(--accent-text); }
/* By tee time: tee time dropdown beside the flight search */
.class-pop__filters { gap: .6rem; margin: 1rem 0 .35rem; align-items: stretch; }
.class-pop__tee { width: auto; min-width: 11rem; max-width: 100%; flex: 0 0 auto; }
.class-pop__filters .class-pop__search { margin-bottom: 0; flex: 1 1 260px; }
@media (max-width: 640px) { .class-pop__tee { flex: 1 1 100%; } }
/* Flight QR codes: small on the Flight scoring links tab (tap to enlarge), large in the pop-up */
.flight-qr { display: block; width: 84px; height: 84px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: zoom-in; overflow: hidden; }
.flight-qr svg, .qr-big__code svg { display: block; width: 100%; height: 100%; }
.flight-qr:hover, .flight-qr:focus-visible { border-color: var(--accent-text); box-shadow: 0 0 0 2px var(--accent-soft); outline: none; }
.qr-big { max-width: 440px; }
.qr-big__code { width: min(320px, 78vw); aspect-ratio: 1; margin: .5rem auto; background: #fff; border-radius: 10px; padding: 8px; }
.qr-big__pin { text-align: center; margin: 0; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.qr-big__pin b { display: block; font: 800 2.2rem/1 var(--font-head); letter-spacing: .25em; color: var(--text); margin-top: .2rem; }
@media print { .flight-qr { width: 30mm; height: 30mm; border: 0; } }
