:root {
  color-scheme: light dark;
  --bg: Canvas;
  --fg: CanvasText;
  --muted: color-mix(in srgb, CanvasText 55%, Canvas);
  --line: color-mix(in srgb, CanvasText 15%, Canvas);
  --panel: color-mix(in srgb, CanvasText 4%, Canvas);
  --accent: #7c5cbf;        /* tabletop purple */
  --win: #2e9e5b;
  --loss: #d2603a;
  --gold: #c9962b;
  --blue: #3f8fe0;
  --teal: #0ea5a4;
}

* { box-sizing: border-box; }

body {
  font: 15px/1.5 -apple-system, system-ui, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  color: var(--fg);
}

/* ── top bar + nav ────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem;
  border-bottom: 1px solid var(--line); padding-bottom: .75rem; margin-bottom: 1.25rem;
}
h1 { font-size: 1.4rem; margin: 0; }
.subtle { color: var(--muted); font-weight: 400; font-size: .9rem; }

.daynav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.navbtn {
  text-decoration: none; color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  padding: .1rem .55rem; line-height: 1.6;
  font: inherit; background: var(--bg); cursor: pointer;
}
.navbtn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.total { color: var(--muted); margin: 0 0 1.25rem; }
.periodnav { margin-left: .5rem; display: inline-flex; gap: .3rem; flex-wrap: wrap; }
.periodnav .navbtn { padding: .12rem .5rem; font-size: .8rem; }
.sortbar { display: flex; align-items: center; gap: .45rem; margin: -.75rem 0 1.25rem; font-size: .85rem; }
.sortbar .sortlabel { color: var(--muted); }
.sortbar select { font: inherit; font-size: .85rem; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); cursor: pointer; }
.sortbar select:hover { border-color: var(--accent); }

a.drill { color: var(--fg); text-decoration: none; }
a.drill:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 1.25rem 0; }

/* ── cards ────────────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; border-left: 4px solid var(--muted); }
.card-kind { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.card-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; word-break: break-word; }
.card-pct { color: var(--muted); font-size: .82rem; }
.accent-a { border-left-color: var(--accent); }
.accent-b { border-left-color: var(--blue); }
.accent-c { border-left-color: var(--teal); }
.accent-d { border-left-color: var(--gold); }
.accent-e { border-left-color: var(--win); }

/* ── panels ───────────────────────────────────────────────────────────────── */
.panel { margin-bottom: 2rem; }
.panelhead { font-size: .95rem; margin: 0 0 .8rem; font-weight: 600; }
.metafoot { margin: .7rem 0 0; font-size: .85rem; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.cols .col { margin-bottom: 0; }
@media (max-width: 720px) { .cols { grid-template-columns: 1fr; } }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.meta { color: var(--muted); font-size: .9rem; }

/* ── most-played bars ─────────────────────────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: .5rem; }
.barrow { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--fg); padding: .15rem 0; }
.barrow:hover .barname { text-decoration: underline; }
.barthumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; flex: none; background: var(--panel); }
.barthumb.placeholder { background: var(--panel); }
.barbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.barname { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bartrack { height: .5rem; border-radius: 4px; background: color-mix(in srgb, CanvasText 7%, Canvas); overflow: hidden; }
.barfill { display: block; height: 100%; background: var(--accent); }
.barval { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; flex: none; }

/* ── plays list ───────────────────────────────────────────────────────────── */
.plays { display: flex; flex-direction: column; gap: .55rem; }
.playcard { display: flex; gap: .7rem; text-decoration: none; color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; }
.playcard:hover { background: var(--panel); }
.playthumb { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; flex: none; background: var(--panel); }
.playthumb.placeholder { background: var(--panel); }
.playbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.playtop { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.playgame { font-weight: 600; }
.playmeta { color: var(--muted); font-size: .82rem; }
.result { font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; white-space: nowrap; flex: none; }
.result.win { color: var(--win); border: 1px solid color-mix(in srgb, var(--win) 45%, transparent); }
.result.loss { color: var(--loss); border: 1px solid color-mix(in srgb, var(--loss) 45%, transparent); }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .15rem; }
.chip { font-size: .76rem; padding: .05rem .45rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.chip.won { color: var(--fg); border-color: color-mix(in srgb, var(--gold) 55%, transparent); background: color-mix(in srgb, var(--gold) 12%, Canvas); }
.chip.me { font-weight: 700; color: var(--fg); }
.chip.bot { border-style: dashed; }
.crown { color: var(--gold); margin-right: .1rem; }
.botmark { margin-right: .1rem; }
.chip-role { color: var(--muted); font-size: .9em; margin-left: .2rem; }
.chip-score { margin-left: .3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--fg); }
.botbadge { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .45rem; margin-left: .3rem; vertical-align: middle; }
.botform { margin-top: .5rem; }
.botlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.botrow { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; border-bottom: 1px solid var(--line); padding: .35rem .1rem; }

/* ── partners ─────────────────────────────────────────────────────────────── */
.partners { display: flex; flex-direction: column; gap: .4rem; }
.partner { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; text-decoration: none; color: var(--fg); border-bottom: 1px solid var(--line); padding: .35rem .1rem; }
.partner:hover { background: var(--panel); }
.partner-name { font-weight: 600; }
.partner-meta { color: var(--muted); font-size: .82rem; text-align: right; }

/* ── collection shelf ─────────────────────────────────────────────────────── */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; }
.gamecard { display: flex; flex-direction: column; text-decoration: none; color: var(--fg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.gamecard:hover { border-color: var(--accent); }
.gamecard.unplayed { opacity: .85; }
.gamethumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--panel); }
.gamethumb.placeholder { background: var(--panel); }
.gameinfo { padding: .55rem .6rem .65rem; display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.gamename { font-weight: 600; font-size: .9rem; line-height: 1.25; }
.gamemeta { color: var(--muted); font-size: .78rem; display: flex; gap: .4rem; align-items: center; }
.star { color: var(--gold); white-space: nowrap; }
.gamefoot { display: flex; justify-content: space-between; gap: .4rem; font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.gamefoot .cost { color: var(--accent); }

/* ── game detail ──────────────────────────────────────────────────────────── */
.gameheadbody { min-width: 0; }
.gametitle { font-size: 1.5rem; margin: 0 0 .25rem; }
.gamesub { margin: .1rem 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.gamecover { width: 150px; border-radius: 10px; object-fit: cover; flex: none; background: var(--panel); }
.bgglink { color: var(--accent); }

/* hero header — the game's art blurred behind its cover (gradient fallback) */
.gamehero { position: relative; overflow: hidden; border-radius: 16px; margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #14102a));
  box-shadow: 0 14px 34px -20px rgba(0,0,0,.6); }
.gamehero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  filter: blur(28px) saturate(1.35) brightness(.6); transform: scale(1.25); z-index: 0; }
.gamehero::after { content: ""; position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 50%, transparent), rgba(10,8,20,.74)); }
.gamehero-inner { position: relative; z-index: 1; display: flex; gap: 1.25rem; padding: 1.4rem 1.5rem; align-items: flex-start; }
.gamehero .gamecover { width: 134px; border-radius: 12px; box-shadow: 0 10px 26px -8px rgba(0,0,0,.65); background: rgba(255,255,255,.08); }
.gamehero .gameheadbody { color: #fff; padding-top: .15rem; }
.gamehero .gametitle { font-size: 1.7rem; color: #fff; text-shadow: 0 1px 14px rgba(0,0,0,.4); line-height: 1.15; }
.gamehero .gamesub { color: rgba(255,255,255,.95); }
.gamehero .gamesub.muted { color: rgba(255,255,255,.72); font-size: .9rem; }
.gamehero .star { color: #ffd764; }
.herotags { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0 0; }
.herotag { font-size: .8rem; color: #fff; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28); border-radius: 999px; padding: .12rem .7rem; }
.herotag a, .herolink { color: #fff; }
.herolink { text-decoration: none; font-size: .85rem; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,.5); }
.herolink:hover { border-bottom-color: #fff; }
@media (max-width: 560px) { .gamehero-inner { flex-direction: column; } .gamehero .gamecover { width: 120px; } }

/* table-shots gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: .55rem; }
.shot { position: relative; display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); }
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.shot:hover img, .shot:focus-visible img { transform: scale(1.06); }
.shot-cap { position: absolute; inset: auto 0 0 0; padding: 1rem .5rem .4rem; display: flex; flex-direction: column; gap: .05rem;
  background: linear-gradient(to top, rgba(0,0,0,.75), transparent); color: #fff; opacity: 0; transition: opacity .2s ease; }
.shot:hover .shot-cap, .shot:focus-visible .shot-cap { opacity: 1; }
.shot-caption { font-size: .76rem; font-weight: 600; line-height: 1.2; }
.shot-date { font-size: .68rem; color: rgba(255,255,255,.82); }

/* pure-CSS lightbox (:target) — no JS */
.lightbox { position: fixed; inset: 0; z-index: 200; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; padding: 2.5rem 1.5rem; background: rgba(8,6,14,.9); backdrop-filter: blur(4px); cursor: zoom-out; }
.lightbox:target { display: flex; animation: lb-fade .18s ease; }
@keyframes lb-fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox-backdrop { position: absolute; inset: 0; z-index: 0; }
.lightbox-imglink { position: relative; z-index: 1; line-height: 0; display: block; }
.lightbox-img { max-width: 94vw; max-height: 82vh; object-fit: contain; border-radius: 10px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.85); }
.lightbox-meta { position: relative; z-index: 1; display: flex; align-items: center; gap: .7rem; color: #fff; font-size: .85rem; cursor: default; }
.lightbox-caption { font-weight: 600; }
.lightbox-meta .subtle { color: rgba(255,255,255,.7); }
.lightbox-edit { color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.5); }
.lightbox-edit:hover { border-bottom-color: #fff; }

.leaders td { padding: .35rem .5rem; }
.leaders tr.me td { font-weight: 700; }
.playertable .pname { font-weight: 600; }
.playertable tr td.num { font-variant-numeric: tabular-nums; }

/* ── calendar heatmap ─────────────────────────────────────────────────────── */
.heatmap { max-width: 100%; height: auto; }
.heat-month { fill: var(--muted); font-size: 10px; }
.hcell { stroke: color-mix(in srgb, var(--fg) 6%, transparent); }
.heat-empty { fill: var(--panel); }
.heat-1 { fill: color-mix(in srgb, var(--accent) 24%, Canvas); }
.heat-2 { fill: color-mix(in srgb, var(--accent) 44%, Canvas); }
.heat-3 { fill: color-mix(in srgb, var(--accent) 64%, Canvas); }
.heat-4 { fill: color-mix(in srgb, var(--accent) 82%, Canvas); }
.heat-5 { fill: var(--accent); }
.heat-legend { display: flex; align-items: center; gap: .25rem; font-size: .8rem; margin-top: .6rem; }
.hswatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; }
.hswatch.heat-1 { background: color-mix(in srgb, var(--accent) 24%, Canvas); }
.hswatch.heat-2 { background: color-mix(in srgb, var(--accent) 44%, Canvas); }
.hswatch.heat-3 { background: color-mix(in srgb, var(--accent) 64%, Canvas); }
.hswatch.heat-4 { background: color-mix(in srgb, var(--accent) 82%, Canvas); }
.hswatch.heat-5 { background: var(--accent); }

/* ── import form ──────────────────────────────────────────────────────────── */
.import-form { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.import-form input[type="file"] { font: inherit; }
.import-form button { font: inherit; padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
.okbox { color: var(--win); border: 1px solid color-mix(in srgb, var(--win) 45%, transparent); border-radius: 8px; padding: .6rem .8rem; background: color-mix(in srgb, var(--win) 8%, Canvas); }
.errbox { color: var(--loss); border: 1px solid color-mix(in srgb, var(--loss) 45%, transparent); border-radius: 8px; padding: .6rem .8rem; background: color-mix(in srgb, var(--loss) 8%, Canvas); }

/* ── write-side: forms, buttons, BGG search, recommender (app #7 v2) ───────── */
.logbtn { background: color-mix(in srgb, var(--accent) 14%, Canvas); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--fg); font-weight: 600; }
.logbtn:hover { background: color-mix(in srgb, var(--accent) 22%, Canvas); }

.btn-primary { font: inherit; padding: .35rem .9rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-small { font: inherit; font-size: .82rem; padding: .2rem .6rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; }
.btn-small.ghost { background: var(--bg); color: var(--fg); border-color: var(--line); }
.btn-danger { font: inherit; font-size: .85rem; padding: .25rem .7rem; border: 1px solid color-mix(in srgb, var(--loss) 55%, transparent); border-radius: 6px; background: color-mix(in srgb, var(--loss) 8%, Canvas); color: var(--loss); cursor: pointer; }

.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* log + meta forms */
.logform, .metaform, .recform, .bggsearch, .inlineadd, .baseform { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.fieldgrid { display: flex; flex-wrap: wrap; gap: .8rem; width: 100%; }
.field { display: flex; flex-direction: column; gap: .2rem; }
.field.wide { flex: 1 1 100%; }
.field.sm { width: 7rem; }
.flabel { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.logform input, .logform select, .logform textarea,
.metaform input, .recform input, .recform select, .bggsearch input, .inlineadd input, .baseform select {
  font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg);
}
.logform textarea { width: 100%; resize: vertical; }
.bggsearch input[type="search"] { min-width: 18rem; flex: 1; }
.checkfield { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; }
.formactions { display: flex; gap: .6rem; align-items: center; margin-top: .9rem; width: 100%; }

/* player rows in the log form */
.players-edit { margin: 1rem 0; width: 100%; }
.players-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .4rem; flex-wrap: wrap; }
.prow { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.pname-in { flex: 2; min-width: 8rem; font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.pscore-in { width: 6rem; font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.prole-in { flex: 1; min-width: 6rem; font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); }
.pwin { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.pbot { display: inline-flex; align-items: center; gap: .2rem; font-size: .85rem; color: var(--muted); white-space: nowrap; }

/* ── play photos ──────────────────────────────────────────────────────────── */
/* upload input on the log/edit form */
.photo-add { margin: 1rem 0 .25rem; display: flex; flex-direction: column; gap: .35rem; width: 100%; }
.photo-in { font: inherit; color: var(--muted); }
/* thumbnails on a play card (dashboard / game / player) */
.playphotos { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.playphoto { display: block; line-height: 0; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.playphoto img { width: 64px; height: 64px; object-fit: cover; display: block; background: var(--panel); transition: transform .15s ease; }
.playphoto:hover img { transform: scale(1.05); }
/* the editable photo grid on the edit form */
.photostrip { display: flex; flex-wrap: wrap; gap: .6rem; }
.photothumb { position: relative; line-height: 0; }
.photothumb img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.photodel { position: absolute; top: -.4rem; right: -.4rem; margin: 0; }
.photodelbtn { cursor: pointer; width: 1.4rem; height: 1.4rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--loss); font-size: .8rem; line-height: 1; padding: 0; display: flex; align-items: center; justify-content: center; }
.photodelbtn:hover { background: var(--loss); color: #fff; border-color: var(--loss); }

.expansions-pick { margin: .6rem 0; width: 100%; }
.expchecks { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .3rem; }
.expcheck { display: inline-flex; align-items: center; gap: .3rem; font-size: .88rem; }

.metaextra { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: .8rem; }

/* BGG search results */
.bggrows { display: flex; flex-direction: column; margin-top: .8rem; }
.bggrow { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .4rem .1rem; border-bottom: 1px solid var(--line); }
.bggname { min-width: 0; }
.addone { margin: 0; }

/* play history edit link + restructured play card */
.playthumblink { flex: none; line-height: 0; }
.playgame { font-weight: 600; color: var(--fg); text-decoration: none; }
.playgame:hover { text-decoration: underline; }
.playtopright { display: inline-flex; align-items: center; gap: .5rem; flex: none; }
.editlink { font-size: .74rem; color: var(--muted); text-decoration: none; }
.editlink:hover { text-decoration: underline; color: var(--accent); }
.expused { color: var(--accent); font-size: .8rem; margin-left: .3rem; }

/* expansions list on the game page */
.explist { display: flex; flex-direction: column; }
.exprow { display: flex; justify-content: space-between; gap: .6rem; padding: .4rem .1rem; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--fg); }
.exprow:hover { background: var(--panel); }
.expname { font-weight: 600; }
.ownedtag.exp { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }

/* notes cross-app link */
.noteslink { text-decoration: none; margin-left: .35rem; font-size: .9rem; opacity: .8; }
.noteslink:hover { opacity: 1; }

/* recommender pick */
.pickcard { display: flex; gap: 1rem; text-decoration: none; color: var(--fg); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 12px; padding: .8rem; background: color-mix(in srgb, var(--accent) 6%, Canvas); }
.pickthumb { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; flex: none; }
.pickbody { display: flex; flex-direction: column; gap: .25rem; justify-content: center; }
.pickname { font-size: 1.2rem; font-weight: 700; }
.picksub { font-size: .9rem; }

/* ── player profile: trend chart + best/worst (app #7 v3) ─────────────────── */
.playerhead { margin-bottom: 1.25rem; }
.mebadge { font-size: .68rem; background: var(--accent); color: #fff; border-radius: 999px; padding: .05rem .5rem; margin-left: .45rem; vertical-align: middle; text-transform: uppercase; letter-spacing: .04em; }
.vsyou { color: var(--fg); }
.plink { color: var(--fg); text-decoration: none; font-weight: 600; }
.plink:hover { text-decoration: underline; }

.trend-chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-ylabel, .chart-xlabel { fill: var(--muted); font-size: 11px; }
.trend-area { fill: color-mix(in srgb, var(--accent) 12%, Canvas); stroke: none; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.trend-dot { fill: var(--accent); }
.trend-fit { stroke-width: 1.5; stroke-dasharray: 5 4; }
.trend-fit.up { stroke: var(--win); }
.trend-fit.down { stroke: var(--loss); }
.trend-fit.flat { stroke: var(--muted); }
.trendtag { font-size: .72rem; padding: .1rem .5rem; border-radius: 999px; margin-left: .45rem; font-weight: 600; }
.trendtag.up { color: var(--win); background: color-mix(in srgb, var(--win) 14%, Canvas); }
.trendtag.down { color: var(--loss); background: color-mix(in srgb, var(--loss) 14%, Canvas); }
.trendtag.flat { color: var(--muted); background: var(--panel); }

/* multi-line "scores over time" chart */
.sc-line { fill: none; stroke: var(--sc); stroke-width: 1.8; }
.sc-dot { fill: var(--sc); }
.sc-0 { --sc: #7c5cbf; } .sc-1 { --sc: #3f8fe0; } .sc-2 { --sc: #2e9e5b; }
.sc-3 { --sc: #d2603a; } .sc-4 { --sc: #c9962b; } .sc-5 { --sc: #0ea5a4; }
.sc-6 { --sc: #d05fa0; } .sc-7 { --sc: #8a8f4f; }
.sc-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; margin-top: .7rem; font-size: .84rem; }
.sc-legitem { display: inline-flex; align-items: center; gap: .35rem; color: var(--fg); }
.sc-swatch { width: .8rem; height: .8rem; border-radius: 3px; background: var(--sc); display: inline-block; flex: none; }
.sc-you { font-size: .62rem; background: var(--accent); color: #fff; border-radius: 999px; padding: .03rem .4rem; text-transform: uppercase; letter-spacing: .04em; }

.costgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .8rem; }
.bwcell { display: block; text-decoration: none; color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; }
.bwcell:hover { background: var(--panel); }
.bwcell.good { border-left: 4px solid var(--win); }
.bwcell.bad { border-left: 4px solid var(--loss); }
.bwname { font-size: 1.1rem; font-weight: 700; margin: .15rem 0; line-height: 1.2; }

/* ── H-index "one play away" games ────────────────────────────────────────── */
.hnote { margin: 0 0 .8rem; }
.hgames { display: flex; flex-wrap: wrap; gap: .55rem; }
.hgame { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: .3rem .65rem .3rem .3rem; }
.hgame:hover { background: var(--panel); border-color: var(--accent); }
.hthumb { width: 34px; height: 34px; border-radius: 5px; object-fit: cover; background: var(--panel); flex: none; }
.hthumb.placeholder { background: var(--panel); }
.hgamebody { display: flex; flex-direction: column; min-width: 0; }
.hgamename { font-weight: 600; font-size: .86rem; line-height: 1.2; }
.hgameplays { color: var(--muted); font-size: .74rem; }

/* ── collection "plays to H-index" badge ──────────────────────────────────── */
.hbadge { align-self: flex-start; margin-top: .3rem; background: color-mix(in srgb, var(--accent) 14%, Canvas); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent); font-size: .66rem; padding: .05rem .45rem; border-radius: 999px; white-space: nowrap; }

/* ── labeled bar lists (taste, win-rate-by-count) ─────────────────────────── */
.lbars { display: flex; flex-direction: column; gap: .45rem; }
.lbar { display: grid; grid-template-columns: 8.5rem 1fr auto; align-items: center; gap: .7rem; }
.lbar-label { font-weight: 600; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbar-track { height: .6rem; border-radius: 4px; background: color-mix(in srgb, CanvasText 7%, Canvas); overflow: hidden; }
.lbar-fill { display: block; height: 100%; background: var(--accent); min-width: 2px; }
.lbar-val { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .lbar { grid-template-columns: 6rem 1fr auto; } }

/* ── value / score cells (collection value, game scores) ──────────────────── */
.costcell { border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; text-decoration: none; color: var(--fg); }
a.costcell:hover { background: var(--panel); }

/* ── records: clickable cards ─────────────────────────────────────────────── */
.cardlink { text-decoration: none; color: var(--fg); display: block; }
.cardlink:hover { background: var(--panel); }

/* ── goals + 10×10 ────────────────────────────────────────────────────────── */
.goals { display: flex; flex-direction: column; gap: .9rem; }
.goalrow { display: flex; flex-direction: column; gap: .3rem; }
.goaltop { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.goallabel { font-weight: 600; }
.goalnums { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.goalnums strong { color: var(--fg); }
.goalbar { display: block; height: .85rem; border-radius: 5px; overflow: hidden; background: color-mix(in srgb, CanvasText 7%, Canvas); }
.goalbar.big { height: 1.05rem; }
.goalfill { display: block; height: 100%; background: var(--accent); }
.goalfill.met { background: var(--win); }
.pacetag { font-size: .72rem; padding: .05rem .45rem; border-radius: 999px; margin-left: .35rem; }
.pacetag.good { color: var(--win); background: color-mix(in srgb, var(--win) 14%, Canvas); }
.pacetag.bad { color: var(--loss); background: color-mix(in srgb, var(--loss) 14%, Canvas); }
.goalform { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; }
.goalform input { font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); width: 6rem; }

.challenge { gap: .5rem; }
.chrow { display: flex; align-items: center; gap: .4rem; }
.chgame { display: flex; flex: 1; align-items: center; gap: .7rem; text-decoration: none; color: var(--fg); min-width: 0; }
.chgame:hover .barname { text-decoration: underline; }
.barfill.met { background: var(--win); }
.done { color: var(--win); font-weight: 700; }
.cat-form { display: inline; margin: 0; }
.del { font: inherit; font-size: .85rem; cursor: pointer; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: .05rem .45rem; }
.del:hover { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 45%, transparent); }

/* ── rivalry matrix ───────────────────────────────────────────────────────── */
.matrixwrap { overflow-x: auto; }
.matrix { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: .3rem .45rem; text-align: center; font-size: .82rem; }
.matrix .mh { font-size: .72rem; color: var(--muted); font-weight: 600; }
.matrix .mrh { text-align: left; font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: var(--bg); }
.matrix .mrh.me { color: var(--accent); }
.mcell.win { background: color-mix(in srgb, var(--win) 22%, Canvas); }
.mcell.loss { background: color-mix(in srgb, var(--loss) 20%, Canvas); }
.mcell.even { background: color-mix(in srgb, var(--gold) 16%, Canvas); }
.mcell.self { background: var(--panel); color: var(--muted); }
.mcell.empty { color: var(--muted); }

/* ── taste refresh row ────────────────────────────────────────────────────── */
.refreshrow { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.refreshrow .panelhead { margin-bottom: .2rem; }

/* ── dashboard vertical chip stack (resurface) ────────────────────────────── */
.hgames.stack { flex-direction: column; }
.hgames.stack .hgame { width: 100%; }
