:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #f0ede7;
  --text: #1f1d1a;
  --muted: #6b665e;
  --border: #e2ddd4;
  --pill-border: #a89f90;
  --pill-bg: #e6e0d5;
  --accent: #b4532a;
  --accent-soft: #f6e3d8;
  --accent-text: #8a3b19;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 14px rgba(40, 30, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #211f1d;
    --surface-2: #2a2825;
    --text: #ece8e1;
    --muted: #a39d93;
    --border: #36332f;
    --pill-border: #6b665e;
    --pill-bg: #38352f;
    --accent: #e48a5c;
    --accent-soft: #3b2a20;
    --accent-text: #f2b08e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
header { padding: 28px 0 8px; }
.home { display: inline-block; margin-bottom: 6px; font-size: 14px; color: var(--muted); text-decoration: none; }
.home:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.bar {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  padding: 12px 4px; /* 4px each side so the bar also covers the open row's 2px outline ring beside it */
  border-bottom: 1px solid var(--border);
  margin: 0 -4px 20px;
}
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.controls input, .controls select, .controls button, .chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 0;
}
.controls input { flex: 1 1 220px; }
.tagbox {
  flex: 1 1 100%; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 3px 6px;
}
.tagbox:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.controls .tagbox input { flex: 1 1 100px; border: 0; background: none; padding: 4px; outline: none; }
.controls select { flex: 0 1 220px; }
.controls button { cursor: pointer; }
input:focus-visible, select:focus-visible, button:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.chips { display: contents; }
.chip { cursor: pointer; border-radius: 999px; padding: 2px 10px; font-size: 14px; }
.chip { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.count { margin-top: 10px; color: var(--muted); font-size: 14px; }
.list { display: flex; flex-direction: column; gap: 14px; }
.row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: clip; /* clips to the rounded corners without making a scroll container, so the header can stick */
  min-width: 0;
}
.rhead {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: start;
  padding: 16px; background: var(--surface); cursor: default;
}
.rhead[role="button"] { cursor: pointer; }
.rhead[role="button"]:hover { background: var(--surface-2); }
.rhead:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row.open { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.row.open .rhead { position: sticky; top: var(--bar-h, 0px); z-index: 1; border-bottom: 1px solid var(--border); }
.row.open.stuck .rhead { box-shadow: inset 0 3px 0 var(--accent); }
.rtitle { display: flex; align-items: center; gap: 10px; }
.name { margin: 0; font-size: 28px; line-height: 1.1; overflow-wrap: anywhere; flex: 0 1 auto; min-width: 0; }
.desc { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.pics { display: flex; gap: 8px; align-items: center; align-self: center; justify-content: flex-end; height: 120px; }
.pics img { display: block; height: 100%; width: auto; flex: none; border-radius: 6px; }
.pills { margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pill { flex: none; display: inline-flex; align-items: center; gap: .3em; min-height: 26px; border: 1px solid var(--pill-border); background: var(--pill-bg); border-radius: 999px; padding: 2px 10px; font-size: 13px; line-height: 1.3; color: var(--muted); white-space: nowrap; }
.pill b { color: var(--text); font-weight: 700; }
.pills.tags { margin-top: 6px; gap: 0; }
.tag {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 30px; height: 30px; font-size: 18px; line-height: 1; cursor: default;
}
.tip {
  position: fixed; z-index: 6; background: var(--text); color: var(--bg); border-radius: 6px; padding: 3px 8px;
  font-size: 12px; line-height: 1.3; white-space: nowrap; pointer-events: none;
}
.tablewrap { overflow-x: auto; }
table.games { width: 100%; border-collapse: collapse; }
.games th, .games td { padding: 8px 14px; text-align: left; vertical-align: middle; }
.games th { background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--muted); }
.games th .sort { border: 0; background: none; padding: 2px 0; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.games th .sort:hover { color: var(--text); }
.games th .sort.on { color: var(--accent-text); }
.games td { border-top: 1px solid var(--border); }
.games tbody tr:nth-child(even) { background: var(--surface-2); }
.games .col-system { width: 22%; color: var(--muted); }
.games .col-year { width: 76px; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.games .col-size { width: 96px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.games th.col-size { text-align: right; }
.size-val { cursor: help; border-bottom: 1px dotted var(--muted); }
.size-none { color: var(--muted); }
.size-pop {
  position: fixed; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 8px 12px; font-size: 13px; pointer-events: none;
  display: grid; grid-template-columns: auto auto; gap: 2px 14px; text-align: right; font-variant-numeric: tabular-nums;
}
.size-pop span:nth-child(odd) { text-align: left; color: var(--muted); }
.size-pop .sum { border-top: 1px solid var(--border); padding-top: 3px; margin-top: 2px; color: var(--text); font-weight: 600; }
.games .col-art { width: 56px; padding-right: 0; }
.thumb {
  display: flex; align-items: center; justify-content: center; width: 42px; height: 56px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; cursor: zoom-in;
}
.thumb img { max-width: 100%; max-height: 100%; display: block; }
.thumb.none { cursor: default; color: var(--muted); font-size: 18px; }
.art-pop {
  position: fixed; z-index: 7; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 8px; width: 316px;
}
.art-pop img { display: block; width: 300px; height: auto; border-radius: 6px; }
.art-pop .cap { font-size: 12px; color: var(--muted); padding: 6px 2px 0; }
.credit { margin-top: 32px; text-align: center; font-size: 13px; color: var(--muted); }
.credit a { color: inherit; }
.games .col-tags { width: 1%; white-space: nowrap; }
.games .col-copy { width: 122px; text-align: right; }
.games .title { overflow-wrap: anywhere; }
.sys-inline { display: none; font-size: 13px; color: var(--muted); }
.cell-tags { line-height: 0; white-space: nowrap; }
.copy {
  border: 1px solid var(--border); background: var(--surface); border-radius: 6px;
  padding: 4px 0; font-size: 13px; cursor: pointer; width: 92px; white-space: nowrap;
}
.export { flex: none; }
.copy.done { border-color: var(--accent); color: var(--accent-text); }
.nomatch td { color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .rhead { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .pics { height: 96px; justify-content: flex-start; }
  .name { font-size: 24px; }
  .games th, .games td { padding: 8px 10px; }
  .games .col-system { display: none; }
  .games .col-art { width: 46px; }
  .thumb { width: 34px; height: 46px; }
  .games .col-year { width: 56px; }
  .games .col-size { width: 74px; }
  .pill { font-size: 12px; padding: 2px 8px; }
  .games .col-copy { width: 112px; }
  .sys-inline { display: block; }
  .copy { min-height: 36px; }
}
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 5;
  background: var(--text); color: var(--bg); border-radius: 999px; padding: 6px 14px; font-size: 13px;
}
.empty { color: var(--muted); text-align: center; padding: 48px 0; }
[hidden] { display: none !important; }
