: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; flex-wrap: wrap; column-gap: 18px; row-gap: 6px; font-size: 15px; margin-bottom: 14px; }
.nav a { color: var(--muted); text-decoration: none; padding-bottom: 3px; border-bottom: 2px solid transparent; white-space: nowrap; }
@media (max-width: 400px) { .nav { column-gap: 12px; } }
.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); }
.sub.en { font-size: .9em; }

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; }
.cd { grid-column: 1 / -1; text-align: center; margin: 2px 0 4px; }
.cd-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px; }
.cd-units { display: flex; justify-content: center; gap: 10px; margin: 0; }
.cd-u { display: flex; flex-direction: column; align-items: center; min-width: 66px; padding: 6px 6px 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.cd-u b { font-size: clamp(24px, 6vw, 34px); font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.cd-u small { color: var(--muted); font-size: 12px; }
.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; }
.grid.pre { grid-template-columns: minmax(0, 1fr); }
.grid.pre .games { max-width: 560px; }
[hidden] { display: none !important; }
.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);
  padding: 3px 10px;
  border: 1px solid #3a4a42;
  border-radius: 8px;
  background: #1b2420;
}
.pick::after { content: " ▸"; color: var(--muted); }
.pick:hover { color: var(--accent); border-color: var(--accent); }
.games tr[aria-current="true"] .pick { color: var(--accent); border-color: var(--accent); }
.games tr[aria-current="true"] .pick::after { content: " ●"; color: var(--accent); }
.games .kom { font-size: 13px; white-space: nowrap; margin-left: 6px; }
.grid.pre .pick-hint { display: none; }
.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; }
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0 4px; }
.figs figure { margin: 0; }
.figs img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }
.figs figcaption { margin-top: 6px; font-size: 14px; color: var(--muted); }
@media (max-width: 560px) { .figs { grid-template-columns: 1fr; } }

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

/* Tekstoj */
.script { max-width: 680px; margin-top: 28px; }
.script h2 { font-size: 24px; }
.vid-no { display: inline-block; min-width: 1.6em; margin-right: 6px; padding: 0 6px; border-radius: 6px; background: var(--accent); color: #fff; text-align: center; }
.vid-link { margin-bottom: 4px; }
.toc { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; padding: 0; margin: 14px 0 8px; font-size: 14px; }
.script section { margin-top: 26px; }
.script h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent2); margin: 0 0 8px; }
.script section p { font-size: 18px; line-height: 1.65; margin: 0 0 14px; }
.script figure { margin: 4px 0 18px; }
.script figure img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; }

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

@media (max-width: 820px) {
  .grid { grid-template-columns: minmax(0, 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; }
}

/* Partioj: komentita partio (tools/partioj_site.py + partioj/vidilo.js) */
.vidilo { display: grid; grid-template-columns: minmax(280px, 440px) 1fr; gap: 20px; align-items: start; margin: 8px 0 12px; }
.v-tabulo { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 8px; }
#pb { order: 1; } .tabulo { order: 2; } #pw { order: 3; } .v-btn { order: 4; } .v-stato { order: 5; }
.v-tabulo.flip #pb { order: 3; } .v-tabulo.flip #pw { order: 1; }
.tabulo { width: 100%; height: auto; display: block; border-radius: 6px; }
.sq-l { fill: #dfe6dc; } .sq-d { fill: #6f8f78; }
.sq-l.sq-h { fill: #ecdf94; } .sq-d.sq-h { fill: #b9ab52; }
.coord { font: 600 9px system-ui, sans-serif; } .on-l { fill: #6f8f78; } .on-d { fill: #dfe6dc; }
.v-ludanto { display: flex; justify-content: space-between; align-items: center; margin: 0; font-weight: 600; }
.hor { font-variant-numeric: tabular-nums; background: var(--panel); border: 1px solid var(--line); padding: 0 8px; border-radius: 4px; }
.v-tabulo.dim .hor { opacity: .45; }
.v-btn { display: flex; gap: 6px; }
.v-btn button { flex: 1; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 0; font-size: 18px; cursor: pointer; }
.v-btn button:hover, .v-btn button:focus-visible { border-color: var(--accent); }
.v-stato { background: var(--panel); border-radius: 8px; padding: 10px 12px; min-height: 5.5em; }
.v-stato p { margin: 0; }
.km-nuna { margin-top: 4px !important; }
.v-movoj { background: var(--panel); border-radius: 8px; padding: 10px 12px; max-height: 82vh; overflow: auto; }
.v-movoj .mvl { margin: 0 0 6px; line-height: 1.9; }
.v-movoj .km { color: var(--muted); font-size: 15px; margin: 0 0 8px; }
.v-movoj span.km { font-size: 14px; }
.v-movoj .var { margin: 0 0 8px 12px; padding-left: 10px; border-left: 2px solid var(--line); font-size: 14px; line-height: 1.8; }
.mv { background: none; border: 0; color: var(--text); font: inherit; padding: 1px 3px; border-radius: 4px; cursor: pointer; }
.mv.main { font-weight: 600; }
.mv:hover { background: var(--line); }
.mv.on { background: var(--accent); color: #fff; }
.v-movoj .res { font-weight: 700; margin-top: 8px; }
.p-listo, .fontoj ul { padding-left: 20px; margin: 0 0 8px; }
@media (max-width: 760px) {
  .vidilo { grid-template-columns: 1fr; }
  .v-tabulo { position: static; }
  .v-movoj { max-height: none; }
}

.video-kadro { aspect-ratio: 16 / 9; width: 100%; max-width: 960px; }
.video-kadro iframe { width: 100%; height: 100%; border: 0; border-radius: 8px; }

/* Hejmpaĝo: komentita partio anstataŭ la tabulo de Lichess (app.js + partioj/vidilo.js) */
.vidilo.hejme { grid-template-columns: minmax(0, 4fr) minmax(0, 3fr); gap: 12px; margin: 0 0 8px; }
.vidilo.hejme .v-tabulo { position: static; }
.vidilo.hejme .v-movoj { max-height: 640px; }
@media (max-width: 760px) {
  .vidilo.hejme { grid-template-columns: 1fr; }
  .vidilo.hejme .v-movoj { max-height: 50vh; }
}
/* telefono: «komentoj →» kaj «▶ video» sub la rezulto, por ke la tabelo ne estu pli larĝa ol la ekrano */
@media (max-width: 560px) { .games td:nth-child(5) { white-space: normal; } }

/* Tabulo: ŝildo antaŭ la komenco de la partio (Lichess ankoraŭ ne montras ĝin: 403) */
.embed.atendo { display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px;
  background: repeating-conic-gradient(#1a231e 0 25%, #131a16 0 50%) 0 0 / 64px 64px; }
.atendo > div { background: rgba(16, 22, 19, .92); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; max-width: 32em; }
.atendo p { margin: 0 0 8px; }
.atendo p:last-child { margin: 0; }
.atendo-t { font-weight: 700; font-size: 20px; }
@media (max-width: 560px) { .embed.atendo { aspect-ratio: auto; min-height: 240px; } }
