/* TCPA — Theta Chi Pool Association. Tokens and shared components, transcribed 1:1 from the
   Claude Design canvas (docs/UI-DESIGN-REFERENCE.md). Pages use classes only: the site's CSP
   forbids inline style attributes. Page-specific rules live at the bottom, grouped by page. */

@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('/assets/fonts/barlow-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap; src: url('/assets/fonts/barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/barlow-700.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 500; font-display: swap; src: url('/assets/fonts/barlow-condensed-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('/assets/fonts/barlow-condensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 700; font-display: swap; src: url('/assets/fonts/barlow-condensed-700.woff2') format('woff2'); }

:root {
  /* Ground and surfaces */
  --bg-deep: #120304;      /* body behind the app column */
  --bg: #1E0507;           /* page */
  --bg-sheet-behind: #0C0203;
  --glow: #3D0E13;         /* radial header glow */
  --surface: #2A0D10;      /* cards, inputs, segmented track */
  --surface-2: #3A1A1E;    /* hairlines, disabled fills, avatar */
  --live-surface: #2E0C10;
  --tabbar: #160405;
  /* Lines */
  --line: #3A1A1E;
  --border: #46242A;
  --border-card: #4A2226;
  --border-strong: #5A3035;
  --border-alert: #6A2A2F;
  --grabber: #4A2A2E;
  /* Ink */
  --ink: #F4EEE6;
  --muted: #B9A6A0;
  --subtle: #998580;
  --tab-idle: #A8948D;
  --faint: #6E5753;
  --disabled-ink: #8E7A74;
  --disabled-ink-2: #7E6A66;
  --soft-ink: #D8CBC5;
  /* Accents */
  --red: #D02131;
  --gold: #D2A86F;
  --gold-hover: #E8C590;
  --gold-tint: rgba(210, 168, 111, 0.09);
  --gold-tint-2: rgba(210, 168, 111, 0.10);
  --gold-line: rgba(210, 168, 111, 0.30);
  --gold-line-2: rgba(210, 168, 111, 0.40);
  --gold-line-3: rgba(210, 168, 111, 0.50);
  --live-dot: #FF5A4E;
  --error-ink: #FFB4AA;
  --error-line: #E5655C;
  /* Type */
  --font-body: 'Barlow', system-ui, sans-serif;
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  /* Layout */
  --col: 480px;
  --gutter: 16px;
  --tabbar-h: 84px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); }
a:hover { color: var(--gold-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus { outline: none; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- App column ---------- */
#app { min-height: 100vh; }
.screen {
  position: relative;
  max-width: var(--col);
  min-height: 100vh;
  margin: 0 auto;
  background: radial-gradient(560px 300px at 50% -60px, var(--glow), rgba(30, 5, 7, 0)), var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}
.screen.has-tabbar { padding-bottom: calc(var(--tabbar-h) + 88px); }
/* Keyboard focus scrolls a control clear of the fixed tab bar and the floating Record match
   button, never under them (WCAG 2.4.11 Focus Not Obscured). */
html:has(.tab-bar) { scroll-padding-bottom: calc(var(--tabbar-h) + 12px); }
html:has(.fab-dock) { scroll-padding-bottom: calc(var(--tabbar-h) + 100px); }
.screen.plain { background: var(--bg-deep); }

/* ---------- Shared bars ---------- */
.app-bar, .sub-bar {
  height: 52px;
  padding: 8px var(--gutter) 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { min-height: 44px; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-tile { width: 34px; height: 34px; border-radius: 9px; background: var(--red); display: flex; align-items: center; justify-content: center; }
.brand-tile img { width: 25px; height: auto; display: block; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: 0.14em; text-transform: uppercase; }
.app-bar-right { display: flex; align-items: center; gap: 4px; }
.live-pill-link { min-height: 44px; display: flex; align-items: center; text-decoration: none; color: var(--ink); }
.live-pill-link:hover { color: var(--ink); }
button.live-pill-link { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.live-list { display: flex; flex-direction: column; gap: 8px; }
.live-list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }
.live-list-who { min-width: 0; overflow-wrap: anywhere; }
.live-list-who.tight { font-family: var(--font-display); font-size: 17px; } /* fitNames: condensed, so a 20-character username stays whole */
.live-pill { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 11px; border-radius: 15px; background: var(--live-surface); border: 1px solid var(--border-alert); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; }
.live-dot { width: 7px; height: 7px; border-radius: 4px; background: var(--live-dot); box-shadow: 0 0 0 3px rgba(255, 90, 78, 0.22); }
.live-score { font-family: var(--font-display); font-size: 15px; letter-spacing: 0; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.avatar-link { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.avatar { width: 32px; height: 32px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--ink); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }

.back-link { min-height: 44px; display: flex; align-items: center; gap: 4px; margin-left: -4px; font-size: 15px; font-weight: 600; text-decoration: none; color: var(--gold); }
.bar-meta { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--subtle); white-space: nowrap; }

.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: var(--col); margin: 0 auto;
  height: var(--tabbar-h);
  background: var(--tabbar); border-top: 1px solid var(--line);
  /* min-content: a label wider than a fifth of a narrow bar widens its own column, never spills. */
  display: grid; grid-template-columns: repeat(5, minmax(min-content, 1fr));
  padding: 6px 4px 22px;
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 52px; text-decoration: none; color: var(--tab-idle); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); }
.tab-indicator { position: absolute; top: -7px; width: 24px; height: 3px; border-radius: 0 0 3px 3px; background: transparent; }
.tab[aria-current="page"] .tab-indicator { background: var(--red); }
.tab-badge { position: absolute; top: 2px; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #FFFFFF; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--tabbar); }

/* Floating primary action above the tab bar */
.fab-dock { position: fixed; left: 0; right: 0; bottom: var(--tabbar-h); z-index: 19; max-width: var(--col); margin: 0 auto; padding: 20px var(--gutter) 12px; background: linear-gradient(to top, var(--bg) 65%, rgba(30, 5, 7, 0)); pointer-events: none; }
.fab-dock > * { pointer-events: auto; }

/* ---------- Type ---------- */
.page-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 52px; line-height: 0.88; text-transform: uppercase; white-space: nowrap; }
/* Wrapping titles may hold a name with no spaces (a username, a tournament name): break inside it. */
.page-title.md { font-size: 44px; line-height: 0.92; white-space: normal; overflow-wrap: anywhere; }
.page-title.sm { font-size: 48px; line-height: 0.9; white-space: normal; overflow-wrap: anywhere; }
/* fitNames (components.js): a username too wide for its box gets .tight; while it measures, no
   mid-word breaks, so a name that doesn't fit overflows. Breaking anywhere stays the fallback. */
.fit-name.fit-measure { overflow-wrap: normal !important; }
/* A hyphen is a break point: fitNames puts each hyphenated word in a .fit-word, kept whole, so
   "Maximilian-Hargreave" shrinks or gets its own line like "Maximilian_Hargreave". .fit-break:
   the box is too narrow even at the smallest size, so a break at the hyphen beats overflowing. */
.fit-name { hyphens: manual; }
.fit-name .fit-word { white-space: nowrap; }
.fit-name.fit-break .fit-word { white-space: normal; }
/* A username inside a line of text (namebox.js, lows-5): its own fit-name box, never wider than
   the line, so it moves to the next line whole or steps down in the condensed face (never under
   11px) rather than split at a hyphen or mid-word. The words around it wrap as before. */
.name-in { display: inline-block; max-width: 100%; }
.name-in.tight { font-family: var(--font-display); }
.name-in.tighter { font-family: var(--font-display); font-size: max(11px, 0.9em); }
/* A rack score beside those names ("8–5"): kept whole, never split at its dash. */
.score-in { white-space: nowrap; }
.page-title.sm.tight { font-size: 32px; line-height: 0.95; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); overflow-wrap: break-word; }
.eyebrow.dim { color: var(--subtle); }
.eyebrow.gold { color: var(--gold); letter-spacing: 0.12em; }
.label-xs { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--subtle); }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.display { font-family: var(--font-display); }
.lead { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); overflow-wrap: break-word; } /* a long email in a sheet wraps, not clips */
.lead strong { color: var(--ink); }

/* ---------- Layout helpers ---------- */
.pad { padding: 14px var(--gutter) 18px; }
.stack { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-18 { gap: 18px; } .gap-20 { gap: 20px; } .gap-22 { gap: 22px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section { padding: 4px var(--gutter) 0; display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.link-action { min-height: 44px; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; text-decoration: none; background: none; border: 0; padding: 0; color: var(--gold); }
.link-action:hover { color: var(--gold-hover); }

/* ---------- Buttons ---------- */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 56px; border: 0; border-radius: 16px;
  background: var(--red); color: #FFFFFF; text-decoration: none;
  font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: 0.1em; text-transform: uppercase;
}
.btn-primary:hover { color: #FFFFFF; filter: brightness(1.06); }
.btn-primary.raised { font-size: 21px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.btn-primary:disabled, .btn-primary[aria-disabled="true"] { background: var(--surface-2); color: var(--disabled-ink); filter: none; box-shadow: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 20px; border-radius: 12px; border: 0; text-decoration: none; font-weight: 700; font-size: 15px; }
.btn.red { background: var(--red); color: #FFFFFF; }
.btn.red:hover { color: #FFFFFF; filter: brightness(1.06); }
.btn.ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--ink); font-weight: 600; }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn.outline { background: transparent; border: 1.5px solid var(--ink); color: var(--ink); height: 44px; padding: 0 18px; font-size: 14px; }
.btn.sm { height: 44px; padding: 0 16px; font-size: 14px; }
.btn.block { width: 100%; }
.text-btn { min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--gold); font-weight: 600; font-size: 14px; }
.text-btn:disabled { color: var(--subtle); }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--muted); text-decoration: none; background: transparent; border: 0; }
.icon-btn:hover { color: var(--ink); }

/* Segmented control */
.seg { display: flex; padding: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.seg > button, .seg > a { height: 40px; padding: 0 13px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; } /* "All-time" never splits at its hyphen */
.seg.fill > button, .seg.fill > a { flex: 1; font-size: 14px; }
.seg > [aria-pressed="true"], .seg > [aria-selected="true"] { background: var(--ink); color: var(--bg); font-weight: 700; }

/* ---------- Cards and lists ---------- */
.card { padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-card); }
.panel { padding: 18px 20px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); }
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.stat-value { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
/* A W–L record or a rank ("10 / 16") stays on one line (the en dash or the slash would break
   it): fitNames shrinks it instead. */
.stat-value.stat-wl, .stat-value.stat-rank { white-space: nowrap; }
.stat-value.stat-wl.tight, .stat-value.stat-rank.tight { font-size: 26px; }
.stat-value.stat-wl.tighter, .stat-value.stat-rank.tighter { font-size: 20px; }

.banner-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 14px;
  border-radius: 12px; background: var(--gold-tint); border: 1px solid var(--gold-line); color: var(--ink); text-decoration: none; font-size: 14px;
}
.banner-link:hover { color: var(--ink); }
.banner-link strong { font-weight: 700; }
.banner-link .accent { color: var(--gold); font-weight: 600; }
/* A season name or prize with no spaces wraps instead of widening the page. */
.banner-link > span { min-width: 0; overflow-wrap: anywhere; }
/* The link text keeps its line ("Results ›" never breaks mid-word); a long prize still wraps in half the row. */
.banner-link > .accent { flex-shrink: 0; max-width: 50%; }

/* Ladder leader card */
.leader { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-card); text-decoration: none; color: var(--ink); }
.leader:hover { color: var(--ink); border-color: var(--border-strong); }
.leader-rank { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.leader-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.leader-name { font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1; text-transform: uppercase; }
.leader-rating { font-family: var(--font-display); font-weight: 700; font-size: 52px; line-height: 0.85; font-variant-numeric: tabular-nums; }
.leader-delta { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Ladder row */
.ladder-row {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 64px; padding: 8px 2px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink);
}
.ladder-row:hover { color: var(--ink); background: rgba(255, 255, 255, 0.02); }
.ladder-row .rank { font-family: var(--font-display); font-weight: 600; font-size: 24px; color: var(--gold); font-variant-numeric: tabular-nums; }
.ladder-row .name { min-width: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; } /* wraps: two teams of one long-named player must not cut to the same text */
.ladder-row .name.tight { font-family: var(--font-display); font-size: 18px; } /* fitNames: condensed, so a 20-character username stays whole */
.ladder-row .meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ladder-row .delta { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ladder-row .rating { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.ladder-row.unplayed { min-height: 56px; padding: 4px 2px; color: var(--muted); }
.ladder-row.unplayed:hover { color: var(--muted); }
.ladder-row.unplayed .rank { color: var(--faint); font-weight: 400; }
.ladder-row.unplayed .rating { font-size: 24px; min-width: 0; }
.ladder-row.unplayed .tag { font-size: 12px; }
.up { color: var(--ink); }
.down { color: var(--subtle); }

/* Recent matches feed */
.feed-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.feed-line { font-size: 15px; line-height: 1.3; }
.feed-line.tight { font-family: var(--font-display); font-size: 16px; } /* fitNames: condensed, so a 20-character username stays whole */
.feed-line .w { color: var(--ink); font-weight: 600; text-decoration: none; }
.feed-line .l { color: var(--muted); text-decoration: none; }
.feed-line .verb { color: var(--subtle); }
.feed-deltas { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.feed-deltas .ld { color: var(--subtle); font-weight: 500; }
.feed-meta { font-size: 12px; color: var(--subtle); }
/* A badge beside a wrapped meta row (a long void reason) stays a pill, not a tall dashed box. */
.feed-item .badge { align-self: start; }

/* Badges and chips */
.badge { justify-self: end; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; border-radius: 6px; padding: 1px 6px; }
.badge.corrected { color: var(--gold); border: 1px solid var(--gold-line-3); }
.badge.voided { color: var(--subtle); border: 1px dashed #7A6460; padding: 2px 7px; }
.result-chip { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 18px; border: 1.5px solid; }
.result-chip.w { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.result-chip.l { background: transparent; color: var(--muted); border-color: var(--faint); }

/* History rows (team, player) */
.hist-row { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-top: 1px solid var(--line); }
.hist-grid { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 44px; align-items: center; gap: 10px; }
.hist-opp { font-size: 15px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; } /* wraps: two teams of one long-named player must not cut to the same text */
.hist-meta { font-size: 12px; color: var(--subtle); }
/* fitNames: condensed, so a 20-character opponent or recorder name stays whole. */
.hist-opp.tight { font-family: var(--font-display); font-size: 17px; }
.hist-meta.tight { font-family: var(--font-display); font-size: 13px; }
.hist-delta { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1; font-variant-numeric: tabular-nums; }
.hist-ratings { font-size: 12px; color: var(--subtle); font-variant-numeric: tabular-nums; }
.hist-row.voided { gap: 6px; color: var(--subtle); }
.hist-row.voided .hist-note { font-size: 13px; line-height: 1.4; }
.audit { margin-left: 44px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-card); }
.audit > summary { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; cursor: pointer; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); list-style: none; }
.audit > summary::-webkit-details-marker { display: none; }
.audit ol { margin: 0; padding: 0 12px 12px 30px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; line-height: 1.4; color: var(--soft-ink); }
.audit strong { color: var(--ink); }

/* ---------- Forms ---------- */
.field-label { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.input { height: 56px; width: 100%; padding: 0 16px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--ink); font-weight: 600; font-size: 20px; }
.input:focus { border-color: var(--ink); outline: none; }
.input.invalid { border-color: var(--error-line); }
textarea.input { height: auto; min-height: 96px; padding: 12px 16px; font-size: 16px; font-weight: 500; resize: vertical; }
.help { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.help strong { color: var(--ink); }
.form-error { margin: 0; display: flex; gap: 8px; font-size: 14px; color: var(--error-ink); }
.form-error > span { min-width: 0; overflow-wrap: anywhere; }
.form-error > svg { flex-shrink: 0; }
.code-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.code-digit { height: 60px; min-width: 0; width: 100%; text-align: center; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--border-strong); color: var(--ink); font: 700 30px var(--font-display); }
.code-digit:focus { border-color: var(--ink); outline: none; }
.code-digit.invalid { border-color: var(--error-line); }
fieldset.plain { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
fieldset.plain > legend { padding: 0; margin-bottom: 10px; }

/* Choice tiles (radio buttons) */
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile {
  min-height: 52px; padding: 6px 12px; border-radius: 12px; text-align: left;
  background: var(--surface); color: var(--ink); border: 1.5px solid var(--border);
  display: flex; flex-direction: column; justify-content: center; gap: 2px; font-weight: 600; font-size: 15px;
}
.tile[aria-checked="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tile:disabled { background: transparent; color: var(--disabled-ink-2); border-color: var(--line); }
.tile .why { font-size: 12px; font-weight: 500; }
.tile > .fit-name { min-width: 0; overflow-wrap: anywhere; }
/* A username too wide for a half-width tile (fitNames): one tile per line, full width. */
.tile-grid:has(.tile > .fit-name.tight) { grid-template-columns: minmax(0, 1fr); }
.winner-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.winner-tile {
  min-height: 96px; padding: 12px; border-radius: 16px; background: var(--surface); color: var(--ink); border: 2px solid var(--border);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: left; font-family: var(--font-display);
}
.winner-tile[aria-checked="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.winner-tile .tag { font-size: 12px; font-family: var(--font-body); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8; }
.winner-tile .name { font-size: 24px; font-weight: 700; line-height: 1; text-transform: uppercase; }
/* A username too wide for a half-width tile (fitNames): the two tiles stack, full width. */
.winner-grid:has(.name.tight) { grid-template-columns: minmax(0, 1fr); }
.picked { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 4px 0 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border-strong); }
.racks { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; }
.rack-field { display: flex; align-self: stretch; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.rack-field span { min-width: 0; line-height: 1.25; overflow-wrap: anywhere; } /* wraps: two long team names that start alike must stay apart */
/* A username too wide for a half-width field (fitNames): one field per line, full width. */
.racks:has(.rack-field span.tight) { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.racks:has(.rack-field span.tight) > .subtle { display: none; }
.rack-field input { width: 44px; height: 36px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--ink); text-align: center; font: 700 18px var(--font-display); flex: none; }

/* Toggle switch (settings) */
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-strong); transition: background 0.15s; pointer-events: none; }
.switch .thumb { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 12px; background: var(--muted); transition: transform 0.15s, background 0.15s; pointer-events: none; }
.switch input:checked + .track { background: var(--red); border-color: var(--red); }
.switch input:checked + .track + .thumb { transform: translateX(20px); background: #FFFFFF; }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Sheets (bottom dialogs) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(12, 2, 3, 0.72); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: 40px; z-index: 41; max-width: var(--col); margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0; border-top: 1px solid var(--border-card);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; color: var(--ink);
}
.sheet-grabber { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--grabber); margin-top: 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 0 16px; }
.sheet-title { margin: 0; min-width: 0; overflow-wrap: anywhere; font-family: var(--font-display); font-weight: 700; font-size: 30px; text-transform: uppercase; }
/* A long title (an email address) wraps; the Close button keeps its place. */
.sheet-head > .icon-btn { flex-shrink: 0; }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px var(--gutter) 16px; display: flex; flex-direction: column; gap: 20px; }
.sheet-foot { padding: 12px var(--gutter) 28px; border-top: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; gap: 8px; }
.sheet-foot:empty { display: none; } /* nothing to act on (a fix sheet for a match that doesn't exist) */
/* A long name in a sheet button grows the button rather than spilling out of its 48px. */
.sheet-foot .btn { height: auto; min-height: 48px; padding-top: 8px; padding-bottom: 8px; text-align: center; }
.step-title { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.step-title .opt { font-weight: 500; letter-spacing: 0.02em; text-transform: none; color: var(--subtle); }

/* ---------- States ---------- */
.skeleton-card { padding: 16px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.sk { border-radius: 4px; background: var(--surface); }
.sk.block { height: 86px; border-radius: 14px; }
.sk-row { display: flex; gap: 12px; align-items: center; }
.sk.dot { width: 20px; height: 20px; }
.sk.line { flex: 1; height: 14px; }
.sk.num { width: 48px; height: 22px; }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.55; } }
}
.empty { padding: 24px 20px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.empty-title { font-family: var(--font-display); font-weight: 700; font-size: 26px; text-transform: uppercase; }
.empty-text { font-size: 14px; line-height: 1.45; color: var(--muted); }
.nudge { padding: 18px 20px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.nudge > span { font-size: 15px; line-height: 1.4; }
.nudge > a { flex: none; }
.error-card { padding: 18px 20px; border-radius: 18px; background: var(--bg); border: 1px solid var(--border-alert); display: flex; flex-direction: column; gap: 10px; }
.error-card .title { font-size: 16px; font-weight: 700; }
.error-card .text { font-size: 14px; line-height: 1.45; color: var(--muted); }
.readonly { padding: 16px 18px; border-radius: 18px; background: var(--gold-tint-2); border: 1px solid var(--gold-line-2); display: flex; gap: 12px; font-size: 14px; line-height: 1.45; }
.readonly strong { font-size: 15px; }
.readonly code { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.status-card { display: flex; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; line-height: 1.45; }
.status-card strong { font-size: 15px; }
.status-card > span { min-width: 0; overflow-wrap: anywhere; } /* a pasted URL as a void reason wraps */

/* Toast */
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 84px); z-index: 60; display: flex; justify-content: center; pointer-events: none; padding: 0 var(--gutter); }
.toast { max-width: calc(var(--col) - 32px); min-width: 0; overflow-wrap: anywhere; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45); }

/* FP-STALE-CLIENT: "TCPA was updated · Refresh", when the app can't reload itself safely.
   In app.css because every index.html ever served links it. */
.update-bar {
  position: fixed; left: var(--gutter); right: var(--gutter); top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 55;
  max-width: calc(var(--col) - 32px); margin: 0 auto;
  display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--gold-line-2); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  color: var(--ink); font-size: 14px; font-weight: 600;
}
.update-bar-text { flex: 1; min-width: 0; }
.update-bar-btn { min-height: 40px; padding: 0 14px; border: 0; border-radius: 9px; background: var(--red); color: #FFFFFF; font: inherit; font-weight: 700; }
.update-bar-x { min-width: 40px; min-height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; }
/* While the bar shows, the page and any sheet start below it (bar: 8px + 50px tall + 8px gap). */
body.has-update-bar { --update-bar-space: calc(env(safe-area-inset-top, 0px) + 66px); padding-top: var(--update-bar-space); }
body.has-update-bar .sheet { top: calc(var(--update-bar-space) + 8px); }

/* ---------- Auth screens ---------- */
.auth { min-height: 100vh; padding: 72px 24px 32px; display: flex; flex-direction: column; gap: 36px; }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-tile { width: 56px; height: 56px; border-radius: 15px; background: var(--red); display: flex; align-items: center; justify-content: center; }
.auth-tile img { width: 40px; height: auto; display: block; }
.auth-name { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1; letter-spacing: 0.14em; text-transform: uppercase; }
.auth-sub { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); }
.auth-email { overflow-wrap: anywhere; } /* a long address wraps instead of widening the page */
.signed-as { margin: 0; font-size: 13px; color: var(--muted); }
.signed-as strong { color: var(--ink); font-weight: 600; }
.auth-foot { margin: auto 0 0; font-size: 13px; line-height: 1.45; color: var(--subtle); }
.captcha:empty { display: none; }
.preview-row { margin-top: 6px; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; border: 1px dashed var(--border-strong); }
.preview-row .rank { font-family: var(--font-display); font-weight: 600; font-size: 22px; color: var(--gold); }
.preview-row .name { min-width: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; } /* wraps like the ladder rows it previews */
.preview-row .rating { font-family: var(--font-display); font-weight: 600; font-size: 24px; }

/* Wider screens: keep the phone column, centred */
@media (min-width: 520px) {
  .screen { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ===== Page-specific rules (added by each page; keep grouped and prefixed) ===== */

/* Very narrow phones: keep the five tab labels from running together, still at 11px (lows-4). */
@media (max-width: 340px) {
  .tab-bar { padding-left: 2px; padding-right: 2px; }
  .tab { letter-spacing: 0; }
}

/* FP-STALE-CLIENT: marker for refreshInPlace (sheetrefresh.js) in the views that draw what it
   styles: the 11px tab bar, no-wrap toggles, .fit-word and (lows-5) .name-in rules above. */
:root { --app-lows5: 1; }
