/* Steam Family Tracker
   One idea carries the whole interface: every family member owns a color, and anything
   that belongs to them (their games, their share of someone's playtime) wears it.
   Steam Families hold at most six people, hence six member hues. */

:root {
  /* Palette: #171A21 ground, #2A475E blue-slate, #66C0F4 accent, #F2F4F7 / #FFFFFF text.
     Layers between ground and slate are blends of the two. Dark is the default: evenings,
     next to the Steam client. */
  --bg: #171A21;
  --panel: #1D2833;
  --surface: #223343;
  --raise: #2A475E;
  --line: #273C4F;
  --track: #1F2D3A;

  /* Text */
  --ink: #F2F4F7;
  --ink-strong: #FFFFFF;
  --ink-2: #C5CDD6;
  --quiet: #93A3B3;

  /* Roles */
  --accent: #66C0F4;
  --accent-ink: #171A21;
  --accent-soft: rgba(102, 192, 244, 0.14);
  --good: #7ee08a;
  --warn: #ff8a9b;

  /* Members (the first is the palette's accent) */
  --m0: #66C0F4;
  --m1: #ffb84d;
  --m2: #ff6f91;
  --m3: #7ee08a;
  --m4: #b38cff;
  --m5: #f2e35c;

  /* Type: one family (Archivo), two voices. Text runs at normal width; the display voice
     (names, page titles, the big hour figures) runs expanded and heavy, like box-art lettering.
     Fixed scale, ~1.25 ratio, 14px floor. */
  --font: 'Archivo', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --t-meta: 0.875rem;
  --t-small: 0.9375rem;
  --t-body: 1.0625rem;
  --t-title: 1.25rem;
  --t-section: 1.75rem;
  --t-figure: 2rem;
  --t-stat: 2.5rem;
  --t-name: 3rem;
  --t-page: 3.75rem;

  /* Space: 4px base */
  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: 4rem;

  --r-sm: 6px;
  --r-md: 10px;
  --page: 70rem;
  --gutter: var(--s5);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    /* Same palette, flipped: #F2F4F7 ground, white panels, #171A21 text, #2A475E accent
       (#66C0F4 is too light to read on white). */
    --bg: #F2F4F7;
    --panel: #E6EBF0;
    --surface: #FFFFFF;
    --raise: #F7F9FB;
    --line: #D3DCE4;
    --track: #DFE6EC;
    --ink: #171A21;
    --ink-strong: #171A21;
    --ink-2: #2A475E;
    --quiet: #5B6B7A;
    --accent: #2A475E;
    --accent-ink: #FFFFFF;
    --accent-soft: rgba(42, 71, 94, 0.1);
    --good: #23853a;
    --warn: #b0263d;
    --m0: #1E88C7;
    --m1: #c77d00;
    --m2: #d63d66;
    --m3: #2e9e45;
    --m4: #7a52d6;
    --m5: #8f8100;
    color-scheme: light;
  }
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scrollbar-color: var(--raise) var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t-body)/1.55 var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.003em; /* light text on dark reads better a touch looser */
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent);
  accent-color: var(--accent);
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }

/* Display voice: expanded + heavy. Used for titles, names and headline numbers only. */
h1, .display, .figures strong, .stats dd, .profile-head h2, .game-head h2 {
  font-stretch: 125%; font-weight: 800; letter-spacing: -0.03em;
}
h1 { font-size: var(--t-page); line-height: 0.98; color: var(--ink-strong); }
h2 { font-size: var(--t-section); line-height: 1.15; font-weight: 700; font-stretch: 112%; letter-spacing: -0.02em; }

a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code { font-size: 0.9em; }
img { max-width: 100%; }

.quiet { color: var(--quiet); font-size: var(--t-small); max-width: 68ch; }
.lede { color: var(--ink-2); font-size: var(--t-small); max-width: 62ch; }
.warn { color: var(--warn); font-size: var(--t-small); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { color: var(--quiet); padding: var(--s4) 0; list-style: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

.skip-link {
  position: absolute; left: var(--s4); top: -3rem; z-index: 10;
  background: var(--accent); color: var(--accent-ink); padding: var(--s2) var(--s4); border-radius: var(--r-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: var(--s4); }

/* ---------- Controls ---------- */

button {
  font: 500 var(--t-small)/1 var(--font);
  min-height: 2.5rem;
  padding: 0 var(--s4);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
button:hover { background: var(--raise); border-color: var(--quiet); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
button[aria-busy="true"] { cursor: progress; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--surface); color: var(--ink); }
button.more { margin-top: var(--s4); align-self: flex-start; }

input, textarea, select {
  font: var(--t-body) var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--s2) var(--s3);
  min-height: 2.5rem;
}
input:hover { border-color: var(--quiet); }
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input::placeholder { color: var(--quiet); }

/* ---------- Header ---------- */

.top { max-width: var(--page); margin: 0 auto; padding: var(--s5) var(--gutter) 0; }
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 2.5rem; }

/* The mark: a shelf of three games, each in a member's color; the leaning one tips a little on hover. */
.brand {
  display: inline-flex; align-items: center; gap: var(--s2);
  color: var(--ink-strong); font-weight: 800; font-stretch: 125%; letter-spacing: -0.02em;
  font-size: var(--t-body); text-decoration: none; white-space: nowrap;
}
.logo { width: 30px; height: 30px; flex: none; display: block; }
.logo .b1 { fill: var(--m0); }
.logo .b2 { fill: var(--m1); }
.logo .b3 { fill: var(--m2); transform: translate(658px, 814px) rotate(-10deg); transition: transform 300ms var(--ease); }
.logo-lg { width: 80px; height: 80px; margin-left: -8px; }
@media (prefers-reduced-motion: no-preference) {
  .brand:hover .logo .b3 { transform: translate(658px, 814px) rotate(-14deg); }
}

.top-actions { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
/* Nav: plain words; the current page gets a straight rule under the word, nothing boxed. */
.nav { display: flex; gap: var(--s5); margin-right: var(--s5); }
.nav a {
  position: relative; padding: var(--s2) 0; color: var(--ink-2);
  text-decoration: none; font-weight: 500; font-size: var(--t-small);
}
.nav a::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform 200ms var(--ease);
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current] { color: var(--ink); font-weight: 600; }
.nav a[aria-current]::after { transform: scaleX(1); }
.nav a:focus-visible { outline-offset: 4px; border-radius: 0; }
.me {
  display: inline-flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2) var(--s1) var(--s1);
  border-radius: var(--r-sm); color: var(--ink); text-decoration: none; font-weight: 500; font-size: var(--t-small); min-width: 0;
}
.me:hover { background: var(--surface); }
.me img { width: 28px; height: 28px; border-radius: 6px; flex: none; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12ch; }

.family-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s5) var(--s6);
  padding: var(--s8) 0 var(--s6); border-bottom: 1px solid var(--line);
}
.family-id { display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }
.family-id h1 { overflow-wrap: anywhere; }
.family-sync { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.sync-line { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: var(--t-small); color: var(--ink-2); text-align: right; }
.sync-line #sync-status { color: var(--quiet); font-size: var(--t-meta); max-width: 40ch; }

/* Faces: the family at a glance; a green dot marks who signed in. */
.faces { list-style: none; padding: 0 0 0 4px; display: flex; flex-wrap: wrap; gap: var(--s3); }
.faces a { position: relative; display: block; border-radius: 10px; }
.faces .face { width: 40px; height: 40px; border-radius: 10px; display: block; box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c); }
.faces b.face { display: grid; place-items: center; background: var(--c); color: var(--accent-ink); font-weight: 700; }
.faces a.is-connected::after {
  content: ''; position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 0 2px var(--bg);
}
.faces a:hover { z-index: 1; transform: translateY(-2px); transition: transform 150ms var(--ease); }

/* ---------- Page ---------- */

main { max-width: var(--page); margin: 0 auto; padding: var(--s6) var(--gutter) var(--s8); }
.view { display: flex; flex-direction: column; gap: var(--s7); }
body:not([data-view="overview"]) main { padding-top: var(--s5); }
#view-games { gap: var(--s4); }
#view-games .section-head { margin-top: var(--s3); }
#view-games .section-head h2 { font-size: var(--t-name); font-weight: 800; font-stretch: 125%; letter-spacing: -0.03em; line-height: 1; }
.view > section { display: flex; flex-direction: column; gap: var(--s2); }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--s2) var(--s5); }
.back { font-size: var(--t-small); text-decoration: none; margin-bottom: calc(-1 * var(--s5)); align-self: flex-start; color: var(--ink-2); }
.back:hover { color: var(--ink); }
.back::before { content: '‹'; margin-right: var(--s1); }

.page-error {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s5);
  padding: var(--s4) var(--s5); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--warn);
  margin-bottom: var(--s5);
}
.page-error p { color: var(--ink); max-width: 60ch; }

/* ---------- People, games, tags ---------- */

.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-meta); color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; min-width: 0; }
.legend li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16ch; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 6px; flex: none; }
.owners { display: inline-flex; gap: 3px; vertical-align: middle; }
.owners .swatch { margin: 0; }
a.person { color: inherit; text-decoration: none; white-space: nowrap; }
a.person:hover, a.game:hover span { text-decoration: underline; text-underline-offset: 0.2em; }
a.game { display: inline-flex; align-items: center; gap: var(--s3); color: inherit; text-decoration: none; min-width: 0; max-width: 100%; }
a.game img, a.game .noicon { width: 24px; height: 24px; border-radius: 4px; flex: none; background: var(--track); }
a.game span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: var(--t-meta); line-height: 1.6; padding: 0 var(--s2); border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; justify-self: start; }
.tag.own { color: var(--m3); }
.tag.family { color: var(--m1); }
.tag.other { color: var(--quiet); }
.tag.free { color: var(--ink-2); margin-left: var(--s2); }
.game-cell { display: inline-flex; align-items: center; min-width: 0; max-width: 100%; }

/* Switch: a real checkbox drawn as a track and knob. */
.switch { display: inline-flex; align-items: center; gap: var(--s2); font-size: var(--t-small); color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input {
  appearance: none; margin: 0; flex: none; width: 2.25rem; height: 1.25rem; min-height: 0; padding: 0;
  border-radius: 999px; border: 1px solid var(--line); background: var(--track); position: relative; cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.switch input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: calc(1.25rem - 6px); height: calc(1.25rem - 6px);
  border-radius: 50%; background: var(--ink-2); transition: transform 200ms var(--ease), background-color 150ms var(--ease);
}
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(1rem); background: var(--accent-ink); }
.switch:hover input { border-color: var(--quiet); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.est { color: var(--quiet); margin-right: 2px; cursor: help; font-weight: 400; }

/* ---------- The shelf: one equal-width bar per member ---------- */

.shelf-rows { list-style: none; padding: 0; margin-top: var(--s4); display: flex; flex-direction: column; }
.shelf-rows > li + li { border-top: 1px solid var(--line); }
.shelf-row {
  display: grid; grid-template-columns: minmax(10rem, 15rem) minmax(0, 1fr) 10rem; align-items: center; gap: var(--s5);
  padding: var(--s4) var(--s3); margin: 0 calc(-1 * var(--s3)); border-radius: var(--r-sm); color: inherit; text-decoration: none;
  transition: background-color 150ms var(--ease);
}
.shelf-row:hover { background: var(--panel); }
.who { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.who > img, .who > .initial { width: 36px; height: 36px; border-radius: 8px; flex: none; box-shadow: 0 0 0 2px var(--c); }
.who > .initial { display: grid; place-items: center; background: var(--c); color: var(--accent-ink); font-weight: 700; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-state { font-size: var(--t-meta); color: var(--quiet); display: inline-flex; align-items: center; gap: 6px; }
.who-state.is-connected { color: var(--good); }
.who-state.is-connected::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.bar { display: flex; height: 14px; background: var(--track); border-radius: 3px; overflow: hidden; min-width: 0; }
.bar .seg { background: var(--c); height: 100%; transform-origin: left; }
.bar .seg + .seg { box-shadow: inset 2px 0 0 var(--bg); }
.bar.is-empty { background: repeating-linear-gradient(-45deg, var(--track) 0 6px, transparent 6px 12px); opacity: 0.7; }
.figures { text-align: right; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; }
.figures strong { font-size: var(--t-figure); line-height: 1; }
.figures .unit { font-size: var(--t-small); font-weight: 600; font-stretch: 100%; letter-spacing: 0; color: var(--quiet); margin-left: 3px; }
.figures small { color: var(--quiet); font-size: var(--t-meta); }

@media (prefers-reduced-motion: no-preference) {
  .shelf-rows.grow .seg { animation: grow 600ms var(--ease) both; }
  @keyframes grow { from { transform: scaleX(0); } }
}

/* Loading: quiet placeholders where rows will land. */
.skeleton-row { height: 4.25rem; border-radius: var(--r-sm); background: var(--panel); margin: var(--s1) 0; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton-row { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.5; } }
}

.share-prompt {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3) var(--s5);
  margin-top: var(--s4); padding: var(--s4) var(--s5); border-radius: var(--r-md); background: var(--panel);
}
.share-prompt p { color: var(--ink-2); font-size: var(--t-small); max-width: 64ch; }

/* ---------- Lending balance + top games: one band, two columns ---------- */

.split {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  background: var(--panel); border-radius: var(--r-md);
}
.split > section { padding: var(--s5) var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.split > section + section { border-left: 1px solid var(--line); }
.balance, .top-games, .game-rows, .player-rows, .dlc-list { list-style: none; padding: 0; }

.balance-axis { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s4); font-size: var(--t-meta); color: var(--quiet); }
.balance-axis span:first-child { text-align: right; padding-right: var(--s2); }
.balance { margin-top: var(--s1); }
.balance li { display: grid; grid-template-columns: 1fr 1fr; align-items: center; column-gap: var(--s1); row-gap: var(--s1); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.balance .name { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: var(--s3); font-weight: 600; min-width: 0; }
.balance .name a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance .name a:hover { text-decoration: underline; }
.balance .net { font-weight: 500; font-size: var(--t-small); color: var(--quiet); white-space: nowrap; }
.balance .net.gives { color: var(--good); }
.half { height: 10px; background: var(--track); display: flex; }
.half.left { justify-content: flex-end; border-radius: 3px 0 0 3px; }
.half:not(.left) { border-radius: 0 3px 3px 0; }
.half i { display: block; height: 100%; background: var(--c); }
.half.left i { opacity: 0.5; }
.balance .amounts { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: var(--t-meta); color: var(--quiet); }

.top-games { margin-top: var(--s3); counter-reset: rank; }
.top-games li {
  counter-increment: rank;
  display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) auto; grid-template-areas: "rank game hrs" "rank meta hrs";
  column-gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line);
}
.top-games li::before { content: counter(rank); grid-area: rank; align-self: center; color: var(--quiet); font-size: var(--t-small); font-weight: 600; }
.top-games li.empty::before { content: none; }
.top-games a.game { grid-area: game; font-weight: 500; }
.top-games .meta { grid-area: meta; color: var(--quiet); font-size: var(--t-meta); padding-left: calc(24px + var(--s3)); }
.top-games .meta .owners { margin-right: 6px; }
.top-games .hrs { grid-area: hrs; align-self: center; font-weight: 600; }

/* ---------- Stats strip (profile + game) ---------- */

/* Even grid: --cols is set from the number of stats. Each cell draws its left and top rule;
   the container clips the outer ones, so dividers only appear between cells. */
.stats {
  display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden;
}
.stats div {
  padding: var(--s4) var(--s5); min-width: 0;
  border-left: 1px solid var(--line); border-top: 1px solid var(--line); margin: -1px 0 0 -1px;
}
.stats dt { color: var(--quiet); font-size: var(--t-meta); }
.stats dd { margin-top: var(--s2); font-size: var(--t-stat); font-stretch: 112%; line-height: 1; white-space: nowrap; }
.stats dd .unit { font-size: var(--t-small); font-weight: 600; font-stretch: 100%; letter-spacing: 0; color: var(--quiet); margin-left: 3px; }
.stats dd small { display: block; margin-top: var(--s2); font-size: var(--t-meta); font-weight: 400; font-stretch: 100%; color: var(--quiet); letter-spacing: 0; }

/* ---------- Profile ---------- */

.profile-head { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.profile-head .profile-id { flex: 1; min-width: 14rem; display: flex; flex-direction: column; gap: var(--s1); }
.profile-head h2 { font-size: var(--t-name); line-height: 1; overflow-wrap: anywhere; }
.who.big img.big, .who.big .initial.big { width: 80px; height: 80px; border-radius: 14px; box-shadow: 0 0 0 3px var(--c); font-size: 2rem; }
.who.big .initial.big { display: grid; place-items: center; background: var(--c); color: var(--accent-ink); font-weight: 700; }
.badges { margin-top: var(--s1); }
.profile-actions button { font-size: var(--t-small); }
.profile-bar { height: 12px; margin-top: calc(-1 * var(--s5)); }
.profile-legend { margin-top: calc(-1 * var(--s6)); }
.consent { font-size: var(--t-small); color: var(--ink-2); display: flex; align-items: center; gap: var(--s2); cursor: pointer; }
.consent input { width: 18px; height: 18px; min-height: 0; }

.game-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.game-rows .hrs, .player-rows .hrs { text-align: right; font-weight: 600; white-space: nowrap; }
.game-rows .hrs small, .player-rows .hrs small { display: block; font-weight: 400; font-size: var(--t-meta); color: var(--quiet); }

/* Segmented tabs */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin: var(--s2) 0 var(--s3); background: var(--panel); border-radius: var(--r-sm); align-self: flex-start; }
.tabs button { min-height: 2.25rem; border: 0; background: transparent; color: var(--ink-2); font-size: var(--t-small); padding: 0 var(--s3); border-radius: 4px; }
.tabs button:hover { color: var(--ink); background: var(--surface); }
.tabs button[aria-selected="true"] { background: var(--raise); color: var(--ink); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding-block: var(--s3); }
tbody tr:hover td { background: var(--panel); }
th { color: var(--quiet); font-weight: 500; font-size: var(--t-meta); }
td.num, th.num { text-align: right; }
td:first-child { max-width: 22rem; }
td:first-child a.game { max-width: 22rem; }
.sort-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: var(--s1); border-radius: 4px; padding: 2px 0; }
.sort-btn:hover { color: var(--ink); }
.sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
th[aria-sort="ascending"] .sort-btn, th[aria-sort="descending"] .sort-btn { color: var(--ink); font-weight: 600; }
.sort-btn .arrow { font-size: 10px; min-width: 10px; color: var(--accent); }
th.num .sort-btn { flex-direction: row-reverse; }

/* ---------- Game page ---------- */

.game-head { display: flex; gap: var(--s5); align-items: center; flex-wrap: wrap; }
.game-head .capsule { width: 320px; max-width: 100%; aspect-ratio: 460 / 215; border-radius: var(--r-md); object-fit: cover; background: var(--track); }
.game-head > div { flex: 1; min-width: 15rem; display: flex; flex-direction: column; gap: var(--s2); }
.game-head h2 { font-size: var(--t-name); line-height: 1; overflow-wrap: anywhere; }
.game-head p { color: var(--ink-2); }
.player-rows li { display: grid; grid-template-columns: minmax(8rem, 12rem) minmax(0, 1fr) auto 6rem; align-items: center; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.player-rows a.person { overflow: hidden; text-overflow: ellipsis; }
.player-rows .bar { height: 10px; }
.dlc-list li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.dlc-list a { color: inherit; min-width: 0; overflow-wrap: anywhere; }
.dlc-owners { text-align: right; font-size: var(--t-small); flex: none; max-width: 50%; }

/* ---------- Games list ---------- */

.filters { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: center; }
.search { flex: 1; min-width: 12rem; max-width: 24rem; }
.search input { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips button { min-height: 2.25rem; padding: 0 var(--s3); border-radius: 999px; background: transparent; color: var(--ink-2); }
.chips button:hover { color: var(--ink); background: var(--surface); }
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* ---------- Sign in ---------- */

.view > .signin { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: var(--s7); align-items: start; padding-top: var(--s7); }
.signin-text { display: flex; flex-direction: column; gap: var(--s4); max-width: 60ch; }
.signin-text h1 { font-size: var(--t-page); }
.signin-text > p:first-of-type { font-size: var(--t-title); color: var(--ink-2); }
.signin-text ol { padding-left: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.signin-text ol li::marker { color: var(--accent); font-weight: 600; }
.qr-box .note {
  font-size: var(--t-meta); line-height: 1.5; color: var(--ink-2); text-align: left;
  padding-top: var(--s3); border-top: 1px solid var(--line); width: 100%;
}
.qr-box .note strong { color: var(--ink); }
.invite { display: flex; flex-direction: column; gap: var(--s2); font-size: var(--t-small); color: var(--ink-2); }
.invite input { width: min(22rem, 100%); }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s5); border-radius: var(--r-md); background: var(--panel); text-align: center; position: sticky; top: var(--s5); }
.qr { width: 15rem; max-width: 100%; aspect-ratio: 1; border-radius: var(--r-sm); background: var(--track); display: grid; place-items: center; overflow: hidden; }
.qr svg { width: 100%; height: 100%; background: #fff; display: block; }
.qr:empty::after { content: 'QR code appears here'; color: var(--quiet); font-size: var(--t-small); padding: var(--s4); }
#signin-status { min-height: 1.5em; color: var(--ink-2); }

/* ---------- Invites ---------- */

.invites { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s5); border-top: 1px solid var(--line); }
.invites h2 { font-size: var(--t-title); }
.invite-form { display: flex; flex-wrap: wrap; gap: var(--s2); }
.invite-form input { flex: 1; min-width: 12rem; max-width: 24rem; }
.invite-list { list-style: none; padding: 0; }
.invite-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2) var(--s4); padding: var(--s2) 0; border-top: 1px solid var(--line); font-size: var(--t-small); }
.invite-list input { width: min(32rem, 100%); font-size: var(--t-meta); }

/* ---------- Narrow screens ---------- */

@media (max-width: 760px) {
  :root { --gutter: var(--s4); --t-page: 2.5rem; --t-name: 2.125rem; --t-stat: 2rem; --t-section: 1.375rem; --t-figure: 1.625rem; }
  .family-head { padding-top: var(--s6); }
  .top { padding-top: var(--s4); }
  .top-bar { flex-wrap: wrap; }
  .top-actions { width: 100%; justify-content: space-between; }
  .nav { margin-right: 0; }
  .family-head { padding-top: var(--s5); align-items: flex-start; }
  .family-sync { width: 100%; justify-content: space-between; }
  .sync-line { align-items: flex-start; text-align: left; }
  main { padding-top: var(--s5); }
  .view { gap: var(--s6); }
  .shelf-row { grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2) var(--s3); align-items: start; }
  .who-state { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
  .shelf-row .bar { grid-column: 1 / -1; grid-row: 2; }
  .split > section + section { border-left: 0; border-top: 1px solid var(--line); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div { padding: var(--s3) var(--s3); }
  .stats dd { font-size: 1.625rem; font-stretch: 100%; }
  .player-rows li { grid-template-columns: minmax(0, 1fr) auto auto; }
  .player-rows .bar { grid-column: 1 / -1; grid-row: 2; }
  .game-rows li { grid-template-columns: minmax(0, 1fr) auto; }
  .game-rows .tag { display: none; }
  .view > .signin { grid-template-columns: 1fr; gap: var(--s5); padding-top: var(--s4); }
  .qr-box { order: -1; position: static; }
  .me span { display: none; }
}

@media (forced-colors: active) {
  .bar .seg, .half i, .swatch { forced-color-adjust: none; }
}
