/* ==========================================================================
   Cachino Tracker — design system
   The same system as Cachino Online (cachino.online): its fonts, its colours, its radii and its buttons. Light is
   Cachino Online's "Bar" theme (cream panels, the blue shell bar), dark is its "Night" theme. The page follows the
   device unless someone picks one. Every colour below is one of Cachino Online's own tokens; nothing is invented
   here, so a change there is one copy away from here.
   Win and loss differ in lightness as well as hue, and every amount also carries its sign, so they stay apart for
   colour-blind players.
   ========================================================================== */
@font-face {
  font-family: 'Figtree'; font-style: normal; font-display: swap; font-weight: 300 900;
  src: url('/assets/fonts/figtree-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Figtree'; font-style: normal; font-display: swap; font-weight: 300 900;
  src: url('/assets/fonts/figtree-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Bricolage Grotesque'; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url('/assets/fonts/bricolage-grotesque-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Bricolage Grotesque'; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url('/assets/fonts/bricolage-grotesque-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Light: Cachino Online's Bar theme. */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Bricolage Grotesque', 'Figtree', ui-sans-serif, system-ui, sans-serif;

  --shell: #1d4f9c; --shell-deep: #173f7e; --shell-ink: #f6f2e8; --shell-ink-2: #c4d3ec;
  --link: #1d4f9c;
  --accent: #b8322a; --accent-2: #9c2821; --accent-ink: #fff7f0;

  --bg:        #ecebe6;   /* ground */
  --surface:   #f6f5f1;   /* panel */
  --surface-2: #ecebe6;   /* panel-2 */
  --surface-3: #dcdcd7;
  --line:   rgba(32, 37, 39, 0.14);
  --line-2: rgba(32, 37, 39, 0.28);

  --ink:   #202527;
  --ink-2: #50575b;
  --muted: #6f767a;

  --pos: #2c7a4b; --neg: #b8322a;
  --pos-text: #2c7a4b; --neg-text: #b8322a;
  --pos-soft: rgba(44, 122, 75, 0.12); --neg-soft: rgba(184, 50, 42, 0.12);

  --gold: #a26e14; --silver: #6f767a; --bronze: #9a5f35;

  --grid: rgba(32, 37, 39, 0.08);
  --axis: rgba(32, 37, 39, 0.22);

  /* up to four highlighted players: Cachino Online's blue first, then hues kept clear of win and loss. */
  --s1: #1d4f9c; --s2: #b07a0b; --s3: #b13a92; --s4: #2a7f86;
  --others: rgba(32, 37, 39, 0.16);
  --card-face: #fbf9f3; --card-red: #c02a22; --card-black: #1d2224;

  --good: #2c7a4b; --warning: #a26e14; --critical: #b8322a;
  --focus: #e4a83a;

  --r-lg: 16px;
  --r:    10px;
  --r-sm: 6px;
  --tap:  44px;
  --shadow: 0 1px 2px rgba(22, 25, 26, 0.08), 0 8px 24px -12px rgba(22, 25, 26, 0.14);
  --shadow-lift: 0 2px 4px rgba(22, 25, 26, 0.16), 0 16px 40px rgba(22, 25, 26, 0.22);
  --overlay: rgba(22, 25, 26, 0.42);
  --header-h: 56px;
}

/* Dark: Cachino Online's Night theme. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --shell: #0f1c33; --shell-deep: #0a1426; --shell-ink: #ece7da; --shell-ink-2: #8fa3c4;
  --link: #8fb4ff;
  --accent: #d6493e; --accent-2: #b93a31; --accent-ink: #fff6ef;

  --bg:        #121618;
  --surface:   #171c1f;
  --surface-2: #20272a;
  --surface-3: #2a3236;
  --line:   rgba(231, 229, 222, 0.11);
  --line-2: rgba(231, 229, 222, 0.22);

  --ink:   #e7e5de;
  --ink-2: #a3abaf;
  --muted: #7d868c;

  --pos: #4fb07a; --neg: #d6493e;
  --pos-text: #5cc089; --neg-text: #e5675d;
  --pos-soft: rgba(79, 176, 122, 0.14); --neg-soft: rgba(214, 73, 62, 0.16);

  --gold: #e4b04a; --silver: #a3abaf; --bronze: #c98a5a;

  --grid: rgba(231, 229, 222, 0.06);
  --axis: rgba(231, 229, 222, 0.2);

  --s1: #8fb4ff; --s2: #e4b04a; --s3: #e98bd0; --s4: #6fd0d6;
  --others: rgba(231, 229, 222, 0.16);
  --card-face: #e9e7e0; --card-red: #b8261f; --card-black: #1b2023;

  --good: #4fb07a; --warning: #e4b04a; --critical: #d6493e;
  --focus: #e4b04a;
  --shadow: none;
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.45), 0 16px 40px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; border-radius: 6px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.pos { color: var(--pos-text); }
.neg { color: var(--neg-text); }
.muted { color: var(--muted); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 24px 56px; }

/* ------------------------------------------------------------------ header */
.header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-in {
  max-width: 1240px; height: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--surface-3), var(--surface));
  border: 1px solid var(--line-2); color: var(--gold);
}
.brand-mark svg { width: 15px; height: 15px; }
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -0.02em; }

.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav-item {
  border: 0; background: none; cursor: pointer; border-radius: var(--r-sm);
  padding: 7px 12px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  transition: color .15s, background .15s;
}
.nav-item:hover { color: var(--ink-2); }
.nav-item[aria-selected="true"] { color: var(--ink); background: var(--surface-2); }

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  cursor: pointer; padding: 0; flex: none; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.on { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); background: color-mix(in srgb, var(--gold) 10%, transparent); }

.sync { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; cursor: pointer;
  font-size: 12px; color: var(--muted); }
.sync:hover { border-color: var(--line-2); color: var(--ink-2); }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: block; flex: none; }
.sync[data-state="synced"] i { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.sync[data-state="dirty"] i, .sync[data-state="checking"] i { background: var(--gold); }
.sync[data-state="error"] i, .sync[data-state="conflict"] i { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 10px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
  font-size: 13.5px; font-weight: 550; transition: background .15s, border-color .15s, opacity .15s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--neg-text); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.btn.danger:hover { background: var(--neg-soft); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .38; cursor: not-allowed; transform: none; }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.link:hover { color: var(--ink); }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 12.5px; font-weight: 550; height: 26px; padding: 0 11px; border-radius: 7px; white-space: nowrap;
}
.seg button:hover { color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.18); }

/* ------------------------------------------------------------------ layout */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin: 4px 0 2px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.page-head .spacer { margin-left: auto; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
/* sections are spaced by the panel's gap; a sibling-margin rule would also push down
   every card after the first inside a row, which is what misaligned them before */
[role="tabpanel"] { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid { align-items: stretch; }
.grid > .card { display: flex; flex-direction: column; }
.grid > .card > .fill { flex: 1 1 auto; }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; }
.c4 { grid-column: span 4; }  .c3 { grid-column: span 3; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0;
}
.card.pad-0 { padding: 0; }
.card-h { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; min-height: 30px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .act { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-f { display: flex; justify-content: center; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.kpi .k-label { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .k-label svg { width: 14px; height: 14px; opacity: .8; }
.kpi .k-value { margin-top: 8px; font-size: 26px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-sub { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ avatars */
.av {
  width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; font-weight: 650; letter-spacing: .02em;
  border: 1px solid var(--line-2);
}
.av.lg { width: 52px; height: 52px; font-size: 17px; }
.av.sm { width: 24px; height: 24px; font-size: 9.5px; }
.av.r1 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--gold); color: var(--gold); }
.av.r2 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--silver); }
.av.r3 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--bronze); }
.av-stack { display: flex; }
.av-stack .av { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.av-stack .av:first-child { margin-left: 0; }
.av-stack .more { font-size: 11px; color: var(--muted); margin-left: 6px; align-self: center; }

/* ------------------------------------------------------------------ leaderboard */
.lb { width: 100%; }
.lb-row {
  display: grid; align-items: center; column-gap: 14px;
  grid-template-columns: 26px minmax(150px, 1.6fr) 64px 70px 58px 84px 84px 84px 64px 150px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; font-family: var(--font); color: var(--ink);
}
.lb-row + .lb-row { border-top: 1px solid var(--line); border-radius: 0; }
.lb-row:hover { background: var(--surface-2); border-radius: 10px; }
.lb-row:hover + .lb-row { border-top-color: transparent; }
.lb-head { cursor: default; padding-top: 0; padding-bottom: 8px; }
.lb-head:hover { background: none; }
.lb-head span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.lb-head [data-sort] { cursor: pointer; user-select: none; }
.lb-head [data-sort]:hover, .lb-head [aria-sort="descending"], .lb-head [aria-sort="ascending"] { color: var(--ink); }
.lb-head [aria-sort="descending"]::after { content: " ↓"; }
.lb-head [aria-sort="ascending"]::after { content: " ↑"; }
.lb-rank { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; text-align: center; }
.lb-player { display: flex; align-items: center; gap: 11px; min-width: 0; }
.lb-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-meta { display: none; font-size: 12px; color: var(--muted); }
.lb-cell { font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.lb-net { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.lb-net b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.lb-bar { position: relative; width: 100%; height: 4px; border-radius: 2px; background: var(--surface-3); }
.lb-bar i { position: absolute; top: 0; bottom: 0; border-radius: 2px; }
.lb-bar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }

/* form: filled = win, ring = loss, dash = level — shape carries the result, not just colour */
.form { display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; }
.form i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.form i.w { background: var(--pos); }
.form i.l { border: 1.5px solid var(--neg); }
.form i.e { width: 8px; height: 2px; border-radius: 1px; background: var(--muted); }

/* ------------------------------------------------------------------ insight cards */
.insights { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.insight { display: flex; gap: 13px; align-items: flex-start; }
.insight .ic {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
}
.insight .ic svg { width: 16px; height: 16px; }
.insight .ic.gold { color: var(--gold); }
.insight .ic.pos  { color: var(--pos-text); }
.insight .ic.neg  { color: var(--neg-text); }
.insight .i-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.insight .i-value { font-size: 15.5px; font-weight: 650; letter-spacing: -0.015em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insight .i-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.insight > div { min-width: 0; }

/* ------------------------------------------------------------------ charts */
.chart-host { position: relative; }
.chart-host svg { display: block; width: 100%; height: auto; font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.legend-item .key { width: 14px; height: 3px; border-radius: 2px; flex: none; }

.tip {
  position: absolute; pointer-events: none; z-index: 30; top: 0; left: 0; min-width: 140px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 11px; font-size: 12.5px; box-shadow: 0 12px 32px -12px rgba(0,0,0,.55);
  opacity: 0; transition: opacity .1s;
}
.tip[data-show="1"] { opacity: 1; }
.tip .tt-title { font-weight: 600; margin-bottom: 5px; }
.tip .tt-sub { color: var(--muted); font-weight: 400; }
.tip .tt-row { display: flex; align-items: center; gap: 8px; padding: 1.5px 0; }
.tip .tt-row .key { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tip .tt-row .nm { color: var(--ink-2); }
.tip .tt-row .vl { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 650; }

/* ------------------------------------------------------------------ session rows */
.srows { display: flex; flex-direction: column; }
.srow {
  display: grid; grid-template-columns: 46px minmax(0, 1fr) auto 16px; align-items: center; gap: 14px;
  padding: 11px 10px; border: 0; background: none; width: 100%; text-align: left; cursor: pointer;
  border-radius: 10px; font-family: var(--font); color: var(--ink);
}
.srow + .srow { border-top: 1px solid var(--line); border-radius: 0; }
.srow:hover { background: var(--surface-2); border-radius: 10px; }
.srow:hover + .srow { border-top-color: transparent; }
.dateblk {
  width: 46px; height: 46px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.dateblk b { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.dateblk span { font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
.s-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.s-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-title span { color: var(--muted); font-weight: 500; }
.s-right { text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.s-right b { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.s-right small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.kdot { display: inline-block; width: 9px; height: 3px; border-radius: 2px; margin-right: 7px; vertical-align: middle; position: relative; top: -1px; }
.chev { color: var(--muted); display: grid; place-items: center; }
.chev svg { width: 14px; height: 14px; }

.srows .srow.menu-row { grid-template-columns: 40px minmax(0, 1fr) 16px; }
.srows .srow.menu-row .chev { display: grid; }
.menu-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.menu-ic svg { width: 18px; height: 18px; }

.sgroup + .sgroup { margin-top: 18px; }
.sgroup-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 0 10px 8px; margin-bottom: 2px; border-bottom: 1px solid var(--line);
}
.sgroup-h h3 { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.sgroup-h span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ player header */
.phero { display: flex; align-items: center; gap: 16px; }
.phero .who { min-width: 0; }
.phero h1 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -0.03em; display: flex; align-items: center; gap: 10px; }
.phero .meta { color: var(--muted); font-size: 13px; margin-top: 3px; }
.rank-badge {
  font-size: 11.5px; font-weight: 650; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); letter-spacing: 0;
}
.rank-badge.r1 { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.phero .act { margin-left: auto; display: flex; gap: 8px; }

.pick-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 12px;
  border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface-2); cursor: pointer;
  text-align: left; font-family: var(--font); color: var(--ink);
}
.pick-btn:hover { background: var(--surface-3); }
.pick-btn .p-label { font-size: 11px; color: var(--muted); display: block; }
.pick-btn .p-name { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.pick-btn .p-net { margin-left: auto; font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pick-btn .chev svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ records + rivals */
.rivals { display: flex; flex-direction: column; }
/* rows are the same height as session rows so side-by-side cards line up */
.rival { display: grid; grid-template-columns: minmax(0, 1fr) 64px 120px; align-items: center; gap: 14px; padding: 11px 10px; min-height: 72px; }
.rival + .rival { border-top: 1px solid var(--line); }
.rival .r-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rival .r-who .av { width: 46px; height: 46px; border-radius: 11px; font-size: 13px; }
.rival .r-name { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rival .r-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.rival .r-rec { font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.split i { display: block; height: 100%; }
.split .a { background: var(--pos); border-radius: 3px 0 0 3px; }
.split .b { background: var(--neg); border-radius: 0 3px 3px 0; margin-left: auto; }

/* ------------------------------------------------------------------ head to head */
.h2h-pick { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px; align-items: center; }
.vs { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  letter-spacing: .04em; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.h2h-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 4px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.h2h-side { display: flex; align-items: center; gap: 14px; min-width: 0; }
.h2h-side.b { flex-direction: row-reverse; text-align: right; }
.h2h-side .nm { font-size: 17px; font-weight: 650; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h2h-side .nt { font-size: 22px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.h2h-side .key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; margin: 0 6px; }
.tug { display: grid; grid-template-columns: 96px minmax(0, 1fr) 96px; gap: 14px; align-items: center; padding: 10px 0; }
.tug + .tug { border-top: 1px solid var(--line); }
.tug .va, .tug .vb { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tug .va { text-align: right; } .tug .vb { text-align: left; }
.tug .va.lose, .tug .vb.lose { color: var(--muted); font-weight: 500; }
.tug .mid { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.tug .lbl { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; }
.tug .track { position: relative; height: 6px; border-radius: 3px; background: var(--surface-3); }
.tug .track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.tug .track i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.callout { margin-top: 14px; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); line-height: 1.55; }
.callout strong { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ modal / sheet */
.scrim { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 24px; overscroll-behavior: contain; animation: fade .15s ease-out; }
.modal {
  width: min(560px, 100%); max-height: min(90vh, 880px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px;
  box-shadow: 0 32px 80px -24px rgba(0,0,0,.7); animation: rise .18s ease-out;
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -0.015em; }
.modal-head .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.modal-head .spacer { margin-left: auto; }
.modal-body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; }
.modal-foot .spacer { margin-left: auto; }
.grab { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 5px; }
.input, .field input, .field select {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 16px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink);
}
.input:focus, .field input:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--s1) 22%, transparent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.note { font-size: 12.5px; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
h4.sec { margin: 0 0 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }

.pot-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 12px; }
.pot-bar .pl { font-size: 12px; color: var(--muted); }
.pot-bar b { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pot-bar .pc { margin-left: auto; font-size: 12px; color: var(--muted); }

.pgrid { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.phead { display: grid; grid-template-columns: minmax(0, 1fr) 72px 72px 28px; gap: 8px; padding: 7px 12px; background: var(--surface-2); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.phead span:nth-child(2), .phead span:nth-child(3) { text-align: right; }
.prow { display: grid; align-items: center; gap: 8px; padding: 7px 12px; min-height: 52px; background: var(--surface); }
.prow + .prow { border-top: 1px solid var(--line); }
.prow.io { grid-template-columns: minmax(0, 1fr) 72px 72px 28px; }
.prow.net { grid-template-columns: minmax(0, 1fr) 36px 96px 28px; }
.psign {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink-2); cursor: pointer; font-size: 17px; font-weight: 600; line-height: 1; padding: 0;
}
.psign:hover { background: var(--surface-3); color: var(--ink); }
.pmeta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pmeta .pn { min-width: 0; display: flex; flex-direction: column; }
.pname { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pnet { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.pnet.pos { color: var(--pos-text); } .pnet.neg { color: var(--neg-text); }
.prow .amt {
  width: 100%; height: 36px; padding: 0 9px; border-radius: 8px; text-align: right; font-size: 16px;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink); font-variant-numeric: tabular-nums;
}
.prow .amt:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--s1) 22%, transparent); }
.prm { width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; padding: 0; }
.prm:hover { background: var(--neg-soft); color: var(--neg-text); }
.prm svg { width: 12px; height: 12px; }

.addrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.chip-add {
  height: 32px; padding: 0 12px; border-radius: 999px; cursor: pointer; font-size: 12.5px; font-weight: 550;
  border: 1px dashed var(--line-2); background: transparent; color: var(--ink-2);
}
.chip-add:hover { border-style: solid; background: var(--surface-2); color: var(--ink); }
.chip-add.new { border-style: solid; color: var(--ink); background: var(--surface-2); }
.newp { display: flex; gap: 6px; width: 100%; margin-top: 2px; }
.newp .input { height: 36px; }

.balance { display: flex; align-items: center; gap: 9px; margin-top: 12px; padding: 11px 13px; border-radius: 10px; font-size: 13px; border: 1px solid var(--line); }
.balance svg { width: 16px; height: 16px; flex: none; }
.balance[data-ok="1"] { background: var(--pos-soft); border-color: color-mix(in srgb, var(--pos) 28%, transparent); }
.balance[data-ok="1"] svg { color: var(--pos-text); }
.balance[data-ok="0"] { background: color-mix(in srgb, var(--gold) 10%, transparent); border-color: color-mix(in srgb, var(--gold) 30%, transparent); }
.balance[data-ok="0"] svg { color: var(--gold); }
.balance .b-val { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

.settle { margin-top: 14px; }
.settle-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.settle-head h4 { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.settle-head .btn { margin-left: auto; }
.settle-list { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.settle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; font-size: 13.5px; background: var(--surface); }
.settle-row + .settle-row { border-top: 1px solid var(--line); }
.settle-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.settle-row .who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settle-row .arr { color: var(--muted); display: grid; place-items: center; }
.settle-row .arr svg { width: 14px; height: 14px; }
.settle-row .amt { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 78px; text-align: right; padding-left: 12px; border-left: 1px solid var(--line); }
.settle-none { padding: 12px; font-size: 13px; color: var(--muted); background: var(--surface); }
.pay {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 650; text-decoration: none; white-space: nowrap;
}
.pay:hover { opacity: .88; }
.pay:active { transform: translateY(1px); }
.pay svg { width: 13px; height: 13px; }
.pay-none { color: var(--muted); width: 32px; text-align: center; }

.det-list { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.det-head, .det-row { display: grid; grid-template-columns: minmax(0, 1fr) 70px 70px 90px; gap: 10px; align-items: center; padding: 9px 12px; }
.det-head { background: var(--surface-2); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.det-head span:not(:first-child), .det-row .dr { text-align: right; }
.det-row { background: var(--surface); font-size: 13.5px; }
.det-row + .det-row { border-top: 1px solid var(--line); }
.det-row .dw { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; }
.det-row .dw span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.det-row .dr { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.det-row .dr.net { color: inherit; font-size: 14px; font-weight: 650; }
.det-list.netonly .det-head, .det-list.netonly .det-row { grid-template-columns: minmax(0, 1fr) 90px; }
.det-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.det-meta div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.det-meta span { display: block; font-size: 11.5px; color: var(--muted); }
.det-meta b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }

.mgr-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; }
.mgr-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-width: 0; }
.mgr-meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.mgr-row + .mgr-row { border-top: 1px solid var(--line); }
.mgr-row .input { height: 36px; font-size: 14.5px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 550;
  box-shadow: 0 12px 32px -12px rgba(0,0,0,.6); max-width: calc(100vw - 32px); text-align: center; animation: rise .18s ease-out;
}
.empty { padding: 24px 8px; text-align: center; color: var(--muted); font-size: 13px; }

/* bottom navigation — phones only */
.bottom-nav { display: none; }

/* ------------------------------------------------------------------ tablet */
@media (max-width: 1099px) {
  .lb-row { grid-template-columns: 26px minmax(140px, 1.6fr) 60px 66px 56px 80px 60px 130px; }
  .lb-row .x-best, .lb-row .x-worst { display: none; }
  .insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ phone */
@media (max-width: 859px) {
  :root { --header-h: 56px; }
  body { font-size: 14px; }
  .wrap { padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); }
  .header-in { padding: 0 14px; gap: 10px; }
  .nav, .sync .sync-label, #addBtn .lbl { display: none; }
  #addBtn { width: 36px; padding: 0; }
  .sync { width: 36px; padding: 0; justify-content: center; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(16px); backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--line);
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 50px; border: 0; background: none; cursor: pointer; border-radius: 12px;
    font-size: 10.5px; font-weight: 600; color: var(--muted); font-family: var(--font);
  }
  .bn-item svg { width: 21px; height: 21px; }
  .bn-item[aria-selected="true"] { color: var(--ink); }
  .bn-item[aria-selected="true"] svg { color: var(--gold); }

  .page-head { margin: 2px 0 0; }
  .page-head h1 { font-size: 21px; }
  .grid { gap: 12px; }
  [role="tabpanel"] { gap: 12px; }
  .c8, .c6, .c4, .c3 { grid-column: span 12; }
  .card { padding: 14px; border-radius: 14px; }
  .card-h { margin-bottom: 10px; }

  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 13px; border-radius: 14px; }
  .kpi .k-value { font-size: 21px; margin-top: 5px; }
  .kpi .k-sub { font-size: 11.5px; }
  .insights { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .insights .card { padding: 12px; }
  .insight { flex-direction: column; gap: 9px; }
  .insight .ic { width: 30px; height: 30px; border-radius: 9px; }
  .insight .i-value { font-size: 14.5px; }

  .lb-row { grid-template-columns: 20px minmax(0, 1fr) auto; column-gap: 10px; padding: 10px 4px; }
  .lb-row > .x { display: none; }
  .lb-meta { display: block; }
  .lb-head { display: none; }
  .lb-net { min-width: 92px; }
  .lb-row:hover { border-radius: 0; background: none; }

  .srow { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 11px; padding: 10px 4px; }
  .srow .chev { display: none; }
  .srow:hover { background: none; }
  .dateblk { width: 42px; height: 42px; border-radius: 10px; }
  .dateblk b { font-size: 15px; }
  .sgroup-h { padding: 0 4px 8px; }

  .phero { flex-wrap: wrap; gap: 12px; }
  .phero .who { flex: 1 1 0; }          /* keep the name beside the avatar */
  .phero .meta { font-size: 12.5px; }
  .phero h1 { font-size: 20px; }
  .phero .av.lg { width: 46px; height: 46px; font-size: 15px; }
  .phero .act { margin-left: 0; width: 100%; }
  .phero .act .switch-btn { flex: 1 1 auto; }

  .h2h-pick { grid-template-columns: 1fr; gap: 8px; }
  .h2h-pick .vs { justify-self: center; width: 32px; height: 32px; font-size: 10.5px; }
  .h2h-side .av.lg { width: 40px; height: 40px; font-size: 13px; }
  .h2h-side .nm { font-size: 14.5px; }
  .h2h-side .nt { font-size: 17px; }
  .h2h-hero { gap: 8px; }
  .h2h-hero .vs { width: 28px; height: 28px; font-size: 9.5px; }
  .tug { grid-template-columns: 76px minmax(0, 1fr) 76px; gap: 10px; }
  .tug .va, .tug .vb { font-size: 13px; }

  .rival { grid-template-columns: minmax(0, 1fr) 56px 80px; gap: 10px; }

  .scrim { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheet .22s ease-out; }
  .grab { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 8px auto 0; }
  .modal-head { padding: 12px 16px 14px; }
  .modal-body { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .det-head, .det-row { grid-template-columns: minmax(0, 1fr) 58px 58px 80px; gap: 8px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } }

@media (max-width: 380px) {
  .kpi .k-value { font-size: 19px; }
  .prow.io, .phead { grid-template-columns: minmax(0, 1fr) 64px 64px 26px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .header, .bottom-nav, .header-actions { display: none !important; }
  body { background: #fff; }
  .card, .kpi { break-inside: avoid; }
}

/* ------------------------------------------------------------------ photos */
.av { overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.av-btn { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; flex: none; }
.av-btn .cam {
  position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink); color: var(--bg); border: 2px solid var(--surface);
}
.av-btn .cam svg { width: 11px; height: 11px; }
.photo-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0 4px; }
.photo-hero .av { width: 128px; height: 128px; font-size: 38px; }
.photo-hero .note { text-align: center; max-width: 34ch; }

/* ------------------------------------------------------------------ player picker sheet */
.pk-search { position: relative; margin-bottom: 10px; }
.pk-search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.pk-search .input { padding-left: 38px; }
.pk-list { display: flex; flex-direction: column; }
.pk-row {
  display: grid; grid-template-columns: 22px 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; min-height: 60px; padding: 8px 10px; border: 0; background: none; border-radius: 12px;
  cursor: pointer; text-align: left; font-family: var(--font); color: var(--ink);
}
.pk-row + .pk-row { margin-top: 2px; }
.pk-row:hover, .pk-row:focus-visible { background: var(--surface-2); outline: none; }
.pk-row[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.pk-row .pk-rank { font-size: 12px; color: var(--muted); font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.pk-row .av { width: 40px; height: 40px; font-size: 13px; }
.pk-row .pk-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-row .pk-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-row .pk-net { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.pk-row .pk-rank svg { width: 16px; height: 16px; color: var(--gold); display: block; margin: 0 auto; }
.pk-empty { padding: 20px; text-align: center; color: var(--muted); }

/* the trigger on a profile */
.switch-btn { min-width: 170px; justify-content: flex-start; }
.switch-btn .chev-i { margin-left: auto; padding-left: 10px; display: grid; place-items: center; color: var(--muted); }
.switch-btn .chev-i svg { width: 14px; height: 14px; }

/* ------------------------------------------------------------------ chart player toggles */
.pchips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.pchip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 4px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); cursor: pointer;
  font-size: 13px; font-weight: 550; font-family: var(--font); transition: background .15s, border-color .15s, color .15s;
}
.pchip .av { width: 26px; height: 26px; font-size: 9.5px; }
.pchip:hover { background: var(--surface-2); color: var(--ink); }
.pchip[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); border-color: var(--chip, var(--line-2)); box-shadow: inset 0 0 0 1px var(--chip, transparent); }
.pchip .key { width: 14px; height: 3px; border-radius: 2px; background: var(--chip, transparent); }
.pchip[aria-pressed="false"] .key { background: var(--others); }
.pchips .pchip-tools { display: inline-flex; gap: 6px; margin-left: auto; align-items: center; }
@media (max-width: 859px) {
  .pchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .pchips::-webkit-scrollbar { display: none; }
  .pchip { flex: none; }
  .pchips .pchip-tools { margin-left: 0; }
  .switch-btn { min-width: 0; }
  .pk-row { grid-template-columns: 18px 40px minmax(0, 1fr) auto; gap: 10px; }
  .mgr-fields { grid-template-columns: 1fr; }
  .mgr-meta .note { display: none; }
  .settle-row { padding: 10px; gap: 8px; }
  .pay { padding: 0 11px; }
}

/* ==========================================================================
   At the table — turn timer and hand rankings
   The clock is sized from one variable (--d) so the number always fills the
   ring; every layout below just changes --d.
   ========================================================================== */
.timer { --d: min(300px, 76vw); display: flex; align-items: center; justify-content: center; gap: 26px; flex-wrap: wrap; padding: 4px 0 2px; }

/* the clock itself is the main control: tapping it starts or pauses */
.tm-clock {
  position: relative; display: grid; place-items: center; border: 0; background: none; padding: 0;
  cursor: pointer; width: var(--d); height: var(--d); flex: none; color: var(--ink);
  font-family: var(--font); border-radius: 50%;
}
.tm-clock svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.tm-clock .ring-track { stroke: var(--surface-3); }
.tm-clock .ring-fill { stroke: var(--s1); transition: stroke-dashoffset .12s linear, stroke .2s; stroke-linecap: round; }
.tm-clock .tm-inner { display: grid; place-items: center; }
.tm-clock .tm-time {
  font-size: calc(var(--d) * 0.42); font-weight: 600; letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums; line-height: .92;
}
.tm-clock .tm-state {
  margin-top: calc(var(--d) * 0.04); font-size: calc(var(--d) * 0.052); font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.timer.warn .ring-fill { stroke: var(--gold); }
.timer.over .ring-fill { stroke: var(--neg); }
.timer.over .tm-time { color: var(--neg-text); }
.timer.over .tm-clock { animation: tm-flash 1s ease-in-out infinite; }
@keyframes tm-flash { 50% { opacity: .45; } }

.tm-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; flex: 1 1 250px; max-width: 380px; }
.tm-buttons { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.tm-buttons .btn { height: 50px; font-size: 14.5px; }

/* the turn length collapses to a single chip once it has been chosen */
.tm-len {
  display: flex; align-items: center; justify-content: center; gap: 7px; height: 38px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 999px; background: transparent; color: var(--ink-2);
  font-family: var(--font); font-size: 13px; font-weight: 600; padding: 0 14px; align-self: center;
}
.tm-len:hover { background: var(--surface-2); color: var(--ink); }
.tm-len .tm-len-v { color: var(--ink); font-variant-numeric: tabular-nums; }
.tm-len .tm-len-k { color: var(--muted); font-weight: 500; }
.tm-len svg { width: 13px; height: 13px; opacity: .6; }
.tm-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.tm-preset {
  height: 38px; min-width: 56px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink-2);
  font-size: 13px; font-weight: 600; font-family: var(--font); font-variant-numeric: tabular-nums;
}
.tm-preset:hover { background: var(--surface-2); color: var(--ink); }
.tm-preset[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tm-custom { display: flex; align-items: center; gap: 6px; }
.tm-custom .input { height: 38px; width: 70px; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; }
.tm-hint { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------- hand rankings
   Ten rows that fit on one screen: rank, name, and the example hand with the
   cards that actually make it at full strength. */
.hands {
  --pc: 32px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.hand {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 7px 12px; background: var(--surface); min-width: 0;
}
.hand .h-rank { font-size: 11.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.hand .h-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hand .h-cards { display: flex; gap: 4px; flex: none; }
.hand.best { background: color-mix(in srgb, var(--gold) 8%, var(--surface)); }
.hand.best .h-name { color: var(--gold); }
.hand.best .h-rank { color: var(--gold); }

.pcard {
  display: grid; place-items: center; flex: none; line-height: 1;
  height: var(--pc); width: calc(var(--pc) * 0.74); border-radius: calc(var(--pc) * 0.14);
  background: var(--card-face); border: 1px solid var(--line-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.pcard b { font-size: calc(var(--pc) * 0.36); font-weight: 700; letter-spacing: -0.04em; }
.pcard i { font-size: calc(var(--pc) * 0.30); font-style: normal; margin-top: 1px; }
.pcard.red { color: var(--card-red); }
.pcard.black { color: var(--card-black); }
.pcard.off { opacity: .3; }          /* cards that are not part of the hand */

/* ------------------------------------------------------------------ full screen */
.fs-layer {
  position: fixed; inset: 0; z-index: 130; background: var(--bg); display: flex; flex-direction: column;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); overflow: hidden; animation: fade .15s ease-out;
}
.fs-head { display: flex; align-items: center; gap: 10px; flex: none; margin-bottom: 8px; }
.fs-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink-2); }
.fs-head .fs-sp { flex: 1 1 auto; }
.fs-head .act { display: flex; gap: 6px; }
.fs-body { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; min-height: 0; }
.fs-body > * { min-height: 0; }
.fs-body .timer { --d: min(66vh, 86vw); gap: 30px; }
.fs-body .tm-buttons .btn { height: 56px; font-size: 16px; }
.fs-body .tm-side { max-width: 460px; }

/* The rankings fill the screen exactly — ten equal rows, no scrolling. The card
   size is capped by width as well as height so the hand names never truncate. */
.fs-body .hands { --pc: min(5.6vh, 9.5vw, 58px); height: 100%; grid-template-rows: repeat(10, minmax(0, 1fr)); }
.fs-body .hand { padding: 0 12px; gap: 8px; }
.fs-body .hand .h-rank { font-size: clamp(11px, 1.8vh, 18px); }
.fs-body .hand .h-name { font-size: clamp(13px, min(2.4vh, 4.2vw), 26px); }
body.fs-open { overflow: hidden; }

/* two columns when there is width to spare: 1–5 on the left, 6–10 on the right */
@media (min-width: 760px) {
  .hands { --pc: 34px; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(5, auto); grid-auto-flow: column; }
  .hand { padding: 9px 14px; }
  .fs-body .hands {
    --pc: min(10vh, 4.6vw, 76px); grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr)); grid-auto-flow: column;
  }
  .fs-body .hand .h-name { font-size: clamp(13px, min(3vh, 2.1vw), 30px); }
}

/* ------------------------------------------------------- phone, portrait */
@media (max-width: 859px) {
  .timer { gap: 16px; }
  .tm-side { flex: 1 1 100%; max-width: none; }
  /* keep each card's buttons on the title row instead of wrapping below it */
  #panel-table .card-h { flex-wrap: nowrap; margin-bottom: 10px; }
  #panel-table .card-h .sub { display: none; }
  .tm-buttons .btn { height: 52px; }      /* big, thumb-friendly at the table */
  .fs-layer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .bn-item .bn-label.counting { color: var(--gold); font-variant-numeric: tabular-nums; }
}

/* --------------------------------------------- phone, held sideways
   Short and wide: the clock goes beside the controls and takes the height. */
@media (max-height: 560px) and (orientation: landscape) {
  .timer { --d: min(74vh, 40vw); flex-wrap: nowrap; gap: 20px; align-items: center; }
  .tm-side { flex: 1 1 auto; max-width: 420px; gap: 8px; }
  .tm-buttons .btn { height: 44px; font-size: 14px; }
  .tm-len, .tm-preset, .tm-custom .input { height: 34px; }
  .fs-body .timer { --d: min(80vh, 44vw); gap: 24px; }
  .fs-body .tm-buttons .btn { height: 46px; font-size: 15px; }
  .fs-layer { padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); }
  .fs-head { margin-bottom: 4px; }

  /* the rankings split into two columns so all ten still fit the short screen */
  .fs-body .hands {
    --pc: min(12vh, 4.4vw, 54px); grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr)); grid-auto-flow: column;
  }
  .fs-body .hand { padding: 0 10px; }
  .fs-body .hand .h-name { font-size: clamp(12px, min(3.4vh, 2vw), 22px); }
}

/* ==========================================================================
   Cachino Online's components, on top of the layout above (2.0)
   ========================================================================== */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--link); text-underline-offset: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* The display face for titles, as on Cachino Online; Figtree for everything else and every number. */
.page-head h1, .phero h1, .modal-head h3, .fs-head h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
.page-head h1 { font-size: 26px; }
.card-h h2 { font-size: 14.5px; font-weight: 700; }

/* The top bar is Cachino Online's: the shell colour, cream ink, the chip mark and the name. Everything inside it
   reads in the shell's own colours, so its buttons and status need no styles of their own. */
.header {
  background: var(--shell); border-bottom: 0;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  --ink: var(--shell-ink); --ink-2: var(--shell-ink-2); --muted: var(--shell-ink-2);
  --line: rgba(246, 242, 232, 0.22); --line-2: rgba(246, 242, 232, 0.36);
  --surface-2: rgba(255, 255, 255, 0.12); --surface-3: rgba(255, 255, 255, 0.18);
  color: var(--shell-ink);
}
:root[data-theme="dark"] .header { --line: rgba(236, 231, 218, 0.16); --line-2: rgba(236, 231, 218, 0.28); }
.brand { gap: 9px; color: var(--shell-ink); }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.brand-light { font-weight: 500; opacity: 0.85; }
.logo-mark { flex: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25)); }
.logo-face { fill: var(--shell-ink); }
.logo-ink { fill: var(--shell); }
.logo-red { fill: var(--accent); }
.logo-ring { fill: none; stroke: var(--shell); stroke-width: 2; }
.nav-item { color: var(--shell-ink-2); font-weight: 600; font-size: 14px; }
.nav-item:hover { color: var(--shell-ink); background: rgba(255, 255, 255, 0.08); }
.nav-item[aria-selected="true"] { color: var(--shell-ink); background: rgba(255, 255, 255, 0.16); }
.header .btn.primary { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

/* Buttons: Cachino Online's. Primary is the accent red with its own ink. */
.btn { border-radius: var(--r); font-weight: 600; background: var(--surface); }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.header .btn { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); opacity: 1; }
.btn.danger { background: var(--surface); }
.btn.ghost { background: transparent; }
.btn.sm { border-radius: var(--r-sm); }
.seg { border-radius: var(--r); }
.seg button { border-radius: var(--r-sm); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 25, 26, 0.16); }
.icon-btn { border-radius: var(--r); }
.input, .field input, .field select { border-radius: var(--r); background: var(--surface); }
.input:focus, .field input:focus, .field select:focus { border-color: var(--link); box-shadow: 0 0 0 3px color-mix(in srgb, var(--link) 22%, transparent); }
.modal { border-radius: var(--r-lg); box-shadow: var(--shadow-lift); }
.bn-item[aria-selected="true"] svg { color: var(--link); }
.bottom-nav { background: color-mix(in srgb, var(--surface) 92%, transparent); }

/* The leaderboard: games, ROI and average buy-in beside the rest. */
.lb-row { grid-template-columns: 26px minmax(150px, 1.6fr) 56px 64px 54px 80px 64px 72px 80px 80px 64px 140px; }
@media (max-width: 1239px) {
  .lb-row { grid-template-columns: 26px minmax(140px, 1.6fr) 56px 64px 54px 78px 64px 72px 64px 130px; }
  .lb-row .x-best, .lb-row .x-worst { display: none; }
}
@media (max-width: 1099px) {
  .lb-row { grid-template-columns: 26px minmax(130px, 1.6fr) 52px 60px 52px 76px 60px 120px; }
  .lb-row .x-in, .lb-row .x-best, .lb-row .x-worst { display: none; }
}
#records { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Finding sessions: one row of filters, wrapping on a phone. */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -4px 0 12px; }
.filters .input { height: 36px; padding: 0 10px; font-size: 13.5px; width: auto; }
.filters select.input { padding-right: 28px; max-width: 180px; }
.search { position: relative; flex: 1 1 200px; min-width: 160px; display: block; }
.search svg { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; color: var(--muted); pointer-events: none; }
.search .input { width: 100%; padding-left: 32px; }

/* A session's tags: the game, the blinds, where it was played. */
.tag { display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--ink-2); font-size: 11px; font-weight: 650; line-height: 18px; vertical-align: 1px; white-space: nowrap; }
.det-about { margin: -2px 0 6px; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.det-from { margin: 0 0 12px; }

/* Empty and no-match states say what to do next. */
.empty { display: grid; gap: 4px; justify-items: center; padding: 28px 12px; }
.empty b { color: var(--ink); font-size: 14.5px; }
.empty .link { color: var(--link); font-size: inherit; text-decoration: underline; }
.callout.bad { border-color: color-mix(in srgb, var(--neg) 45%, transparent); background: var(--neg-soft); }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout.dup { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }

/* The editor: the game and its blinds side by side. */
.blinds { display: flex; align-items: center; gap: 6px; }
.blinds input { min-width: 0; }
.blinds i { color: var(--muted); font-style: normal; }
.field small { font-weight: 400; color: var(--muted); }

/* Importing a game: the check, then who each player is. */
.imp-text { width: 100%; min-height: 140px; padding: 10px 12px; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; resize: vertical; }
.imp-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.imp-game { margin-top: 14px; }
.imp-h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.imp-h span { color: var(--muted); font-size: 12.5px; }
.imp-list .det-head, .imp-list .det-row { grid-template-columns: minmax(0, 1fr) minmax(120px, 160px) 64px 64px 76px; }
.imp-is { display: grid; gap: 2px; text-align: left !important; }
.input.sm { height: 32px; padding: 0 8px; font-size: 13px; }

/* Merging two players. */
.merge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.merge-row .input { flex: 1 1 140px; width: auto; height: 36px; }

/* The footer: whose app this is, and where the games are played. */
.site-foot { max-width: 1240px; margin: 0 auto; padding: 4px 24px 32px; display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 12.5px; }
.site-foot a { margin-left: auto; color: var(--link); font-weight: 600; text-decoration: none; }
.site-foot a:hover { text-decoration: underline; }

@media (max-width: 859px) {
  .brand-name { font-size: 17px; }
  .page-head h1 { font-size: 22px; }
  #records { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters select.input { flex: 1 1 120px; max-width: none; }
  .imp-list .det-head, .imp-list .det-row { grid-template-columns: minmax(0, 1fr) minmax(104px, 130px) 64px; }
  .imp-list .det-head span:nth-child(3), .imp-list .det-head span:nth-child(4),
  .imp-list .det-row > span:nth-child(3), .imp-list .det-row > span:nth-child(4) { display: none; }
  .wrap { padding-bottom: 16px; }
  .site-foot { padding: 0 14px calc(92px + env(safe-area-inset-bottom)); }
}
