/* ============================================================================
   LocalPod single stylesheet (app.css)

   Loaded by every HTML page. Replaces the former three-file split
   (shared.css, auth.css, style.css). See CLAUDE.md for the design system.

   ── @layer order ──
     components : tokens (:root) + element resets ([hidden], html, body,
                  the universal reset) + all universal primitives +
                  auth-family components
     page       : main-app components (index.html — body.page-main scoped)
     utilities  : bounded .u-* one-off nudges

   The page layer wins over components. Utilities wins over both. Source
   order within each layer determines precedence for same-layer rules.

   ── Page-class scoping ──
   The body styling is universal; per-page intent opts in via a body class:
     body.page-main    — index.html              → font-size: 15px
     body.page-narrow  — auth-box pages          → flex-centered
     body.page-admin   — admin.html              → scopes admin rules
     (no class)        — pod-manage / profile /  → default block layout
                         styleguide

   ── TOC ──
   Components block (universal primitives + auth-family)
     • :root tokens (colors, radius, spacing, type, motion)
     • [hidden] reset
     • Tags (.tag, .tag--*)
     • Small buttons (.btn-sm, .btn-sm--{accent,ghost,danger})
     • Extra-small buttons (.btn-xs, .btn-xs--{accent,danger})
     • Icon buttons (.icon-btn, .icon-btn--{edit,delete,restore,resend})
     • Spinner (.spinner, .spinner--{sm,muted}, @keyframes spin)
     • Stat tiles (.pc-stats, .pc-stat, .pc-stat-label)
     • Mana pips (.color-pips, .mana-pip)
     • Section heads (.section-head, .section-title, .section-subtitle)
     • Stat cards (.stat-cards, .stat-card, .stat-card-{val,label,sub})
     • List-card rows (.list-card, .cmd-entry, .cmd-art, .game-num,
       .cmd-name, .cmd-rate*, .cmd-wins-hero, .cmd-count-sub,
       .cmd-last-played)
     • Card hover tooltip (#card-tooltip, #card-tooltip-img)
     • Generic tooltip (#tooltip)
     • Toasts (.toast-stack, .toast, .toast--*, .toast-progress*,
       @keyframes toast-tick/in/out)
     • Native form controls (input[type=date|number], select)
     • Date range (.range-inputs)
     • Picker options (.picker-opt)
     • Popup year row (.popup-year-row, .popup-custom)
     • Popup chrome (.popup-overlay, .popup-box, .popup-header,
       .popup-close-btn)
     • Filter triggers (.btn-range-open, .custom-multiselect,
       .custom-multiselect-{btn,panel}, .ms-{label,chevron})
     • Apply button (.btn-apply)

   Auth-family components block
     • Body + reset + box-sizing
     • Auth box (.auth-box, .auth-box--{sm,md})
     • Branding (.auth-logo, .auth-tagline, .auth-hero, .auth-heading)
     • Form fields (.form-row, .form-group, .form-input, .form-checkbox)
     • Custom select (.custom-select, .custom-select-{btn,panel,opt})
     • Data table (.data-table-wrap, .data-table, .cell-name, .cell-sub,
       .td-actions, .table-section-row)
     • Password (.pw-wrap, .pw-toggle, .strength-{wrap,bar,fill,text})
     • Field/form messages (.field-error, .form-msg, .form-msg--*)
     • Primary button (.auth-btn)
     • Links & footer (.auth-link, .auth-footer, .remember-me-row)
     • Loading (.auth-loading)
     • Pod list / cards (.pod-list, .pod-card, .pod-card-{body,name,meta,role})
     • Invites (.invite-card, .invite-actions, .btn-accept, .btn-reject,
       .inv-count)
     • Section labels (.section-label, .section-heading, .form-section)
     • Create pod (.btn-create-pod, .create-pod-{form,row})
     • Profile card (.profile-card, .profile-field*)
     • Utility classes (.logout-form, .auth-{centered,hint,btn--link},
       .card-leaving, .row-fading)
     • Page heading + header (.page-heading, .page-header)
     • Tab bar (.tab-bar, .tab-btn, .tab-panel)
     • Full-width page (.page-wrap, .page-card)
     • Modal (.modal-overlay, .modal-box, .modal-{title,body,actions})
     • Mobile (max-width: 600px) media query

   Main-app components block (index.html — wrapped in @layer page)
     • :root tokens (--header-img, --rank1-gradient, --sp-section, etc.)
     • Body + form-element font reset
     • Header (.header-main, .header-actions, .header-action-btn)
     • Section nav (#section-nav-wrap, .snav-*)
     • Sticky filters (.snav-filters, .snav-chips, .snav-filter-sheet-btn,
       .gf-cmd-search, .picker-input, .ms-mode-{toggle,btn})
     • Main layout (main, .controls, .ng-label,
       .sort-{wrap,btn,panel,opt})
     • Filters (.custom-color-panel, .check-pill, .color-option,
       input[type=checkbox])
     • Player cards (#player-cards, .player-card, .pc-{identity,winrate,
       form,color-pips}, .form-pip*, .streak-label)
     • H2H (.h2h-layout, .h2h-nav, .h2h-opp-*, .h2h-detail-*)
     • Cmd entry overrides (.cmd-entry, .cmd-name, .cmd-details)
     • Game rows (.game-row, .commanders-cell, .result-pills)
     • Empty states (.empty-state, .lb-error, .empty-clear-btn)
     • Colour statistics (.color-stats-grid, .color-stat-*, .cs-donut*)
     • Form timeline (#timeline-rows, .tl-*)
     • Game log + session headers (.session-header, .session-date,
       .session-rule, .game-num, .commanders-cell, .player-result)
     • Modals (#new-game-modal, #pp-*-modal)
     • Section loader, FAB (#new-game-fab, .fab-label, #data-panel,
       .data-panel-btn, .nav-invite-badge)
     • Speed-dial (.speed-dial-*)
     • Players side panel (#players-panel, .players-panel-box, .pp-*)
     • Card art skeleton + section skeleton (@keyframes skeleton-shimmer)
     • New-game modal cards (.ng-pcard, .ng-add-card, .ng-trophy-btn,
       .ng-cmd-*, .ng-partner-btn, .ng-unknown-*)
     • Rich tooltips (#att-tooltip, #streak-tooltip, #skill-tooltip,
       #bayesian-tooltip, .skill-tip-*)
     • Mobile media queries (max-width: 900px, max-width: 600px)
   ============================================================================ */

@layer components, page, utilities;


/* ╔═══════════════════════════════════════════════════════════════════════╗
   ║ RETIRED CLASSES — never use these                                     ║
   ║                                                                       ║
   ║ Enforced by scripts/pre-commit. The replacements below all live in    ║
   ║ this file; grep for the retired name to find the section that hosts   ║
   ║ its replacement.                                                      ║
   ║                                                                       ║
   ║   btn-icon              → icon-btn icon-btn--{modifier}               ║
   ║   profile-edit-btn      → icon-btn icon-btn--edit                     ║
   ║   pod-icon-btn          → icon-btn icon-btn--{modifier}               ║
   ║   admin-tabs            → tab-bar                                     ║
   ║   admin-tab             → tab-btn                                     ║
   ║   admin-loading         → auth-loading                                ║
   ║   admin-table-wrap      → data-table-wrap                             ║
   ║   admin-table           → data-table                                  ║
   ║   pod-leave-btn         → btn-xs btn-xs--danger                       ║
   ║   game-edit-btn         → icon-btn icon-btn--edit                     ║
   ║   game-delete-btn       → icon-btn icon-btn--delete                   ║
   ║   game-restore-btn      → btn-xs btn-xs--accent                       ║
   ║   game-perm-delete-btn  → btn-xs btn-xs--danger                       ║
   ║   dd-select-wrap        → custom-multiselect-btn  (main app)          ║
   ║   select-wrap           → custom-select           (auth pages)        ║
   ║   auth-box--wide        → auth-box / auth-box--sm / auth-box--md      ║
   ║                            or page-card for full-width pages          ║
   ║   panel-separator       → border-top: 1px solid var(--divider)        ║
   ╚═══════════════════════════════════════════════════════════════════════╝ */


/* ╔═══════════════════════════════════════════════════════════════════════╗
   ║ COMPONENTS — tokens (:root) + universal primitives                    ║
   ╚═══════════════════════════════════════════════════════════════════════╝ */
@layer components {
/* Ensure [hidden] always wins, even on flex/grid containers */
[hidden] { display: none !important; }

:root {
  /* ── Color tokens ── */
  --bg:           #1a2224;
  --surface:      #263032;
  --surface-hover:#2e3c3e;
  --border:       #3a5558;
  --divider:      rgba(58,85,88,0.3);  /* --border at 30% opacity */
  --accent:       #d4732e;
  --accent-h:     #f48d4f;
  --gold:         #f0c040;
  --win:          #5dc99e;
  --loss:         #c94040;
  --loss-h:       #e05555;
  --loss-text:    #ec7a7a;
  --text:         #d8e8e8;
  --muted:        #80a8a8;
  --on-accent:    #fff;
  --scrim:        rgba(10,16,18,0.75);
  --accent-soft:  rgba(212,115,46,0.16);
  --loss-soft:    rgba(201,64,64,0.12);
  --win-soft:     rgba(93,201,158,0.12);
  --warn-soft:    rgba(240,192,64,0.15);
  --muted-soft:   rgba(128,168,168,0.20);
  --gold-glow:    rgba(240,192,64,0.5);
  --loss-border:  rgba(201,64,64,0.4);
  --win-border:   rgba(93,201,158,0.3);
  --focus-ring:   0 0 0 2px rgba(212,115,46,0.5);

  /* ── Radius scale ── */
  --radius-xs: 3px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius:    10px;
  --edge-gap:  1.5rem;

  /* ── Spacing scale (padding, margin, gap only — NOT font-size, width, height) ── */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-7: 2rem;
  --sp-8: 3rem;

  /* ── Letter-spacing tokens ── */
  --ls-caps:    0.06em;
  --ls-display: 0.1em;

  /* ── Type scale ── */
  --sz-h1:    1.6rem;
  --sz-h2:    1.25rem;
  --sz-h3:    1.1rem;
  --sz-body:  1rem;
  --sz-sm:    0.85rem;
  --sz-label: 0.75rem;
  --sz-micro: 0.68rem;

  /* ── Motion tokens ── */
  --motion-fast: 150ms;
  --motion-base: 220ms;
  --ease-out:    cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ── Tags ─────────────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--sz-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  line-height: 1;
  vertical-align: middle;
}
.tag--accent { color: var(--accent);    background: var(--accent-soft); }
.tag--win    { color: var(--win);       background: var(--win-soft); }
.tag--loss   { color: var(--loss-text); background: var(--loss-soft); }
.tag--warn,
.tag--gold   { color: var(--gold);      background: var(--warn-soft); }
.tag--muted  { color: var(--muted);     background: var(--muted-soft); }

/* ── Small inline buttons (.btn-sm) ───────────────────────────────────────── */
.btn-sm {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: var(--sz-sm);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-sm:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-sm--accent { background: var(--accent); color: var(--on-accent); }
.btn-sm--accent:hover:not(:disabled) { background: var(--accent-h); }
.btn-sm--accent:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm--ghost  { background: none; border: 1px solid var(--border); color: var(--muted); }
.btn-sm--ghost:hover:not(:disabled)  { border-color: var(--text); color: var(--text); }
.btn-sm--danger { background: none; border: 1px solid var(--loss-border); color: var(--loss); }
.btn-sm--danger:hover:not(:disabled) { background: var(--loss-soft); border-color: var(--loss); }

/* ── Extra-small action buttons (.btn-xs) ─────────────────────────────────── */
/* Use inside .action-row inside a .td-actions cell (admin), or as standalone
   row actions elsewhere. Mixed-case label — not uppercase. */
.btn-xs {
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--sz-label);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn-xs:hover:not(:disabled)                { border-color: var(--text);        color: var(--text); }
.btn-xs.btn-xs--danger                      { border-color: var(--loss-border); color: var(--loss); }
.btn-xs.btn-xs--danger:hover:not(:disabled) { background: var(--loss-soft); border-color: var(--loss); color: var(--loss); }
.btn-xs.btn-xs--accent:hover:not(:disabled) { border-color: var(--accent-h); color: var(--accent-h); }
.btn-xs:disabled { opacity: 0.45; cursor: not-allowed; }
.action-row { display: flex; gap: var(--sp-1); align-items: center; justify-content: flex-end; }

/* ── Icon buttons (.icon-btn) ─────────────────────────────────────────────── */
/* Always pair with a semantic modifier. Hover backgrounds carry the colour. */
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  width: 1.8rem;
  height: 1.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.icon-btn--delete:hover:not(:disabled)  { background: rgba(201,64,64,0.18); color: var(--loss);    }
.icon-btn--restore:hover:not(:disabled) { background: var(--accent-soft);   color: var(--accent-h); }
.icon-btn--edit:hover:not(:disabled)    { background: var(--accent-soft);   color: var(--accent-h); }
.icon-btn--resend:hover:not(:disabled)  { background: var(--win-soft);      color: var(--win);     }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}
.spinner--sm    { width: 10px; height: 10px; margin: 0; }
.spinner--muted { border-color: rgba(106,142,142,0.4); border-top-color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Stat tiles (.pc-stats > .pc-stat) ───────────────────────────────────────
   Row of compact metric tiles — big value on top, small-caps label underneath.
   Promoted from style.css so profile/auth-family pages can reuse the same
   idiom the main app uses for player-card stats. Callers can override the
   container (border-top, padding) when used outside a card. */
.pc-stats {
  display: flex;
  justify-content: center;
  gap: var(--sp-7);
  width: 100%;
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--divider);
}
.pc-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
}
.pc-stat .stat-val { font-size: var(--sz-h2); font-weight: 800; color: var(--text); }
.pc-stat-label {
  font-size: var(--sz-micro);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
}

/* ── Mana pips (WUBRG colour-identity swatches) ──────────────────────────────
   The `img` carries the actual coloured SVG (Scryfall card-symbols). Promoted
   from style.css so profile/auth pages can render colour identities exactly
   the way the main app does. Context-specific size overrides (e.g.
   `.pc-color-pips .mana-pip`, `.color-stat-box .mana-pip`) stay in style.css. */
.color-pips {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: 5px;
  vertical-align: middle;
}
.mana-pip {
  width: 13px;
  height: 13px;
  display: inline-block;
}

/* ── Section header (.section-head > .section-head-main > .section-title + .section-subtitle)
   Promoted from style.css so auth-family pages get the same major heading idiom
   the main app uses for "Top Players", "Top Commanders", etc. — display caps with
   a 3px accent bar on the left and an optional muted subtitle underneath. */
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-6);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.section-head-main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}
.section-title {
  font-size: var(--sz-h2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-display);
  color: var(--text);
}
.section-head .section-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.section-head .section-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.section-subtitle {
  font-size: var(--sz-sm);
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
}
.section-head h2 {
  white-space: nowrap;
  padding-top: var(--sp-1);
}

/* Top-level stats sections stack vertically with a thin divider between
   them. Mirrors the `main > section + section` rule the main app uses for
   "Top Players → Form → H2H → Commanders → Colours → Games" — first
   section sits flush, every subsequent one gets a 1px --divider line above
   it and matching vertical breathing room. */
.stats-section + .stats-section {
  margin-top: var(--sp-7);
  border-top: 1px solid var(--divider);
  padding-top: var(--sp-7);
}

/* ── Stat cards (.stat-cards > .stat-card)
   Boxed metric tiles for dashboard overviews. Each card is a --surface box
   with consistent padding and a fixed minimum height so a row of cards stays
   aligned regardless of value length. Value on top (display-weight), small-caps
   label underneath. Distinct from .pc-stats (which is a borderless row of
   tile *contents* inside a parent card) — .stat-card stands on its own surface. */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-4) var(--sp-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 6.5rem;
  text-align: center;
}
/* Inside .page-card, the surrounding card is --surface; drop the inner
   stat tile to --bg so it reads as a darker inset block without needing
   a border. */
.page-card .stat-card { background: var(--bg); }
.stat-card-val {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-card-val--sm { font-size: var(--sz-h3); }
.stat-card-label {
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  line-height: 1.2;
}
.stat-card-sub {
  font-size: var(--sz-micro);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
}

/* ── List-card row pattern (ol > li.list-card.cmd-entry)
   Promoted from style.css. The main app uses this for the Top Commanders and
   H2H opponent lists; profile-page sections reuse it so their leaderboards look
   identical instead of dropping into a tabular grid. .cmd-art stays in style.css
   because only the main app has Scryfall card art to render. */
ol.list-stack {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: 0;
  margin: 0 0 var(--sp-6) 0;
}
.list-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  transition: background 0.15s, border-color 0.15s;
}
/* Inside .page-card, the surrounding card is --surface so a --surface
   row would vanish. Drop to --bg — darker inset block, no border. The
   click-to-expand hover lift from style.css (main app) is suppressed
   here because profile rows aren't expandable. */
.page-card .list-card { background: var(--bg); }
.page-card .list-card:hover { background: var(--bg); }

.cmd-entry {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "num name stat"
    "num meta sub";
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--sz-body);
}
.cmd-entry.cmd-entry--with-art {
  grid-template-columns: auto auto 1fr auto;
  grid-template-areas:
    "num art name stat"
    "num art meta sub";
}
.cmd-entry > .game-num        { grid-area: num; }
.cmd-entry > .cmd-art         { grid-area: art; }

/* Scryfall card art crop on a list-card row. Both pages use the same size /
   border / placement; the actual artwork is set via inline `background-image`
   from the cached image URL (main: scryfallCache; profile: API response). */
.cmd-art {
  width: 4.5rem;
  min-height: 3rem;
  align-self: stretch;
  border-radius: var(--radius-sm);
  background-color: var(--bg);
  background-size: cover;
  background-position: center 30%;
  border: 1px solid var(--border);
}
.cmd-art--empty { background: var(--bg); }
.cmd-entry > .cmd-name        { grid-area: name; }
.cmd-entry > .cmd-win-group   { grid-area: stat; justify-self: end; }
.cmd-entry > .cmd-last-played { grid-area: meta; }
.cmd-entry > .cmd-count-sub   { grid-area: sub; justify-self: end; }

.game-num {
  width: 2.5rem;
  flex-shrink: 0;
  font-size: var(--sz-label);
  font-weight: 600;
  color: var(--muted);
  text-align: left;
}
.game-num--milestone { color: var(--gold); }

.cmd-entry .cmd-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text);
  font-weight: 600;
  min-width: 0;
}
.cmd-entry .cmd-name.cmd-top { color: var(--gold); font-weight: 700; }

.cmd-win-group {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
}
.cmd-rate {
  color: var(--muted);
  font-size: var(--sz-sm);
  font-weight: 400;
}
.cmd-entry .cmd-rate {
  font-size: var(--sz-h3);
  font-weight: 700;
}
.cmd-rate--hot  { color: var(--gold); }
.cmd-rate--good { color: var(--win); }
.cmd-rate--avg  { color: var(--text); }
.cmd-rate--cold { color: var(--loss-text); }

.cmd-wins-hero {
  font-size: var(--sz-h3);
  font-weight: 700;
  color: var(--text);
}

.cmd-count-sub {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--muted);
  font-size: var(--sz-sm);
  font-weight: 400;
  white-space: nowrap;
}

.cmd-last-played {
  font-size: var(--sz-sm);
  color: var(--muted);
}

/* ── Scryfall card hover tooltip (large card preview) ────────────────────────
   Element pair: <div id="card-tooltip" hidden><img id="card-tooltip-img"></div>
   Both pages position it via a mousemove listener following the cursor. */
#card-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  width: 200px;
}
#card-tooltip-img { display: block; width: 100%; height: auto; }

/* ── Generic tooltip ──────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--sz-sm);
  color: var(--text);
  white-space: pre-line;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  max-width: 280px;
}

/* ── Toast notifications ──────────────────────────────────────────────────────
   Universal action feedback. Anchored bottom-center, click-to-dismiss, auto-
   dismiss when the circular progress ring completes. See toast.js. */
.toast-stack {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  z-index: 2000;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  font-size: var(--sz-sm);
  color: var(--text);
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  cursor: pointer;
  pointer-events: auto;
  max-width: min(420px, calc(100vw - var(--sp-7)));
  animation: toast-in 180ms ease-out;
}
.toast--leaving      { animation: toast-out 220ms ease-in forwards; }
.toast--success      { border-left-color: var(--win);  }
.toast--error        { border-left-color: var(--loss); }
.toast--info         { border-left-color: var(--muted); }
.toast-msg           { flex: 1; line-height: 1.4; }
.toast-progress      { width: 16px; height: 16px; flex-shrink: 0; transform: rotate(-90deg); }
.toast-progress-track { fill: none; stroke: var(--border); stroke-width: 2.5; }
.toast-progress-bar {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 62.83;
  animation: toast-tick var(--toast-duration, 3000ms) linear forwards;
}
.toast--success .toast-progress-bar { stroke: var(--win);  }
.toast--error   .toast-progress-bar { stroke: var(--loss); }
.toast--info    .toast-progress-bar { stroke: var(--muted); }
@keyframes toast-tick { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 62.83; } }
@keyframes toast-in   { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out  { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(8px); } }

/* ── Native form controls (cross-page) ─────────────────────────────────────
   Lifted from style.css so auth-family pages get matching date / number /
   select chrome without redefining them. */
input[type=date],
input[type=number],
select {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text);
  font-size: var(--sz-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select option { background: var(--surface); color: var(--text); }
input[type=date]:hover,
input[type=number]:hover,
select:hover { border-color: var(--border); }
input[type=date]:focus,
input[type=number]:focus,
select:focus { outline: none; box-shadow: var(--focus-ring); }
input[type=date]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(0.3);
  cursor: pointer;
}
input[type=number] {
  width: 70px;
  text-align: center;
  -moz-appearance: textfield;
}
input[type=number]::-webkit-inner-spin-button { display: none; }

/* ── Date range inputs (from – to row) ─────────────────────────────────── */
.range-inputs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.range-inputs input[type=date] { flex: 1 1 0; min-width: 0; }
.range-inputs span { color: var(--muted); font-size: var(--sz-sm); flex: 0 0 auto; }

/* ── Picker options (selectable row inside a picker dropdown) ──────────── */
.picker-opt {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  font-size: var(--sz-sm);
  color: var(--text);
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.picker-opt:hover, .picker-opt:focus-visible {
  border-color: var(--border);
  background: var(--surface-hover);
  outline: none;
}
.picker-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Date-range popup inner layout ─────────────────────────────────────── */
.popup-year-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.popup-year-row > label,
.popup-custom label {
  font-size: var(--sz-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
}
.popup-custom label { display: block; margin-bottom: var(--sp-2); }

/* ── Popup chrome (overlay + box + header + close) ─────────────────────── */
.popup-overlay { position: absolute; inset: 0; background: var(--scrim); cursor: pointer; }
.popup-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-6);
  width: min(380px, calc(100vw - 2 * var(--edge-gap)));
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  z-index: 1;
}
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-4);
}
.popup-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 0;
  margin: calc(var(--sp-2) * -1);
  transition: background 0.15s, color 0.15s;
}
.popup-close-btn:hover { color: var(--text); background: var(--surface-hover); }
.popup-close-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Filter-trigger buttons (range trigger + multiselect trigger) ──────── */
.btn-range-open,
.custom-multiselect-btn {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--text);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--sz-sm);
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.btn-range-open:hover,
.custom-multiselect-btn:hover { border-color: var(--border); }
.btn-range-open:focus-visible,
.custom-multiselect-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.custom-multiselect { position: relative; }
.custom-multiselect-btn { width: 220px; }
.ms-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 1.4em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  text-align: left;
}
.ms-chevron {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: var(--muted);
}

.custom-multiselect-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  z-index: 100;
  flex-direction: column;
  min-width: 220px;
  gap: var(--sp-1);
  max-height: 55vh;
  overflow-y: auto;
}
.custom-multiselect-panel.open { display: flex; }

/* ── Apply button (inside filter popup) ────────────────────────────────── */
.btn-apply {
  display: block;
  width: 100%;
  margin-top: var(--sp-3);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--on-accent);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--sz-sm);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-apply:hover:not(:disabled) { background: var(--accent-h); }
.btn-apply:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn-apply:disabled { opacity: 0.45; cursor: not-allowed; }

/* Filter triggers inside a .page-card sit on --surface; drop them to --bg
   so they read as inset controls (matches the .page-card .stat-card and
   .page-card .list-card pattern). */
.page-card .btn-range-open,
.page-card .custom-multiselect-btn { background: var(--bg); }

/* Year row inside a popup: full-width button + inline (non-overlay) panel
   so the popup-box's overflow-y: auto can scroll without clipping it. */
.popup-year-row .custom-multiselect { width: 100%; }
.popup-year-row .custom-multiselect-btn { width: 100%; background: var(--bg); }
.popup-year-row .custom-multiselect-panel {
  position: static;
  width: 100%;
  margin-top: var(--sp-1);
  box-shadow: none;
}
}

/* ╔═══════════════════════════════════════════════════════════════════════╗
   ║ COMPONENTS — auth-family + base resets (html, *, body)                ║
   ║ Universal body styling; .page-narrow opts in to flex-centered layout. ║
   ╚═══════════════════════════════════════════════════════════════════════╝ */
@layer components {
html { overflow-x: clip; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; font-family: inherit; }

/* ── Body base (every page) ──────────────────────────────────────────────────
   Universal body styling. Optional class modifiers tweak per-page intent:
     .page-main   — index.html (main app):  font-size: 15px
     .page-narrow — auth-box pages (login, signup, etc.):  flex-centered
   Other auth-family pages (admin, pod-manage, profile, styleguide) use the
   bare body — default block layout, no centering, no font-size override.   */
body {
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
  color: var(--text);
  min-height: 100vh;
  background: var(--bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  transition: background-image 0.7s ease;
}

body.page-narrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-7) var(--edge-gap);
}

/* Force Poppins on form elements — browsers override font-family by default */
button, input, select, textarea, option, optgroup {
  font-family: 'Poppins', system-ui, sans-serif;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* ── Box ── */
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.1rem 2.25rem 1.9rem;
  width: min(430px, 100%);
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}
.auth-box--md     { width: min(560px, 100%); }
.auth-box--sm     { width: min(480px, 100%); }

/* ── Branding ── */
.auth-logo {
  font-family: 'Metal Mania', 'Poppins', system-ui, sans-serif;
  font-size: var(--sz-h1);
  color: var(--accent);
  text-align: center;
  letter-spacing: 0.03em;
  margin: 0 0 0.15rem;
  line-height: 1;
}
.auth-tagline {
  font-size: var(--sz-label);
  color: var(--muted);
  text-align: center;
  margin-bottom: 1.6rem;
  letter-spacing: 0.03em;
}

/* ── Hero branding (login / signup) ── */
.auth-hero {
  text-align: center;
  margin-bottom: var(--sp-6);
}
.auth-hero .auth-logo {
  font-size: 3.2rem;
  margin-bottom: 0.35rem;
}
.auth-hero .auth-tagline {
  font-size: var(--sz-body);
  margin-bottom: 0;
}
.auth-heading {
  font-size: var(--sz-h3);
  font-weight: 700;
  color: #fff;
  margin-bottom: 1.1rem;
}

/* ── Form fields ── */
.form-row {
  display: flex;
  gap: 0.65rem;
}
.form-row .form-group { flex: 1; min-width: 0; }

.form-group {
  margin-bottom: 0.9rem;
}
.form-group label {
  display: block;
  font-size: var(--sz-label);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  margin-bottom: 0.3rem;
}
.form-input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: inherit;
  font-size: var(--sz-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { box-shadow: var(--focus-ring); outline: none; }
.form-input::placeholder { color: var(--muted); }
.form-input.invalid { box-shadow: 0 0 0 2px var(--loss-border); }

.form-checkbox {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--sz-sm);
  color: var(--text);
  cursor: pointer;
  accent-color: var(--accent);
}
.form-checkbox-hint { color: var(--muted); }

/* ── Custom single-select dropdown (no native <select>) ─────────────────────── */
/* Mirrors style.css custom-multiselect-btn. Use everywhere a dropdown is needed
   on auth pages — never use a native <select> directly. */
.custom-select { position: relative; }
.custom-select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: inherit;
  font-size: var(--sz-sm);
  cursor: pointer;
  transition: border-color 0.15s;
  text-align: left;
}
.custom-select-btn:hover { border-color: var(--border); }
.custom-select-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.custom-select-btn .ms-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.custom-select-btn.has-value .ms-label { color: var(--text); }
.ms-chevron { flex-shrink: 0; color: var(--muted); line-height: 0; }
.custom-select-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.35rem;
  z-index: 200;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.custom-select-panel.open { display: flex; }
.custom-select-opt {
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: var(--sz-sm);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.custom-select-opt:hover { background: var(--accent-soft); }
.custom-select-opt.selected { color: var(--accent); }

/* ── Data table ─────────────────────────────────────────────────────────── */
/* Canonical table for all auth pages (admin, pod-manage, etc.).
   Use data-table-wrap > data-table. All column headers left-aligned.
   Action cells: add class="td-actions" for right-align + vertical-align middle.
   Section divider rows: <tr class="table-section-row"><td colspan="N">Label</td></tr> */
.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--sz-body);
}
.data-table thead { background: var(--bg); }
.data-table th {
  text-align: left;
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  padding: 0.65rem var(--sp-4);
  white-space: nowrap;
}
.data-table td {
  padding: 0.7rem var(--sp-4);
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tbody tr.row-fading { opacity: 0; transition: opacity 0.3s; }
.data-table .table-section-row td {
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  background: var(--bg);
  padding: var(--sp-2) var(--sp-4);
  text-align: left;
}
.cell-name { font-weight: 600; font-size: var(--sz-body); color: var(--text); }
.cell-sub  { font-size: var(--sz-label); color: var(--muted); margin-top: 0.1rem; }
/* Action column cell — right-aligned, vertically centered */
.td-actions { text-align: right; white-space: nowrap; vertical-align: middle; }


/* Fix browser autofill overriding dark background/text */
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border-color: var(--border);
  transition: background-color 9999s ease-in-out 0s;
}

/* Password show/hide */
.pw-wrap { position: relative; }
.pw-wrap .form-input { padding-right: 2.6rem; }
.pw-toggle {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.1rem;
  line-height: 1;
  transition: color 0.15s;
}
.pw-toggle:hover { color: var(--text); }

/* Password strength bar */
.strength-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 0.35rem;
}
.strength-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition: width 0.25s, background-color 0.25s;
}
.strength-text {
  font-size: var(--sz-label);
  color: var(--muted);
  min-width: 3.5rem;
  text-align: right;
  transition: color 0.2s;
}

/* Field-level error */
.field-error {
  font-size: var(--sz-sm);
  color: var(--loss);
  margin-top: 0.22rem;
  display: none;
}
.field-error.show { display: block; }

/* Form-level messages */
.form-msg {
  font-size: var(--sz-sm);
  border-radius: var(--radius-lg);
  padding: 0.55rem 0.8rem;
  margin-bottom: 0.85rem;
  display: none;
  line-height: 1.45;
}
.form-msg.show { display: block; }
.form-msg--error { color: var(--loss);  background: var(--loss-soft); border: 1px solid var(--loss-border); }
.form-msg--success { color: var(--win); background: var(--win-soft); border: 1px solid var(--win-border); }
.form-msg--info  { color: var(--text); background: var(--muted-soft);   border: 1px solid var(--border); }

/* ── Primary button ── */
.auth-btn {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--on-accent);
  font-family: inherit;
  font-size: var(--sz-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  margin-top: 0.2rem;
}
.auth-btn:hover:not(:disabled) { background: var(--accent-h); }
.auth-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.auth-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Links & footer ── */
/* Remember me row (login page) — checkbox label + forgot password link */
.remember-me-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -0.35rem;
  margin-bottom: var(--sp-4);
}
.remember-me-row label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--sz-sm);
  color: var(--muted);
  cursor: pointer;
  accent-color: var(--accent);
}
.remember-me-row .auth-link { font-size: var(--sz-sm); font-weight: 400; }

.auth-footer {
  text-align: center;
  font-size: var(--sz-sm);
  color: var(--muted);
  margin-top: 1.1rem;
}
.auth-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.auth-link:hover { text-decoration: underline; }

/* ── Info icon box (verify-email, etc.) ── */
.auth-icon-wrap {
  text-align: center;
  margin: 1.2rem 0 0.8rem;
}
.auth-icon-wrap svg {
  color: var(--accent);
}

/* ── Descriptive body text (help text under headings) ── */
.auth-body-text {
  font-size: var(--sz-body);
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0.9rem;
}

/* ── Loading state ── */
.auth-loading[hidden] { display: none; } /* beats display:flex below when [hidden] is set */
.auth-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: var(--sp-8) 0;
  color: var(--muted);
  font-size: var(--sz-body);
}

/* ── Pod card body (groups name + meta, fills flex space) ── */
.pod-card-body { flex: 1; min-width: 0; }

/* ── Back-nav link (Back to pod, etc.) inside .form-section ── */
.form-section .auth-link { font-size: var(--sz-sm); }

/* ── Pod-select cards ── */
.pod-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: var(--sp-2);
}
.pod-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pod-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.pod-card-name {
  font-weight: 600;
  font-size: var(--sz-body);
  flex: 1;
}
.pod-card-meta {
  font-size: var(--sz-label);
  color: var(--muted);
}
.pod-card-role {
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem;
}
/* Invitation count badge */
.inv-count {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--sz-label);
  font-weight: 700;
  line-height: 1;
  padding: 0.2em 0.5em;
  border-radius: 99px;
  vertical-align: middle;
  margin-left: 0.4rem;
  position: relative;
  top: -1px;
}

/* Invitation card */
.invite-card {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem var(--sp-4);
}
.invite-card-header {
  font-weight: 600;
  font-size: var(--sz-body);
  margin-bottom: 0.2rem;
}
.invite-card-sub {
  font-size: var(--sz-label);
  color: var(--muted);
  margin-bottom: 0.7rem;
}
.invite-actions { display: flex; gap: var(--sp-2); }
.btn-accept {
  flex: 1;
  padding: 0.42rem;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--on-accent);
  font-family: inherit;
  font-size: var(--sz-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-accept:hover { background: var(--accent-h); }
.btn-reject {
  flex: 1;
  padding: 0.42rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
  font-family: inherit;
  font-size: var(--sz-sm);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-reject:hover { border-color: var(--loss); color: var(--loss); }

.section-label {
  display: block;
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  margin-bottom: var(--sp-2);
}
.section-heading {
  font-size: var(--sz-h3);
  font-weight: 600;
  color: #fff;
  margin-bottom: var(--sp-3);
  letter-spacing: 0.01em;
}
.form-section { margin-bottom: 1.4rem; }

/* Create pod button */
.btn-create-pod {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  background: none;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-family: inherit;
  font-size: var(--sz-sm);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  white-space: nowrap;
}
.btn-create-pod:hover { border-color: var(--accent-h); color: var(--accent-h); }

/* Create pod inline form */
.create-pod-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem var(--sp-4);
  display: none;
  flex-direction: column;
  gap: 0.6rem;
}
.create-pod-form.show { display: flex; }
.create-pod-row { display: flex; gap: var(--sp-2); justify-content: space-between; }

/* ── Profile page card ───────────────────────────────────────────────────── */
.profile-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.profile-field {
  padding: 0.85rem var(--sp-4);
  border-bottom: 1px solid var(--divider);
}
.profile-field:last-child { border-bottom: none; }
.profile-field-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.profile-field-info { flex: 1; min-width: 0; }
/* Primary field label — row identifier inside a card.
   Use for labels that ARE the main text of a row (e.g. "Email", "Password").
   Distinct from section-label which is for subordinate/supporting labels. */
.profile-field-label {
  font-size: var(--sz-sm);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.profile-field-value {
  font-size: var(--sz-body);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-field-edit { margin-top: 0.9rem; }
.profile-edit-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}


/* ── Utility classes ── */
.logout-form        { margin: var(--sp-6) 0 0; }
.logout-form .btn-sm { width: 100%; }
.auth-centered      { text-align: center; }
.auth-hint          { font-size: var(--sz-sm); color: var(--muted); line-height: 1.45; }
.auth-btn--link     { display: block; text-decoration: none; text-align: center; }
.form-msg--centered { text-align: center; }
.card-leaving       { opacity: 0.4; pointer-events: none; transition: opacity 0.3s; }
.row-fading         { opacity: 0; transition: opacity 0.3s; }

/* ── Page-level identity heading (pod name, user name) ── */
.page-heading {
  font-size: var(--sz-h1);
  font-weight: 700;
  color: #fff;
  margin: 0;
}

/* ── Subpage header: back link left, title centered ── */
.page-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2.25rem;
}
.page-header .auth-link {
  position: absolute;
  left: 0;
}

/* ── Tab navigation ─────────────────────────────────────────────────────── */
/* Usage: .tab-bar contains .tab-btn[data-tab="id"] elements.
   Each .tab-panel[id="id"] is shown/hidden via .active class.
   JS: see tab-switcher pattern in pod-manage.html. */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}
.tab-btn {
  padding: var(--sp-2) var(--sp-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--sz-body);
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover:not(:disabled) { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Leave pod inline confirm row */
.pod-leave-confirm {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.pod-leave-confirm-text {
  font-size: var(--sz-sm);
  color: var(--muted);
  white-space: nowrap;
}
/* ── Pod-manage page ────────────────────────────────────────────────────── */

/* ── Full-width page layout (admin, pod-manage, profile, etc.) ──────────── */
/* Usage: <div class="page-wrap"><div class="page-card">…</div></div>        */
.page-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--edge-gap);
}
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.1rem 2.25rem 1.9rem;
  width: 100%;
  max-width: 1350px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
}

/* ── Modal overlay ───────────────────────────────────────────────────────── */
/* Usage: <div class="modal-overlay"><div class="modal-box">…</div></div>    */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--edge-gap);
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-6) 1.75rem;
  width: min(420px, 100%);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.modal-title   { font-size: var(--sz-body); font-weight: 600; color: var(--text); }
.modal-body    { font-size: var(--sz-sm); color: var(--muted); line-height: 1.5; }
.modal-body strong { color: var(--text); }
.modal-actions { display: flex; justify-content: space-between; gap: var(--sp-2); }
/* Destructive confirm — solid red btn inside a modal (overrides ghost default) */
.modal-box .btn-sm--danger       { background: var(--loss);   border-color: var(--loss);   color: var(--on-accent); }
.modal-box .btn-sm--danger:hover { background: var(--loss-h); border-color: var(--loss-h); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --edge-gap: var(--sp-4); }

  /* Full-width page layout: tighter vertical padding on small screens */
  .page-wrap { padding-top: var(--sp-6); padding-bottom: var(--sp-6); }
  .page-card { padding: var(--sp-6) var(--sp-5) var(--sp-5); }

  /* Auth box: reduce side padding */
  .auth-box { padding: 1.75rem var(--sp-6) var(--sp-6); }

  /* Hero logo (login/signup/pod-select): 3.2rem is aggressive on narrow phones */
  .auth-hero .auth-logo { font-size: 2.6rem; }

  /* First/last name row: stack instead of side-by-side */
  .form-row { flex-direction: column; gap: 0; }

  /* Modal: tighten internal padding since the overlay already pads by --edge-gap */
  .modal-box { padding: var(--sp-5) var(--sp-5); }

  /* Tables: allow horizontal scroll when columns overflow on mobile */
  .data-table-wrap { overflow-x: auto; }

  /* Tab bar: scroll horizontally if tabs exceed viewport width */
  .tab-bar { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .tab-bar::-webkit-scrollbar { display: none; }
}

}

/* ╔═══════════════════════════════════════════════════════════════════════╗
   ║ PAGE — main-app components (index.html)                               ║
   ║ body.page-main scoping; main-app token augmentations.                 ║
   ╚═══════════════════════════════════════════════════════════════════════╝ */
@layer page {
/* Main-app token augmentations (header art, rank-1 gradient, section spacing) */
:root {
  --header-img:       none;
  --card-bg-overlay:  linear-gradient(rgba(20,30,32,0.76) 0%, rgba(20,30,32,0.88) 100%);
  --rank1-bg-overlay: linear-gradient(160deg, rgba(20,30,32,0.76) 0%, rgba(70,38,12,0.86) 100%);
  --rank1-gradient:   linear-gradient(160deg, #1e2e30 0%, #3d1f08 100%);
  --page-bg-overlay:  linear-gradient(var(--scrim) 0%, rgba(10,16,18,0.62) 100%);
  --sp-section:       4rem;  /* 64px — gap between top-level sections in main */
}

body.page-main {
  font-size: 15px;
}

/* ── Header ── */
header {
  background:
    linear-gradient(to right, rgba(20,28,30,0.96) 0%, rgba(20,28,30,0.75) 40%, rgba(20,28,30,0.08) 100%),
    linear-gradient(to top, rgba(20,28,30,0.55) 0%, transparent 50%),
    var(--header-img);
  background-size: cover;
  background-position: center center;
  min-height: 260px;
  padding: var(--sp-7) max(var(--edge-gap), var(--sp-8)) var(--sp-7);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  position: relative;
}
.header-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
header h1 {
  font-size: 3rem;
  font-family: 'Metal Mania', 'Poppins', system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--text);
  text-shadow: 0 2px 20px rgba(0,0,0,0.85);
}

/* Header action cluster (top-right): pod switch + global menu */
.header-actions {
  position: absolute;
  top: var(--sp-4);
  right: var(--edge-gap);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  z-index: 10;
}
.header-action-btn {
  position: relative;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.header-action-btn:hover,
.header-action-btn.is-open { background: var(--surface-hover); }
.header-action-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.header-action-btn .nav-invite-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  margin-left: 0;
}
.header-meta {
  font-size: var(--sz-sm);
  color: var(--muted);
  margin-top: var(--sp-2);
  letter-spacing: var(--ls-caps);
  text-shadow: 0 1px 8px rgba(0,0,0,0.9);
}

/* ── Section Nav ── */
#section-nav-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: var(--sp-2);
  gap: var(--sp-3);
  padding: var(--sp-2) var(--edge-gap);
}
/* Active-filter chip row: full-width below the nav, shown only when any filter is non-default */
.snav-chips {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  /* Match parent #section-nav-wrap's padding-bottom (var(--sp-2)) so the
     visual space above the chips equals the space below them. */
  padding-top: var(--sp-2);
  border-top: 1px solid var(--divider);
}
.snav-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--sz-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  padding: var(--sp-1) var(--sp-2);
  border-radius: 999px;
  white-space: nowrap;
}
.snav-chip--neutral { background: var(--muted-soft); color: var(--text); }
.snav-chip-clear {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: var(--muted-soft);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: var(--sz-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  /* Same padding + no border so total height matches .snav-chip exactly */
  padding: var(--sp-1) var(--sp-2);
  border: 0;
  border-radius: 999px;
  transition: color 0.12s, background 0.12s;
}
.snav-chip-clear svg { width: 0.7rem; height: 0.7rem; flex-shrink: 0; }
.snav-chip-clear:hover { color: var(--text); background: var(--surface-hover); }
#section-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--sp-1);
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#section-nav::-webkit-scrollbar { display: none; }
.snav-link {
  font-size: var(--sz-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  text-decoration: none;
  padding: var(--sp-1) var(--sp-3);
  border-radius: 20px;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.snav-link:hover { color: var(--text); }
.snav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── Sticky-nav filter cluster (right side of #section-nav-wrap) ── */
.snav-filters {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.snav-filters .custom-multiselect-panel { left: auto; right: 0; }
.snav-filters .custom-multiselect-btn { width: auto; min-width: 130px; max-width: 220px; }
.snav-filters #cmd-color-btn { min-width: 110px; }

/* ── Phase 3 / 6 / 7: mobile filter sheet trigger + count badge ── */
/* Typography matches .snav-link so it aligns optically with the anchor row. */
.snav-filter-sheet-btn {
  position: relative;
  display: none; /* hidden on desktop; shown ≤600px via media query */
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: var(--sz-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.snav-filter-sheet-btn:hover { color: var(--text); background: var(--surface-hover); }
.snav-filter-sheet-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.snav-filter-sheet-btn svg { flex-shrink: 0; }
.snav-filter-sheet-btn.has-active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.snav-filters-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 var(--sp-1);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--sz-micro);
  font-weight: 700;
  line-height: 1;
}

/* Per-field labels and bottom-sheet footer — visible only inside the open sheet */
.snav-sheet-label,
.snav-sheet-footer { display: none; }
.gf-btn--active {
  border-color: var(--accent) !important;
}
/* Global commander search input in the sticky filter bar */
.gf-cmd-search {
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--text);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--sz-sm);
  font-family: inherit;
  outline: none;
  width: 150px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.gf-cmd-search:hover { border-color: var(--border); }
.gf-cmd-search:focus { box-shadow: var(--focus-ring); }
.gf-cmd-search::placeholder { color: var(--muted); }
/* ── Shared picker styles (search inputs + option rows) ──────────────────── */
/* Add .picker-input to any search input inside a picker dropdown.           */
.picker-input {
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--sz-sm);
  padding: var(--sp-2) var(--sp-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.picker-input:focus { box-shadow: var(--focus-ring); }
.picker-input::placeholder { color: var(--muted); }


/* Search input positioned sticky inside a scrollable panel */
.gf-player-search { width: 100%; position: sticky; top: 0; z-index: 1; }
/* Segmented Any / Together toggle, pinned to top of the player panel.
   Disabled "Together" stays in the layout but is dimmed; tooltip explains why. */
.ms-mode-toggle {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
  margin-bottom: var(--sp-2);
  gap: 2px;
}
.ms-mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--sz-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
}
.ms-mode-btn:hover:not(.active):not(:disabled) { color: var(--text); }
.ms-mode-btn.active { background: var(--accent); color: var(--on-accent); }
.ms-mode-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ms-mode-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Main layout ── */
main {
  max-width: 1350px;
  margin: 0 auto;
  padding: var(--sp-7) var(--edge-gap);
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}
/* Anchor target offset: clears the sticky #section-nav (~2.7rem tall) */
main > section {
  scroll-margin-top: 3rem;
}
/* Divider + balanced spacing between top-level stats sections */
main > section + section {
  margin-top: var(--sp-7);
  border-top: 1px solid var(--divider);
  padding-top: var(--sp-7);
  /* padding-top pushes heading down — subtract it so heading still lands below nav */
  scroll-margin-top: calc(3rem - var(--sp-7));
}

/* First section sits directly below sticky nav — strip the double-border */
#leaderboard {
  margin-top: 0;
  padding-top: var(--sp-6);
  border-top: none;
}


/* ── Controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: flex-start;
}
.players-add-field label,
.ng-label {
  font-size: var(--sz-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
}
.ng-label { display: block; margin-bottom: var(--sp-2); }



/* ── Sort dropdown (button + menu) ── */
.sort-wrap { position: relative; }
.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  color: var(--text);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--sz-sm);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.sort-btn:hover { border-color: var(--border); }
.sort-btn[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.sort-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sort-btn .sort-dir {
  color: var(--accent);
  font-weight: 600;
  line-height: 1;
  margin-right: var(--sp-1);
}
.sort-btn .sort-chev {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  opacity: 0.7;
  transition: transform 0.15s, opacity 0.15s;
}
.sort-btn[aria-expanded="true"] .sort-chev { transform: rotate(180deg); opacity: 1; }
.sort-opt .sort-dir {
  color: var(--accent);
  font-weight: 600;
  margin-right: var(--sp-1);
}
.sort-opt.active .sort-dir { color: inherit; }

.sort-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  z-index: 100;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 9rem;
}
.sort-panel.open { display: flex; }
.sort-opt {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--sz-sm);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.sort-opt:hover { border-color: var(--accent); }
.sort-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Colour-filter dropdown panel (main-app only) ── */
.custom-color-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  z-index: 100;
  flex-direction: column;
  min-width: 140px;
  max-height: 290px;
  overflow-y: auto;
  gap: var(--sp-1);
}
.custom-color-panel.open { display: flex; }

/* ── Check pills & colour options (shared base) ── */
.check-pill,
.color-option {
  display: flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--sz-sm);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.check-pill { gap: var(--sp-2); }

/* Symbol-only color filter options — pips are the identifier; no name text */
.color-option {
  gap: 0;
  white-space: nowrap;
  justify-content: center;
  min-width: 3rem;
}
.color-option .color-pips { margin: 0; }
.color-option .mana-pip { width: 20px; height: 20px; }
/* "All colors" option falls back to text label */
.color-option--all {
  justify-content: flex-start;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: var(--ls-caps);
  font-size: var(--sz-label);
  text-transform: uppercase;
}
.color-option--all.selected { color: var(--accent); }
/* ── Custom themed checkboxes ── */
input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  transition: border-color 0.15s, background 0.15s;
}
input[type=checkbox]:hover { border-color: var(--accent); }
input[type=checkbox]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type=checkbox]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: 2px solid var(--bg);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.check-pill input[type=checkbox] { cursor: pointer; }
.check-pill:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.check-pill-all {
  margin-bottom: var(--sp-1);
}
.custom-color-filter { position: relative; }
.color-option:hover { border-color: var(--accent); }
.color-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* ── Player Cards ── */
#player-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--sp-4);
  align-items: stretch;
}
.player-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-5);
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.player-card.rank-1 {
  background: var(--rank1-gradient);
  box-shadow: 0 0 0 1.5px var(--gold-glow);
}
.player-card--has-art {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 4px 24px rgba(0,0,0,0.45);
}
.player-card--has-art.rank-1 {
  box-shadow:
    0 0 0 1.5px var(--gold-glow),
    0 4px 24px rgba(0,0,0,0.45);
}

/* Rank badge */
.player-card .rank {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-3);
  font-size: var(--sz-label);
  font-weight: 700;
  color: var(--muted);
}
.player-card.rank-1 .rank { color: var(--gold); font-weight: 800; }

/* Identity section */
.pc-identity {
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.player-card .name {
  font-weight: 700;
  font-size: var(--sz-h3);
}
.player-card .player-epithet {
  font-size: var(--sz-label);
  font-style: italic;
  color: var(--muted);
}
.pc-color-pips { position: absolute; top: var(--sp-3); right: var(--sp-3); display: flex; gap: var(--sp-1); }
.pc-color-pips .mana-pip { width: 14px; height: 14px; }

/* Win rate section — outlined P/T-style stat block (Scryfall card-corner pattern) */
.pc-winrate {
  margin-bottom: var(--sp-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.player-card .win-pct {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--win);
  line-height: 1;
  border: 2px solid currentColor;
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
  display: inline-block;
}
.player-card.rank-1 .win-pct { color: var(--gold); }
.pc-skill--uncertain { opacity: 0.5; }


/* Form section (recent + streak) */
.pc-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--divider);
}
.pc-winrate-label,
.recent-label {
  font-size: var(--sz-micro);
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
}
.pc-winrate-label { font-size: var(--sz-label); font-weight: 600; }
.pc-winrate-record { font-size: var(--sz-micro); text-transform: uppercase; letter-spacing: var(--ls-caps); color: var(--muted); }
.form-pips {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-1);
  margin-top: var(--sp-1);
}
.form-pip {
  font-size: var(--sz-sm);
  line-height: 1;
}
.form-pip--loss { opacity: 0.8; }
.player-card .streak-label {
  font-size: var(--sz-label);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  margin-bottom: var(--sp-1);
}
.player-card .streak-label--drought { color: var(--loss-text); }

/* ── H2H custom player dropdown ── */
.h2h-player-wrap { width: 100%; margin-top: var(--sp-2); }
.h2h-player-wrap .custom-multiselect-btn { width: 100%; }
.h2h-player-panel { width: 100%; }
/* .h2h-player-opt uses .picker-opt for all visual style */

/* ── Head-to-Head ── */
.h2h-layout {
  display: flex;
  gap: var(--sp-7);
  align-items: flex-start;
}
.h2h-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
  position: sticky;
  top: var(--sp-4);
}
.h2h-card-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
}
.h2h-nav .player-card {
  width: 240px;
  cursor: default;
}
.h2h-nav .player-card:hover { transform: none; }
.h2h-opponents {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.h2h-opp-row {
  border-left: 3px solid transparent;
}
.h2h-opp-row.h2h-row--winning { border-left-color: var(--win); }
.h2h-opp-row.h2h-row--losing  { border-left-color: var(--loss); }
/* Same as .cmd-entry .cmd-name */
.h2h-opp-name { color: var(--text); font-weight: 600; min-width: 0; }
/* Win/loss values inside cmd-win-group */
.h2h-stat-win  { color: var(--win);       font-weight: 700; font-size: var(--sz-body); }
.h2h-stat-loss { color: var(--loss-text); font-weight: 700; font-size: var(--sz-body); }
.h2h-stat-sub  { color: var(--muted); font-size: var(--sz-label); }
/* Expanded detail — spans full grid width */
.h2h-opp-detail {
  display: none;
  grid-column: 1 / -1;
  flex-direction: column;
  border-top: 1px solid var(--divider);
  padding-top: var(--sp-3);
  margin-top: var(--sp-3);
  gap: var(--sp-1);
}
.h2h-opp-row.open .h2h-opp-detail { display: flex; }
.h2h-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--sz-sm);
  padding: var(--sp-1) 0;
}
.h2h-detail-label { color: var(--muted); }
.h2h-detail-val   { font-weight: 700; color: var(--text); }
.h2h-detail--mine   .h2h-detail-val { color: var(--win); }
.h2h-detail--theirs .h2h-detail-val { color: var(--loss-text); }

/* .list-card and ol reset live in shared.css.
   Main-app overrides: index.html keeps cursor:pointer + a hover lift to
   --surface-hover (rows are click-to-expand); the art-bearing form of
   .cmd-entry adds a 5th column for the card art and a spanning details row.
   Auth-family pages use the shared art-less 3-column form and have the
   hover lift suppressed via `.page-card .list-card:hover` in shared.css. */
.list-card { cursor: pointer; }
.list-card:hover { background: var(--surface-hover); }
ol { list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); }

/* Main-app commander entry: 5 columns (art is the second column) plus a
   spanning details row. The auth-family form lives in shared.css. */
.cmd-entry {
  grid-template-columns: auto auto 1fr auto;
  grid-template-areas:
    "num art name stat"
    "num art meta sub";
}
.cmd-entry > .cmd-art         { grid-area: art; }
.cmd-entry > .cmd-win-group   { justify-self: start; }
.cmd-entry > .cmd-count-sub   { justify-self: start; }
.cmd-entry > .cmd-details     { grid-column: 1 / -1; }

.h2h-opp-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "num name top"
    "num last bot";
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--sz-body);
  border-left: 3px solid transparent;
}
.h2h-opp-row > .game-num       { grid-area: num; }
.h2h-opp-row > .h2h-opp-name   { grid-area: name; }
.h2h-opp-row > .cmd-win-group  { grid-area: top; justify-self: start; }
.h2h-opp-row > .h2h-opp-games  { grid-area: last; }
.h2h-opp-row > .cmd-count-sub  { grid-area: bot; justify-self: start; }
.h2h-opp-row > .h2h-opp-detail { grid-column: 1 / -1; }

.game-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "num cmds milestones"
    "num pills milestones";
  align-items: center;
  column-gap: var(--sp-3);
  row-gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--sz-body);
}
.game-row > .game-num          { grid-area: num; }
.game-row > .commanders-cell   { grid-area: cmds; }
.game-row > .result-pills      { grid-area: pills; }
.game-row > .game-milestones   { grid-area: milestones; align-self: center; display: flex; flex-direction: column; gap: var(--sp-1); align-items: flex-end; }
.game-row > .game-deck-details { grid-column: 1 / -1; }


/* .cmd-entry .cmd-name (base) lives in shared.css. Main-app variant uses an
   inner .cmd-name-text span so the name itself is the hover target. */
.cmd-entry .cmd-name { cursor: default; }
.cmd-entry .cmd-name-text { cursor: default; }
.cmd-entry .cmd-name-text:hover { color: var(--accent-h); }
.cmd-entry .cmd-name.cmd-top .cmd-name-text { color: var(--gold); font-weight: 700; }
.cmd-entry .cmd-count { color: var(--gold); font-weight: 700; font-size: var(--sz-body); }

/* ── Shared expanded detail panels (span full grid width) ── */
.cmd-details,
.game-deck-details {
  display: none;
  font-size: var(--sz-body);
  border-top: 1px solid var(--divider);
  padding-top: var(--sp-3);
  margin-top: var(--sp-3);
}
.cmd-details {
  grid-template-columns: 1fr auto;
  gap: var(--sp-2) var(--sp-7);
}
.cmd-details.open { display: grid; }

.h2h-opp-games { font-size: var(--sz-sm); color: var(--muted); }

/* Shared panel header row */
.cprow-tracked {
  grid-column: 1 / -1;
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  opacity: 0.6;
  margin-bottom: 0;
}
.cprow-name { color: var(--text); font-size: var(--sz-body); font-weight: 600; min-width: 4.5rem; }
.cprow-pct  { color: var(--muted); font-size: var(--sz-sm); text-align: right; }

.btn-show-more {
  display: block;
  margin: var(--sp-3) auto 0;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  color: var(--muted);
  padding: var(--sp-1) var(--sp-6);
  font-size: var(--sz-sm);
  cursor: pointer;
  width: auto;
  transition: background 0.15s, color 0.15s;
}
.btn-show-more:hover { background: var(--surface-hover); }




.game-delete-confirm {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--sz-sm);
  color: var(--muted);
  flex-shrink: 0;
}
.game-delete-yes,
.game-delete-no {
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--sp-1) var(--sp-2);
  font-size: var(--sz-label);
  cursor: pointer;
  transition: opacity 0.15s;
}
.game-delete-yes { background: var(--loss); color: var(--on-accent); font-weight: 700; }
.game-delete-yes:hover { opacity: 0.85; }
.game-delete-no  { background: var(--bg); color: var(--muted); }
.game-delete-no:hover  { background: var(--surface-hover); }
.game-deck-details {
  flex-direction: column;
  gap: var(--sp-2);
}
.game-deck-details.open { display: flex; }
.deck-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.deck-player { font-weight: 600; color: var(--text); min-width: 4.5rem; flex-shrink: 0; }
.deck-player--win { color: var(--gold); font-weight: 700; }
.deck-unknown { color: var(--muted); font-style: italic; }
.game-delete-area {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  justify-content: flex-end;
}
.deck-row ~ .game-delete-area {
  margin-top: var(--sp-2);
}

/* ── Deleted game rows ── */
.game-row--deleted {
  border-left: 3px solid var(--loss);
  pointer-events: auto;
}
/* ── Data panel active state ── */
.data-panel-btn.active { color: var(--accent); }

/* .color-pips + .mana-pip live in shared.css. Context-specific size overrides
   (.color-option, .pc-color-pips, .color-stat-box) remain in this file. */


/* ── Pod welcome / empty state ── */
#pod-empty-state[hidden] { display: none; }
#pod-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--sp-8) var(--sp-4);
  gap: var(--sp-4);
}
#pod-empty-state .section-title {
  font-size: var(--sz-h1);
  color: var(--gold);
  text-shadow: 0 0 28px var(--gold-glow);
}
#pod-empty-state .pp-section-hint {
  max-width: 30ch;
  font-size: var(--sz-body);
}

/* ── Empty / no-results state (shared across all sections) ── */
.empty-state,
.lb-error {
  color: var(--muted);
  font-size: var(--sz-body);
  padding: var(--sp-3) var(--sp-4);
  text-align: center;
  border-radius: var(--radius-md);
  list-style: none;
  background: var(--surface);
}
.lb-error { margin-bottom: var(--sp-3); }
.empty-state .pp-section-hint { margin-bottom: 0; }
.empty-clear-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--accent);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--sz-sm);
  font-family: inherit;
  cursor: pointer;
  margin-left: var(--sp-2);
  transition: border-color 0.15s, background 0.15s;
}
.empty-clear-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.empty-clear-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ── Colour Statistics ── */
.color-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}
.color-stat-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
}
/* Inside .page-card (profile), the wrapper is --surface; drop the box to --bg
   so it reads as an inset tile — same pattern as .page-card .stat-card / .list-card. */
.page-card .color-stat-box { background: var(--bg); }
.color-stat-box--has-art {
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.06),
    0 4px 24px rgba(0,0,0,0.45);
}
.color-stat-label {
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  margin-bottom: var(--sp-2);
}
.color-stat-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.color-stat-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.color-stat-rank {
  font-size: var(--sz-label);
  font-weight: 700;
  color: var(--muted);
  min-width: 0.9rem;
  text-align: left;
  flex-shrink: 0;
}
.color-stat-body .color-stat-row:first-child .color-stat-rank { color: var(--gold); }
.color-stat-pips { line-height: 1; flex-shrink: 0; }
.color-stat-box .mana-pip { width: 15px; height: 15px; }
.color-stat-row-name {
  flex: 1;
  font-size: var(--sz-body);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* margin-left:auto right-aligns the count whether or not a .color-stat-row-name
   precedes it (main app has a name; profile is pips-only with no name span). */
.color-stat-row-count { font-size: var(--sz-label); color: var(--muted); flex-shrink: 0; margin-left: auto; }
.color-stat-empty { color: var(--muted); font-style: italic; font-size: var(--sz-sm); }

/* Plays / Wins donut pair (above the colour-stats grid) */
.cs-donuts {
  display: flex;
  justify-content: center;
  gap: var(--sp-7);
  padding: var(--sp-2) 0 var(--sp-5);
  flex-wrap: wrap;
}
.cs-donut-fig {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
}
.cs-donut {
  width: 170px;
  height: 170px;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
}
.cs-donut path,
.cs-donut circle {
  cursor: pointer;
  transition: opacity 0.15s;
}
.cs-donut:hover path,
.cs-donut:hover circle { opacity: 0.45; }
.cs-donut path:hover,
.cs-donut circle:hover { opacity: 1; }
.cs-donut-fig figcaption {
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
}
.cs-donut-empty {
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--sz-sm);
  color: var(--muted);
  font-style: italic;
  border: 1px dashed var(--border);
  border-radius: 50%;
  box-sizing: border-box;
}

/* ── Form Timeline ── */
#timeline-rows {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.tl-row {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-4);
  display: grid;
  grid-template-columns: 140px 1fr 90px;
  align-items: center;
  gap: var(--sp-4);
}
.tl-name {
  font-size: var(--sz-body);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-track {
  position: relative;
  height: 54px;
}
.tl-track-line {
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--divider);
}
.tl-dot {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: default;
}
.tl-dot--win {
  background: var(--gold);
  box-shadow: 0 0 5px var(--gold-glow);
}
.tl-dot--loss {
  background: var(--muted);
  opacity: 0.55;
}
.tl-dot:hover {
  z-index: 1;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.4);
}

/* Date axis row above player rows. Same grid as .tl-row so the centre column lines up. */
.tl-axis {
  background: transparent;
  padding: 0 var(--sp-4) var(--sp-1);
}
.tl-axis-track {
  position: relative;
  height: 14px;
}
.tl-axis-tick {
  position: absolute;
  top: 0;
  font-size: var(--sz-micro);
  color: var(--muted);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  transform: translateX(-50%);
  white-space: nowrap;
}
.tl-axis-tick:first-child  { transform: translateX(0); }
.tl-axis-tick:last-child   { transform: translateX(-100%); }
.tl-track-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--sz-sm);
  color: var(--muted);
  font-style: italic;
}
.tl-summary {
  font-size: var(--sz-sm);
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}
.tl-summary-wins {
  color: var(--gold);
  font-weight: 700;
}
.tl-tip-cmd {
  color: var(--muted);
}

@media (max-width: 720px) {
  .tl-row { grid-template-columns: 80px 1fr 60px; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); }
  .tl-name { font-size: var(--sz-sm); }
  .tl-summary { font-size: var(--sz-label); }
}

/* ── Game Log ── */
#games-list {
  min-height: 24rem;
}

/* ── Session header ── */
.session-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0 var(--sp-1);
  margin-top: var(--sp-1);
}
.session-header.session-first { margin-top: 0; padding-top: 0; }
.session-date {
  font-size: var(--sz-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--ls-caps);
  color: var(--muted);
  white-space: nowrap;
}
.session-count {
  font-size: var(--sz-micro);
  color: var(--muted);
  white-space: nowrap;
}
.session-rule {
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.commanders-cell {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.commander-name { color: var(--text); cursor: default; }
.commander-name:hover { color: var(--accent-h); }
.cmd-sep { color: var(--muted); font-size: var(--sz-sm); }
.result-pills { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.player-result {
  font-size: var(--sz-sm);
  white-space: nowrap;
}
.player-result.win {
  font-weight: 700;
  color: var(--gold);
}
.player-result.loss {
  font-weight: 400;
  color: var(--muted);
}

/* ── Popup ── */
#gf-range-popup,
#pf-range-popup,
#new-game-modal,
#pp-invite-modal,
#pp-add-player-modal,
#pp-edit-player-modal,
#player-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Background scroll lock when any modal or the players panel is open */
html:has(#gf-range-popup:not([hidden])),
html:has(#pf-range-popup:not([hidden])),
html:has(#new-game-modal:not([hidden])),
html:has(#pp-invite-modal:not([hidden])),
html:has(#pp-add-player-modal:not([hidden])),
html:has(#pp-edit-player-modal:not([hidden])),
html:has(#player-confirm-modal:not([hidden])),
html:has(#players-panel:not([hidden])) {
  overflow-y: hidden;
}


/* ── Small inline buttons (used in players panel) ── */
/* Padding follows the 1x/2x rule: 1x vertical, 2x horizontal. */

/* ── Section loader ── */
.section-loader {
  text-align: center;
  color: var(--muted);
  font-size: var(--sz-sm);
  padding: var(--sp-3) var(--sp-4);
  animation: loader-pulse 1.4s ease-in-out infinite;
}
@keyframes loader-pulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 1;   }
}

/* ── New-game FAB (speed-dial main button) ── */
#new-game-fab {
  position: fixed;
  right: var(--edge-gap);
  z-index: 100;
  will-change: transform;
  height: 3.4rem;
  border-radius: 1.7rem;
  cursor: pointer;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 0;
  overflow: hidden;
  padding: 0 var(--sp-4);
  transition: background 0.15s;
}

.fab-label {
  font-size: var(--sz-sm);
  font-weight: 600;
  white-space: nowrap;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 0.26s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.12s;
}
#new-game-fab:hover .fab-label {
  max-width: 6rem;
  opacity: 1;
}
#new-game-fab:hover { gap: var(--sp-2); }

#data-panel {
  position: fixed;
  top: calc(var(--sp-4) + 2.6rem + var(--sp-2));
  right: var(--edge-gap);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
a.data-panel-btn { text-decoration: none; }
#data-panel > form { display: flex; flex-direction: column; margin: 0; }
.data-panel-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  cursor: pointer;
  font-size: var(--sz-body);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.data-panel-btn:hover { background: var(--surface-hover); }
.data-panel-divider {
  height: 1px;
  background: var(--divider);
  margin: var(--sp-1) 0;
}
.nav-invite-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--sz-micro);
  font-weight: 700;
  line-height: 1;
  min-width: 1.1rem;
  height: 1.1rem;
  border-radius: 9999px;
  padding: 0 var(--sp-1);
  margin-left: var(--sp-2);
}

#new-game-fab {
  bottom: var(--edge-gap);
  background: var(--accent);
  color: var(--on-accent);
  border: none;
}
#new-game-fab .fab-icon { font-size: 2rem; line-height: 1; transition: transform 0.2s ease; }
#new-game-fab:hover { background: var(--accent-h); }

/* ── Speed-dial (Phase 2) ── */
.speed-dial[data-open="true"] #speed-dial-icon { transform: rotate(45deg); }
.speed-dial-actions {
  position: fixed;
  right: var(--edge-gap);
  bottom: calc(var(--edge-gap) + 3.4rem + 0.8rem);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-2);
}
.speed-dial-mini {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 2.6rem;
  padding: 0 var(--sp-4);
  border-radius: 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: var(--sz-sm);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  animation: speed-dial-in 0.18s ease-out both;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.speed-dial-mini-label { white-space: nowrap; }
.speed-dial-mini-icon { flex-shrink: 0; }
.speed-dial-mini:hover { background: var(--surface-hover); }
.speed-dial-mini--accent {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}
.speed-dial-mini--accent:hover { background: var(--accent-h); }
.speed-dial-mini:focus-visible { outline: none; box-shadow: var(--focus-ring), 0 4px 12px rgba(0,0,0,0.35); }
@keyframes speed-dial-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Scrim while open (mobile primarily, lets a tap-outside close it) */
.speed-dial-scrim {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 99;
}

/* ── Players Side Panel ── */
#players-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
}
.players-panel-box {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, calc(100vw - var(--edge-gap)));
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: var(--sp-6);
  gap: var(--sp-4);
  overflow-y: auto;
}
.pp-player {
  display: flex;
  flex-direction: column;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border-radius: var(--radius);
}
.pp-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.pp-player--expandable { cursor: pointer; }
.pp-player--expandable:hover,
.pp-player--expandable.pp-player--expanded { background: var(--surface-hover); }
.pp-player-name { font-weight: 700; font-size: var(--sz-body); display: flex; align-items: center; gap: var(--sp-2); flex: 1; min-width: 0; }
.pp-player-right { display: flex; align-items: center; gap: var(--sp-2); flex-shrink: 0; }
.pp-player-stats { font-size: var(--sz-label); color: var(--muted); }
.pp-verified-icon { color: var(--win); font-size: var(--sz-sm); line-height: 1; cursor: default; }
.pp-player-expand {
  display: none;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding-top: var(--sp-2);
  margin-top: var(--sp-1);
  border-top: 1px solid var(--divider);
}
.pp-player--expanded .pp-player-expand { display: flex; }
.pp-player--removed { opacity: 0.55; }
/* Guest checkbox in add-player form */
.players-add-guest {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--sz-body); cursor: pointer;
}
.players-guest-hint { color: var(--muted); font-size: var(--sz-sm); }


/* Player panel search */
.pp-search-wrap { position: relative; }
.pp-search {
  width: 100%;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--sz-sm);
  font-family: inherit;
  padding: var(--sp-2) var(--sp-3);
  box-sizing: border-box;
  transition: box-shadow 0.15s;
}
.pp-search:focus { outline: none; box-shadow: var(--focus-ring); }
.players-add-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  width: 100%;
}
.players-add-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text);
  font-size: var(--sz-sm);
  width: 100%;
  transition: box-shadow 0.15s;
}
.players-add-field input:focus { outline: none; box-shadow: var(--focus-ring); }
.new-player-error { color: var(--loss-text); font-size: var(--sz-sm); }

/* Suppress browser autofill/contacts icon that makes inputs appear unequal */
.players-panel-box input::-webkit-contacts-auto-fill-button,
.players-panel-box input::-webkit-credentials-auto-fill-button { visibility: hidden; }


.pp-section-hint {
  font-size: var(--sz-sm);
  color: var(--muted);
  margin: 0 0 var(--sp-3);
  line-height: 1.45;
}
.pp-invite-form-row {
  display: flex;
  width: 100%;
}
.pp-invite-form-row > * + * {
  margin-left: var(--sp-2);
}
/* Modal action row variant: anchor children to opposite ends */
.pp-invite-form-row--split { justify-content: space-between; }
.pp-invite-form-row--split > * + * { margin-left: 0; }

.pp-manage-input {
  flex: 1;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2) var(--sp-3);
  color: var(--text);
  font-family: inherit;
  font-size: var(--sz-sm);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.pp-manage-input:focus { box-shadow: var(--focus-ring); }
.pp-manage-input::placeholder { color: var(--muted); }

/* ── Card art skeleton (shimmer while Scryfall background image loads) ── */
@keyframes skeleton-shimmer {
  0%   { transform: rotate(20deg) translateX(-120%); }
  100% { transform: rotate(20deg) translateX(120%); }
}
.player-card--art-loading {
  background-color: rgba(255, 255, 255, 0.12) !important;
  min-height: 220px;
  overflow: hidden;
}
.player-card--art-loading::before {
  content: '';
  position: absolute;
  inset: -50%;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.07) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: skeleton-shimmer 1.8s infinite linear;
  pointer-events: none;
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .player-card--art-loading::before { animation: none; }
  .section-skel-row::before         { animation: none; }
}

/* ── Generic section skeleton row (timeline/commanders/games/h2h placeholders) ── */
.section-skel-row {
  position: relative;
  overflow: hidden;
  height: 2.4rem;
  margin-bottom: var(--sp-2);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}
.section-skel-row::before {
  content: '';
  position: absolute;
  inset: -50%;
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: skeleton-shimmer 1.8s infinite linear;
  pointer-events: none;
  will-change: transform;
}

/* ── Modals ── */
#pp-invite-modal,
#pp-add-player-modal,
#pp-edit-player-modal { z-index: 400; }
#new-game-modal .popup-overlay,
#pp-invite-modal .popup-overlay,
#pp-add-player-modal .popup-overlay,
#pp-edit-player-modal .popup-overlay { position: fixed; }

/* Add/Edit-player modals: stack children with consistent spacing */
#pp-add-player-modal .popup-box,
#pp-edit-player-modal .popup-box {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
#pp-add-player-modal .popup-header,
#pp-edit-player-modal .popup-header { margin-bottom: 0; }
#pp-edit-player-modal #pp-edit-player-name-fields[hidden] { display: none; }
#pp-edit-player-modal #pp-edit-player-name-fields {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
#pp-add-player-modal .pp-section-hint { margin: 0; }
#pp-add-player-modal .new-player-error,
#pp-edit-player-modal .new-player-error { margin: 0; }

/* Fields */
.ng-field { margin-bottom: var(--sp-4); }

/* Player dropdown (portaled to body) — visual matches .custom-multiselect-panel */
.ng-player-dropdown {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  list-style: none;
  padding: var(--sp-1) 0;
  margin: 0;
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
}
/* .ng-player-option uses .picker-opt for all visual style */
/* Scrollable modal */
.popup-box--wide {
  width: fit-content;
  min-width: min(580px, calc(100vw - 2 * var(--edge-gap)));
  max-width: min(1150px, calc(100vw - 2 * var(--edge-gap)));
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
}

/* #ng-rows horizontal flex container */
#ng-rows {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding-top: 2.4rem;
  margin-top: var(--sp-2);
  margin-bottom: var(--sp-4);
}

/* Dotted "add player" card */
.ng-add-card {
  width: 210px;
  flex-shrink: 0;
  min-height: 290px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  transition: border-color 0.15s;
}
.ng-add-card:hover { border-color: var(--accent); }
.ng-add-btn {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: none; /* card handles the click */
  transition: background 0.15s, transform 0.15s;
}
.ng-add-card:hover .ng-add-btn { background: var(--accent-h); transform: scale(1.1); }

/* Player cards (new game) */
.ng-pcard {
  position: relative;
  width: 210px;
  flex-shrink: 0;
  min-height: 290px;
  border-radius: var(--radius);
  background-color: var(--bg);
  background-size: cover;
  background-position: center 20%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: visible;
}
/* Positioning + subtle background so the icon stays visible on the card art.
   Pair with .icon-btn.icon-btn--delete for hover/sizing. */
.ng-pcard-remove {
  position: absolute;
  top: -2.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: rgba(255,255,255,0.08);
}
.ng-pcard-content { padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.ng-pcard-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
/* Player selector — sticky at top of solid card */
.ng-pcard-player {
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

/* Trophy mid zone — grows between name bar and content, centers trophy */
.ng-pcard-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 1.8rem; /* clear the absolute name bar */
}

/* Trophy button */
.ng-trophy-btn {
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.ng-trophy-btn svg { width: 1.6rem; height: 1.6rem; }
.ng-trophy-btn:hover { background: rgba(0,0,0,0.55); color: rgba(255,255,255,0.85); transform: scale(1.08); }
.ng-trophy-btn.active {
  background: rgba(240,192,64,0.25);
  color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240,192,64,0.6);
}
.ng-pcard--has-art .ng-trophy-btn {
  background: rgba(0,0,0,0.62);
  color: rgba(255,255,255,0.8);
}
.ng-pcard--has-art .ng-trophy-btn.active {
  background: var(--gold-glow);
}

/* Winner state */
.ng-pcard--winner {
  box-shadow: inset 0 0 0 2px rgba(240,192,64,0.8), 0 0 12px rgba(240,192,64,0.2);
}
.ng-pcard-winner-tag { display: none; }
.ng-pcard--winner .ng-pcard-winner-tag { display: inline-flex; }

/* Commander input row */
.ng-cmd-row {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.ng-cmd-field { position: relative; flex: 1; }
.ng-cmd-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-1) var(--sp-6) var(--sp-1) var(--sp-2);
  color: var(--text);
  font-size: var(--sz-sm);
  width: 100%;
  transition: box-shadow 0.15s;
}
.ng-cmd-input:focus { outline: none; box-shadow: var(--focus-ring); }
.ng-cmd-input--invalid { border-color: var(--loss) !important; }
.ng-cmd-clear {
  position: absolute;
  right: var(--sp-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 var(--sp-1);
  line-height: 1;
  display: none;
}
.ng-cmd-row:hover .ng-cmd-input:not(:placeholder-shown) + .ng-cmd-clear { display: block; }
.ng-cmd-row--partner:hover .ng-cmd-clear { display: block; }
.ng-pcard-player:hover .ng-cmd-input:not(:placeholder-shown) + .ng-cmd-clear { display: block; }
.ng-pcard[data-unknown="true"] .ng-cmd-clear { display: none !important; }
.ng-cmd-clear:hover { color: var(--text); }

/* Autocomplete dropdown — portaled to body, positioned via JS */
.ng-cmd-dropdown {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  list-style: none;
  padding: var(--sp-1) 0;
  margin: 0;
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
}
.ng-cmd-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  cursor: pointer;
  font-size: var(--sz-body);
}
.ng-cmd-option:hover,
.ng-cmd-option:focus { background: var(--surface-hover); outline: none; }
.ng-cmd-option--info {
  color: var(--muted);
  cursor: default;
  font-size: var(--sz-sm);
}
.ng-cmd-option--info:hover,
.ng-cmd-option--info:focus { background: none; }
.ng-opt-art {
  width: 36px;
  height: 27px;
  border-radius: var(--radius-xs);
  background: var(--bg);
  background-size: cover;
  background-position: center top;
  flex-shrink: 0;
}

/* Partner button */
.ng-partner-btn {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
  font-size: var(--sz-sm);
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: border-color 0.15s;
}
.ng-partner-btn:hover { border-color: var(--border); }

/* Unknown commander checkbox */
.ng-unknown-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--sz-sm);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.ng-unknown-label:hover { color: var(--text); }
.ng-unknown-cb { accent-color: var(--accent); cursor: pointer; }


/* Error */
.ng-error { color: var(--loss-text); font-size: var(--sz-body); margin-top: var(--sp-3); margin-bottom: var(--sp-3); }


/* ── Rich tooltips (structured HTML — see script.js for placement logic).
   The generic single-line #tooltip lives in shared.css. */
#att-tooltip,
#streak-tooltip,
#skill-tooltip,
#bayesian-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3) var(--sp-3);
  font-size: var(--sz-sm);
}
#streak-tooltip    { min-width: 140px; }
#skill-tooltip     { min-width: 180px; }
#bayesian-tooltip  { min-width: 220px; max-width: 260px; }
.color-stat-info-icon {
  margin-left: var(--sp-1);
  cursor: default;
  font-style: normal;
  opacity: 0.6;
}
.skill-tip-row {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-6);
  line-height: 1.8;
}
.skill-tip-label { color: var(--muted); }
.skill-tip-val   { font-weight: 600; color: var(--text); }
.skill-tip--pos  { color: var(--win); }
.skill-tip--neg  { color: var(--loss-text); }
.skill-tip-divider {
  border-top: 1px solid var(--divider);
  margin: var(--sp-1) 0;
}
.skill-tip-note {
  color: var(--text);
  font-size: var(--sz-sm);
  font-style: italic;
  border-top: 1px solid var(--divider);
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
}


@media (max-width: 900px) {
  /* H2H: stack card above opponents list */
  .h2h-layout { flex-direction: column; align-items: stretch; }
  .h2h-nav { position: static; justify-content: center; }
  .h2h-nav .player-card { flex: 1; width: auto; max-width: 360px; }
  .h2h-opponents { width: 100%; }

  /* Player cards: 3-up on tablet */
  #player-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; }

  /* Colour stats: 2 columns */
  .color-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  :root { --edge-gap: var(--sp-4); }

  .section-head { flex-direction: column; }
  /* Title was nowrap + baseline-nudged for desktop side-by-side with controls.
     In column layout the nudge creates a stray gap and nowrap can clip long titles. */
  .section-head h2 { white-space: normal; padding-top: 0; }
  .controls { flex-wrap: wrap; }
  header { min-height: 110px; padding: var(--sp-5) var(--edge-gap) var(--sp-4); }
  header h1 { font-size: 1.8rem; }
  /* Reserve space for the absolutely-positioned action cluster on long pod names */
  .header-main { padding-right: 6rem; }

  /* Player cards: 2-up grid; allow pip row to wrap so it doesn't force card width */
  #player-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); min-width: 0; }
  .form-pips { flex-wrap: wrap; }

  /* Game row: prevent commander cell overflow */
  .commanders-cell { flex-wrap: wrap; word-break: break-word; }
  .game-num { font-size: var(--sz-micro); }

  /* Multiselect buttons: narrower */
  .custom-multiselect-btn { width: 130px; }
  .gf-cmd-search { width: 130px; }
  .snav-filters .custom-multiselect-btn { min-width: 0; max-width: 100%; }
  .snav-filters #cmd-color-btn { min-width: 0; }
  .snav-filters { gap: var(--sp-1); row-gap: var(--sp-2); }
  /* Panel defaults to min-width 220px; that overhangs the narrower mobile button. */
  .custom-multiselect-panel { min-width: 0; max-width: calc(100vw - 2 * var(--edge-gap)); }

  /* Section nav: horizontal scroll on mobile (Phase 4) with a right-edge fade hint */
  #section-nav-wrap {
    flex-wrap: nowrap;
    row-gap: 0;
    position: sticky;
    top: 0;
    align-items: center;
  }
  #section-nav-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2.5rem;
    height: 100%;
    background: linear-gradient(to right, transparent 0%, var(--bg) 80%);
    pointer-events: none;
  }
  #section-nav {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    row-gap: 0;
    padding-top: var(--sp-1);
    padding-bottom: var(--sp-1);
    scroll-padding-right: 2.5rem;
  }
  /* Show the bottom-sheet trigger; hide the inline cluster until opened */
  .snav-filter-sheet-btn { display: inline-flex; }
  .snav-filters {
    display: none;
  }
  .snav-filters.is-open {
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 200;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-2);
    padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
    animation: filter-sheet-in 0.2s ease-out;
  }
  /* Field labels show inside the open sheet only */
  .snav-filters.is-open .snav-sheet-label {
    display: block;
    font-size: var(--sz-label);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--ls-caps);
    color: var(--muted);
    margin-top: var(--sp-2);
    margin-bottom: var(--sp-1);
  }
  .snav-filters.is-open .snav-sheet-label:first-child { margin-top: 0; }
  /* Uniform control sizing — match the rest of the form-style inputs */
  .snav-filters.is-open .custom-multiselect,
  .snav-filters.is-open .custom-color-filter { width: 100%; }
  .snav-filters.is-open .custom-multiselect-btn,
  .snav-filters.is-open .btn-range-open,
  .snav-filters.is-open .gf-cmd-search {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 2.6rem;
    padding: 0 var(--sp-3);
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
  }
  .snav-filters.is-open .gf-cmd-search { font-size: var(--sz-body); }
  /* Footer with Clear / Done */
  .snav-filters.is-open .snav-sheet-footer {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--divider);
  }
  .snav-filters-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 199;
    animation: filter-sheet-fade 0.2s ease-out;
  }
  @keyframes filter-sheet-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  @keyframes filter-sheet-fade {
    from { opacity: 0; } to { opacity: 1; }
  }

  /* Colour stats: single column on small phones */
  .color-stats-grid { grid-template-columns: 1fr; }

  /* FAB: compact icon-only circle on mobile */
  #new-game-fab {
    width: 3.4rem; justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  }

  /* Disable hover/expand entirely on mobile — icon-only, no animation */
  .fab-label { max-width: 0 !important; opacity: 0 !important; }
  #new-game-fab:hover { gap: 0; }
  /* First-visit hint: keep the label visible on the speed-dial main FAB
     until the user opens it (`data-open="true"` on the wrap clears it) */
  body[data-fab-onboard="1"] #new-game-fab .fab-label {
    max-width: 6rem !important;
    opacity: 1 !important;
  }
  body[data-fab-onboard="1"] #new-game-fab { gap: var(--sp-2); width: auto; padding: 0 var(--sp-4); }

  /* Header action buttons sit half-overlapping the section-nav on small screens */
  .header-actions { top: var(--sp-3); right: var(--edge-gap); }

  /* Bottom padding clears the FAB stack; section+section spacing scales down */
  main { padding-bottom: 6rem; }
  /* Sticky nav is a single row on mobile (Phase 4) — much smaller anchor offset */
  main > section { scroll-margin-top: 4rem; }
  main > section + section {
    margin-top: var(--sp-6);
    padding-top: var(--sp-6);
    scroll-margin-top: calc(4rem - var(--sp-6));
  }
  #leaderboard {
    margin-top: 0;
    padding-top: var(--sp-5);
    border-top: none;
  }

  /* New game modal: 2-up player cards on mobile, smaller min-height */
  .ng-pcard {
    width: calc(50% - var(--sp-1));
    min-height: 200px;
  }
  .ng-add-card {
    width: calc(50% - var(--sp-1));
    min-height: 200px;
  }
  /* Tighten internal padding so the smaller cards still breathe */
  .ng-pcard-content { padding: var(--sp-1) var(--sp-2) var(--sp-2); }
  .ng-pcard-player { padding: var(--sp-1) var(--sp-2) 0; }
  .ng-pcard-mid { padding-top: var(--sp-6); }
  .ng-trophy-btn { width: 2.6rem; height: 2.6rem; }
  .ng-trophy-btn svg { width: 1.3rem; height: 1.3rem; }
  /* Row-gap large to clear the absolutely-positioned remove button above each card;
     column-gap small so two cards fit side-by-side */
  #ng-rows { row-gap: var(--sp-8); column-gap: var(--sp-2); padding-top: 2rem; }
  /* Tighter modal padding on phones to give the cards more room */
  #new-game-modal .popup-box { padding: var(--sp-3); }

  /* Leaderboard card: trim the win-rate hero so 2-up cards don't feel oversized */
  .player-card .win-pct { font-size: 1.8rem; }
  .pc-stats { gap: var(--sp-5); }

  /* ── iOS Safari input-zoom guard ──
     Mobile Safari auto-zooms when a focused field's effective font-size is
     under 16px. Most of our fields use --sz-sm (~12.75px), so promote them
     for the duration of mobile only. Selects/buttons aren't affected. */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="number"],
  input[type="date"],
  textarea {
    font-size: 16px;
  }

  /* ── Tap targets ──
     Apple HIG / Material both target ≥44px. Several controls fall just
     short on the desktop sheet; nudge them up on phones only. */
  .header-action-btn { width: 2.75rem; height: 2.75rem; }
  .speed-dial-mini { height: 2.9rem; padding: 0 var(--sp-4); }
  .snav-filter-sheet-btn { padding: var(--sp-2) var(--sp-3); }
  .popup-close-btn { width: 2.75rem; height: 2.75rem; }
  /* Sort/range/multiselect triggers a touch beefier so they're easy to hit */
  .sort-btn,
  .btn-range-open,
  .custom-multiselect-btn { min-height: 2.6rem; }
  /* Touch-action: prevent the iOS double-tap zoom delay on primary CTAs */
  .btn-apply,
  .btn-sm,
  .btn-xs,
  .icon-btn,
  .speed-dial-mini,
  .header-action-btn,
  #new-game-fab { touch-action: manipulation; }
}


/* ─── Admin page (body.page-admin) ─────────────────────────────────────────
   Moved from inline <style> in admin.html during Phase 2.                  */
body.page-admin .admin-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
body.page-admin .admin-search       { width: 260px; }
body.page-admin .admin-stat         { font-size: var(--sz-label); color: var(--muted); margin-left: auto; }
body.page-admin .admin-filter-label { font-size: var(--sz-label); color: var(--muted); }

body.page-admin .pods-cell { display: flex; flex-wrap: wrap; gap: 0.3rem; }
body.page-admin .pod-pill {
  display: inline-block;
  font-size: var(--sz-micro);
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
body.page-admin .pod-pill:hover  { border-color: var(--accent); color: var(--accent); }
body.page-admin .pod-pill.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
body.page-admin .pods-empty { color: var(--muted); font-size: var(--sz-label); }

/* Suppress generic row hover for pod rows — hover handled by JS across both rows */
body.page-admin .data-table tbody tr.pod-main-row:not(.pod-group-hovered):hover td,
body.page-admin .data-table tbody tr.pod-detail-row:not(.pod-group-hovered):hover td { background: transparent; }
body.page-admin .data-table tbody tr.faded { opacity: 0.3; pointer-events: none; }

body.page-admin .inline-email-form { display: flex; margin-top: 0.45rem; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
body.page-admin .inline-email-form[hidden] { display: none; }
body.page-admin .inline-email-form input {
  flex: 1; min-width: 170px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0.28rem 0.55rem; color: var(--text); font-family: inherit; font-size: var(--sz-label);
  outline: none; transition: box-shadow 0.15s;
}
body.page-admin .inline-email-form input:focus { box-shadow: var(--focus-ring); }

body.page-admin .row-msg { font-size: var(--sz-label); margin-top: 0.3rem; display: none; }
body.page-admin .row-msg.ok  { color: var(--win);  display: block; }
body.page-admin .row-msg.err { color: var(--loss); display: block; }

body.page-admin tr.pod-row-expanded td { border-bottom: none; }
body.page-admin .pod-main-row { cursor: pointer; }
body.page-admin .pod-group-hovered td { background: rgba(255,255,255,0.02); }
body.page-admin .pod-main-row.deleted { opacity: 0.55; }
body.page-admin .td-date  { color: var(--muted); white-space: nowrap; }
body.page-admin .pod-empty { color: var(--muted); }
body.page-admin .pod-members-empty { font-size: var(--sz-sm); color: var(--muted); }
body.page-admin .confirm-danger { color: var(--loss); }
body.page-admin .pod-detail-row { display: table-row; }
body.page-admin .pod-detail-row[hidden] { display: none; }
body.page-admin .pod-detail-row td { padding: 0.75rem 1rem; border-top: none; }
body.page-admin .pod-member-row { display: flex; align-items: center; gap: 0.6rem; font-size: var(--sz-sm); margin-bottom: 0.3rem; }
body.page-admin .pod-member-name  { color: var(--text); font-weight: 500; }
body.page-admin .pod-member-email { color: var(--muted); font-size: var(--sz-label); }

body.page-admin .active-filter-tag { font-size: var(--sz-label); font-weight: 600; color: var(--accent); }

@media (max-width: 600px) {
  body.page-admin .admin-controls { flex-direction: column; align-items: stretch; }
  body.page-admin .admin-controls .form-input { width: 100% !important; }
  body.page-admin .admin-stat { margin-left: 0 !important; }
}
}

/* ╔═══════════════════════════════════════════════════════════════════════╗
   ║ UTILITIES — bounded set of one-off nudges, named with .u- prefix      ║
   ║                                                                       ║
   ║ Use sparingly: only when no existing class covers the case AND the    ║
   ║ nudge is a single-property tweak. Two or more elements wanting the    ║
   ║ same combo of utilities → write a real class instead.                 ║
   ║                                                                       ║
   ║ Declared in @layer utilities so they win over component rules         ║
   ║ without needing !important.                                           ║
   ╚═══════════════════════════════════════════════════════════════════════╝ */
@layer utilities {
  /* Margin */
  .u-m-0     { margin: 0; }
  .u-mt-0    { margin-top: 0; }
  .u-mb-0    { margin-bottom: 0; }
  .u-mb-2    { margin-bottom: var(--sp-2); }
  .u-mb-3    { margin-bottom: var(--sp-3); }
  .u-mb-4    { margin-bottom: var(--sp-4); }
  .u-ml-auto { margin-left: auto; }

  /* Flex */
  .u-flex     { display: flex; }
  .u-flex-1   { flex: 1; }
  .u-shrink-0 { flex-shrink: 0; }

  /* Alignment */
  .u-va-middle   { vertical-align: middle; }
  .u-text-center { text-align: center; }
}
