/* My SimGolfBoss — phone review surface.
   Phone-first, one column, big numbers, graphics over tables (spec).

   Themes: every shell colour is a CSS variable. The default (:root)
   set is Fairway; the [data-theme] blocks below swap the whole set.
   The picker lives on the Account screen, the choice is stored on
   the device (localStorage "mysgb-theme", see js/app.js) and applied
   as <html data-theme="…">. Brand colours (per-sim palette, source
   chips, On-Course violet) are identity, not theme — they stay
   constant in :root so a PurePlay column is PurePlay green in
   every theme. */

:root {
  /* Fairway — the original deep-green look (default). */
  --bg: #0a1a13;
  --bg-raise: #10241b;
  --bg-card: #132b20;
  --line: #21402f;
  --ink: #eef5f0;
  --ink-dim: #9db8a8;
  --ink-faint: #6d8a7a;
  --accent: #46d17c;
  --good: #46d17c;
  --accent-ink: #06230f;
  --warn: #e8b93e;
  --warn-ink: #231a02;
  --danger: #e4574d;
  --danger-ink: #ffb3ad;
  --danger-bg: rgba(228, 87, 77, 0.14);
  --chrome-bg: rgba(10, 26, 19, 0.94);
  --chip-sim: #2e6fd8;
  --chip-tracker: #8a5fd6;
  --chip-phone: #d17f2e;
  /* Desktop palette — per-sim brand colours + On-Course violet */
  --pureplay: #3ee06f;
  --gspro: #57a8ff;
  --muni: #1e9e6a;
  --shotforge: #ff8a3d;
  --oncourse: #b18cff;
  --radius: 14px;
}

/* Midnight — dark navy / charcoal blue. */
html[data-theme="midnight"] {
  --bg: #0a0e18;
  --bg-raise: #101827;
  --bg-card: #141f31;
  --line: #263650;
  --ink: #edf2fa;
  --ink-dim: #a3b4cc;
  --ink-faint: #6e82a0;
  --accent: #4da3ff;
  --good: #3ecf6f;
  --accent-ink: #04101f;
  --warn: #e8b93e;
  --warn-ink: #231a02;
  --danger: #e4574d;
  --danger-ink: #ffb3ad;
  --danger-bg: rgba(228, 87, 77, 0.14);
  --chrome-bg: rgba(10, 14, 24, 0.94);
}

/* Clubhouse — warm dark brown, amber accents. */
html[data-theme="clubhouse"] {
  --bg: #17100a;
  --bg-raise: #211810;
  --bg-card: #271c11;
  --line: #46331a;
  --ink: #f7efe1;
  --ink-dim: #cbb391;
  --ink-faint: #94805f;
  --accent: #e8a33d;
  --good: #57b368;
  --accent-ink: #2a1802;
  --warn: #ffd23e;
  --warn-ink: #231a02;
  --danger: #e4574d;
  --danger-ink: #ffb3ad;
  --danger-bg: rgba(228, 87, 77, 0.14);
  --chrome-bg: rgba(23, 16, 10, 0.94);
}

/* Tour Black — near-black, gold accents. */
html[data-theme="tour-black"] {
  --bg: #060606;
  --bg-raise: #0f0f0f;
  --bg-card: #141414;
  --line: #2b2b2b;
  --ink: #f5f2ea;
  --ink-dim: #b5ad9c;
  --ink-faint: #7e7768;
  --accent: #d4af37;
  --good: #3ecf6f;
  --accent-ink: #1a1402;
  --warn: #e8b93e;
  --warn-ink: #231a02;
  --danger: #e4574d;
  --danger-ink: #ffb3ad;
  --danger-bg: rgba(228, 87, 77, 0.14);
  --chrome-bg: rgba(6, 6, 6, 0.95);
}

/* Daylight — the light theme: off-white, dark text, green accents.
   --bg-raise is a warm grey (not white) so bar tracks, the seg
   control and inputs stay visible against the white cards; warn and
   danger darken so their text uses stay readable on light ground. */
html[data-theme="daylight"] {
  --bg: #f5f3ec;
  --bg-raise: #eceade;
  --bg-card: #ffffff;
  --line: #d9d3c0;
  --ink: #17251b;
  --ink-dim: #4d6053;
  --ink-faint: #62745d;
  --accent: #177a43;
  --good: #177a43;
  --accent-ink: #ffffff;
  --warn: #8a6100;
  --warn-ink: #fff8e7;
  --danger: #c93a30;
  --danger-ink: #9c2b21;
  --danger-bg: rgba(201, 58, 48, 0.08);
  --chrome-bg: rgba(245, 243, 236, 0.94);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.offline-banner {
  background: var(--warn);
  color: var(--warn-ink);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  padding: 6px 12px;
}

.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }
.brand-icon { width: 28px; height: 28px; border-radius: 7px; }
.sync-pill {
  font-size: 12px; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; white-space: nowrap;
  background: var(--bg-raise);
}
.sync-pill.stale { color: var(--warn); border-color: var(--warn); }

.view {
  max-width: 600px; margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
}
.view.signed-out { padding-bottom: 32px; }

h1 { font-size: 24px; margin: 4px 0 6px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
.subtle { color: var(--ink-dim); }
.small { font-size: 13px; }
.muted { color: var(--ink-faint); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 12px;
}
.stat-row { display: flex; gap: 12px; }
.stat {
  flex: 1; background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat .num { font-size: 34px; font-weight: 800; line-height: 1.05; }
.stat .lbl { color: var(--ink-dim); font-size: 13px; margin-top: 2px; }

/* Source chips — sim / tracker / phone are always labelled, never blended */
.chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  border-radius: 999px; padding: 2px 8px; vertical-align: middle;
  color: #fff;
}
.chip-sim { background: var(--chip-sim); }
.chip-tracker { background: var(--chip-tracker); }
.chip-phone { background: var(--chip-phone); }
.chip-pureplay { background: var(--pureplay); color: #06230f; }
.chip-gspro { background: var(--gspro); color: #0a1a2e; }
.chip-muni { background: var(--muni); color: #fff; }
.chip-shotforge { background: var(--shotforge); color: #2a1503; }
.chip-oncourse { background: var(--oncourse); color: #1d1030; }

/* The hidden attribute must always win — the header and tab bar set
   display:flex, which otherwise overrides the UA's [hidden] rule and
   leaves the chrome visible on the sign-in screen. */
[hidden] { display: none !important; }

/* Pending-delivery badge on phone-round rows */
.badge-pending {
  display: inline-block; font-size: 11px; font-weight: 700;
  color: var(--warn); border: 1px solid var(--warn); border-radius: 999px;
  padding: 1px 8px; vertical-align: middle; white-space: nowrap;
}

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { margin: 0 0 10px; }
.row-card {
  display: block; width: 100%; text-align: left;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  color: var(--ink); text-decoration: none; cursor: pointer;
  font: inherit;
}
.row-card:active { background: var(--bg-raise); }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row-title { font-weight: 700; font-size: 16px; }
.row-meta { color: var(--ink-dim); font-size: 13px; margin-top: 3px; }
.big-num { font-size: 26px; font-weight: 800; white-space: nowrap; }
.big-num .unit { font-size: 13px; font-weight: 600; color: var(--ink-dim); }

/* Bag table — Sim and On-Course side by side, never blended */
.bag-table { width: 100%; border-collapse: collapse; }
.bag-table th, .bag-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.bag-table th:first-child, .bag-table td:first-child { text-align: left; }
.bag-table th { color: var(--ink-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.bag-table td.club { font-weight: 700; }
.bag-table td.gap { color: var(--ink-dim); font-size: 15px; font-weight: 600; }
.bag-table td.carry { font-size: 19px; font-weight: 700; }
.bag-table .missing { color: var(--ink-faint); font-weight: 400; }
.bag-table .oc, .bag-table .oc-head { color: var(--oncourse); }
.bag-table .col-pureplay { color: var(--pureplay); }
.bag-table .col-gspro { color: var(--gspro); }
.bag-table .col-muni { color: var(--muni); }
.bag-table .col-shotforge { color: var(--shotforge); }

/* By-sim variant — six columns (Club + four sims + On-course) must
   fit a ~360px phone with NO sideways scrolling and no column
   clipped by the card edge (Dec 4, P-1b: with the shared cell
   padding the table's min-content width overflowed the card and its
   border cut through the On-course numbers). Fixed layout makes the
   columns share the card width exactly; tighter padding, a smaller
   header and slightly smaller numerals do the rest. The two widest
   headers stack in the markup (Shot/Forge, On/Course). */
.bag-table.by-sim { table-layout: fixed; }
.bag-table.by-sim th, .bag-table.by-sim td { padding: 8px 2px; }
.bag-table.by-sim th { font-size: 9.5px; letter-spacing: 0; }
.bag-table.by-sim th:first-child, .bag-table.by-sim td:first-child { width: 11%; }
.bag-table.by-sim td.club { font-size: 13px; }
.bag-table.by-sim td.carry { font-size: 16px; }

/* Bag Combined ⇄ By sim app toggle */
.seg {
  display: flex; gap: 4px; background: var(--bg-raise);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px;
  margin: 0 0 12px;
}
.seg button {
  flex: 1; border: 0; border-radius: 999px; padding: 9px 10px;
  background: transparent; color: var(--ink-dim);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.seg button.active { background: var(--accent); color: var(--accent-ink); }

/* Capture round entry (History) */
.capture-bar { margin: 4px 0 16px; }

/* Scorecard — squeezed to the phone width (Dec 5, item 14): all
   nine holes + the Out/In total must fit with NO sideways swipe.
   The old cells carried a 30px min-width, so the grid's natural
   width ran past the viewport and the total column hid behind a
   swipe. Now the table is fixed-layout at 100% and the columns
   share the width: the label column takes a fixed slice, the ten
   number columns split the rest. overflow-x stays as a safety net
   for pathological widths, not as the design. */
.scorecard { overflow-x: auto; }
.scorecard table { border-collapse: collapse; width: 100%; table-layout: fixed; }
.scorecard th, .scorecard td {
  border: 1px solid var(--line); padding: 6px 1px; text-align: center;
  font-size: 13px; overflow: hidden;
}
.scorecard th:first-child, .scorecard td:first-child { width: 13%; }
.scorecard th { background: var(--bg-raise); color: var(--ink-dim); font-size: 11px; text-transform: uppercase; }
.scorecard td.tot, .scorecard th.tot { font-weight: 800; background: var(--bg-raise); }
.scorecard .under { color: var(--accent); font-weight: 700; }
.scorecard .over { color: var(--warn); }

/* History score tint (Dec 5): the Analytics treatment — under par
   is the theme's good green, over par its danger red. */
.score-good { color: var(--good); font-weight: 700; }
.score-bad { color: var(--danger); font-weight: 700; }

/* Gapping check (Home bag card, Dec 5; standalone + graphical +
   coloured in the v9 corrections): the yardage scale with a marker
   per club, the stretch between neighbours tinted by the verdict —
   wide red, tight amber, healthy green — and the flagged lines
   under it in the same colours. */
.gap-check { margin-top: 4px; }
.gap-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-dim); }
.gap-line { margin: 6px 0 0; font-size: 14px; }
.gap-line.ok { color: var(--good); font-weight: 600; }
.gap-line.wide { color: var(--danger); font-weight: 600; }
.gap-line.tight { color: var(--warn); font-weight: 600; }
/* v10: names only, on two staggered levels above the line, spread
   with enforced separation (see gappingLabelLayout in views.js);
   the yardage numbers live in the flagged lines, not on the strip. */
.gap-scale { position: relative; height: 62px; margin: 10px 10px 2px; }
.gap-seg { position: absolute; top: 41px; height: 8px; border-radius: 4px; }
.gap-seg.ok { background: var(--good); opacity: 0.4; }
.gap-seg.wide { background: var(--danger); }
.gap-seg.tight { background: var(--warn); }
.gap-dot {
  position: absolute; top: 39px; width: 12px; height: 12px; margin-left: -6px;
  border-radius: 50%; background: var(--bg-card); border: 3px solid var(--ink);
}
.gap-label {
  position: absolute; transform: translateX(-50%);
  font-size: 11px; font-weight: 700; color: var(--ink-dim); white-space: nowrap;
}
.gap-label.lvl-0 { top: 0; }
.gap-label.lvl-1 { top: 17px; }

/* Handicap strip (Home only since the v9 move, items 11/13 —
   it lived on Bag and History in v8): Sim Handicap and GHIN side
   by side, two blocks, never one blended number. With colour
   (item 11): the Sim number wears the theme accent, the GHIN
   number the On-Course violet — the app's two worlds, two hues. */
.hcaps { display: flex; gap: 12px; }
.hcap { flex: 1; min-width: 0; }
.hcap + .hcap { border-left: 1px solid var(--line); padding-left: 12px; }
.hcap-num { font-size: 30px; font-weight: 800; line-height: 1.1; }
.hcap-sim .hcap-num { color: var(--accent); }
.hcap-ghin .hcap-num { color: var(--oncourse); }
.hcap-lbl { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-dim); }
.hcap-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* Update banner (item 9): raised by app.js when the served shell
   is newer than the one running — its button hard-refreshes. */
.update-banner {
  background: var(--warn); color: var(--warn-ink);
  padding: 10px 14px; font-size: 14px; font-weight: 600; text-align: center;
}
.update-banner button {
  background: transparent; color: inherit; font: inherit; font-weight: 800;
  border: 2px solid currentColor; border-radius: 8px; padding: 2px 10px;
  margin-left: 8px; cursor: pointer;
}

/* Practice-session per-club totals */
.club-total { padding: 10px 0; border-bottom: 1px solid var(--line); }
.club-total:last-child { border-bottom: 0; }
.ct-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ct-club { font-weight: 700; font-size: 16px; }
.ct-avg { font-size: 22px; font-weight: 800; }
.ct-avg .unit { font-size: 12px; font-weight: 600; color: var(--ink-dim); }

/* Bars — analytics stat bars + session totals */
.bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.bar-label { flex: 0 0 38%; font-size: 14px; color: var(--ink-dim); }
.bar-track {
  flex: 1; height: 10px; border-radius: 999px;
  background: var(--bg-raise); overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.bar-value { flex: 0 0 auto; font-weight: 800; font-size: 15px; white-space: nowrap; }
.club-total .bar-track { margin: 6px 0 2px; }

/* Analytics — insight cards, trend, strokes-gained bars */
.insight { border-left: 4px solid var(--accent); }
/* Facet cards: the best facet (highest SG) wears a green border, the
   leak (lowest SG) a red one — Dec 4, Ron. --good is a true green in
   every theme; --danger is each theme's red. The inset ring keeps
   the colour readable at a glance without widening the card. */
.facet-card.facet-best { border-color: var(--good); box-shadow: inset 0 0 0 1px var(--good); }
.facet-card.facet-worst { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.insight.warn { border-left-color: var(--warn); }
.insight-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }
.insight-value { font-size: 30px; font-weight: 800; line-height: 1.15; margin: 2px 0; }
.trend { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.trend-val { font-size: 13px; font-weight: 800; }
.trend-bar { width: 70%; max-width: 44px; border-radius: 6px 6px 0 0; background: var(--accent); }
.trend-lbl { font-size: 12px; color: var(--ink-dim); }
.sg-bar {
  position: relative; height: 12px; border-radius: 999px;
  background: var(--bg-raise); margin: 10px 0 4px; overflow: hidden;
}
.sg-bar::after {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; background: var(--ink-faint); transform: translateX(-1px);
}
.sg-fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.hero-sg { font-size: 56px; font-weight: 800; line-height: 1; }
.facet-scale { display: flex; justify-content: space-between; color: var(--ink-faint); font-size: 12px; margin-top: 2px; }
a.facet-card { text-decoration: none; }

/* Forms + buttons */
label.field { display: block; margin: 0 0 14px; font-weight: 600; font-size: 14px; }
input[type="email"], input[type="text"], input[type="tel"] {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg-raise); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 14px; font-size: 17px; font-weight: 400;
}
input.code-input { font-size: 28px; letter-spacing: 0.35em; text-align: center; font-weight: 700; }
.btn {
  display: block; width: 100%; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 17px; font-weight: 700; padding: 14px 16px; cursor: pointer;
  text-align: center; text-decoration: none;
}
.btn:active { filter: brightness(1.1); }
.btn.secondary { background: var(--bg-raise); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.armed { animation: pulse 1s infinite; }
.btn:disabled { opacity: 0.55; cursor: default; }
@keyframes pulse { 50% { filter: brightness(1.25); } }
.link-btn {
  background: none; border: 0; color: var(--accent); font: inherit;
  font-size: 15px; cursor: pointer; padding: 8px 0;
}
.error-box {
  background: var(--danger-bg); border: 1px solid var(--danger);
  color: var(--danger-ink); border-radius: 10px; padding: 11px 13px; margin: 0 0 14px; font-size: 14px;
}
.empty {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 26px 18px; text-align: center; color: var(--ink-dim);
}
.empty .big { font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

/* Sign-in */
.signin-wrap { max-width: 420px; margin: 6vh auto 0; }
.signin-logo { width: 72px; height: 72px; border-radius: 16px; display: block; margin: 0 auto 14px; }
.signin-wrap h1 { text-align: center; }
.signin-wrap .lede { text-align: center; color: var(--ink-dim); margin: 0 0 22px; }
.signpost {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--bg-card); border-radius: 10px;
  padding: 11px 13px; margin: 0 0 14px; font-size: 14px; color: var(--ink-dim);
}

/* Toggle (pause sync) */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--bg-raise); border: 1px solid var(--line); transition: background 0.15s;
  pointer-events: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--ink-dim); transition: all 0.15s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { left: 25px; background: #fff; }

/* Tab bar */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--chrome-bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar a {
  flex: 1; text-align: center; padding: 8px 2px 10px;
  color: var(--ink-faint); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tab-bar a .tab-ico { display: block; font-size: 19px; line-height: 1.2; }
.tab-bar a.active { color: var(--accent); }

/* Theme picker (Account) — one row per theme: a swatch in the
   theme's own colours (ground + accent dot), its name, and a check
   on the one in use. Colours come from the CURRENT theme's
   variables; each swatch carries its theme's colours inline. */
.theme-list { display: flex; flex-direction: column; gap: 8px; }
.theme-opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--bg-raise); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer; text-align: left;
}
.theme-opt.active { border-color: var(--accent); border-width: 2px; padding: 11px 13px; }
.theme-swatch {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.theme-dot {
  position: absolute; right: 3px; bottom: 3px; width: 11px; height: 11px;
  border-radius: 50%;
}
.theme-name { flex: 1; }
.theme-check { color: var(--accent); font-weight: 800; }

.notice { border-left: 3px solid var(--warn); padding: 4px 0 4px 12px; color: var(--ink-dim); font-size: 14px; margin: 12px 0; }
.sync-action { margin: 12px 0 4px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-dim); }
.kv .v { font-weight: 700; text-align: right; }

/* Home (Dec 5): the "Full bag →" jump and the driver-by-sim line,
   whose per-sim numbers wear the sims' brand colours (the bag
   table's .col-* rules are scoped to the table; these are not). */
.see-all { color: var(--accent); font-weight: 700; font-size: 14.5px; text-decoration: none; }
.bysim-line .col-pureplay { color: var(--pureplay); }
.bysim-line .col-gspro { color: var(--gspro); }
.bysim-line .col-muni { color: var(--muni); }
.bysim-line .col-shotforge { color: var(--shotforge); }
