:root {
  --bg: #fbfaf7;
  --fg: #1d1c1a;
  --muted: #6d6a64;
  --line: #e6e2da;
  --row-hover: #f3f0e9;
  --accent: #2f7d4f;
  --q2: #1a8f1a;
  --gold: #b8860b;
  --silver: #7b8088;
  --copper: #b05a2a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --fg: #ecebe7;
    --muted: #9c988f;
    --line: #2e2c28;
    --row-hover: #1e1d1a;
    --accent: #6cc28f;
    --q2: #3fd13f;
    --gold: #f0c24b;
    --silver: #c4c8cf;
    --copper: #e0884f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Everything below is in rem, so the whole UI scales with the root size per screen width. */
html { font-size: 15px; }
@media (min-width: 1024px) { html { font-size: 16px; } }
@media (min-width: 1280px) { html { font-size: 18px; } }
@media (min-width: 1800px) { html { font-size: 20px; } }
@media (min-width: 2400px) { html { font-size: 23px; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 60rem; margin: 0 auto; padding: 2.2rem 16px 3rem; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0.25rem 0 1.6rem; font-size: 0.87rem; }
a { color: var(--accent); }

.filters {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(12rem, 1.3fr) minmax(12rem, 1.3fr) auto;
  gap: 1rem 1.6rem;
  align-items: end;
  margin-bottom: 1.3rem;
}
.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.label { font-size: 0.8rem; color: var(--muted); display: flex; justify-content: space-between; gap: 0.5rem; }
.label output { color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
select, button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0.4rem;
  padding: 0.33rem 0.55rem;
}
#reset { cursor: pointer; }
#reset:hover { border-color: var(--muted); }

/* Two range inputs stacked into one from–to slider. */
.range { position: relative; height: 1.5rem; }
.range::before {
  content: "";
  position: absolute; left: 0; right: 0; top: calc(50% - 1.5px);
  height: 3px; border-radius: 2px; background: var(--line);
}
.range input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  background: none; pointer-events: none;
  -webkit-appearance: none; appearance: none;
}
.range input::-webkit-slider-runnable-track { background: none; height: 1.5rem; }
.range input::-moz-range-track { background: none; }
.range input::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; cursor: pointer;
  width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.range input::-moz-range-thumb {
  pointer-events: auto; cursor: pointer;
  width: 0.8rem; height: 0.8rem; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.range input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 0.4rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
th.num, td.num { text-align: right; }
tbody tr:hover { background: var(--row-hover); }
th button {
  border: 0; padding: 0; font-weight: 600; color: inherit; cursor: pointer;
}
th button::after { content: " ↕"; opacity: 0.35; }
th button[data-dir="asc"]::after { content: " ↑"; opacity: 1; }
th button[data-dir="desc"]::after { content: " ↓"; opacity: 1; }
th button[data-dir] { color: var(--fg); }
.icon-col { width: 2.7rem; padding-right: 0; }
td img { display: block; width: 1.9rem; height: 1.9rem; border-radius: 0.27rem; border: 1px solid var(--line); }
td a { color: inherit; text-decoration: none; }
td a:hover { text-decoration: underline; }
.q2 a { color: var(--q2); }
.muted { color: var(--muted); }

.g, .s, .c { margin-left: 0.4rem; }
.g::after { content: "g"; color: var(--gold); }
.s::after { content: "s"; color: var(--silver); }
.c::after { content: "c"; color: var(--copper); }
.g::after, .s::after, .c::after { margin-left: 1px; font-size: 0.85em; }

.count { color: var(--muted); font-size: 0.87rem; margin: 0.65rem 0 0; }
footer { margin-top: 2.1rem; color: var(--muted); font-size: 0.87rem; max-width: 43rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.error { color: #c0392b; }

@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  html { font-size: 14px; }
  .filters { grid-template-columns: 1fr; }
  th, td { padding: 0.4rem 0.3rem; }
  th, td:nth-child(2), td:last-child { white-space: normal; }
  .icon-col { width: 2rem; }
  td img { width: 1.6rem; height: 1.6rem; }
  .g, .s, .c { margin-left: 0.2rem; }
}
