:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #6b6560;
  --border: #e7e5e4;
  --accent: #b91c1c;
  --link: #1d4ed8;
  --win: #15803d;
  --loss: #b91c1c;
  --draw: #a16207;
  --nc: #57534e;
  --tag-bg: #f5f5f4;
  --title-bg: #fef3c7;
  --title-text: #78350f;
  --note-bg: #eff6ff;
  --note-border: #bfdbfe;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412;
    --surface: #1f1c1a;
    --text: #e7e5e4;
    --muted: #a8a29e;
    --border: #3a3532;
    --accent: #f87171;
    --link: #93c5fd;
    --win: #4ade80;
    --loss: #f87171;
    --draw: #facc15;
    --nc: #a8a29e;
    --tag-bg: #2a2623;
    --title-bg: #422006;
    --title-text: #fde68a;
    --note-bg: #172033;
    --note-border: #1e3a8a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  margin: 1.5rem 0 0.5rem;
}
h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}

.lead {
  font-size: 1.1rem;
  margin-top: 0;
}
.muted {
  color: var(--muted);
}
.nickname {
  font-weight: 400;
  color: var(--muted);
}
.nowrap {
  white-space: nowrap;
}

/* Header and footer */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--accent);
}
.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}
.site-header a {
  color: var(--text);
  font-weight: 500;
}
.site-header .brand {
  font-weight: 800;
  letter-spacing: 0.02em;
}
.site-header .search {
  margin-left: auto;
}
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}
.site-footer p {
  margin: 0.25rem 0;
}

/* Forms */
input[type="search"] {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.search-big {
  display: flex;
  gap: 0.5rem;
  max-width: 32rem;
  margin: 1rem 0;
}
.search-big input {
  flex: 1;
  font-size: 1.1rem;
}

.letters,
.years {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  margin: 0.75rem 0 1.25rem;
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}
caption {
  text-align: left;
  font-weight: 600;
  padding: 0.6rem 0.75rem 0.25rem;
}
th,
td {
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td {
  border-bottom: 0;
}
th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Stat grids */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem 1.5rem;
  margin: 1rem 0;
}
.stat dt {
  font-size: 0.8rem;
  color: var(--muted);
}
.stat dd {
  margin: 0;
  font-weight: 600;
}

/* Badges and tags */
.badge {
  display: inline-block;
  min-width: 2.2em;
  text-align: center;
  padding: 0 0.35em;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}
.result-w {
  background: var(--win);
}
.result-l {
  background: var(--loss);
}
.result-d {
  background: var(--draw);
}
.result-nc {
  background: var(--nc);
}
.result-line .badge {
  margin-left: 0.5rem;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.tags:empty {
  display: none;
}
.tag {
  display: inline-block;
  padding: 0 0.4em;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--muted);
}
.tag.title {
  background: var(--title-bg);
  color: var(--title-text);
}

.note {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid var(--note-border);
  background: var(--note-bg);
  border-radius: 0 6px 6px 0;
}

@media (max-width: 600px) {
  h1 {
    font-size: 1.4rem;
  }
  .site-header .search {
    margin-left: 0;
    width: 100%;
  }
  .site-header .search input {
    width: 100%;
  }
}

/* Records */
.record-links {
  columns: 2 16rem;
  padding-left: 1.1rem;
  margin: 0.5rem 0 1rem;
}
.record-links li {
  margin: 0.15rem 0;
  break-inside: avoid;
}
.crumbs {
  margin: 1rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.crumbs + h1 {
  margin-top: 0.25rem;
}
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 1rem 0;
}
.filters .presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-bottom: 0.6rem;
}
.filters .fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem 1rem;
}
.filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 0.15rem;
}
.filters label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--text);
  padding-bottom: 0.35rem;
}
.filters select,
.filters input[type="number"] {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  max-width: 14rem;
}
.filters input[type="number"] {
  width: 6rem;
}
.filters .fields a {
  padding-bottom: 0.4rem;
}
.count {
  color: var(--muted);
  margin: 0.5rem 0;
}
table.record td.value {
  font-weight: 700;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin: 0.5rem 0 1.5rem;
}

.prose li {
  margin: 0.4rem 0;
}
