/* Rank & File Weekly — annotated chess games
   Look: ASCII / terminal. Monospaced type everywhere, boxes drawn as dashed lines with "+"
   corners, [bracketed] buttons and tags, "#" headings, "//" labels and a clean blue board.
   Light is a printout, dark is a terminal; Rank & File Blue (#2F5BFF) is the one color.
   Everything is themed through the variables below. */

:root {
  --brand: #2f5bff;            /* Rank & File Blue */
  --brand-ink: #ffffff;        /* text on a blue block */
  --brand-wash: rgba(47, 91, 255, 0.09);

  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #101318;
  --ink-2: #4a5160;
  --ink-3: #8a909c;
  --line: #a3a9b4;             /* the dashed box lines */
  --corner: #101318;           /* the "+" corners */
  --hair: #d9dde3;
  --wash: rgba(16, 19, 24, 0.05);

  /* old names, kept so every component follows the theme */
  --surface: var(--bg);
  --card: var(--panel);
  --accent: var(--brand);
  --accent-ink: var(--brand-ink);
  --accent-wash: var(--brand-wash);
  --hair-2: var(--line);

  /* move quality (status) — always paired with a glyph + word */
  --q-blunder: #e5372c;
  --q-mistake: #f07b2f;
  --q-inaccuracy: #c99300;
  --q-good: #1a9a45;
  --q-brilliant: #0097b5;
  --q-great: #5b7cfa;

  /* board: clean blue squares */
  --sq-light: #f7f9ff;
  --sq-dark: #bccaf4;
  --sq-last: rgba(47, 91, 255, 0.16);   /* last move: a light blue tint (and a blue frame on the board) */
  --sq-select: rgba(47, 91, 255, 0.45);
  --sq-dest: rgba(16, 19, 24, 0.35);
  --sq-check: radial-gradient(circle, rgba(229, 55, 44, 0.9) 0%, rgba(229, 55, 44, 0.45) 45%, rgba(229, 55, 44, 0) 72%);
  --bar-dark: #101318;
  --bar-light: #ffffff;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: var(--mono);
  --display: var(--mono);
  --rounded: var(--mono);

  --radius: 0;
  --shadow: none;
  color-scheme: light;
}

/* Dark: chosen by the reader with the [dark]/[light] button, or following the device until they
   choose (assets/js/theme.js sets data-theme on <html> before the page draws). */
:root[data-theme="dark"] {
  --brand: #6e8bff;
  --brand-ink: #07090d;
  --brand-wash: rgba(110, 139, 255, 0.12);
  --bg: #07090d;
  --panel: #0c1016;
  --ink: #d7dee9;
  --ink-2: #9aa5b8;
  --ink-3: #5f6a7c;
  --line: #3b4556;
  --corner: #8c97ab;
  --hair: #1d2430;
  --wash: rgba(255, 255, 255, 0.05);
  --q-brilliant: #2fd0e8;
  --q-great: #8aa2ff;
  --sq-light: #dfe5f4;
  --sq-dark: #a9b8e6;
  --bar-dark: #000000;
  --bar-light: #d7dee9;
  color-scheme: dark;
}

/* Switching themes fades the colors instead of snapping (theme.js adds this class for a moment). */
html.theme-switching, html.theme-switching *, html.theme-switching *::before {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease !important;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
  font-variant-ligatures: none;
}
a { color: inherit; }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1px dashed var(--brand); outline-offset: 3px; }
::selection { background: var(--brand); color: var(--brand-ink); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.narrow { max-width: 760px; }

@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* ------------------------------------------------------------ ASCII boxes */

/* Every panel is a box drawn like
     +--------------+
     |              |
     +--------------+
   a dashed line with a "+" at each corner: "+ +" spread across the top and bottom edges. */
.card, .note-card, .engine-panel, .movelist-card, .issue-row, .framework section,
.next-games a, .explainer div, .why, .next-games .soon {
  position: relative;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 0;
}
.card::before, .card::after, .note-card::before, .note-card::after, .engine-panel::before, .engine-panel::after,
.movelist-card::before, .movelist-card::after, .issue-row::before, .issue-row::after,
.framework section::before, .framework section::after, .next-games a::before, .next-games a::after,
.explainer div::before, .explainer div::after, .why::before, .why::after,
.next-games .soon::before, .next-games .soon::after {
  content: "+ +"; position: absolute; left: -0.3em; right: -0.3em; height: 1em;
  font: 400 14px/1 var(--mono); color: var(--corner);
  text-align: justify; text-align-last: justify; pointer-events: none;
}
.card::before, .note-card::before, .engine-panel::before, .movelist-card::before, .issue-row::before,
.framework section::before, .next-games a::before, .explainer div::before, .why::before, .next-games .soon::before {
  top: calc(-0.5em - 0.5px);
}
.card::after, .note-card::after, .engine-panel::after, .movelist-card::after, .issue-row::after,
.framework section::after, .next-games a::after, .explainer div::after, .why::after, .next-games .soon::after {
  bottom: calc(-0.5em - 0.5px);
}

/* [bracketed] labels: chips, tags, buttons and links in the bar */
.chip::before, .btn::before, .nav a::before { content: "["; }
.chip::after, .btn::after, .nav a::after { content: "]"; }

/* ------------------------------------------------------------ chrome */

.masthead { background: var(--bg); border-bottom: 1px dashed var(--line); }
/* The bar stays at the top as you scroll (on wide screens; phones pin the board instead). */
@media (min-width: 1001px) { #site-header { position: sticky; top: 0; z-index: 30; } }
.masthead .wrap { display: flex; align-items: center; gap: 20px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
/* The mark: ▚ (a 2x2 board, as in the logo) */
.brand-mark { display: inline-block; width: auto; height: auto; }
.brand-mark span { display: none; }
.brand-mark::before { content: "\259A"; color: var(--brand); font: 700 24px/1 var(--mono); }
.brand-name { font: 700 17px/1 var(--mono); letter-spacing: -0.01em; }
.brand-name::after { content: "_"; color: var(--brand); animation: blink 1.1s steps(1) infinite; margin-left: 1px; }
.nav { display: flex; gap: 2px; margin-left: auto; align-items: center; }
.nav a { text-decoration: none; padding: 4px 6px; color: var(--ink-2); font-size: 14px; }
.nav a:hover { color: var(--ink); background: var(--wash); }
.nav a[aria-current="page"] { color: var(--brand-ink); background: var(--brand); font-weight: 700; }

/* Light / dark switch: reads [dark] in light mode and [light] in dark mode. */
.theme-toggle {
  flex: none; margin-left: 6px; border: 1px dashed var(--line); padding: 3px 8px; background: transparent;
  cursor: pointer; color: var(--ink-2); font: 500 13px/1.4 var(--mono);
}
.theme-toggle svg { display: none; }
.theme-toggle::after { content: "dark"; }
[data-theme="dark"] .theme-toggle::after { content: "light"; }
.theme-toggle:hover { color: var(--brand-ink); background: var(--brand); border-color: var(--brand); }

.footer { margin-top: 72px; padding: 28px 0 48px; border-top: 1px dashed var(--line); color: var(--ink-3); font-size: 12.5px; }
.footer p { margin: 0 0 8px; max-width: 820px; }
.footer p:first-child::before { content: "-- "; }
.footer a { color: var(--ink-2); }
.footer .wrap::after { content: "[EOF]"; display: block; margin-top: 18px; color: var(--ink-3); }

/* ------------------------------------------------------------ type */

.eyebrow { font: 600 12px/1.3 var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow::before { content: "// "; color: var(--brand); }
h1, h2, h3 { font-family: var(--mono); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(26px, 4.2vw, 44px); line-height: 1.15; }
h1::before { content: "# "; color: var(--brand); }
h2 { font-size: 21px; line-height: 1.3; }
h2::before { content: "## "; color: var(--brand); }
h3 { font-size: 16.5px; line-height: 1.35; }
.issue-hero h1::after, .page-head h1::after { content: "\2588"; color: var(--brand); margin-left: .2em; font-size: .8em; animation: blink 1.1s steps(1) infinite; }
.dek { font: 400 16.5px/1.55 var(--mono); color: var(--ink-2); margin: 14px 0 0; max-width: 760px; }
.dek::before { content: "> "; color: var(--brand); }
.prose { font: 400 15px/1.7 var(--mono); }
.prose p { margin: 0 0 1em; }
.prose strong { font-weight: 700; color: var(--ink); background: var(--brand-wash); }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }

/* ------------------------------------------------------------ home */

.issue-hero { padding: 44px 0 8px; }
/* The intro: its first paragraph in a quieter tone, the rest behind "+ Read the rest of the intro". */
.issue-hero .intro { max-width: 760px; margin-top: 22px; color: var(--ink-2); font-size: 14.5px; }
.issue-hero .intro strong { color: var(--ink); }
/* A rundown paragraph: its first sentence, then "- " bullets with a bold opening phrase. */
.intro .rundown-lead { margin: 0 0 .5em; }
.intro .rundown { list-style: none; margin: 0 0 1.1em; padding: 0; }
.intro .rundown li { position: relative; padding-left: 2.4ch; margin: 0 0 .45em; }
.intro .rundown li::before { content: "-"; position: absolute; left: 0; color: var(--brand); font-weight: 700; }
.intro .rundown li b { color: var(--ink); font-weight: 700; }
/* The bold phrase links to its game: a dotted blue underline, a blue block on hover. */
.intro .rundown li b a { color: inherit; text-decoration: underline dotted var(--brand); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.intro .rundown li b a:hover { background: var(--brand); color: var(--brand-ink); text-decoration: none; }
.more-link { border: 0; background: none; padding: 2px 0; color: var(--brand); font: 700 13px/1.4 var(--mono); cursor: pointer; }
.more-link::before { content: "["; } .more-link::after { content: "]"; }
.more-link:hover { background: var(--brand); color: var(--brand-ink); }

/* Section headings on the home page ("## This week's games") with a "//" line under them. */
.section-head { margin: 40px 0 22px; }
.section-head h2 { font-size: 24px; }
.section-head p { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-3); }
.section-head p::before { content: "// "; color: var(--brand); }
.explainer-head { margin-top: 64px; }
.issue-meta { display: flex; gap: 6px 14px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 1px; color: var(--ink-2); font: 500 12.5px/1.6 var(--mono); white-space: nowrap; }
button.chip { background: transparent; padding: 0; color: var(--brand); }   /* key moments under the board */
button.chip:hover { background: var(--brand); color: var(--brand-ink); }
.chip.accent { background: var(--brand); color: var(--brand-ink); padding: 0 6px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.chip.accent::before, .chip.accent::after { content: none; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 26px 24px; }
.card { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; text-decoration: none; min-width: 0; }
.card:hover { border-color: var(--brand); border-style: solid; }
.card:hover::before, .card:hover::after { color: var(--brand); }
.card:hover h3 { color: var(--brand); }
.card:hover .card-head { background: var(--brand-wash); }
/* The card's header strip: the level, big, then its name and the level meter. */
.card-head {
  display: flex; align-items: baseline; gap: 10px; margin: 0 -16px; padding: 11px 16px 10px;
  background: var(--wash); border-bottom: 1px dashed var(--line);
}
.card-level { font: 700 18px/1.1 var(--mono); color: var(--brand); white-space: nowrap; }
.card-name { font: 600 12px/1 var(--mono); color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.card-head .pips { margin-left: auto; align-self: center; }
.card.upcoming { background: transparent; border-style: dotted; }
.card.upcoming .card-head { background: transparent; border-bottom-style: dotted; }
.card.upcoming .card-level { color: var(--ink-2); }
.card.upcoming:hover { border-color: var(--line); border-style: dotted; }
.card.upcoming::before, .card.upcoming::after { color: var(--ink-3); }
.card.upcoming .thumb { opacity: .4; }
.card.upcoming h3 { color: var(--ink-2); }
.issue-hero .schedule { margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.issue-hero .schedule::before { content: "$ "; color: var(--brand); }
.card-top { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 14px; align-items: start; }
.card .thumb { width: 108px; height: 108px; outline: 1px solid var(--ink); outline-offset: 2px; }
.card h3 { margin: 0; font-size: 16.5px; line-height: 1.3; }
/* The summary: at most three lines on the card (the game page has the rest). */
.card .card-dek {
  margin: 6px 0 0; color: var(--ink-2); font: 13px/1.55 var(--mono);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
/* Players, result and length on one quiet line. */
.card-meta { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta b { color: var(--ink-2); font-weight: 700; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: -4px; }
.card .tags .chip { font-size: 12px; color: var(--ink-3); }

.level { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; row-gap: 4px; }
/* The level meter: █ for each level up to this one, ░ for the rest. */
.pips { display: inline-flex; gap: 0; font: 11px/1 var(--mono); letter-spacing: 0; }
.pips i { font-style: normal; color: var(--ink-3); }
.pips i::before { content: "\2591"; }
.pips i.on { color: var(--brand); }
.pips i.on::before { content: "\2588"; }
.level-name { font: 700 12px/1.2 var(--mono); letter-spacing: .03em; text-transform: uppercase; color: var(--brand); }
.level-range { font: 500 12px/1.2 var(--mono); color: var(--ink-3); }

.explainer { margin-top: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 26px 22px; }
.explainer div { padding: 18px 20px; }
.explainer h3 { font-size: 15px; margin-bottom: 6px; }
.explainer h3::before { content: "> "; color: var(--brand); }
.explainer p { margin: 0; color: var(--ink-2); font-size: 13.5px; }

/* ------------------------------------------------------------ game page */

.game-head { padding: 36px 0 20px; display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; }
.game-head .level { margin-bottom: 14px; }
/* The game's level, the same strip as on the home page's cards. */
.game-level { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 14px; }
.game-level .pips { align-self: center; }
.game-head h1 { font-size: clamp(24px, 3.4vw, 36px); line-height: 1.2; }
.matchup { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; font-size: 14px; align-items: center; }
.matchup .side { display: inline-flex; align-items: center; gap: 8px; }
.matchup .swatch { width: 11px; height: 11px; border: 1px solid var(--ink); }
.matchup .swatch.w { background: #fff; }
.matchup .swatch.b { background: #101318; }
.matchup .title { font: 700 11px/1 var(--mono); padding: 3px 4px; background: var(--ink); color: var(--bg); }
.matchup .result { font-weight: 700; }
.meta-line { color: var(--ink-3); font-size: 13px; margin-top: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 8px; border: 0; background: transparent;
  text-decoration: none; font: 700 14px/1 var(--mono); cursor: pointer; white-space: nowrap; color: var(--ink);
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { color: var(--brand); }
.btn.primary:hover { background: var(--brand); color: var(--brand-ink); }
.btn.small { height: 28px; padding: 0 6px; font-size: 13px; }

.lede { max-width: 820px; padding: 8px 0 0; }
/* The heading over the board sits closer to it than other section headings. */
.board-head { margin: 32px 0 0; }
/* Left-hand headings of the end sections ("## Takeaways // For 1600-1999 players"). */
.side-head h2 { font-size: 21px; }
.side-head p { margin: 6px 0 0; font-size: 13px; color: var(--ink-3); }
.side-head p::before { content: "// "; color: var(--brand); }
@media (max-width: 900px) { .game-head { grid-template-columns: 1fr; } }

/* "Why this game", after the takeaways: laid out like them, the reasons in a box. */
.why-section { margin-top: 36px; padding-top: 28px; display: grid; grid-template-columns: 260px 1fr; gap: 32px; position: relative; }
.why {
  list-style: none; margin: 0; padding: 8px 22px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px;
}
.why li { padding: 12px 0; font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.why li b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 3px; }
.why li b::before { content: "> "; color: var(--brand); }
@media (max-width: 800px) { .why-section { grid-template-columns: 1fr; gap: 14px; } .why { padding: 6px 18px; grid-template-columns: 1fr; } }

/* A row of "=" between the sections at the end of the page. */
.takeaways::before, .why-section::before {
  content: "================================================================================================================================================================";
  position: absolute; top: -0.8em; left: 0; right: 0; overflow: hidden; white-space: nowrap;
  font: 13px/1.6 var(--mono); color: var(--line);
}

/* viewer layout */
.viewer { display: grid; grid-template-columns: minmax(0, 600px) minmax(0, 1fr); gap: 28px; padding: 28px 0; align-items: start; }
@media (max-width: 1000px) { .viewer { grid-template-columns: 1fr; } }
.board-col { position: sticky; top: 76px; }
@media (max-width: 1000px) { .board-col { position: static; } }
.board-row { display: grid; grid-template-columns: 22px 1fr; gap: 10px; }

.evalbar { position: relative; overflow: hidden; background: var(--bar-dark); outline: 1px solid var(--ink); outline-offset: 2px; }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--bar-light); transition: height .35s steps(8); }
.evalbar.flipped .fill { bottom: auto; top: 0; }
.evalbar .mid { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--brand); }
.evalbar .num { position: absolute; left: 0; right: 0; text-align: center; font: 700 9px/1 var(--mono); }
.evalbar .num.top { top: 5px; color: var(--bar-light); }
.evalbar .num.bottom { bottom: 5px; color: var(--bar-dark); }

.variation-banner {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 6px 10px; border: 1px dashed var(--brand); background: var(--brand-wash); color: var(--ink); font-size: 13.5px;
}
.variation-banner.on { display: flex; }
.variation-banner .line { font-family: var(--mono); font-size: 13px; color: var(--ink-2); flex: 1 1 200px; }
.variation-banner .line b { color: var(--ink); }

.controls { display: flex; gap: 6px; margin: 14px 0 0 32px; align-items: center; flex-wrap: wrap; }
.controls button {
  height: 38px; min-width: 44px; padding: 0 12px; border: 1px solid var(--ink); background: var(--panel);
  cursor: pointer; font: 700 14px/1 var(--mono); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.controls button:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
.controls button:active:not(:disabled) { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.controls button:disabled { opacity: .35; cursor: default; }
.controls .spacer { flex: 1; }
.controls .grow { font-size: 13px; }
.board-hint { margin: 10px 0 0 32px; font-size: 12px; color: var(--ink-3); }
.board-hint::before { content: "// "; color: var(--brand); }

.engine-panel { margin: 18px 0 0 32px; padding: 10px 12px; font-size: 13px; }
.engine-head { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.engine-head .name { font-weight: 700; color: var(--ink); }
.engine-head .state { margin-left: auto; color: var(--ink-3); font-size: 12px; }
/* The engine switch is a checkbox: [ ] off, [x] on. */
.switch { position: relative; width: auto; height: auto; background: none; border: 0; cursor: pointer; padding: 0; flex: none; font: 700 14px/1 var(--mono); color: var(--ink-2); }
.switch::after { content: "[ ]"; }
.switch[aria-checked="true"] { color: var(--brand); }
.switch[aria-checked="true"]::after { content: "[x]"; }
.engine-lines { margin-top: 8px; display: grid; gap: 4px; }
.engine-line { display: flex; gap: 10px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.engine-line .ev { font-weight: 700; color: var(--ink); min-width: 52px; }
.engine-line .pv { overflow: hidden; text-overflow: ellipsis; }

.graph-wrap { margin: 18px 0 0 32px; position: relative; }
.graph-wrap .graph-title { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.evalgraph { display: block; width: 100%; height: 96px; cursor: pointer; background: var(--panel); border: 1px dashed var(--line); touch-action: none; }
.evalgraph .area-w { fill: var(--brand); opacity: .12; }
.evalgraph .area-b { fill: var(--ink); opacity: .07; }
[data-theme="dark"] .evalgraph .area-w { fill: #d7dee9; opacity: .12; }
[data-theme="dark"] .evalgraph .area-b { fill: #000; opacity: .5; }
.evalgraph .mid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.evalgraph .line { fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linejoin: miter; }
.evalgraph .cursor { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 2; }
.evalgraph .hover { stroke: var(--ink-3); stroke-width: 1; }
.evalgraph .dot { stroke: var(--panel); stroke-width: 2; }
.graph-tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg);
  padding: 5px 8px; font-size: 12px; line-height: 1.4; white-space: nowrap; transform: translate(-50%, -100%); opacity: 0; transition: opacity .1s;
}
.graph-tip b { font-size: 13px; }
.graph-tip.on { opacity: 1; }

/* commentary */
.notes-col { min-width: 0; }
.note-card { padding: 22px 24px; min-height: 280px; }
.note-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.note-move { font: 700 24px/1.15 var(--mono); }
.note-move::before { content: "> "; color: var(--brand); }
.qual { display: inline-flex; align-items: center; gap: 6px; padding: 1px 7px; border: 1px solid var(--line); font: 600 12px/1.5 var(--mono); color: var(--ink); }
.qual .dot { width: 8px; height: 8px; background: var(--ink-3); }
.qual.blunder .dot { background: var(--q-blunder); }
.qual.mistake .dot { background: var(--q-mistake); }
.qual.inaccuracy .dot, .qual.dubious .dot { background: var(--q-inaccuracy); }
.qual.best .dot, .qual.excellent .dot, .qual.good .dot, .qual.book .dot, .qual.forced .dot { background: var(--q-good); }
.qual.brilliant .dot { background: var(--q-brilliant); }
.qual.great .dot, .qual.interesting .dot { background: var(--q-great); }
.qual.ok .dot { background: var(--ink-3); }
.critical-flag { font: 700 11.5px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--bg); background: var(--brand); padding: 3px 5px; }
.note-eval { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-3); margin: 6px 0 14px; }
.note-eval b { color: var(--ink); font-weight: 700; }
.note-body { font: 400 15px/1.7 var(--mono); }
/* A note of several paragraphs: the first (the one-line summary) reads as its headline. */
.note-body p:first-child:not(:last-child) { font-weight: 700; }
.note-body p { margin: 0 0 .85em; }
.note-body p:last-child { margin-bottom: 0; }
.note-body .auto { color: var(--ink-3); font-style: italic; }

.options { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; }
.options h4 { margin: 0 0 10px; font: 700 12px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.options h4::before { content: "// "; color: var(--brand); }
.opt { display: grid; grid-template-columns: 22px 1fr; gap: 4px 10px; padding: 10px 0; border-top: 1px dashed var(--hair); }
.opt:first-of-type { border-top: 0; padding-top: 2px; }
.opt .mark { width: 18px; height: 18px; display: grid; place-items: center; font: 700 12px/1 var(--mono); color: #fff; margin-top: 2px; }
.opt.good .mark { background: var(--q-good); }
.opt.bad .mark { background: var(--q-blunder); }
.opt.engine .mark { background: var(--brand); }
.opt .opt-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.opt .san { font: 700 15px/1.3 var(--mono); }
.opt .ev { font: 700 12px/1 var(--mono); color: var(--ink-2); }
.opt .kind { font-size: 12px; color: var(--ink-3); }
.opt .opt-note { grid-column: 2; font: 13.5px/1.6 var(--mono); color: var(--ink-2); }
.opt .show { grid-column: 2; justify-self: start; border: 0; background: none; padding: 2px 0; color: var(--brand); font: 700 12.5px/1.3 var(--mono); cursor: pointer; }
.opt .show::before { content: "["; } .opt .show::after { content: "]"; }
.opt .show:hover { background: var(--brand); color: var(--brand-ink); }
.opt .pvtext { font-family: var(--mono); font-size: 12px; color: var(--ink-3); font-weight: 400; }

.movelist-card { margin-top: 26px; }
.movelist-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px dashed var(--line); font-size: 12.5px; color: var(--ink-3); }
.movelist { max-height: 340px; overflow-y: auto; display: grid; grid-template-columns: 44px 1fr 1fr; font-size: 14px; }
.movelist .num { padding: 5px 10px; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.movelist button { border: 0; background: transparent; text-align: left; padding: 5px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.movelist button:hover { background: var(--wash); }
.movelist button.cur { background: var(--brand); color: var(--brand-ink); }
.movelist button .g { font-weight: 800; font-size: 12.5px; }
.movelist button .g.blunder { color: var(--q-blunder); }
.movelist button .g.mistake { color: var(--q-mistake); }
.movelist button .g.inaccuracy, .movelist button .g.dubious { color: var(--q-inaccuracy); }
.movelist button .g.brilliant { color: var(--q-brilliant); }
.movelist button .g.great, .movelist button .g.interesting { color: var(--q-great); }
.movelist button.cur .g { color: inherit; }
.movelist button .star { width: 6px; height: 6px; background: var(--brand); }
.movelist button.cur .star { background: var(--brand-ink); }
.movelist .result-row { grid-column: 1 / -1; text-align: center; padding: 10px; font-weight: 700; border-top: 1px dashed var(--line); }

.explore-moves { font-family: var(--mono); font-size: 13px; }

.takeaways { position: relative; padding-top: 28px; display: grid; grid-template-columns: 260px 1fr; gap: 32px; }
.takeaways ol { margin: 0; padding-left: 34px; list-style: decimal-leading-zero; }
.takeaways li { margin-bottom: 16px; padding-left: 6px; color: var(--ink-2); }
/* Each takeaway's bold first sentence is its headline, on a line of its own. */
/* (It stays inline with a line break after it: as a block, Safari puts the "01." on a line of its own.) */
.takeaways li > span > strong:first-child { color: var(--ink); }
.takeaways li > span > strong:first-child::after { content: "\A"; white-space: pre; }
.takeaways li::marker { color: var(--brand); font-weight: 700; }
@media (max-width: 800px) { .takeaways { grid-template-columns: 1fr; gap: 10px; } }

.next-games { margin-top: 52px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.next-games a { display: block; padding: 16px 18px; text-decoration: none; }
.next-games a:hover { border-style: solid; border-color: var(--brand); }
.next-games a:hover::before, .next-games a:hover::after { color: var(--brand); }
.next-games .dir { font-size: 12px; color: var(--brand); font-weight: 700; }
.next-games .t { font: 700 15px/1.4 var(--mono); margin-top: 4px; }
.next-games a.next { text-align: right; }
.next-games .soon { padding: 16px 18px; background: transparent; border-style: dotted; }
.next-games .soon .t { color: var(--ink-3); }
.next-games .soon.next { text-align: right; }

/* ------------------------------------------------------------ board */

/* Quick taps on buttons (stepping through moves) shouldn't count as a double-tap zoom on phones. */
button, a, .chip { touch-action: manipulation; }
.board {
  position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden;
  user-select: none; -webkit-user-select: none; touch-action: none;
  outline: 1px solid var(--ink); outline-offset: 3px;
}
.board .sq { position: absolute; width: 12.5%; height: 12.5%; }
.board .sq.l { background: var(--sq-light); }
.board .sq.d { background: var(--sq-dark); }
.board .sq.last::after, .board .sq.sel::after, .board .sq.check::after, .board .sq.hl::after { content: ""; position: absolute; inset: 0; }
.board .sq.last::after { background: var(--sq-last); }
/* The last move takes the color of its rating, the same as its dot in the notes: stronger where the
   piece landed, lighter where it left. Lines you play yourself, which have no rating, stay blue.
   (game.js puts the rating on the board as data-q.) */
.board { --mv: var(--brand); }
.board[data-q="blunder"] { --mv: var(--q-blunder); }
.board[data-q="mistake"] { --mv: var(--q-mistake); }
.board[data-q="inaccuracy"], .board[data-q="dubious"] { --mv: #f5c400; }   /* brighter than the text color, so the pastel reads as yellow */
.board[data-q="best"], .board[data-q="excellent"], .board[data-q="good"],
.board[data-q="book"], .board[data-q="forced"] { --mv: var(--q-good); }
.board[data-q="brilliant"] { --mv: var(--q-brilliant); }
.board[data-q="great"], .board[data-q="interesting"] { --mv: var(--q-great); }
.board[data-q="ok"] { --mv: var(--ink-3); }
/* Solid pastels rather than see-through tints, so the color stays true on the blue squares too
   (yellow over blue would turn green). */
.board .sq.from::after { background: color-mix(in srgb, var(--mv) 22%, var(--sq-light)); }
.board .sq.to::after { background: color-mix(in srgb, var(--mv) 44%, var(--sq-light)); }
.board .sq.sel::after { background: var(--sq-select); }
.board .sq.check::after { background: var(--sq-check); }
.board .sq.dest::before { content: ""; position: absolute; left: 50%; top: 50%; width: 24%; height: 24%; margin: -12% 0 0 -12%; background: var(--sq-dest); z-index: 3; pointer-events: none; }
.board .sq.dest.occ::before { width: 92%; height: 92%; margin: -46% 0 0 -46%; background: transparent; border: 4px solid var(--sq-dest); box-sizing: border-box; }
.board .coord { position: absolute; font: 700 10.5px/1 var(--mono); pointer-events: none; z-index: 1; }
.board .coord.file { right: 3px; bottom: 3px; }
.board .coord.rank { left: 3px; top: 3px; }
.board .sq.l .coord { color: #2f5bff; }
.board .sq.d .coord { color: #101318; }
.board .pc { position: absolute; width: 12.5%; height: 12.5%; z-index: 2; background-size: 100% 100%; pointer-events: none; will-change: transform; }
.board .pc.drag { z-index: 10; transition: none !important; }
.board svg.arrows { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; }
.board.interactive { cursor: pointer; }

.mini { display: block; width: 100%; height: 100%; }

/* ------------------------------------------------------------ archive & about */

.page-head { padding: 44px 0 26px; }
.issue-list { display: grid; gap: 26px; }
.issue-row { padding: 20px 22px; }
.issue-row h2 { font-size: 19px; }
.issue-row h2 a { text-decoration: none; }
.issue-row h2 a:hover { color: var(--brand); }
.issue-row ul { margin: 12px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 24px; }
.issue-row li { font-size: 13.5px; display: flex; gap: 10px; align-items: baseline; }
.issue-row li a { text-decoration-style: dotted; text-underline-offset: 3px; }
.issue-row li a:hover { color: var(--brand); }
.issue-row li .level-range { min-width: 74px; }

.bracket-table { width: 100%; border-collapse: collapse; margin: 16px 0 8px; font-size: 13.5px; }
.bracket-table th, .bracket-table td { text-align: left; padding: 10px 10px; border-top: 1px dashed var(--line); vertical-align: top; }
.bracket-table th { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); border-top: 0; }
.bracket-table td:first-child { white-space: nowrap; font-weight: 700; }
.framework { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px 22px; margin-top: 18px; align-items: start; }
.framework section { padding: 18px 20px; }
.framework h3 { font-size: 15px; margin-bottom: 8px; }
.framework ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; list-style: "- "; }
.framework li { margin-bottom: 6px; }
.legend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 20px; margin-top: 14px; font-size: 13.5px; }
.legend-grid div { display: flex; gap: 10px; align-items: center; }
.about-section { margin-top: 56px; scroll-margin-top: 76px; }
.about-section > p { max-width: 780px; }
.about-section .section-head { margin-top: 0; }
/* Jump links under the About page's title. */
.jump { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 20px; }
.jump a { color: var(--brand); text-decoration: none; font: 700 13px/1.5 var(--mono); }
.jump a::before { content: "["; } .jump a::after { content: "]"; }
.jump a:hover { background: var(--brand); color: var(--brand-ink); }
/* The seven levels, as cards with the same strip as the home page. */
.level-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 16px 22px; }
.level-list li { border: 1px dashed var(--line); background: var(--panel); padding: 12px 16px 14px; }
.level-top { display: flex; align-items: baseline; gap: 10px; }
.level-top .pips { margin-left: auto; align-self: center; }
.level-list p { margin: 8px 0 0; font-size: 13.5px; line-height: 1.6; }
.level-list .level-src { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.about-note { margin: 16px 0 0; font-size: 13px; color: var(--ink-3); max-width: 780px; }
/* "Reading the board": "- " bullets with a bold label. */
.guide { list-style: none; margin: 0; padding: 0; max-width: 780px; }
.guide li { position: relative; padding-left: 2.4ch; margin: 0 0 10px; color: var(--ink-2); line-height: 1.65; }
.guide li::before { content: "-"; position: absolute; left: 0; color: var(--brand); font-weight: 700; }
.guide li b { color: var(--ink); }
.legend-head { margin: 26px 0 0; font-size: 14px; }
.legend-head::before { content: "// "; color: var(--brand); }
.legend-text { font-size: 13px; color: var(--ink-3); }
#legend { grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 12px 28px; }
#legend > div { display: grid; grid-template-columns: 12.5em minmax(0, 1fr); gap: 12px; align-items: baseline; }
#legend .qual { white-space: nowrap; justify-self: start; }
/* "How a game gets picked": numbered steps, each headline on its own line (as in the takeaways). */
.steps { margin: 0; padding-left: 34px; max-width: 780px; list-style: decimal-leading-zero; }
.steps li { margin-bottom: 16px; padding-left: 6px; color: var(--ink-2); line-height: 1.65; }
.steps li::marker { color: var(--brand); font-weight: 700; }
.steps li b { color: var(--ink); }
.steps li b::after { content: "\A"; white-space: pre; }
/* "What makes a game interesting": eight one-line items that open to show their points. */
.framework details { border: 1px dashed var(--line); background: var(--panel); padding: 0 16px; }
.framework summary { list-style: none; cursor: pointer; padding: 12px 0; font: 700 14.5px/1.4 var(--mono); }
.framework summary::-webkit-details-marker { display: none; }
.framework summary::before { content: "[+] "; color: var(--brand); }
.framework details[open] summary::before { content: "[-] "; }
.framework summary:hover { color: var(--brand); }
.framework details ul { margin: 0 0 14px; }

.empty { padding: 80px 0; text-align: center; color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ small screens */

@media (max-width: 1000px) {
  .viewer { display: flex; flex-direction: column; gap: 0; align-items: stretch; }
  .board-col { display: contents; }
  .board-pin { order: 1; }
  .controls { margin-left: 0; }
  .board-hint { order: 4; margin-left: 0; }
  .notes-col { order: 5; margin-top: 18px; }
  .engine-panel { order: 6; margin-left: 0; margin-top: 24px; }
  .graph-wrap { order: 7; margin-left: 0; }
}

@media (max-width: 560px) {
  body { font-size: 14px; }
  .wrap { padding: 0 16px; }
  .masthead .wrap { gap: 10px; height: 52px; }
  .brand-name { font-size: 15px; white-space: nowrap; }
  .brand-mark::before { font-size: 20px; }
  .nav { gap: 0; }
  .nav a { padding: 4px 4px; font-size: 13px; white-space: nowrap; }
  .board-row { grid-template-columns: 16px 1fr; gap: 6px; }
  .evalbar .num { font-size: 8px; }
  .note-card { padding: 20px 16px; }
  .note-move { font-size: 20px; }
  .note-body { font-size: 14.5px; }
  .engine-head span:nth-child(3) { display: none; }
  .next-games { grid-template-columns: 1fr; }
  .issue-hero { padding-top: 30px; }
  .issue-hero .dek, .game-head .dek { font-size: 15px; }
  /* Game pages on phones: get the board onto the first screen. The collapsed intro shows four lines
     of its first paragraph; the arrow-keys hint is for computers. */
  .game-head { padding: 26px 0 14px; gap: 14px; }
  .game-head .matchup { margin-top: 12px; }
  .lede .prose:has(> .intro-more[hidden]) > p:first-child {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; line-clamp: 4; overflow: hidden; margin-bottom: .4em;
  }
  .board-head { margin-top: 22px; }
  .board-head p { display: none; }
  .issue-hero .intro { font-size: 13.5px; }
  .section-head { margin-top: 32px; }
  .section-head h2 { font-size: 21px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card-meta { white-space: normal; }
}

/* Phones and tablets held upright: pin the board to the top of the screen so the note for the
   current move can be read beside the position, with the move buttons in a column on the board's
   right (for the right thumb). The board is at most 40% of the screen's height, and narrower if
   the screen is narrow. Landscape phones are too short to pin.
   --pin-h is set once by game.js from the height at load: phone browsers change the viewport
   height while scrolling (the address bar slides away), which would resize the board. */
@media (max-width: 1000px) and (orientation: portrait) {
  .board-pin {
    position: sticky; top: 0; z-index: 5;
    margin: 0 -24px; padding: 10px 24px;
    background: var(--bg); border-bottom: 1px dashed var(--line);
    display: grid; justify-content: center; column-gap: 8px;
    grid-template-columns: minmax(0, calc(var(--pin-h, 40vh) + 22px)) 52px;
  }
  @supports (height: 1svh) { .board-pin { grid-template-columns: minmax(0, calc(var(--pin-h, 40svh) + 22px)) 52px; } }
  .board-pin .board { outline-offset: 2px; }
  .board-pin .board-row { grid-column: 1; grid-row: 2; }
  /* A line being played: across the top, in two short rows (title and buttons, then the moves on one scrolling row). */
  .board-pin .variation-banner { grid-column: 1 / -1; grid-row: 1; margin-bottom: 8px; padding: 5px 8px; gap: 4px 8px; font-size: 12.5px; }
  .board-pin .variation-banner strong { flex: 1 1 auto; }
  .board-pin .variation-banner .line { order: 3; flex: 1 1 100%; position: relative; font-size: 12px; white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
  .board-pin .variation-banner .btn.small { height: 26px; padding: 0 4px; font-size: 12px; }
  .board-pin .controls { grid-column: 2; grid-row: 2; margin: 0; flex-direction: column; flex-wrap: nowrap; gap: 6px; align-self: stretch; }
  .board-pin .controls button { flex: 1 1 0; min-height: 0; height: auto; width: 100%; min-width: 0; padding: 0; }
  .board-pin .controls button:nth-child(2), .board-pin .controls button:nth-child(3) { flex-grow: 1.6; }
  .board-pin .controls .spacer { display: none; }
  .board-pin .controls .grow { flex: 0.9 1 0; white-space: normal; font-size: 11px; line-height: 1.15; flex-direction: column; gap: 0; }
  .board-hint { margin-top: 12px; }
  .notes-col { margin-top: 14px; }
}
@media (max-width: 560px) and (orientation: portrait) { .board-pin { margin: 0 -16px; padding: 10px 16px; } }

/* The full name "Rank & File Weekly" plus three links doesn't fit one row on phones:
   put the links on their own row under the name. */
@media (max-width: 480px) {
  .masthead .wrap { flex-wrap: wrap; height: auto; padding-top: 12px; padding-bottom: 8px; row-gap: 6px; }
  .nav { width: 100%; margin-left: -4px; }
  .theme-toggle { margin-left: auto; }
}
