:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #e2e2dd;
  --accent: #1f6f43;
  --accent-hover: #17532f;
  --row-alt: #fafaf8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 8px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a;
    --surface: #1e1e24;
    --text: #e9e9e6;
    --muted: #9a9a94;
    --border: #33333b;
    --accent: #57c98a;
    --accent-hover: #7ad9a5;
    --row-alt: #24242b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 20px;
}

.site-title {
  display: inline-block;
  padding: 16px 20px;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}

.header-link {
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.site-footer {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--muted);
  font-size: 0.85rem;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 4px;
}

h2 {
  font-size: 1.15rem;
  margin: 32px 0 12px;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 0.9rem;
  text-decoration: none;
}

.loading, .empty, .error {
  color: var(--muted);
  padding: 24px 0;
}
.error { color: #c0392b; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a7a; } }

/* Search */
.search {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.search input {
  flex: 1 1 240px;
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.search button {
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.search button:hover { background: var(--accent-hover); }
.search-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 28px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  background: var(--row-alt);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--row-alt); }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 220px; }

/* Definition list for competition meta */
.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 20px;
  margin: 0 0 8px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.92rem;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

.round-heading {
  margin: 26px 0 10px;
  font-size: 1rem;
  font-weight: 600;
}
.round-heading .count {
  color: var(--muted);
  font-weight: 400;
}

/* --- API docs page --- */
.doc {
  max-width: 820px;
}
.doc p { margin: 12px 0; }
.doc h2 {
  border-top: 1px solid var(--border);
  padding-top: 26px;
}
.doc h3 {
  margin: 28px 0 8px;
  font-size: 1.02rem;
}
.doc ul { padding-left: 22px; }
.doc li { margin: 5px 0; }

.doc code,
.endpoint code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--row-alt);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

.doc pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.doc pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.endpoint {
  margin: 14px 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.endpoint .method {
  display: inline-block;
  font: 600 0.75rem/1 ui-monospace, monospace;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  padding: 4px 6px;
  margin-right: 8px;
  vertical-align: middle;
}

.note {
  border-left: 3px solid var(--accent);
  padding: 8px 14px;
  margin: 16px 0;
  background: var(--row-alt);
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
}
