:root {
  --bg: #101613;
  --panel: #1b241f;
  --line: #2b3832;
  --text: #f0f4f1;
  --muted: #a0b0a7;
  --accent: #23a55a;
  --accent2: #e8a33d;
  --live: #e5484d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: #3cc576; }

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 16px 48px;
  border-top: 6px solid var(--accent);
}

h1 { font-size: clamp(26px, 5vw, 40px); line-height: 1.15; margin: 4px 0 6px; }
h2 { font-size: 20px; margin: 0 0 12px; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; margin-top: 10px; }

.top { padding: 24px 0 8px; }
.nav { display: flex; gap: 18px; font-size: 15px; margin-bottom: 14px; }
.nav a { color: var(--muted); text-decoration: none; padding-bottom: 3px; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.kicker { color: var(--accent); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 14px; }
.kicker a { text-decoration: none; }
.sub { color: var(--muted); }

section { margin-top: 28px; }

/* Score */
.score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px 16px;
  background: var(--panel);
  border-radius: 12px;
  padding: 20px;
}
.player .name { font-size: clamp(20px, 4.4vw, 30px); font-weight: 700; margin: 0; }
.player .meta, .player .elo { color: var(--muted); font-size: 14px; margin: 0; }
.player.right { text-align: right; }
.nums {
  font-size: clamp(40px, 10vw, 72px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 0;
  white-space: nowrap;
}
.colon { color: var(--muted); margin: 0 .15em; }
.status, .rule { grid-column: 1 / -1; text-align: center; }
.status { font-size: 17px; margin-top: 6px; }
.rule { color: var(--muted); font-size: 14px; margin: 0; }
.winner .name { color: var(--accent2); }

.dot {
  display: inline-block;
  width: .6em; height: .6em;
  border-radius: 50%;
  background: var(--live);
  margin-right: .4em;
  vertical-align: .05em;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

/* Board + games */
.grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
.embed { position: relative; width: 100%; aspect-ratio: 600 / 397; background: #161512; border-radius: 8px; overflow: hidden; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.games td:nth-child(1), .games td:nth-child(3), .games td:nth-child(5) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.games td:nth-child(2) { white-space: nowrap; }
.games tr[aria-current="true"] td { background: #23302a; }
.games tr.rest td { color: var(--muted); font-size: 13px; padding: 3px 8px; text-align: center; font-style: italic; }
.games tr.off td { color: var(--muted); }
.pick {
  all: unset;
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px dashed var(--muted);
}
.pick:hover { color: var(--accent); border-color: var(--accent); }
.pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.res { font-weight: 700; }
.res.live { color: var(--live); font-weight: 600; }

.format ul { margin: 0; padding-left: 20px; }
.format li { margin-bottom: 6px; }

.glossary .scroll { overflow-x: auto; }
.glossary td:first-child { font-weight: 600; }
.glossary td:first-child .muted { font-weight: 400; }

footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }

@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  /* Lichess shows the board above its move list on narrow screens */
  .embed { aspect-ratio: 5 / 7; }
  .score { padding: 16px 12px; gap: 6px 8px; }
  .player .meta, .player .elo { font-size: 12px; }
  table { font-size: 14px; }
  td, th { padding-left: 5px; padding-right: 5px; }
}
