/* XeChess site styles, built on the Gambit design system tokens.
   Shared by the Go-rendered pages and the React game screens. */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg-000: #14120f;
  --bg-100: #1f1c18;
  --bg-200: #2b2722;
  --line: #48423a;
  --ink: #f2efe9;
  --ink-muted: #a8a29a;
  --accent: #d9ad4f;
  --on-accent: #1a1408;
  --danger: #ff7b72;
  --good: #7fc28a;

  --piece-white: #f7f4ee;
  --piece-white-line: #1d1b19;
  --piece-black: #1d1b19;
  --piece-black-line: #f7f4ee;
  --square-last: rgba(255, 214, 10, 0.4);
  --square-select: rgba(255, 214, 10, 0.62);
  --square-check: rgba(229, 72, 77, 0.8);
  --square-hint: rgba(0, 0, 0, 0.26);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --nav-h: 56px;

  /* Board squares: the html[data-board] rules below override these. */
  --sq-l: #e3e9d8;
  --sq-d: #5f8a70;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg-000: #f6f4ef;
    --bg-100: #ffffff;
    --bg-200: #ebe7df;
    --line: #c9c2b6;
    --ink: #1d1b19;
    --ink-muted: #5f5a53;
    --accent: #8a6414;
    --on-accent: #ffffff;
    --danger: #b3261e;
    --good: #2f7a3e;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg-000: #f6f4ef;
  --bg-100: #ffffff;
  --bg-200: #ebe7df;
  --line: #c9c2b6;
  --ink: #1d1b19;
  --ink-muted: #5f5a53;
  --accent: #8a6414;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --good: #2f7a3e;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* "hidden" always wins over component display rules (menus, buttons, panels). */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  /* Header, main, footer: main takes the free space so the footer sits at the bottom. */
  display: flex;
  flex-direction: column;
  background: var(--bg-000);
  color: var(--ink);
  font: 400 15px/22px var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 40px; line-height: 44px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 24px; line-height: 30px; }
h3 { font-size: 17px; line-height: 24px; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
code, kbd, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; line-height: 18px; }
.caption {
  font: 500 11px/14px var(--font-sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip-link {
  position: absolute; inset-inline-start: var(--space-4); top: -48px; z-index: 50;
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  background: var(--accent); color: var(--on-accent); text-decoration: none;
}
.skip-link:focus { top: var(--space-2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 36px; padding: var(--space-2) var(--space-3);
  border: 1px solid transparent; border-radius: var(--radius-md);
  font: 500 13px/18px var(--font-sans); text-decoration: none; white-space: nowrap;
  cursor: pointer; background: none; color: var(--ink);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.secondary { background: var(--bg-200); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink-muted); }
.btn.ghost:hover { background: var(--bg-200); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.large { min-height: 46px; padding: var(--space-3) var(--space-6); font-size: 15px; line-height: 22px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* ---------- header ----------
   Three parts on one line: the language and settings at the start, the menu
   in the middle split around the logo, the inbox and account at the end. The
   logo, the app icon alone, sits on the centre line of the page, the same on
   every page.
   At the top of a page the bar spans the width on a hairline. Scrolling down
   it slides away; scrolling back up it returns as a floating bar, inset, with
   its own border and the page blurred behind it, and it settles back into the full bar at the top (site.js headerScroll). The
   surface is a layer of its own (::before), so the bar changes shape without
   moving its contents. Game screens keep it still. */
.site-header {
  --hdr-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --hdr-inset: 0px;
  position: sticky; top: 0; z-index: 30; isolation: isolate;
  height: var(--nav-h);
  display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center; gap: var(--space-4);
  padding: 0 calc(var(--space-6) + var(--hdr-inset));
  transition: transform 460ms var(--hdr-ease), padding 460ms var(--hdr-ease);
}
.site-header::before {
  content: ""; position: absolute; z-index: -1;
  inset: 0 var(--hdr-inset);
  background: var(--bg-000);
  border: 1px solid transparent; border-bottom-color: var(--line);
  border-radius: 0;
  transition: inset 460ms var(--hdr-ease), border-radius 460ms var(--hdr-ease), background-color 300ms ease-out, border-color 300ms ease-out;
}
.site-header.floating { --hdr-inset: var(--space-3); }
.site-header.floating::before {
  inset: 6px var(--hdr-inset);
  background: color-mix(in srgb, var(--bg-000) 80%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.3); backdrop-filter: blur(16px) saturate(1.3);
  border-color: var(--line);
  border-radius: var(--radius-lg);
}
/* Away while reading down; back as soon as the reader scrolls up or tabs into it. */
.site-header.away:not(:focus-within) { transform: translateY(calc(-100% - 8px)); }

.hdr-tools { justify-self: start; display: flex; align-items: center; gap: var(--space-1); }
.hdr-tools .lang-host { position: relative; }
.hdr-tools .menu { inset-inline-end: auto; inset-inline-start: 0; }
.nav-actions { justify-self: end; display: flex; align-items: center; gap: var(--space-2); }

/* The logo: the app icon alone, in the middle of the bar. */
.brand {
  display: flex; align-items: center; justify-content: center; height: 100%; padding: 0 var(--space-4);
  border-radius: var(--radius-md);
}
.brand-mark { width: 32px; height: 32px; border-radius: 9px; transition: transform 460ms var(--hdr-ease); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }

/* The links sit on a quiet rail, half on each side of the logo; a gold ink
   line glides under the one pointed at, and rests under the current section
   (site.js navInk). Without script the current section shows as a filled pill. */
.nav-links {
  position: relative; height: 100%;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: var(--space-4);
}
.nav-half { display: flex; align-items: center; gap: 2px; }
.nav-half:first-child { justify-content: flex-end; }
.nav-half a {
  position: relative; display: flex; align-items: center; height: 36px;
  padding: 0 var(--space-3); border-radius: var(--radius-md);
  font: 500 13.5px/18px var(--font-sans); color: var(--ink-muted); text-decoration: none; white-space: nowrap;
  transition: color 160ms ease-out, background-color 160ms ease-out;
}
.nav-half a:hover { color: var(--ink); }
.nav-half a[aria-current="page"] { color: var(--ink); background: var(--bg-200); }
.nav-links.inked a[aria-current="page"] { background: none; }
.nav-ink {
  /* Placed by site.js in physical pixels from the left, in both directions. */
  position: absolute; left: 0; bottom: 8px;
  width: 1px; height: 2px; border-radius: 2px;
  background: var(--accent); opacity: 0; pointer-events: none;
}
.nav-links.inked .nav-ink { opacity: 1; }
.nav-links.inked.glide .nav-ink { transition: transform 380ms var(--hdr-ease, ease-out), width 380ms var(--hdr-ease, ease-out), opacity 200ms ease-out; }
.nav-links.inked .nav-ink.rest { opacity: 0; }
/* Narrower screens: the links draw closer, the account shows its picture only. */
@media (max-width: 1320px) {
  .site-header { gap: var(--space-3); padding: 0 calc(var(--space-4) + var(--hdr-inset)); }
  .site-header .account-chip [data-name] { display: none; }
  .site-header .account-chip { padding-inline-end: 2px; }
}
@media (max-width: 1160px) {
  .nav-half a { padding: 0 var(--space-2); font-size: 13px; }
  .nav-links { column-gap: var(--space-2); }
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-md);
  color: var(--ink-muted); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: var(--bg-200); }
.icon-btn svg { width: 20px; height: 20px; }
.account { position: relative; }
/* Notifications and messages: icons with an unread count. */
.inbox-icons { display: flex; align-items: center; gap: var(--space-1); }
.notes-host { position: relative; }
.notes-host summary { list-style: none; }
.notes-host summary::-webkit-details-marker { display: none; }
.inbox-icons .icon-btn { position: relative; }
.notes-host[open] > summary { color: var(--ink); background: var(--bg-200); }
.badge {
  position: absolute; top: -2px; inset-inline-end: -5px; min-width: 14px; height: 16px; padding: 0 4px; border-radius: 999px; pointer-events: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--bg-000); border: 2px solid var(--bg-000);
  font: 700 10px/1 var(--font-sans); font-variant-numeric: tabular-nums; box-sizing: content-box;
}
.notes-menu { width: min(360px, calc(100vw - 24px)); padding: 0; inset-inline-end: -8px; }
.notes-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); font: 600 14px/20px var(--font-sans); }
.notes-list { max-height: min(420px, 70vh); overflow-y: auto; padding: var(--space-1); }
.notes-list a, .notes-list .note { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); white-space: normal; }
.note-body { font: 400 13px/18px var(--font-sans); color: var(--ink); }
.note-time { font-size: 12px; color: var(--ink-muted); }
.notes-list .note.unread .note-body { font-weight: 600; }
.notes-list .note.unread { position: relative; padding-inline-start: calc(var(--space-3) + 10px); }
.notes-list .note.unread::before { content: ""; position: absolute; inset-inline-start: 8px; top: 15px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
@media (max-width: 560px) {
  .account-chip [data-name] { display: none; }
  .account-chip { padding-inline-end: 2px; }
  .inbox-icons .icon-btn, .nav-actions > .icon-btn { width: 34px; }
}
.notes-empty { margin: 0; padding: var(--space-4); text-align: center; color: var(--ink-muted); font-size: 13px; }
.account summary { list-style: none; cursor: pointer; }
.account summary::-webkit-details-marker { display: none; }
.account-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding-block: 2px; padding-inline: 2px var(--space-2); border-radius: var(--radius-md);
  font: 500 13px/18px var(--font-sans);
}
.account-chip:hover { background: var(--bg-200); }
.menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 200px; z-index: 40;
  display: flex; flex-direction: column; padding: var(--space-1);
  background: var(--bg-100); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.menu a, .menu button {
  display: block; width: 100%; text-align: start; padding: var(--space-2) var(--space-3);
  border: 0; border-radius: var(--radius-md); background: none; cursor: pointer;
  font: 500 13px/18px var(--font-sans); text-decoration: none; color: var(--ink);
}
.menu a:hover, .menu button:hover { background: var(--bg-200); }
.menu .menu-head { padding: var(--space-2) var(--space-3); color: var(--ink-muted); font-size: 13px; }

/* ---------- avatars ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: var(--bg-200); border: 1px solid var(--line);
  font: 600 15px/1 var(--font-sans); color: var(--ink); overflow: hidden;
}
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; border-radius: var(--radius-lg); }
.bot-portrait { flex: none; border-radius: 50%; }

/* ---------- layout ---------- */
main { display: flex; flex-direction: column; flex: 1 0 auto; }
main > * { flex-shrink: 0; }
.wrap { width: min(1200px, 100% - 2 * var(--space-4)); margin-inline: auto; }
.wrap.narrow { width: min(760px, 100% - 2 * var(--space-4)); }
.section { padding: calc(var(--space-8) * 1.5) 0; }
.section + .section { padding-top: 0; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); }
.section-head p { margin-top: var(--space-1); }
.page-head { padding: calc(var(--space-8) * 1.5) 0 var(--space-6); }
.page-head p { margin-top: var(--space-3); max-width: 62ch; font-size: 17px; line-height: 26px; color: var(--ink-muted); }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-bottom: var(--space-3); font-size: 13px; color: var(--ink-muted); list-style: none; padding: 0; }
.breadcrumbs li + li::before { content: "/"; margin-inline-end: var(--space-1); opacity: 0.6; }
.breadcrumbs a { text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); }
.panel {
  background: var(--bg-100); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--space-4);
}
.grid { display: grid; gap: var(--space-4); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: var(--space-3); }

/* ---------- hero: the opening moment of a game ---------- */
.match {
  display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 440px); gap: var(--space-8);
  justify-content: center; align-items: center; padding: var(--space-8) 0 calc(var(--space-8) * 1.5);
}
.match-board { display: flex; flex-direction: column; gap: var(--space-2); }
.match-seat { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; }
.match-seat .bot-portrait { width: 44px; height: 44px; }
.match-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 20px; }
.match-who strong { font-weight: 600; }
.match-clock {
  font: 600 20px/26px var(--font-mono); font-variant-numeric: tabular-nums; padding: 2px var(--space-3);
  border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--bg-100); color: var(--ink-muted);
}
.match-clock.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg-000); }
.match-line {
  position: relative; align-self: flex-start; max-width: 88%; margin: 0 0 var(--space-1) 56px;
  padding: var(--space-2) var(--space-3); background: var(--bg-200); border: 1px solid var(--line);
  border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg); font-size: 14px; line-height: 20px;
  transition: opacity 160ms ease;
}
.match-line.swap { opacity: 0; }
.match-panel { display: flex; flex-direction: column; gap: var(--space-4); }
.match-panel h1 { font-size: clamp(34px, 3.6vw, 44px); line-height: 1.05; letter-spacing: -0.025em; }
.match-panel .lede { color: var(--ink-muted); font-size: 16px; line-height: 24px; max-width: 44ch; }
.match-panel #lineup-label { margin-top: var(--space-2); }
.lineup { list-style: none; margin: calc(var(--space-2) * -1) 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-1); }
.lineup-pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-2) 2px;
  border: 2px solid transparent; border-radius: var(--radius-md); text-decoration: none; text-align: center;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.lineup-pick:hover { background: var(--bg-200); }
.lineup-pick[aria-pressed="true"] { border-color: var(--accent); background: var(--bg-200); }
.lineup-pick .bot-portrait { width: 44px; height: 44px; margin-bottom: 2px; }
.lineup-name { font: 500 12px/15px var(--font-sans); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lineup-pick .rating { font-size: 11px; line-height: 14px; }
.hero-board .board-svg { cursor: pointer; touch-action: manipulation; }
.hero-board use { transition: transform 220ms cubic-bezier(0.22, 0.9, 0.3, 1); }
.hero-board .hl-sel { fill: var(--square-select); }
.hero-board .hint { fill: var(--square-hint); pointer-events: none; }
.match-quick { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-3); }
.match-quick a { font-family: var(--font-mono); color: var(--ink); text-underline-offset: 3px; }
.swatch {
  display: grid; grid-template-columns: 1fr 1fr; aspect-ratio: 2 / 1;
  border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line);
}
.swatch i { display: block; }

/* ---------- boards (server-rendered SVG) ---------- */
.board-figure { margin: 0; }
.board-svg { width: 100%; height: auto; border-radius: var(--radius-sm); }
.board-svg .sq-l { fill: var(--sq-l); }
.board-svg .sq-d { fill: var(--sq-d); }
.board-svg .hl { fill: var(--square-last); }
.board-svg .coord { fill: var(--ink-muted); font: 500 0.24px var(--font-sans); }
.board-svg .fin { fill: url(#fin-satin); }
.board-svg .grain { fill: url(#fin-grain-lines); display: none; }
html[data-finish="grain"] .board-svg .grain { display: inline; }
html[data-finish="flat"] .board-svg .fin { display: none; }
.board-figure figcaption { margin-top: var(--space-2); font-size: 13px; color: var(--ink-muted); }
.board-figure.thumb .board-svg { border-radius: var(--radius-sm); }

/* pieces: colours flow into <use> shadow trees through custom properties */
.pc-w { --pf: var(--piece-white); --pl: var(--piece-white-line); --so: 0.16; --ho: 0; }
.pc-b { --pf: var(--piece-black); --pl: var(--piece-black-line); --so: 0; --ho: 0.18; }
.gp-a { fill: var(--pf); stroke: var(--pl); stroke-width: 1.4; stroke-linejoin: round; }
.gp-f { fill: var(--pf); }
.gp-o { fill: none; stroke: var(--pl); stroke-width: 1.4; stroke-linejoin: round; }
.gp-s { fill: #000; opacity: var(--so); }
.gp-h { fill: #fff; opacity: var(--ho); }
.gp-b { fill: var(--pl); }
.gp-c { fill: none; stroke: var(--pl); stroke-width: 1.1; stroke-linecap: round; }

/* ---------- cards ---------- */
.card {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-100); text-decoration: none; color: var(--ink);
  transition: border-color 120ms ease, background-color 120ms ease;
}
a.card:hover { border-color: var(--ink-muted); background: color-mix(in srgb, var(--bg-100) 70%, var(--bg-200)); }
.card p { color: var(--ink-muted); font-size: 14px; line-height: 21px; }
.bot-card { flex-direction: row; align-items: center; gap: var(--space-4); }
.bot-card .who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bot-card h3 { display: flex; align-items: baseline; gap: var(--space-2); }
.rating { font: 400 13px/18px var(--font-mono); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.tag {
  display: inline-flex; align-items: center; padding: 1px var(--space-2); border-radius: 999px;
  border: 1px solid var(--line); font: 500 11px/16px var(--font-sans); color: var(--ink-muted);
  letter-spacing: 0.02em; white-space: nowrap;
}
/* A house player (a bot account): the Bot badge next to its name everywhere. */
.tag.tag-bot { color: var(--accent); border-color: var(--accent); }
.house-note { margin-top: var(--space-2); }
.opening-card .moves { font: 500 13px/20px var(--font-mono); color: var(--ink-muted); }

ul.grid { list-style: none; padding: 0; margin: 0; }
.opening-card .board-figure, .puzzle-grid .board-figure { margin-bottom: var(--space-1); }
.bot-hero { display: flex; align-items: center; gap: var(--space-6); }
.bot-hero h1 { display: flex; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-1); }
.bot-hero p:not(.caption) { margin-top: var(--space-2); color: var(--ink-muted); font-size: 17px; line-height: 26px; }
.article-grid, .bot-body { align-items: start; gap: calc(var(--space-8) * 1.5); grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.article-grid aside, .bot-body aside { position: sticky; top: calc(var(--nav-h) + var(--space-4)); }
.opening-trainer { margin-bottom: var(--space-8); }
.opening-trainer-fallback { max-width: 520px; }
.opening-article { max-width: 760px; }
.guide-notes { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: var(--space-2) var(--space-3); }
.guide-notes dt { white-space: nowrap; }
.guide-notes dd { margin: 0; }
.guide-branch { padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.guide-branch p { margin: 0; }
.guide-branch p + p { margin-top: var(--space-1); }
@media (max-width: 560px) { .guide-notes { grid-template-columns: 1fr; gap: 0; } .guide-notes dd { margin-bottom: var(--space-2); } }
.article-grid aside.stack { position: static; }
/* Generated SEO pages: opening variations, puzzle themes, time controls */
.variation-board { max-width: 520px; margin-bottom: var(--space-8); }
.result-bar { display: flex; height: 28px; margin: var(--space-3) 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; font: 600 12px/26px var(--font-mono); font-variant-numeric: tabular-nums; }
.result-bar span { flex-basis: 0; min-width: 0; text-align: center; overflow: hidden; }
.rb-white { background: var(--piece-white); color: var(--piece-white-line); }
.rb-draw { background: var(--bg-200); color: var(--ink-muted); }
.rb-black { background: var(--piece-black); color: var(--piece-black-line); }
.theme-grid { margin-bottom: var(--space-6); }
.theme-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.theme-guide { max-width: 760px; margin-bottom: var(--space-8); }
.theme-level { margin-bottom: var(--space-8); }
.theme-level h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-4); }
.theme-level h2 .small { font-weight: 400; }
.theme-links, .tc-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.tc-grid { margin-bottom: var(--space-3); }
.tc-card { justify-content: space-between; }
.tc-card-name { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink); }
.tc-card-name strong { font: 600 22px/28px var(--font-mono); font-variant-numeric: tabular-nums; }
.tc-games { padding-inline-start: var(--space-4); }
.site-footer .footer-more { order: 3; flex-basis: 100%; }
.stats .stat { margin-top: var(--space-2); font: 600 28px/32px var(--font-mono); font-variant-numeric: tabular-nums; }
.players { display: flex; flex-direction: column; gap: var(--space-3); }
.player-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.seat { display: inline-flex; align-items: center; gap: var(--space-3); min-width: 0; }
.seat a { text-decoration: none; font-weight: 500; }
.seat a:hover { text-decoration: underline; }
.score { font-size: 22px; font-weight: 600; }
.center { text-align: center; }
.page-head.center p { margin-inline: auto; }
.auth-wrap { width: min(400px, 100% - 2 * var(--space-4)); margin: auto; padding: var(--space-8) 0; }
.auth-wrap .page-head { padding-top: 0; }
.auth-wrap .panel { border: 0; background: none; padding: 0; }
/* Sign in with Google: Google's own button (branding rules), dark or light with the theme. */
.btn-google { --g-bg: #131314; --g-line: #8e918f; --g-ink: #e3e3e3;
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; padding: 0 12px;
  background: var(--g-bg); border: 1px solid var(--g-line); border-radius: 22px; color: var(--g-ink);
  font: 500 14px/20px Roboto, var(--font-sans); letter-spacing: .25px; text-decoration: none; }
.btn-google:hover { background: color-mix(in srgb, var(--g-ink) 8%, var(--g-bg)); }
.btn-google:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-google svg { flex: none; }
:root[data-theme="light"] .btn-google { --g-bg: #ffffff; --g-line: #747775; --g-ink: #1f1f1f; }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] .btn-google { --g-bg: #ffffff; --g-line: #747775; --g-ink: #1f1f1f; } }
/* Sign in with Apple: Apple's own button, white on the dark theme, black on the light one. */
.btn-apple { --a-bg: #ffffff; --a-ink: #000000;
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--a-bg); border: 1px solid var(--a-bg); border-radius: 22px; color: var(--a-ink);
  font: 500 15px/20px -apple-system, BlinkMacSystemFont, var(--font-sans); text-decoration: none; }
.btn-apple:hover { background: color-mix(in srgb, var(--a-ink) 8%, var(--a-bg)); }
.btn-apple:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-apple svg { flex: none; margin-top: -3px; }
:root[data-theme="light"] .btn-apple { --a-bg: #000000; --a-ink: #ffffff; }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] .btn-apple { --a-bg: #000000; --a-ink: #ffffff; } }
/* Sign in with Facebook: Facebook's blue with its white logo, the same on both themes. */
.btn-facebook { display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; padding: 0 12px;
  background: #1877f2; border: 1px solid #1877f2; border-radius: 22px; color: #ffffff;
  font: 600 15px/20px var(--font-sans); text-decoration: none; }
.btn-facebook:hover { background: #166fe5; border-color: #166fe5; }
.btn-facebook:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-facebook svg { flex: none; }
.signin-buttons { gap: var(--space-3); }
/* The analytics question: a calm card at the bottom (above the tab bar on
   phones). Both answers look the same, so saying no is as easy as yes. */
.consent { position: fixed; z-index: 45; left: 50%; transform: translateX(-50%); bottom: var(--space-4);
  width: min(560px, calc(100% - 2 * var(--space-4))); display: grid; gap: var(--space-3); padding: var(--space-4);
  background: var(--bg-100); border: 1px solid var(--line); border-radius: var(--radius-lg);
  color: var(--ink-muted); font-size: 14px; line-height: 1.5; }
.consent[hidden] { display: none; }
.consent p { margin: 0; }
.consent strong { color: var(--ink); font-weight: 600; }
.consent-actions { display: flex; gap: var(--space-2); }
.consent-actions .btn { flex: 1 1 0; min-height: 40px; }
@media (max-width: 760px) { .consent { bottom: calc(var(--tab-h) + var(--safe-b) + var(--space-2)); } }
.or-rule { display: flex; align-items: center; gap: var(--space-3); color: var(--ink-muted); font-size: 13px; }
.or-rule::before, .or-rule::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.shell-title { font-size: 24px; line-height: 30px; margin-bottom: var(--space-2); }

/* ---------- prose and FAQ ---------- */
.prose { font-size: 16px; line-height: 26px; }
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: calc(var(--space-8) * 1.25); }
.prose h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-inline-start: 1.3em; }
.prose li + li { margin-top: var(--space-1); }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose .answer { font-size: 18px; line-height: 28px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th, .prose td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.prose th { font-weight: 600; color: var(--ink-muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.faq { border-top: 1px solid var(--line); }
.faq-block { max-width: 760px; margin: 0 auto; }
.faq-block h2 { text-align: center; margin-bottom: var(--space-6); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) 0;
  cursor: pointer; list-style: none; font: 600 16px/24px var(--font-sans);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--ink-muted); font-weight: 400; }
.faq details[open] summary::after { content: "−"; }
.faq details p { padding: 0 0 var(--space-4); max-width: 70ch; color: var(--ink-muted); }

/* ---------- moves, tables ---------- */
.move-text { font: 500 14px/24px var(--font-mono); }
.move-text .no { color: var(--ink-muted); margin-inline-end: 2px; }
.move-table { list-style: none; margin: 0; padding: 0; font: 500 14px/20px var(--font-mono); columns: 2 220px; column-gap: var(--space-6); }
.move-table.panel { padding: var(--space-2) var(--space-4); }
.move-table li { display: grid; grid-template-columns: 40px 1fr 1fr; gap: var(--space-1); padding: 3px 0; break-inside: avoid; }
.move-table li span:first-child { color: var(--ink-muted); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: var(--space-3); border-bottom: 1px solid var(--line); text-align: start; }
.data-table th { font: 500 11px/14px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.data-table td a { text-decoration: none; }
.data-table td a:hover { text-decoration: underline; }
.result-win { color: var(--good); }
.result-loss { color: var(--danger); }
.pgn { white-space: pre-wrap; word-break: break-word; font: 400 13px/20px var(--font-mono); color: var(--ink-muted); margin: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label { font: 500 13px/18px var(--font-sans); }
.input {
  width: 100%; min-height: 42px; padding: var(--space-2) var(--space-3);
  background: var(--bg-000); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-md);
  font: 400 15px/22px var(--font-sans);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.tabs { display: flex; gap: var(--space-1); padding: var(--space-1); background: var(--bg-000); border: 1px solid var(--line); border-radius: var(--radius-md); }
.tabs a { flex: 1; text-align: center; padding: var(--space-2); border-radius: var(--radius-sm); text-decoration: none; font: 500 13px/18px var(--font-sans); color: var(--ink-muted); }
.tabs a[aria-current="page"] { background: var(--bg-200); color: var(--ink); }
.form-error { padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--danger); color: var(--danger); font-size: 14px; }
.form-ok { margin: 0; padding: var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--good); color: var(--ink); font-size: 14px; }

/* ---------- footer ---------- */
.site-footer { flex-shrink: 0; margin-top: calc(var(--space-8) * 2); border-top: 1px solid var(--line); padding: var(--space-8) 0; color: var(--ink-muted); font-size: 13px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--space-6); justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* ---------- app shell (React game screens) ---------- */
body.app-page { overflow: hidden; }
body.app-page #root { height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h)); }
.shell-placeholder { display: grid; place-items: center; height: 100%; padding: var(--space-6); text-align: center; }
.shell-placeholder .board-figure { width: min(420px, 70vw, 60vh); margin: 0 auto var(--space-4); }

/* ---------- board colourways ---------- */
html[data-board="tournament"] { --sq-l: #e3e9d8; --sq-d: #5f8a70; }
html[data-board="walnut"] { --sq-l: #e8cfa6; --sq-d: #8a5a3b; }
html[data-board="maple"] { --sq-l: #f4dfb0; --sq-d: #c98f4c; }
html[data-board="mahogany"] { --sq-l: #e6c3a1; --sq-d: #7a3324; }
html[data-board="ivory"] { --sq-l: #ece6d8; --sq-d: #3c3836; }
html[data-board="slate"] { --sq-l: #d5dae0; --sq-d: #5d6b7a; }
html[data-board="marble"] { --sq-l: #f1f0ec; --sq-d: #9a9c9f; }
html[data-board="newsprint"] { --sq-l: #f4f1e8; --sq-d: #8c8a84; }
html[data-board="forest"] { --sq-l: #dfe8cf; --sq-d: #3f6b46; }
html[data-board="ocean"] { --sq-l: #d6e6f0; --sq-d: #2f6690; }
html[data-board="desert"] { --sq-l: #f2e1bf; --sq-d: #c48a4a; }
html[data-board="glacier"] { --sq-l: #eaf4f7; --sq-d: #7fb0c4; }
html[data-board="lavender"] { --sq-l: #ebe4f3; --sq-d: #8b74b3; }
html[data-board="sakura"] { --sq-l: #fbe9ec; --sq-d: #d17d92; }
html[data-board="moss"] { --sq-l: #e3e2c3; --sq-d: #6b7a3a; }
html[data-board="coral"] { --sq-l: #fde6d8; --sq-d: #e07856; }
html[data-board="sandstone"] { --sq-l: #efdcc5; --sq-d: #b0785a; }
html[data-board="midnight"] { --sq-l: #a9b4c9; --sq-d: #27324a; }
html[data-board="graphite"] { --sq-l: #bfc3c8; --sq-d: #40454c; }
html[data-board="mono"] { --sq-l: #f5f5f5; --sq-d: #2b2b2b; }
html[data-board="blueprint"] { --sq-l: #cfe0f5; --sq-d: #2f5fa8; }
html[data-board="mint"] { --sq-l: #e4f5ec; --sq-d: #5fb08a; }
html[data-board="rose"] { --sq-l: #f7e3e3; --sq-d: #b85c6b; }
html[data-board="amber"] { --sq-l: #fdf0c8; --sq-d: #d99a1f; }
html[data-board="terminal"] { --sq-l: #9fd3a8; --sq-d: #2c6b45; }
html[data-board="ultraviolet"] { --sq-l: #e3d9ff; --sq-d: #6a3fd0; }
html[data-board="contrast"] { --sq-l: #fff7d6; --sq-d: #1f5fbf; }
html[data-board="sepia"] { --sq-l: #f0e2c8; --sq-d: #a08260; }
html[data-board="nebula"] { --sq-l: #f0cfe6; --sq-d: #8a2f7d; }
html[data-board="deep-space"] { --sq-l: #b8c4dc; --sq-d: #1c2541; }
html[data-board="plasma"] { --sq-l: #d8fbff; --sq-d: #0fa3b1; }
html[data-board="mars"] { --sq-l: #f4d3c0; --sq-d: #b4482f; }
html[data-board="lunar"] { --sq-l: #e6e6e6; --sq-d: #8d9199; }
html[data-board="reactor"] { --sq-l: #e8f7c8; --sq-d: #6aa80f; }
html[data-board="solar-flare"] { --sq-l: #ffe9b8; --sq-d: #e2571c; }
html[data-board="dungeon"] { --sq-l: #c9c2b5; --sq-d: #5b5348; }
html[data-board="dragonfire"] { --sq-l: #f6d9b8; --sq-d: #a3271b; }
html[data-board="elven"] { --sq-l: #e6f0d8; --sq-d: #4f8a6b; }
html[data-board="arcade"] { --sq-l: #ffe3f1; --sq-d: #e0218a; }
html[data-board="pocket-lcd"] { --sq-l: #c4cfa1; --sq-d: #4d533c; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .match { grid-template-columns: minmax(0, 560px); padding-top: var(--space-6); }
  .match-panel { order: -1; }
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .article-grid, .bot-body { grid-template-columns: minmax(0, 1fr); }
  .article-grid aside, .bot-body aside { position: static; }
}
@media (max-width: 760px) {
  .nav-half { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .lineup { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .match-line { margin-inline-start: 0; max-width: 100%; }
  h1 { font-size: 32px; line-height: 38px; }
  .section { padding: var(--space-8) 0; }
  .section-head { flex-direction: column; align-items: start; }
  .data-table .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- moderation: announcement banner, puzzle filters and pager, report links (admin agent) ---------- */
.announce {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-100)); color: var(--ink); font-size: 14px; line-height: 20px;
}
.announce p { max-width: 90ch; text-align: center; }
.announce-warning { background: color-mix(in srgb, var(--danger) 16%, var(--bg-100)); }
.announce-close { flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-muted); cursor: pointer; }
.announce-close:hover { background: var(--bg-200); color: var(--ink); }
.announce-close svg { width: 16px; height: 16px; }
/* React screens fill the window under the header and the banner. */
body.app-page.has-announce { height: 100vh; height: 100dvh; }
body.app-page.has-announce main { flex: 1 1 auto; min-height: 0; }
body.app-page.has-announce #root { height: 100%; }
@media (max-width: 1000px) {
  body.app-page.has-announce { height: auto; }
  body.app-page.has-announce #root { height: auto; }
}
.puzzle-filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-3); margin-bottom: var(--space-6); }
.puzzle-filters .field { min-width: 200px; }
.puzzle-filters select.input { min-height: 38px; padding-block: var(--space-1); }
.puzzle-filters-actions { display: flex; gap: var(--space-2); }
.games-tabs { margin: 0; }
.games-tabs a { flex: none; white-space: nowrap; padding-inline: var(--space-3); }
.games-tabs a .muted { margin-inline-start: 2px; font-variant-numeric: tabular-nums; }
.games-note { margin: 0 0 var(--space-3); padding-inline: var(--space-6); }
.split-foot { margin: var(--space-4) 0 0; }
.pager { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-8); }
.pager-pages { display: flex; align-items: center; gap: var(--space-1); }
.pager-pages a, .pager-current { display: grid; place-items: center; min-width: 34px; height: 34px; padding: 0 var(--space-2); border-radius: var(--radius-md); text-decoration: none; font: 500 13px/1 var(--font-mono); }
.pager-pages a:hover { background: var(--bg-200); }
.pager-current { border: 1px solid var(--ink); }
.report-link { display: inline-flex; align-items: center; gap: var(--space-1); font-size: 13px; color: var(--ink-muted); text-decoration: none; }
.report-link:hover { color: var(--ink); text-decoration: underline; }
.report-link svg { width: 14px; height: 14px; }
.report-links { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.report-links:empty { display: none; }

/* ---------- community: leaderboards, countries, clans, leagues (community.go) ---------- */
.country { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; }
a.country { text-decoration: none; }
a.country:hover span:last-child { text-decoration: underline; }
.who-cell { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 0; flex-wrap: wrap; }
.who-cell a { font-weight: 500; }
.show-sm { display: none; }
.table-panel { position: relative; padding: 0; overflow-x: auto; }
.table-panel .data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: end; width: 1%; white-space: nowrap; }
.data-table td.strong { font-weight: 600; color: var(--ink); }
.data-table td.rank { color: var(--ink-muted); }
.rank-table tbody tr:nth-child(-n+3) td.rank { color: var(--accent); font-weight: 600; }
.board-tabs { display: inline-flex; margin-bottom: var(--space-4); }
.board-tabs a { flex: none; padding: var(--space-2) var(--space-4); }
.lb-filter { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
.lb-filter label { font: 500 13px/18px var(--font-sans); color: var(--ink-muted); }
.lb-filter select { width: auto; min-width: 220px; min-height: 38px; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--space-4); margin-top: var(--space-4); }
.empty-state { padding: var(--space-8) var(--space-6); text-align: center; }
.empty-state h2 { font-size: 20px; line-height: 26px; }
.empty-state p { margin: var(--space-2) auto 0; max-width: 52ch; }
.empty-state .btn { margin-top: var(--space-4); }
.note { margin-top: var(--space-3); max-width: 80ch; }
.note a, .section-note a, .empty-state a:not(.btn) { color: var(--accent); }
.page-head.with-action { display: flex; align-items: end; justify-content: space-between; gap: var(--space-6); }
.page-head.with-action .btn { flex: none; }
.crest { flex: none; display: block; }
.clan-cell { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.clan-cell > span { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.clan-cell:hover .clan-name { text-decoration: underline; }
.clan-name { font-weight: 600; }
.clan-hero .crest { width: 72px; height: auto; }
.clan-hero .caption a { color: inherit; text-decoration: none; }
.clan-hero .caption a:hover { text-decoration: underline; }
.community-grid > * { min-width: 0; }
.data-table time { white-space: nowrap; }
.clan-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-6); min-height: 40px; }
.clan-actions .form-error { flex-basis: 100%; }
.stats .stat-text { margin-top: var(--space-2); font: 600 17px/24px var(--font-sans); }
.clan-body { margin-top: var(--space-8); }
.stack-lg > * + * { margin-top: var(--space-8); }
.stack-lg h2 { margin-bottom: var(--space-3); }
.section-note { margin: calc(var(--space-2) * -1) 0 var(--space-3); max-width: 70ch; }
.clan-about p + p { margin-top: var(--space-3); }
.league-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.league-card { gap: var(--space-1); padding: var(--space-3) var(--space-4); }
.league-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.tag.status-open { color: var(--accent); border-color: var(--accent); }
.tag.status-active { color: var(--good); border-color: var(--good); }
.tag.role-owner { color: var(--accent); border-color: var(--accent); }
.member-list { list-style: none; margin: 0; padding: var(--space-1) var(--space-4); }
.member-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; min-height: 44px; }
.member-list li + li { border-top: 1px solid var(--line); }
.member-list a { text-decoration: none; }
.member-list a:hover { text-decoration: underline; }
.member-meta { display: inline-flex; align-items: center; gap: var(--space-2); }
.side-title { font-size: 15px; line-height: 20px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); margin: 0; font-size: 14px; }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; }
.facts a { color: var(--accent); text-decoration: none; }
.data-table .act-col { width: 1%; white-space: nowrap; text-align: end; padding-top: var(--space-1); padding-bottom: var(--space-1); }
.btn.small-btn { min-height: 30px; padding: var(--space-1) var(--space-3); font-size: 13px; }
.bot-hero p.profile-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-size: 15px; line-height: 22px; }
.clan-chip { display: inline-flex; align-items: center; gap: var(--space-2); text-decoration: none; color: var(--ink); }
.clan-chip:hover span { text-decoration: underline; }
.clan-chip .crest { width: 22px; height: auto; }
@media (max-width: 760px) {
  .page-head.with-action { flex-direction: column; align-items: stretch; }
  .show-sm { display: inline-flex; }
  .board-tabs { display: flex; }
  .board-tabs a { flex: 1; padding: var(--space-2); }
  .lb-filter select { flex: 1; min-width: 0; }
  .clan-hero .crest { width: 56px; }
  .grid.cols-4.clan-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .clan-stats .panel { padding: var(--space-3); }
  .clan-stats .stat { font-size: 22px; line-height: 28px; }
}

/* ---------- profile photos ---------- */
.avatar.xl { width: 144px; height: 144px; font-size: 56px; border-radius: var(--radius-lg); }
.avatar.photo { padding: 0; background: var(--bg-200); }
.avatar.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- player profile ---------- */
.profile-head { padding-bottom: var(--space-4); }
.profile-hero {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "photo id actions" "facts facts facts";
  gap: var(--space-4) var(--space-6); padding: var(--space-6);
}
.profile-photo { grid-area: photo; }
.profile-id { grid-area: id; min-width: 0; align-self: center; }
.profile-name { margin: var(--space-1) 0 0; font-size: 36px; line-height: 42px; overflow-wrap: anywhere; }
.profile-display { margin: var(--space-1) 0 0; font-size: 18px; line-height: 26px; color: var(--ink); }
.profile-bio { margin: var(--space-2) 0 0; max-width: 60ch; color: var(--ink-muted); font-size: 15px; line-height: 22px; overflow-wrap: anywhere; }
.profile-hero .profile-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin: var(--space-3) 0 0; font-size: 14px; }
.profile-actions { grid-area: actions; display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-3); }
.profile-facts { grid-area: facts; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); padding-top: var(--space-4); }
.profile-facts > div { padding: 0 var(--space-4); }
.profile-facts > div + div { border-inline-start: 1px solid var(--line); }
.profile-facts > div:first-child { padding-inline-start: 0; }
.profile-facts dt { font: 500 11px/14px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.profile-facts dd { margin: var(--space-1) 0 0; font: 600 26px/32px var(--font-mono); font-variant-numeric: tabular-nums; }

.profile-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; margin: var(--space-4) 0 var(--space-8); }
.profile-main, .profile-side { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.profile-card { padding: var(--space-4) var(--space-6); }
.profile-card h2 { font-size: 18px; line-height: 24px; margin: 0 0 var(--space-3); }
.profile-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3); }
.profile-card-head h2 { margin: 0; }
.profile-card-head p { margin: 0; }
.profile-about p { margin: 0 0 var(--space-3); max-width: 68ch; white-space: pre-line; overflow-wrap: anywhere; line-height: 24px; }
.profile-about p:last-child { margin-bottom: 0; }

.rating-plot { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-2); }
.rating-axis { display: flex; flex-direction: column; justify-content: space-between; padding: 2px 0; font: 500 12px/14px var(--font-mono); color: var(--ink-muted); text-align: end; }
.rating-chart { display: block; width: 100%; height: 160px; }
.rating-chart .rc-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.rating-chart .rc-area { fill: var(--accent); opacity: 0.12; }
.rating-chart .rc-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

.profile-games { padding-inline: 0; padding-bottom: var(--space-2); }
.profile-games .profile-card-head, .profile-games > p { padding-inline: var(--space-6); }
.table-scroll { overflow-x: auto; }
.profile-table td, .profile-table th { padding-inline: var(--space-3); }
.profile-table td:first-child, .profile-table th:first-child { padding-inline-start: var(--space-6); }
.profile-table td:last-child, .profile-table th:last-child { padding-inline-end: var(--space-6); text-align: end; }
.profile-table tbody tr:last-child td { border-bottom: 0; }
.side-dot { flex: none; width: 10px; height: 10px; border-radius: 2px; border: 1px solid var(--ink-muted); }
.side-dot.white { background: #f2efe8; }
.side-dot.black { background: #1b1a18; }
.outcome { font-weight: 600; }
.outcome-Win { color: var(--good); }
.outcome-Loss { color: var(--danger); }
.outcome-Draw, .outcome-Playing { color: var(--ink-muted); }
.pager { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-6) var(--space-2); border-top: 1px solid var(--line); }

.split + .split { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.split-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.split-label { font-weight: 600; font-size: 14px; }
.split-bar { display: flex; height: 8px; margin: var(--space-2) 0; border-radius: 999px; overflow: hidden; background: var(--bg-200); gap: 2px; }
.split-bar span { display: block; height: 100%; min-width: 0; }
.split-bar span[style="width:0%"] { display: none; }
.split-bar .w { background: var(--good); }
.split-bar .d { background: var(--ink-muted); opacity: 0.6; }
.split-bar .l { background: var(--danger); }
.split-nums { margin: 0; }

@media (max-width: 980px) {
  .profile-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .profile-hero { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "photo id" "actions actions" "facts facts"; padding: var(--space-4); gap: var(--space-4); }
  .avatar.xl { width: 88px; height: 88px; font-size: 36px; }
  .profile-name { font-size: 26px; line-height: 32px; }
  .profile-actions { flex-direction: row; align-items: center; justify-content: flex-start; }
  .profile-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--space-4); }
  .profile-facts > div:nth-child(3) { border-inline-start: 0; padding-inline-start: 0; }
  .profile-card { padding: var(--space-4); }
  .profile-games .profile-card-head, .profile-games > p { padding-inline: var(--space-4); }
  .profile-table td:first-child, .profile-table th:first-child { padding-inline-start: var(--space-4); }
  .profile-table td:last-child, .profile-table th:last-child { padding-inline-end: var(--space-4); }
  .pager, .games-note { padding-inline: var(--space-4); }
  .profile-games { padding-inline: 0; }
  .profile-table .who-cell { flex-wrap: nowrap; max-width: 52vw; }
  .profile-table .who-cell a, .profile-table .who-cell > span:not(.avatar):not(.side-dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile-table .who-cell .rating { display: none; }
}

/* provisional rating mark */
abbr.prov { text-decoration: none; cursor: help; margin-inline-start: 1px; color: var(--ink-muted); }

/* a clan picture in place of the drawn crest: rounded square, framed like profile photos */
.crest-photo { object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--bg-200); }
.clan-hero .crest-photo { height: 72px; }
.clan-chip .crest-photo { height: 22px; border-radius: var(--radius-sm); }
@media (max-width: 560px) { .clan-hero .crest-photo { height: 56px; } }

/* a live game: a small dot that says "now" (with the words, never on its own) */
.live-dot { display: inline-block; width: 8px; height: 8px; margin-inline-end: 6px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 30%, transparent); vertical-align: 1px; }
@media (prefers-reduced-motion: no-preference) { .live-dot { animation: live-pulse 1.6s ease-in-out infinite; } }
@keyframes live-pulse { 50% { opacity: .45; } }

/* ---------- puzzle modes and leaderboard ---------- */
.puzzle-modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-3); }
.mode-card { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-100); color: inherit; text-decoration: none; }
.mode-card:hover { border-color: var(--accent); }
.mode-card > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.mode-card > span:last-child > span { font-size: 13px; line-height: 19px; color: var(--ink-muted); }
.mode-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--bg-200); color: var(--accent); }
.mode-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.puzzle-links { margin-bottom: var(--space-6); }
.puzzle-browse { margin-bottom: var(--space-3); }
.puzzle-credit { margin-top: var(--space-6); }
.lb-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }

/* ---------- app chrome on phones ----------
   Under 761px the site behaves like an app: a short header (logo, inbox,
   account), the sections in a tab bar at the bottom where the thumb rests,
   and "More" as a sheet that rises above the bar. Live games hide the bar
   and dock their own controls there instead (frontend styles.css). */
:root { --tab-h: 58px; --safe-b: env(safe-area-inset-bottom, 0px); }
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --nav-h: 52px; }
  .site-header { gap: var(--space-2); padding: 0 calc(max(var(--space-3), env(safe-area-inset-right)) + var(--hdr-inset)) 0 calc(max(var(--space-4), env(safe-area-inset-left)) + var(--hdr-inset)); }
  .site-header.floating { --hdr-inset: var(--space-2); }
  /* Phones: the icon alone in the middle; the sections are in the tab bar. */
  .nav-links { grid-template-columns: auto; }
  .brand { padding: 0 var(--space-3); }
  .header-settings { display: none; }
  .nav-actions { gap: var(--space-1); }
  .nav-actions .btn.secondary { min-height: 34px; padding: 0 var(--space-3); }
  body { padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
  .site-footer { margin-top: var(--space-8); padding: var(--space-6) 0; }
  .site-footer nav { gap: var(--space-2) var(--space-4); }

  .tabbar {
    position: fixed; inset-inline-start: 0; inset-inline-end: 0; bottom: 0; z-index: 35;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tab-h) + var(--safe-b)); padding: 0 env(safe-area-inset-right) var(--safe-b) env(safe-area-inset-left);
    background: var(--bg-000); border-top: 1px solid var(--line);
  }
  .tabbar > a, .tab-more > summary {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tab-h);
    color: var(--ink-muted); text-decoration: none; cursor: pointer; list-style: none;
    font: 500 11px/14px var(--font-sans); letter-spacing: 0.01em;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-more > summary::-webkit-details-marker { display: none; }
  .tabbar svg {
    width: 44px; height: 28px; padding: 3px 11px; border-radius: 999px;
    fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
    transition: background-color 160ms ease-out;
  }
  /* The current section: an inverted pill behind the icon, and a heavier label. */
  .tabbar [aria-current="page"] { color: var(--ink); font-weight: 600; }
  .tabbar [aria-current="page"] svg { background: var(--ink); color: var(--bg-000); }
  .tab-more[open] > summary { color: var(--ink); }
  .tab-more[open] > summary svg { background: var(--bg-200); }
  .tabbar > a:active svg, .tab-more > summary:active svg { background: var(--bg-200); }
  .tabbar :focus-visible { outline-offset: -4px; border-radius: var(--radius-md); }

  /* The open details element covers the page as the sheet's backdrop (a tap on it closes the sheet, site.js). */
  .tab-more[open]::before {
    content: ""; position: fixed; inset: 0 0 calc(var(--tab-h) + var(--safe-b)); z-index: -1;
    background: color-mix(in srgb, var(--bg-000) 55%, transparent);
  }
  .tab-more .sheet {
    position: fixed; inset-inline-start: 8px; inset-inline-end: 8px; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); z-index: 1;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; padding: var(--space-2);
    background: var(--bg-100); border: 1px solid var(--line); border-radius: var(--radius-lg);
    animation: sheet-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .tab-more .sheet a {
    display: flex; align-items: center; min-height: 48px; padding: 0 var(--space-3); border-radius: var(--radius-md);
    font: 500 15px/20px var(--font-sans); color: var(--ink); text-decoration: none;
  }
  .tab-more .sheet a:active { background: var(--bg-200); }
  .notes-menu { position: fixed; inset-inline-start: 8px; inset-inline-end: 8px; top: calc(var(--nav-h) + 6px); width: auto; }
  .account .menu { position: fixed; inset-inline-end: 8px; top: calc(var(--nav-h) + 6px); }
  .account .menu a, .account .menu button { min-height: 44px; display: flex; align-items: center; font-size: 15px; }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } }
@media (hover: none) {
  .menu a, .menu button { min-height: 44px; display: flex; align-items: center; }
}
.page-head .cta { margin-top: var(--space-4); }
.page-head .cta + p { margin-top: var(--space-3); }
.legal-address { font-style: normal; margin: var(--space-3) 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); line-height: 22px; max-width: 360px; }
/* Long storage keys and names wrap inside the legal tables on phones. */
.legal-page td, .legal-page th { overflow-wrap: anywhere; }
/* Phones: each row of a legal table becomes a block, with the column name as a small label. */
@media (max-width: 560px) {
  .legal-page table, .legal-page tbody, .legal-page tr, .legal-page td { display: block; width: 100%; }
  .legal-page thead { display: none; }
  .legal-page tr { padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
  .legal-page td { padding: 0; border: 0; }
  .legal-page td + td { margin-top: var(--space-2); }
  .legal-page td:first-child { font-weight: 600; }
  .legal-page td + td::before { content: attr(data-label); display: block; font: 500 12px/16px var(--font-sans); color: var(--ink-muted); letter-spacing: 0.02em; }
}

/* ---- Languages (web/lang.go) ---- */
.flag { display: block; flex-shrink: 0; border-radius: 2px; outline: 1px solid color-mix(in srgb, var(--ink) 18%, transparent); outline-offset: -1px; }
.lang-host summary { list-style: none; }
.lang-host summary::-webkit-details-marker { display: none; }
.lang-btn .flag { width: 20px; height: 14px; }
/* A player's flag (a small picture, web/flags.go): inline beside a name. */
img.flag { display: inline-block; width: 21px; height: 14px; vertical-align: -2px; }
.lang-menu { min-width: 180px; }
.lang-menu a { display: flex; align-items: center; gap: var(--space-3); }
.lang-menu a[aria-current="true"] { background: var(--bg-200); color: var(--ink); font-weight: 600; }
.lang-note { margin-top: var(--space-4); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink-muted); font-size: 14px; }

/* Right-to-left (Arabic): the layout flips through logical properties. Boards,
   the photo cropper and the move buttons (like media controls) stay left to right. */
.board-frame, .board-svg, .board-figure, .crop-window, .nav-controls { direction: ltr; }
[dir="rtl"] .pref-switch:checked::after { transform: translateX(-18px); }
/* Numbers with signs between them ("3 + 2", "1-0", "10:00") read left to right in every language. */
[dir="rtl"] :is(.mono, .num, .tc-chip, .tc-options button, .rating, .clock, .match-clock, .seek-clock, .score) { direction: ltr; unicode-bidi: isolate; }

/* ---------- events (events.go, events.js) ---------- */
.tag.state-registration { color: var(--accent); border-color: var(--accent); }
.tag.state-running { color: var(--good); border-color: var(--good); }
.tag.state-cancelled { color: var(--danger); border-color: var(--danger); text-decoration: line-through; }
.plain-list { margin: 0; padding-inline-start: 1.2em; display: flex; flex-direction: column; gap: var(--space-2); max-width: 70ch; }

/* The calendar */
.cal { padding: var(--space-4); margin-top: var(--space-6); }
.cal-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); }
.cal-head h2 { font-size: 20px; line-height: 26px; min-width: 10ch; text-align: center; }
.cal-nav { min-width: 40px; padding-inline: var(--space-3); font-size: 20px; line-height: 1; }
.cal-today { margin-inline-start: auto; color: var(--accent); }
.cal-grid { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top: 1px solid var(--line); }
.cal-days span { padding: var(--space-2); font: 500 11px/14px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); text-align: center; }
.cal-day { min-height: 96px; padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.cal-day + .cal-day { border-inline-start: 1px solid var(--line); }
.cal-day.out { background: var(--bg-000); }
.cal-day.out .cal-num { opacity: 0.45; }
.cal-num { font: 500 13px/18px var(--font-mono); color: var(--ink-muted); }
.cal-day.today .cal-num time { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.cal-event {
  display: block; padding: 3px var(--space-2); border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-200); color: var(--ink); text-decoration: none; font-size: 12px; line-height: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-event time { font-family: var(--font-mono); color: var(--ink-muted); }
.cal-event:hover { border-color: var(--accent); }
.cal-event.state-running { border-color: var(--good); }
.cal-event.state-registration { border-inline-start: 3px solid var(--accent); }
.cal-event.state-cancelled span { text-decoration: line-through; color: var(--ink-muted); }
.cal-note { margin-top: var(--space-3); }
.events-lists { margin-top: var(--space-8); }
.events-lists h2 { margin-bottom: var(--space-3); }
.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.event-item { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3) var(--space-4); text-decoration: none; color: var(--ink); }
.event-item:hover { border-color: var(--ink-muted); background: var(--bg-200); }
.event-date { flex: none; width: 9ch; font: 500 12px/16px var(--font-sans); color: var(--ink-muted); }
.event-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.event-main strong { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .cal { padding: var(--space-3); }
  .cal-day { min-height: 56px; padding: var(--space-1); }
  .cal-days span { padding: var(--space-1) 0; font-size: 10px; letter-spacing: 0; }
  /* Phones: a dot per event; the list below names them. */
  .cal-event { padding: 0; height: 6px; width: 6px; border-radius: 999px; background: var(--accent); border: 0; font-size: 0; }
  .cal-event.state-running { background: var(--good); }
  .cal-event.state-cancelled { background: var(--ink-muted); }
  .cal-day.has-events { gap: 3px; }
  .event-item { gap: var(--space-3); padding: var(--space-3); flex-wrap: wrap; }
  .event-date { width: auto; flex-basis: 100%; }
}

/* An event page */
.event-hero { margin-top: var(--space-6); padding: var(--space-4) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.event-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3) var(--space-6); margin: 0; }
.event-facts dt { font: 500 11px/14px var(--font-sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); }
.event-facts dd { margin: var(--space-1) 0 0; font-weight: 600; }
.event-live { border-top: 1px solid var(--line); padding-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.event-live:empty { display: none; }
.event-countdown { font: 600 17px/24px var(--font-sans); font-variant-numeric: tabular-nums; }
.event-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.event-missing { flex-basis: 100%; margin: 0; padding-inline-start: 1.2em; color: var(--ink-muted); font-size: 14px; }
.event-seeking { font-weight: 600; }
.seek-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--good); }
@media (prefers-reduced-motion: no-preference) { .seek-dot { animation: live-pulse 1.2s ease-in-out infinite; } }
.podium { margin-top: var(--space-8); }
.podium h2 { margin-bottom: var(--space-3); }
.podium-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.podium-list li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.podium-list li > span { display: flex; flex-direction: column; min-width: 0; }
.podium-list .place-1 { border-color: var(--accent); }
.event-page .community-grid { margin-top: var(--space-8); }
.prize-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.prize-list li { display: flex; align-items: center; gap: var(--space-3); }
.prize-list li > span { display: flex; flex-direction: column; }
.medal { flex: none; display: block; }
.streak { margin-inline-start: var(--space-2); padding: 0 5px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent); font: 700 11px/16px var(--font-mono); }
/* Rounds of a swiss or round robin: one panel per round, the latest open. */
.rounds-title { margin-top: var(--space-8); }
.event-rounds { display: flex; flex-direction: column; gap: var(--space-2); }
.event-round { padding: 0; }
.event-round > summary { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); cursor: pointer; list-style: none; }
.event-round > summary::-webkit-details-marker { display: none; }
.event-round > summary::after { content: "+"; margin-inline-start: auto; color: var(--ink-muted); }
.event-round[open] > summary::after { content: "−"; }
.event-round[open] > summary { border-bottom: 1px solid var(--line); }
.pairings tr:last-child td { border-bottom: 0; }
.pairings .side-w { text-align: end; }
.pairings .res { text-align: center; width: 1%; white-space: nowrap; }
.standings tr.dq td { color: var(--ink-muted); }
.standings tr.dq a { text-decoration: line-through; }
.event-rules { max-width: 70ch; white-space: pre-line; }
.event-page aside .panel > p { margin-top: var(--space-3); }
.event-page aside .panel > ul + p { margin-top: var(--space-3); }
.event-rules + .event-rules { margin-top: var(--space-3); }
@media (max-width: 760px) {
  .event-hero { padding: var(--space-4); }
  .podium-list { grid-template-columns: 1fr; }
  .event-actions .btn.primary { flex: 1; }
}

/* Medals on a profile */
.medal-row { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.medal-row a { display: inline-flex; align-items: center; gap: var(--space-2); padding: 2px var(--space-3) 2px var(--space-1); border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; font-size: 13px; }
.medal-row a:hover { border-color: var(--accent); }

/* Home: games from other sites (/import) */
.import-callout { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); margin-top: var(--space-2); }
.import-callout h3 { margin: 0; }
.import-callout p { margin: 0; }
.match-import { margin-top: var(--space-2); }
.match-import a { color: var(--ink); text-underline-offset: 3px; }

/* Ad places (web/ads.go, frontend src/components/AdSlot.tsx). Each place is a
   box of a fixed size per screen width, labelled and centred between blocks; a
   responsive AdSense unit fills it with any ad that fits, so nothing moves when
   it loads. With ads.placeholders the box is drawn empty. Never on game
   screens, the puzzle board while solving, or account pages. */
.ad-slot { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); width: 100%; margin: var(--space-6) auto; clear: both; }
.ad-label { margin: 0; font: 500 11px/14px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.ad-unit { width: 100%; overflow: hidden; }
.ad-fmt-banner { max-width: 970px; height: 90px; }
.ad-fmt-rectangle, .ad-fmt-inline { max-width: 336px; height: 280px; }
.ad-fmt-rail { width: 300px; height: 600px; }
.ad-box { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: var(--space-2); border: 1px dashed color-mix(in srgb, var(--ink-muted) 55%, transparent); border-radius: var(--radius-sm); background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--ink-muted) 7%, transparent) 10px 20px); color: var(--ink-muted); font: 12px/16px var(--font-sans); text-align: center; }
.ad-box span:first-child { font: 600 13px/18px var(--font-sans); color: var(--ink); }
.ad-box-phone { display: none; }
.prose .ad-slot, aside .ad-slot { margin-block: var(--space-4); }
@media (max-width: 767px) {
  .ad-fmt-banner { max-width: 336px; height: 100px; }
  .ad-box span:nth-child(2) { display: none; }
  .ad-box-phone { display: block; }
}
/* The side ad: a column beside the article on wide screens only, held in view
   while the article scrolls (it never covers text). Where it shows, the
   rectangle inside the article gives way to it: one ad per page. */
.ad-rail { display: none; }
@media (min-width: 1280px) {
  .rail-layout:has(> .ad-rail) { display: grid; grid-template-columns: minmax(0, 1fr) 300px; column-gap: var(--space-8, 40px); align-items: start; }
  .rail-layout > .ad-rail { display: flex; position: sticky; top: calc(var(--nav-h) + var(--space-6)); margin: 0; }
  .rail-layout:has(> .ad-rail) .ad-inline { display: none; }
  .wrap.narrow:has(> .rail-layout > .ad-rail) { width: min(1100px, 100% - 2 * var(--space-4)); }
}

/* ---- the chess level assessment (assessment.html, assessment-certificate.html) ---- */
.assess-hero { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
.assess-hero-text { max-width: 64ch; }
.assess-cta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); margin-top: var(--space-6); }
.assess-coach { flex: none; width: 260px; margin: 0; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.assess-coach img { width: 132px; height: 132px; }
.assess-coach figcaption { padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-100); font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.assess-coach figcaption strong { display: block; color: var(--accent); }
.assess-prose { max-width: 72ch; }
.assess-steps li + li { margin-top: var(--space-3); }
.assess-callout { flex-direction: row; align-items: center; gap: var(--space-6); padding: var(--space-6); }
.assess-callout img { flex: none; width: 88px; height: 88px; }
.assess-callout .stack { flex: 1; min-width: 0; }
.assess-callout .btn { flex: none; }
/* Home: the mobile app (store badges beside a phone drawn in CSS) and Follow us. */
.app-promo {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-8);
  padding: var(--space-8); overflow: hidden;
}
.app-promo-text > * { margin: 0; max-width: 60ch; }
.app-promo-text > * + * { margin-top: var(--space-3); }
.app-promo-text > .caption + h2 { margin-top: var(--space-1); }
.app-promo-text h2 { font-size: 32px; line-height: 38px; }
.app-promo-text .store-badges { margin-top: var(--space-6); }
/* The stores' own badge style: black, a thin grey edge, the logo, two lines of text. */
.store-badges { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.store-badge {
  display: inline-flex; align-items: center; gap: 10px; min-width: 168px; height: 52px; padding: 0 16px 0 12px;
  border: 1px solid #a6a6a6; border-radius: 10px; background: #000; color: #fff; text-decoration: none;
  transition: border-color 120ms ease;
}
a.store-badge:hover { border-color: #fff; }
.store-logo { width: 26px; height: 26px; flex: none; }
.store-text { display: flex; flex-direction: column; line-height: 1.1; text-align: start; white-space: nowrap; }
.store-text small { font-size: 11px; letter-spacing: .02em; }
a.store-badge .store-text small { text-transform: uppercase; }
.store-text strong { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.store-badge.is-soon { cursor: default; color: #fff; opacity: .55; }
.app-phone {
  width: 230px; padding: 9px; margin-block: calc(var(--space-2) * -1) calc(var(--space-8) * -1.2);
  border: 1px solid var(--line); border-radius: 38px; background: var(--bg-200);
}
.app-screen {
  display: flex; flex-direction: column; gap: var(--space-2); min-height: 400px; padding: var(--space-3);
  border: 1px solid var(--line); border-radius: 30px; background: var(--bg-000);
}
.app-screen-bar { display: flex; align-items: center; gap: var(--space-2); padding: 2px 4px var(--space-1); font-size: 15px; }
.app-screen-bar img { border-radius: 6px; }
.app-screen-bar .xe { color: #8fc25b; }
.app-screen-seat { display: flex; align-items: center; gap: var(--space-2); font-size: 12px; font-weight: 600; }
.app-screen-seat img, .app-screen-seat .avatar { width: 26px; height: 26px; flex: none; }
.app-screen-seat .rating { font-weight: 400; color: var(--ink-muted); }
.app-screen-board svg { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); }
.app-screen-tabs {
  display: flex; justify-content: space-around; margin: auto calc(var(--space-3) * -1) calc(var(--space-3) * -1);
  padding: var(--space-3) var(--space-3) var(--space-4); border-top: 1px solid var(--line);
}
.app-screen-tabs span { width: 18px; height: 18px; border: 2px solid var(--ink-muted); border-radius: 6px; opacity: .6; }
.app-screen-tabs .is-on { border-color: var(--accent); background: var(--accent); opacity: 1; }
.follow { text-align: center; }
.follow h2 { margin: 0; }
.follow > p { margin: var(--space-2) 0 0; }
.social-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin: var(--space-6) 0 0; padding: 0; list-style: none; }
.social-link {
  display: inline-flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-6) var(--space-3) var(--space-3);
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg-100); color: var(--ink); text-decoration: none;
  transition: border-color 120ms ease;
}
.social-link:hover { border-color: var(--ink-muted); }
.social-icon { width: 40px; height: 40px; flex: none; }
.social-link > span { display: flex; flex-direction: column; text-align: start; line-height: 1.25; }
.social-link small { color: var(--ink-muted); font-size: 12px; }
.assess-section h2 { margin-bottom: var(--space-2); }
.assess-note { max-width: 70ch; margin-bottom: var(--space-4); }
.assess-levels .assess-level-name { font-weight: 600; white-space: nowrap; color: var(--ink); }
.assess-levels .nowrap { white-space: nowrap; }
.assess-styles .card h3 { font-size: 18px; line-height: 24px; }
.assess-twin { display: inline-flex; align-items: center; gap: var(--space-2); margin-top: auto; font-weight: 600; font-size: 14px; }
.assess-twin img { width: 36px; height: 36px; }
.assess-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; }
.assess-end h2, .assess-end p { flex-basis: 100%; }
.assess-cert { margin: 0 0 var(--space-6); }
.assess-cert img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); }
.assess-cert-facts .card h2 { font-size: 20px; line-height: 26px; }
@media (max-width: 760px) {
  .assess-hero { flex-direction: column; align-items: stretch; }
  .assess-coach { width: auto; flex-direction: row; text-align: start; }
  .assess-coach img { width: 72px; height: 72px; }
  .assess-callout { flex-wrap: wrap; gap: var(--space-4); }
  .assess-callout img { width: 64px; height: 64px; }
  .assess-callout .btn { flex: 1 1 100%; }
  .app-promo { grid-template-columns: 1fr; padding: var(--space-6) var(--space-4); }
  .app-promo-text h2 { font-size: 26px; line-height: 32px; }
  .app-phone { display: none; }
  .store-badges { gap: var(--space-2); }
  .store-badge { min-width: 0; height: 46px; gap: 8px; padding: 0 12px 0 10px; }
  .store-logo { width: 22px; height: 22px; }
  .store-text small { font-size: 9.5px; }
  .store-text strong { font-size: 17px; }
  .assess-styles, .assess-cert-facts { grid-template-columns: 1fr; }
}
