:root {
  --bg: #100e0c;
  --bg-raise: #181511;
  --ink: #efe6d6;
  --muted: #a89880;
  --line: #3a3228;
  --gold: #d4b15a;
  --gold-dim: #8a7030;
  --accent: #c4a35a;
  --row: #16130f;
  --row-alt: #1c1914;
  --row-hover: #241f18;
  --focus: #e6c87a;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  color-scheme: dark;
}

body {
  background:
    radial-gradient(1200px 500px at 50% -80px, rgba(212, 177, 90, 0.08), transparent 60%),
    var(--bg);
}

a {
  color: var(--gold);
}

a:hover {
  color: #f0d78a;
}

.wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

header.hero {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 22px;
}

.kicker {
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 0 8px;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.5;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.nav {
  display: flex;
  gap: 2px;
  margin: 16px 0 -22px;
  font-size: 0.95rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 11px 18px 13px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
}

.nav a:hover {
  color: var(--ink);
  background: var(--row-hover);
}

.nav a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.nav a[aria-current="page"] {
  color: var(--gold);
  background: rgba(212, 177, 90, 0.08);
  border-bottom-color: var(--gold);
}

.meta strong {
  color: var(--ink);
  font-weight: 600;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 0 0 14px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-raise);
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: #2a241a;
  color: var(--gold);
  font-weight: 600;
}

.search {
  flex: 1 1 220px;
  min-width: 180px;
}

.search input,
.sort select {
  width: 100%;
  background: var(--bg-raise);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
}

.sort {
  flex: 0 0 160px;
}

.filter-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--row);
}

table.board {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  min-width: 860px;
}

.board th,
.board td {
  padding: 9px 12px;
  text-align: center;
  border-bottom: 1px solid #2a241c;
  white-space: nowrap;
}

.board th {
  position: sticky;
  top: 0;
  background: #201c16;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 650;
  z-index: 1;
}

.board th:nth-child(1),
.board td:nth-child(1) {
  text-align: center;
  color: var(--muted);
  width: 4.6rem;
}

.board td.rank {
  white-space: nowrap;
}

.board .rank-n {
  display: inline-block;
  min-width: 1.4em;
}

.board .move {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.board .move.up {
  color: #76cc94;
}

.board .move.down {
  color: #e07666;
}

.board .move.same {
  color: var(--muted);
  font-weight: 500;
}

.board .move.in {
  color: var(--gold);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
}

.board th:nth-child(2),
.board td:nth-child(2) {
  text-align: left;
}

.board tbody tr:nth-child(even) {
  background: var(--row-alt);
}

.board tbody tr:hover {
  background: var(--row-hover);
}

.board th.sortable {
  cursor: pointer;
}

.board th.sortable:hover,
.board th[aria-sort]:not([aria-sort="none"]) {
  color: var(--gold);
}

.board td.num {
  font-variant-numeric: tabular-nums;
}

.board td.heat {
  font-weight: 650;
}

.board td.wld {
  color: var(--ink);
  font-weight: 500;
}

.clan .tag {
  color: var(--gold);
  font-weight: 700;
  margin-right: 8px;
}

.clan .name {
  color: var(--ink);
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.caption {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.recent {
  margin: 0 0 22px;
}

.recent-hint {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.recent-list {
  list-style: none;
  margin: 0 -18px;
  padding: 0;
}

.recent-list li {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr) 4.2rem;
  gap: 12px;
  align-items: baseline;
  padding: 8px 18px;
  border-bottom: 1px solid #2a241c;
  background: var(--row);
}

.recent-list li:nth-child(even) {
  background: #221e18;
}

.recent-list li:hover {
  background: var(--row-hover);
}

.recent-list li:last-child {
  border-bottom: 0;
}

.recent-list .when {
  color: var(--muted);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.recent-list .match {
  min-width: 0;
}

.recent-list .vs {
  color: var(--muted);
  margin: 0 0.45rem;
  font-size: 0.82rem;
}

.recent-list .side .tag {
  font-weight: 700;
  margin-right: 6px;
}

.recent-list .side.win,
.recent-list .side.win .tag {
  color: #76cc94;
}

.recent-list .side.lose,
.recent-list .side.lose .tag {
  color: #e07666;
}

.recent-list .delta {
  margin-left: 0.4rem;
  font-size: 0.86em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.recent-list .side .delta.up {
  color: #76cc94;
}

.recent-list .side .delta.down {
  color: #e07666;
}

.recent-list .side .delta.flat {
  color: var(--muted);
}

.recent-list .score {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.recent-empty {
  color: var(--muted);
}

@media (max-width: 700px) {
  .recent-list li {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "match score"
      "when score";
    gap: 2px 12px;
    padding: 10px 18px;
  }

  .recent-list .when {
    grid-area: when;
  }

  .recent-list .match {
    grid-area: match;
  }

  .recent-list .score {
    grid-area: score;
    align-self: center;
  }
}

.explain {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .explain {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.rules {
  margin: 0 0 16px;
  padding-left: 1.15rem;
  color: var(--ink);
  line-height: 1.45;
}

.rules li + li {
  margin-top: 6px;
}

.ex-block + .ex-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.ex-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ex-rows li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid #2a241c;
  color: var(--ink);
  font-size: 0.94rem;
}

.ex-rows li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.ex-delta,
.ex-result {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--gold);
}

.ex-note,
.card .note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.card .note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

#explain-board {
  margin-top: 12px;
}

.cols {
  display: grid;
  gap: 0;
  margin: 0;
}

.cols > div {
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid #2a241c;
}

.cols > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.cols dt {
  margin: 0;
  color: var(--gold);
  font-weight: 650;
  font-size: 0.88rem;
}

.cols dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.4;
}

@media (max-width: 520px) {
  .cols > div {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 10px 0;
  }
}

footer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
