:root {
  --ink: #12141c;
  --ink-raised: #1b2029;
  --ink-raised-2: #222835;
  --ink-line: #2b3240;
  --bone: #edeae1;
  --bone-dim: #a9a79f;
  --brass: #c9a15c;
  --brass-bright: #dcb878;
  --brass-dim: #8a7248;
  --sage: #7fa073;
  --rust: #c4634b;

  --sq-light: #f0d9b5;
  --sq-dark: #b58863;
  --sq-last: rgba(205, 210, 106, 0.55);
  --sq-selected: rgba(127, 160, 115, 0.75);

  --font-display: "Instrument Serif", ui-serif, Georgia, serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --page-max: 1200px;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--brass-bright); }
a:hover { color: var(--bone); }
img { max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.15; letter-spacing: 0.01em; }
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); margin: 0 0 0.4em; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); margin: 1.6em 0 0.5em; }
h3 { font-size: 1.4rem; margin: 1.2em 0 0.4em; }
.wrap { max-width: var(--page-max); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--bone-dim); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- header / footer ---------- */
.site-header { border-bottom: 1px solid var(--ink-line); background: rgba(18, 20, 28, 0.92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; }
.brand { flex: none; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--bone); }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand span { font-family: var(--font-display); font-size: 1.7rem; line-height: 1; }
.brand b { color: var(--brass); font-weight: 400; }
.site-nav { display: flex; gap: 4px; }
.site-nav a { text-decoration: none; color: var(--bone-dim); padding: 8px 12px; border-radius: 8px; font-size: 0.95rem; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--bone); background: var(--ink-raised); }
@media (max-width: 560px) {
  .site-nav a { padding: 8px 7px; font-size: 0.88rem; }
  .site-nav .hide-sm { display: none; }
  .brand span { font-size: 1.45rem; }
}

.site-footer { border-top: 1px solid var(--ink-line); margin-top: 48px; padding: 28px 0 40px; color: var(--bone-dim); font-size: 0.9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: var(--bone-dim); text-decoration: none; }
.site-footer a:hover { color: var(--bone); }

/* ---------- ad slots ---------- */
.ad-slot { margin: 16px auto; text-align: center; min-height: 0; overflow: hidden; }
.ad-slot .ad-label { display: block; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bone-dim); opacity: 0.6; margin-bottom: 4px; }
.ad-slot ins { display: block; }
.ad-top { max-width: 970px; }
.ad-side { margin: 16px 0 0; }
.house-ad {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px dashed var(--brass-dim); border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(201, 161, 92, 0.1), rgba(127, 160, 115, 0.06));
  color: var(--bone); text-decoration: none; font-size: 0.95rem;
}
.house-ad strong { font-family: var(--font-display); font-size: 1.3rem; font-weight: 400; color: var(--brass-bright); }
.house-ad .cta { padding: 6px 14px; border-radius: 999px; background: var(--brass); color: var(--ink); font-weight: 600; font-size: 0.85rem; }
.house-ad:hover { border-color: var(--brass); color: var(--bone); }

/* ---------- game layout ---------- */
.hero-intro { padding: 18px 0 4px; }
.hero-intro h1 { margin-bottom: 0.15em; }
.hero-intro p { margin: 0; color: var(--bone-dim); }

.play { padding-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 14px; }
@media (min-width: 900px) { .play { grid-template-columns: minmax(0, 1fr) 360px; } }

.board-col { width: 100%; max-width: min(640px, calc(100vh - 380px)); min-width: 280px; margin: 0 auto; }
@media (max-width: 899px) { .board-col { max-width: 640px; } }

.player { display: flex; align-items: center; gap: 10px; padding: 8px 2px; min-height: 48px; }
.player .avatar { width: 34px; height: 34px; border-radius: 8px; background: var(--ink-raised-2); display: grid; place-items: center; flex: none; overflow: hidden; }
.player .avatar img { width: 28px; height: 28px; }
.player .who { min-width: 0; flex: 1; }
.player .name { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .captured { display: flex; align-items: center; gap: 0; height: 18px; font-size: 0.75rem; color: var(--bone-dim); }
.player .captured img { width: 17px; height: 17px; margin-right: -5px; }
.player .captured .adv { margin-left: 9px; }
.clock { font-family: var(--font-mono); font-size: 1.25rem; padding: 4px 12px; border-radius: 7px; background: var(--ink-raised); color: var(--bone-dim); min-width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.clock.active { background: var(--bone); color: var(--ink); }
.clock.low { background: var(--rust); color: #fff; }
.clock[hidden] { display: none; }
.thinking { display: none; gap: 3px; margin-left: 6px; vertical-align: middle; }
.thinking.on { display: inline-flex; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--brass); animation: blink 1s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- board ---------- */
.board-frame { position: relative; border-radius: 6px; overflow: hidden; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(201, 161, 92, 0.35); }
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1 / 1; width: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.sq { position: relative; background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last::before, .sq.selected::before, .sq.hint::before, .sq.check::before { content: ""; position: absolute; inset: 0; pointer-events: none; }
.sq.last::before { background: var(--sq-last); }
.sq.selected::before { background: var(--sq-selected); }
.sq.hint::before { box-shadow: inset 0 0 0 4px var(--sage); background: rgba(127, 160, 115, 0.35); }
.sq.check::before { background: radial-gradient(circle, rgba(255, 40, 20, 0.95) 0%, rgba(230, 30, 10, 0.6) 30%, rgba(170, 0, 0, 0) 75%); }
.sq.drop-over { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.55); }
.sq .piece { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; transition: transform 0.18s ease-out; }
.sq .piece.dragging { opacity: 0.3; }
.sq.movable { cursor: pointer; }
.sq.target::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; margin: -15% 0 0 -15%; border-radius: 50%; background: rgba(18, 20, 28, 0.28); z-index: 3; pointer-events: none; }
.sq.target.capture::after { width: 100%; height: 100%; margin: 0; left: 0; top: 0; background: radial-gradient(transparent 0%, transparent 76%, rgba(18, 20, 28, 0.32) 78%); border-radius: 0; }
.sq.target { cursor: pointer; }
.coord { position: absolute; font-size: clamp(8px, 1.5vw, 12px); font-weight: 600; line-height: 1; pointer-events: none; z-index: 1; }
.coord.file { right: 4%; bottom: 4%; }
.coord.rank { left: 4%; top: 4%; }
.sq .coord { color: var(--sq-dark); }
.sq.dark .coord { color: var(--sq-light); }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; transform: translate(-50%, -50%) scale(1.08); filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45)); }

.board-banner { position: absolute; inset: auto 0 0 0; z-index: 5; display: none; }

/* ---------- side panel ---------- */
.panel { background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: var(--radius); overflow: hidden; }
.panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--ink-line); }
.panel-head .opp { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.1; }
.panel-head .meta { font-size: 0.85rem; color: var(--bone-dim); }
.status { padding: 10px 16px; font-weight: 600; min-height: 44px; border-bottom: 1px solid var(--ink-line); display: flex; align-items: center; gap: 8px; }
.status.win { color: var(--sage); }
.status.loss { color: var(--rust); }
.status .hint-text { color: var(--sage); }

.moves { height: 230px; overflow-y: auto; font-family: var(--font-mono); font-size: 0.92rem; background: var(--ink); }
@media (max-width: 899px) { .moves { height: 150px; } }
.moves table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.moves td { padding: 3px 8px; }
.moves td.n { width: 44px; color: var(--bone-dim); background: var(--ink-raised); text-align: right; padding-right: 10px; }
.moves td.m { cursor: pointer; border-radius: 4px; }
.moves td.m:hover { background: var(--ink-raised-2); }
.moves td.m.cur { background: var(--brass); color: var(--ink); font-weight: 600; }
.moves .empty { padding: 14px 16px; color: var(--bone-dim); font-family: var(--font-body); font-size: 0.9rem; }

.navbar { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--ink-line); border-bottom: 1px solid var(--ink-line); }
.navbar button { background: none; border: 0; padding: 9px; cursor: pointer; color: var(--bone-dim); font-size: 1.05rem; }
.navbar button:hover:not(:disabled) { background: var(--ink-raised-2); color: var(--bone); }
.navbar button:disabled { opacity: 0.35; cursor: default; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--ink-line); background: var(--ink-raised-2); cursor: pointer; font-size: 0.9rem; font-weight: 500; color: var(--bone); text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--brass-dim); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--brass-bright); }
.btn.danger:hover:not(:disabled) { border-color: var(--rust); color: #ffb4a3; }
.btn.wide { grid-column: 1 / -1; padding: 12px; font-size: 1rem; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--ink-line); font-size: 0.85rem; color: var(--bone-dim); }
.linkbtn { background: none; border: 0; padding: 2px 0; cursor: pointer; color: var(--bone-dim); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--bone); }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--ink-line); border-radius: 14px; background: var(--ink-raised); color: var(--bone); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
dialog::backdrop { background: rgba(6, 7, 10, 0.72); }
.dlg-body { padding: 20px 22px 22px; }
.dlg-body h2 { margin: 0 0 4px; font-size: 2rem; }
.dlg-close { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 1.6rem; color: var(--bone-dim); cursor: pointer; line-height: 1; padding: 4px 8px; }
.field-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--bone-dim); margin: 18px 0 8px; display: block; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
@media (max-width: 480px) { .level-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; } }
.level-grid button { padding: 9px 2px 7px; border-radius: 8px; border: 1px solid var(--ink-line); background: var(--ink); cursor: pointer; line-height: 1.15; }
.level-grid button b { display: block; font-size: 1.15rem; }
.level-grid button small { display: block; font-size: 0.68rem; color: var(--bone-dim); }
.level-grid button[aria-pressed="true"] { background: var(--brass); border-color: var(--brass); color: var(--ink); }
.level-grid button[aria-pressed="true"] small { color: var(--ink); }
.level-desc { margin-top: 8px; font-size: 0.9rem; color: var(--bone-dim); min-height: 1.4em; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { padding: 9px 4px; border-radius: 8px; border: 1px solid var(--ink-line); background: var(--ink); cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button img { width: 22px; height: 22px; }
.seg button[aria-pressed="true"] { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); background: rgba(201, 161, 92, 0.12); }
.dlg-actions { display: flex; gap: 10px; margin-top: 22px; }
.dlg-actions .btn { flex: 1; padding: 12px; font-size: 1rem; }

.promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.promo-grid button { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--ink-line); background: var(--sq-light); cursor: pointer; padding: 6px; }
.promo-grid button:hover { background: var(--brass-bright); }
.promo-grid img { width: 100%; height: 100%; }

.result-score { font-family: var(--font-mono); color: var(--bone-dim); margin: 0 0 8px; }
.record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; text-align: center; }
.record div { background: var(--ink); border-radius: 8px; padding: 8px 4px; }
.record b { display: block; font-size: 1.3rem; }
.record span { font-size: 0.75rem; color: var(--bone-dim); text-transform: uppercase; letter-spacing: 0.08em; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--bone); color: var(--ink); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 2000; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- content sections ---------- */
.content { max-width: 860px; }
.content p, .content li { color: #d6d3ca; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 18px 0; }
.card { background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: var(--radius); padding: 16px 18px; }
.card h3 { margin: 0 0 6px; font-size: 1.3rem; color: var(--brass-bright); }
.card p { margin: 0; font-size: 0.95rem; }
table.levels { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 0.95rem; }
table.levels th, table.levels td { padding: 8px 10px; border-bottom: 1px solid var(--ink-line); text-align: left; }
table.levels th { color: var(--bone-dim); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.faq details { background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: var(--radius); margin: 8px 0; padding: 0 16px; }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.faq details p { margin: 0 0 14px; }
.piece-row { display: flex; align-items: flex-start; gap: 16px; margin: 18px 0; }
.piece-row img { width: 64px; height: 64px; flex: none; background: var(--sq-light); border-radius: 10px; padding: 4px; }
.piece-row h3 { margin-top: 0; }
.page { padding-top: 24px; }
.page h1 { margin-top: 8px; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }

/* ---------- details added in the design pass ---------- */
h1, h2, h3 { text-wrap: balance; }
.skip { position: absolute; left: 16px; top: -60px; z-index: 100; background: var(--brass); color: var(--ink); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.skip:focus { top: 10px; }
:focus-visible { outline: 2px solid var(--brass-bright); outline-offset: 2px; }
.board:focus-visible { outline-offset: 4px; }
.eyebrow { font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brass); margin-bottom: 2px; }
.lede { font-size: 1.12rem; max-width: 65ch; }
.content p { max-width: 70ch; }
.intro { padding-top: 22px; }
.intro h1 { margin-bottom: 0.3em; }
.steps { padding-left: 1.3em; display: grid; gap: 8px; max-width: 70ch; }
.steps li::marker { color: var(--brass); font-family: var(--font-display); font-size: 1.2em; }
.table-scroll { overflow-x: auto; }
table.levels td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--brass-bright); }
table.levels td:first-child { font-family: var(--font-display); font-size: 1.25rem; }
table.levels tbody tr:hover { background: var(--ink-raised); }
table.levels a { font-weight: 600; text-decoration: none; padding: 4px 10px; border: 1px solid var(--brass-dim); border-radius: 999px; font-size: 0.85rem; }
table.levels a:hover { background: var(--brass); color: var(--ink); }
.seg-wrap { grid-auto-flow: row; grid-template-columns: repeat(5, 1fr); }
@media (max-width: 480px) { .seg-wrap { grid-template-columns: repeat(3, 1fr); } }
.review { display: block; margin: 14px auto 0; }
#gameover .ad-slot { margin-bottom: 0; }
.side-col { min-width: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- studio page ---------- */
.products { display: grid; gap: 14px; margin: 18px 0 8px; }
.product { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 20px; align-items: start; background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: 14px; padding: 20px; }
.product > img { width: 88px; height: 88px; border-radius: 20px; object-fit: cover; background: var(--ink); }
.product h3 { margin: 2px 0 6px; font-size: 1.7rem; }
.product p { margin: 0; }
.product-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
@media (max-width: 520px) {
  .product { grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding: 16px; }
  .product > img { width: 64px; height: 64px; border-radius: 15px; }
}
.select { user-select: all; color: var(--bone); }

/* ---------- installable app ---------- */
.site-header .wrap > .site-nav { margin-left: auto; }
.install-btn { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--brass); background: transparent; color: var(--brass-bright); font-size: 0.85rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.install-btn:hover { background: var(--brass); color: var(--ink); }
@media (max-width: 560px) { .can-install .site-nav a[href$="about.html"] { display: none; } .install-btn { padding: 5px 10px; font-size: 0.8rem; } }
/* Running as an installed app: the board comes first, no skip link or install prompts. */
.is-app .skip, .is-app #app { display: none; }

/* ---------- AdSense ---------- */
/* Hide a unit (and its label) when Google has no ad for it, so no empty box is left behind. */
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.ad-multiplex { margin-top: 40px; max-width: none; }
/* Local preview only: shows where each AdSense unit goes. */
.ad-preview { display: grid; place-items: center; min-height: 90px; padding: 12px; border: 1px dashed var(--bone-dim); border-radius: 8px; color: var(--bone-dim); font-family: var(--font-mono); font-size: 0.8rem; background: repeating-linear-gradient(45deg, transparent 0 10px, rgba(255, 255, 255, 0.025) 10px 20px); }
.ad-preview-rectangle { min-height: 250px; }
.ad-preview-autorelaxed { min-height: 320px; }

/* ---------- guides ---------- */
.guide-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 20px; }
.guide-nav a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--ink-line); color: var(--bone-dim); text-decoration: none; font-size: 0.9rem; }
.guide-nav a:hover { color: var(--bone); border-color: var(--brass-dim); }
.guide-nav a[aria-current="page"] { background: var(--brass); border-color: var(--brass); color: var(--ink); font-weight: 600; }
.opening { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; margin: 26px 0; }
.opening h3 { margin-top: 0; }
.opening p { margin: 0 0 10px; }
@media (max-width: 620px) { .opening { grid-template-columns: minmax(0, 1fr); gap: 12px; } }
.moves-line { font-family: var(--font-mono); color: var(--brass-bright); font-size: 0.95rem; }
.diagram { margin: 0; width: 100%; max-width: 280px; }
.content > .diagram { margin: 12px 0 20px; }
.diagram-board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); aspect-ratio: 1; max-width: 100%; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px rgba(201, 161, 92, 0.35), 0 10px 26px rgba(0, 0, 0, 0.4); }
.diagram-board span { background: var(--sq-light); position: relative; aspect-ratio: 1; min-width: 0; }
.diagram-board span.d { background: var(--sq-dark); }
.diagram-board span.m::before { content: ""; position: absolute; inset: 0; background: var(--sq-last); }
.diagram-board img { position: relative; width: 100%; height: 100%; display: block; }
.diagram figcaption { font-size: 0.82rem; color: var(--bone-dim); margin-top: 6px; }
.glossary { display: grid; gap: 2px; margin: 18px 0; }
.glossary div { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--ink-line); }
.glossary dt { font-family: var(--font-display); font-size: 1.25rem; color: var(--brass-bright); }
.glossary dd { margin: 0; color: #d6d3ca; }
@media (max-width: 560px) { .glossary div { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.card-link { text-decoration: none; color: inherit; transition: border-color 0.15s; }
.card-link:hover { border-color: var(--brass); color: inherit; }
.opening .diagram figcaption { display: none; }

/* ---------- hero slogan ---------- */
.hero { padding-top: 20px; display: grid; gap: 6px; }
.hero h1 { font-size: clamp(1.7rem, 3.6vw, 2.6rem); margin: 0; }
.hero h1 em { font-style: italic; color: var(--brass-bright); }
.hero .tagline { margin: 0; color: var(--bone-dim); font-size: 1.02rem; max-width: 65ch; }
.perks { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; padding: 0; }
.perks li { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px 4px 9px; border: 1px solid var(--ink-line); border-radius: 999px; font-size: 0.82rem; color: var(--bone); background: var(--ink-raised); white-space: nowrap; }
.perks li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--sage); }
.hero + .play { padding-top: 6px; }
@media (max-width: 560px) {
  .hero { padding-top: 14px; }
  .hero .tagline { font-size: 0.92rem; }
  .perks li { font-size: 0.75rem; padding: 3px 9px 3px 8px; }
  .perks li:nth-child(n+4) { display: none; }
}
.is-app .hero { display: none; }
.foot-slogan { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; color: var(--brass-bright); }
/* Wide screens: slogan and perks share one compact block so the whole board stays in view. */
@media (min-width: 900px) {
  .hero { grid-template-columns: auto minmax(0, 1fr); align-items: end; column-gap: 28px; padding-top: 14px; }
  .hero h1 { font-size: 2.1rem; }
  .hero .tagline { grid-column: 1; }
  .hero .perks { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; align-self: center; margin: 0; }
}

/* ---------- top-of-page banner (homepage) ---------- */
.ad-lead { margin: 8px auto 0; }
.ad-lead .ad-label { margin-bottom: 2px; font-size: 0.6rem; }
.ad-lead .ad-fixed, .ad-preview-fixed { width: 320px; height: 100px; max-width: 100%; margin: 0 auto; }
@media (min-width: 500px) { .ad-lead .ad-fixed, .ad-preview-fixed { width: 468px; height: 60px; } }
@media (min-width: 800px) { .ad-lead .ad-fixed, .ad-preview-fixed { width: 728px; height: 90px; } }
.ad-preview-fixed { min-height: 0; padding: 4px; }
/* With the banner on top, wide screens show the slogan and perks on a single line. */
@media (min-width: 900px) {
  .ad-lead + .hero { padding-top: 10px; align-items: center; }
  .ad-lead + .hero .tagline { display: none; }
  .ad-lead + .hero .perks { grid-row: 1; }
  .ad-lead + .hero h1 { font-size: 1.85rem; }
}
@media (max-width: 899px) {
  .ad-lead + .hero { padding-top: 10px; }
  .ad-lead + .hero .tagline { display: none; }
  .ad-lead + .hero h1 { font-size: 1.55rem; }
}
.install-btn .lbl-short { display: none; }
@media (max-width: 560px) { .install-btn .lbl-long { display: none; } .install-btn .lbl-short { display: inline; } }

/* ---------- "add to home screen" suggestion card (phones) ---------- */
.a2hs {
  position: fixed; z-index: 1500; left: 0; right: 0; bottom: 0;
  margin: 0 auto; max-width: 560px;
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  background: var(--ink-raised-2); border: 1px solid var(--brass-dim); border-bottom: 0; border-radius: 16px 16px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(110%); transition: transform 0.3s ease-out; visibility: hidden;
}
.a2hs.show { transform: none; visibility: visible; }
.a2hs img { width: 44px; height: 44px; border-radius: 11px; }
.a2hs-text { min-width: 0; display: grid; gap: 2px; }
.a2hs-text b { font-size: 0.98rem; }
.a2hs-text span { font-size: 0.82rem; color: var(--bone-dim); line-height: 1.35; }
.a2hs-actions { display: grid; gap: 4px; justify-items: center; }
.a2hs-actions .btn { padding: 8px 18px; }

/* =====================================================================
   Play flow: start card, result card, status strip (UX pass)
   ===================================================================== */
.board-frame { isolation: isolate; }
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 12px;
  background: rgba(14, 16, 22, 0.66);
  backdrop-filter: blur(2.5px); -webkit-backdrop-filter: blur(2.5px);
  animation: ov-in 0.22s ease-out;
}
.overlay[hidden] { display: none; }
@keyframes ov-in { from { opacity: 0; } to { opacity: 1; } }
.ov-card {
  width: min(360px, 100%); max-height: 100%; overflow: auto;
  display: grid; gap: 12px; justify-items: stretch; text-align: center;
  padding: 20px 20px 16px; border-radius: 16px;
  background: var(--ink-raised); border: 1px solid var(--brass-dim);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: card-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes card-in { from { transform: translateY(10px) scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.ov-kicker { margin: 0; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass); }
.ov-title { margin: -4px 0 2px; font-size: clamp(1.6rem, 5vw, 2.1rem); }

/* level picker: − [name + one-line description] + , with a slider underneath */
.lvl-pick { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.step {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--ink-line);
  background: var(--ink); color: var(--bone); font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.step:hover:not(:disabled) { border-color: var(--brass); color: var(--brass-bright); }
.step:disabled { opacity: 0.3; cursor: default; }
.lvl-now { display: grid; gap: 2px; min-height: 58px; align-content: center; }
.lvl-now b { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; line-height: 1.1; }
.lvl-now span { font-size: 0.8rem; color: var(--bone-dim); line-height: 1.3; }
#ov-level { width: 100%; accent-color: var(--brass); margin: 0; height: 22px; cursor: pointer; }
.ov-color { grid-auto-columns: 1fr; }
.ov-color button { padding: 8px 4px; font-size: 0.88rem; }
.ov-play { padding: 13px; font-size: 1.1rem; border-radius: 10px; }
.ov-links { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; }
.ov-text { margin: 0; color: var(--bone-dim); font-size: 0.95rem; }
.ov-record { margin: 0; font-size: 0.85rem; color: var(--bone-dim); font-variant-numeric: tabular-nums; }
.ov-record b { color: var(--bone); }
.ov-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.ov-row[hidden] { display: none; }
.ov-result .ov-title { font-size: clamp(1.9rem, 6vw, 2.5rem); }

/* small boards (phones): tighten the cards so they fit on the board */
@media (max-width: 480px) {
  .overlay { padding: 8px; }
  .ov-card { gap: 9px; padding: 14px 14px 12px; }
  .ov-kicker { display: none; }
  .ov-title { font-size: 1.5rem; margin: 0; }
  .lvl-now { min-height: 50px; }
  .lvl-now b { font-size: 1.25rem; }
  .lvl-now span { font-size: 0.74rem; }
  .step { width: 40px; height: 40px; }
  .lvl-pick { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .ov-play { padding: 11px; }
  .ov-result .ov-kicker { display: block; }
}

/* status + controls strip */
.game-strip { display: grid; gap: 8px; }
.board-col > .game-strip { margin-top: 2px; }
.game-strip .status {
  display: flex; align-items: center; gap: 9px; min-height: 40px;
  padding: 8px 12px; border: 1px solid var(--ink-line); border-radius: 10px;
  background: var(--ink-raised); font-weight: 600; font-size: 0.95rem;
}
.game-strip .status::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--bone-dim); opacity: 0.5; }
.game-strip .status.turn::before { background: var(--sage); opacity: 1; box-shadow: 0 0 0 4px rgba(127, 160, 115, 0.22); }
.game-strip .status.think::before { background: var(--brass); opacity: 1; animation: blink 1s infinite ease-in-out; }
.game-strip .status.check { color: #ffb4a3; border-color: rgba(196, 99, 75, 0.6); }
.game-strip .status.check::before { background: var(--rust); opacity: 1; }
.game-strip .status.hint { color: var(--sage); }
.game-strip .status.hint::before { background: var(--sage); opacity: 1; }
.game-strip .status.win { color: var(--sage); }
.game-strip .status.win::before { background: var(--sage); opacity: 1; }
.game-strip .status.loss { color: #ffb4a3; }
.game-strip .status.loss::before { background: var(--rust); opacity: 1; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.qbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px 4px; min-height: 52px; border-radius: 10px;
  border: 1px solid var(--ink-line); background: var(--ink-raised); color: var(--bone);
  font-size: 0.78rem; font-weight: 500; cursor: pointer;
}
.qbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.qbtn:hover:not(:disabled) { border-color: var(--brass-dim); }
.qbtn:disabled { opacity: 0.35; cursor: default; }
.qbtn-new { background: var(--brass); border-color: var(--brass); color: var(--ink); font-weight: 600; }
.qbtn-new:hover:not(:disabled) { background: var(--brass-bright); }
.qbtn-new.attention { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 161, 92, 0.6); } 50% { box-shadow: 0 0 0 7px rgba(201, 161, 92, 0); } }

/* inside the desktop side panel */
.strip-slot .game-strip { padding: 12px 16px; border-bottom: 1px solid var(--ink-line); }
.panel .panel-foot { justify-content: space-around; padding: 10px 12px 12px; border-top: 0; }
#btn-resign:hover:not(:disabled) { color: #ffb4a3; }
.linkbtn:disabled { opacity: 0.35; cursor: default; text-decoration: none; }
/* Phones: the slogan stays, the perk chips go, so the game buttons fit on the first screen. */
@media (max-width: 560px) { .ad-lead + .hero .perks { display: none; } }

/* =====================================================================
   Start flow steps + online play
   ===================================================================== */
[hidden] { display: none !important; }

.mode-tile {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--ink-line); background: var(--ink);
  color: var(--bone); cursor: pointer; transition: border-color 0.15s, transform 0.15s;
}
.mode-tile:hover { border-color: var(--brass); transform: translateY(-1px); }
.mode-emoji { font-size: 2rem; line-height: 1; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--ink-raised-2); }
.mode-text { display: grid; gap: 2px; min-width: 0; }
.mode-text b { font-size: 1.05rem; }
.mode-text small { color: var(--bone-dim); font-size: 0.82rem; line-height: 1.3; }

.google-btn { background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; }
.google-btn:hover:not(:disabled) { border-color: #9aa0a6; }
.google-btn .g-logo { width: 18px; height: 18px; flex: none; }
.ov-error { margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(196, 99, 75, 0.15); color: #ffb4a3; font-size: 0.85rem; }

.invite-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.invite-box input {
  min-width: 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--ink-line);
  background: var(--ink); color: var(--bone); font-family: var(--font-mono); font-size: 0.82rem;
}
.wait-line { margin: 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--bone-dim); font-size: 0.9rem; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sage); animation: blink 1.2s infinite ease-in-out; }
.spinner { justify-self: center; width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--ink-line); border-top-color: var(--brass); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* connection pill next to the friend's name */
.conn-pill { display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; vertical-align: middle; background: var(--ink-raised); color: var(--bone-dim); }
.conn-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.conn-pill.ok { color: var(--sage); }
.conn-pill.wait { color: var(--brass); }
.conn-pill.wait::before { animation: blink 1s infinite ease-in-out; }
.conn-pill.off { color: #ffb4a3; }

/* emoji reactions */
.player { position: relative; }
.bubble {
  position: absolute; left: 44px; top: 50%; z-index: 30; pointer-events: none;
  font-size: 2rem; line-height: 1; padding: 6px 10px; border-radius: 16px;
  background: var(--ink-raised-2); border: 1px solid var(--brass-dim); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  opacity: 0; transform: translateY(-50%) scale(0.5);
}
.bubble.pop { animation: bubble 2.6s ease-out forwards; }
@keyframes bubble {
  0% { opacity: 0; transform: translateY(-50%) scale(0.5); }
  10% { opacity: 1; transform: translateY(-50%) scale(1.15); }
  18% { transform: translateY(-50%) scale(1); }
  80% { opacity: 1; transform: translateY(-50%) scale(1); }
  100% { opacity: 0; transform: translateY(-90%) scale(0.95); }
}
.qemoji { font-size: 1.25rem; line-height: 1; }
.emoji-bar { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 6px; border-radius: 12px; border: 1px solid var(--ink-line); background: var(--ink-raised); }
.emoji-bar button { font-size: 1.5rem; line-height: 1; padding: 6px 0; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.emoji-bar button:hover, .emoji-bar button:focus-visible { background: var(--ink-raised-2); }

/* draw / rematch / "friend left" questions */
.online-prompt {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--brass); background: rgba(201, 161, 92, 0.12);
  font-weight: 600; font-size: 0.92rem;
}
.prompt-actions { display: flex; gap: 6px; }
.prompt-actions .btn { padding: 7px 14px; }

@media (max-width: 480px) {
  .mode-tile { padding: 10px 12px; grid-template-columns: 40px minmax(0, 1fr); }
  .mode-emoji { width: 40px; height: 40px; font-size: 1.6rem; }
  .mode-text small { font-size: 0.76rem; }
  .ov-card .ov-text { font-size: 0.86rem; }
  section[data-view="home"] .ov-kicker, section[data-view="join"] .ov-kicker { display: block; }
}
@media (prefers-reduced-motion: reduce) { .bubble.pop { animation: none; opacity: 1; transform: translateY(-50%); } }
.bubble { left: auto; right: 12%; }

/* chat (online games) */
.chat { display: grid; gap: 6px; }
.chat-log { display: grid; gap: 3px; max-height: 112px; overflow-y: auto; padding: 8px 10px; border-radius: 10px; background: var(--ink); border: 1px solid var(--ink-line); }
.chat-log p { margin: 0; font-size: 0.88rem; line-height: 1.35; overflow-wrap: anywhere; }
.chat-log b { font-weight: 600; margin-right: 2px; }
.chat-log .me b { color: var(--brass-bright); }
.chat-log .them b { color: var(--sage); }
.chat-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; align-items: center; }
.chat-row input {
  min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--ink-line);
  background: var(--ink-raised); color: var(--bone); font-size: 16px; /* 16px stops phones zooming in */
}
.chat-row input:disabled { opacity: 0.55; }
.chat-count { min-width: 2ch; text-align: right; font-family: var(--font-mono); font-size: 0.78rem; color: var(--bone-dim); font-variant-numeric: tabular-nums; }
.chat-count.low { color: #ffb4a3; }
.chat-row .btn { padding: 9px 14px; }

/* players online now */
.online-count { margin: 0; display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 0.85rem; color: var(--sage); font-weight: 600; }
.online-count::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 4px rgba(127, 160, 115, 0.2); }

/* share the invitation */
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 10px; border-radius: 10px; font-weight: 600; font-size: 0.95rem; text-decoration: none; color: #fff;
}
.share-btn svg { width: 20px; height: 20px; flex: none; fill: #fff; }
.share-wa { background: #25d366; color: #0b3d1f; }
.share-wa svg { fill: #0b3d1f; }
.share-wa svg .glyph { fill: #25d366; }
.share-ms { background: linear-gradient(135deg, #0a7cff, #a033ff 60%, #ff5c87); }
.share-btn:hover { filter: brightness(1.08); color: inherit; }
.share-ms:hover { color: #fff; }

/* ratings + Top players */
.my-rating { margin: 0; font-weight: 600; color: var(--brass-bright); font-variant-numeric: tabular-nums; }
.leaders-wrap { max-height: 260px; overflow-y: auto; border: 1px solid var(--ink-line); border-radius: 10px; }
.leaders { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.leaders th { position: sticky; top: 0; background: var(--ink-raised-2); color: var(--bone-dim); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 7px 8px; text-align: left; }
.leaders td { padding: 7px 8px; border-top: 1px solid var(--ink-line); text-align: left; }
.leaders td:nth-child(1) { width: 2.2em; color: var(--bone-dim); }
.leaders td:nth-child(3) { font-family: var(--font-mono); color: var(--brass-bright); }
.leaders td:nth-child(4) { color: var(--bone-dim); }
.leaders tr.you td { background: rgba(201, 161, 92, 0.16); font-weight: 700; }
.leaders tr.you td:nth-child(2) { color: var(--brass-bright); }
.leaders tr:first-child td:nth-child(1) { color: var(--brass-bright); font-weight: 700; }

/* Top banner sizes (AdSense fixed sizes per screen width; these rules come last and win):
   phones 320x50 (small) · tablets 468x60 · laptops 728x90 · large screens 970x90 (large leaderboard) */
.ad-lead .ad-fixed, .ad-preview-fixed { width: 320px; height: 50px; }
@media (min-width: 500px) { .ad-lead .ad-fixed, .ad-preview-fixed { width: 468px; height: 60px; } }
@media (min-width: 800px) { .ad-lead .ad-fixed, .ad-preview-fixed { width: 728px; height: 90px; } }
@media (min-width: 1024px) { .ad-lead .ad-fixed, .ad-preview-fixed { width: 970px; height: 90px; } }
.ad-preview-fixed { font-size: 0.72rem; }

/* homepage "Top players" card */
.top-card { margin-top: 16px; background: var(--ink-raised); border: 1px solid var(--ink-line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.top-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.top-head h2 { margin: 0; font-size: 1.45rem; }
.top-sub { font-size: 0.75rem; color: var(--bone-dim); text-transform: uppercase; letter-spacing: 0.08em; }
.top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 330px; overflow-y: auto; font-variant-numeric: tabular-nums; }
.top-list li { display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 0.92rem; }
.top-list li:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.top-list li.you { background: rgba(201, 161, 92, 0.18); font-weight: 700; }
.top-list li.you .top-name { color: var(--brass-bright); }
.top-rank { text-align: center; color: var(--bone-dim); font-size: 0.85rem; }
.top-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-rating { font-family: var(--font-mono); color: var(--brass-bright); }
.top-empty { margin: 0; font-size: 0.88rem; color: var(--bone-dim); }
.top-cta { width: 100%; }

/* wide screens: ranking column left of the board */
.rank-slot { display: none; }
@media (min-width: 1280px) {
  .play { grid-template-columns: 250px minmax(0, 1fr) 360px; }
  .rank-slot { display: block; min-width: 0; padding-top: 6px; }
  .rank-slot .top-card { margin-top: 0; position: sticky; top: 76px; }
  .rank-slot .top-list { max-height: calc(100vh - 260px); }
}
@media (min-width: 1280px) {
  .rank-slot .top-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .rank-slot .top-head h2 { white-space: nowrap; }
}

/* Scrolling to the board (invitation links, "Play online") stops below the sticky header,
   so the top row of squares is never hidden behind it. */
#play { scroll-margin-top: calc(72px + env(safe-area-inset-top, 0px)); }

/* incoming chat message: floats under the header for a few seconds */
.chat-pop {
  position: fixed; z-index: 1600; left: 50%; top: calc(70px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: min(92vw, 420px);
  padding: 10px 16px 10px 12px; border-radius: 14px; border: 1px solid var(--sage);
  background: var(--ink-raised-2); color: var(--bone); font-size: 0.98rem; text-align: left; cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translate(-50%, -12px); transition: opacity 0.25s ease, transform 0.25s ease;
}
.chat-pop.show { opacity: 1; transform: translate(-50%, 0); }
.chat-pop-icon { font-size: 1.3rem; line-height: 1; }
.chat-pop-text { min-width: 0; overflow-wrap: anywhere; }
.chat-pop b { color: var(--sage); }
@media (prefers-reduced-motion: reduce) { .chat-pop { transition: none; } }
.search-more { display: grid; gap: 10px; }
.search-more .ov-text { margin: 0; }


/* named computer players in the rankings */
.cpu-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em; line-height: 1.6; vertical-align: 2px; color: var(--ink); background: var(--sage); }
.top-list li.cpu, .leaders tr.cpu { cursor: pointer; }
.top-list li.cpu:hover, .top-list li.cpu:focus-visible { background: rgba(127, 160, 115, 0.16); }
.leaders tr.cpu:hover td, .leaders tr.cpu:focus-visible td { background: rgba(127, 160, 115, 0.12); }

/* language switcher (footer) */
.lang-switch { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; padding-top: 12px; border-top: 1px solid var(--ink-line); font-size: 0.85rem; }
.lang-switch a[aria-current="page"] { color: var(--brass-bright); font-weight: 600; }

/* Right-to-left languages (Arabic): text flows right to left, but the board, the move list and the
   game controls keep chess's left-to-right geometry. */
[dir="rtl"] #play { direction: ltr; }
[dir="rtl"] .content, [dir="rtl"] .hero { text-align: right; }

/* account corner (optional Google sign-in) */
.acct { position: relative; flex: none; }
.acct-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 4px; border-radius: 999px;
  border: 1px solid var(--ink-line); background: var(--ink-raised); color: var(--bone); font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.acct-btn:hover { border-color: var(--brass-dim); }
.acct-btn.in { border-color: var(--brass-dim); }
.acct-btn.in .acct-label { color: var(--brass-bright); font-family: var(--font-mono); }
.acct-avatar { width: 30px; height: 30px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--ink-raised-2); color: var(--brass-bright); font-weight: 700; }
.acct-avatar img { width: 100%; height: 100%; object-fit: cover; }
.acct-avatar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.acct-avatar svg.g-logo { stroke: none; }
.acct-btn:not(.in) .acct-avatar { background: #fff; }
.acct-label .lbl-short { display: none; }
.acct-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 260px; display: grid; gap: 10px; padding: 14px;
  border-radius: 12px; border: 1px solid var(--ink-line); background: var(--ink-raised); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}
.acct-who { display: grid; gap: 2px; min-width: 0; }
.acct-who b { font-size: 1rem; }
.acct-who span { font-size: 0.8rem; color: var(--bone-dim); overflow: hidden; text-overflow: ellipsis; }
.acct-rating { margin: 0; font-size: 0.88rem; color: var(--brass-bright); font-variant-numeric: tabular-nums; }
#go-signin { justify-self: center; }
@media (max-width: 560px) {
  .acct-btn { padding: 0 10px 0 3px; height: 36px; gap: 6px; }
  .acct-label { font-size: 0.8rem; }
  .acct-label .lbl-long { display: none; }
  .acct-label .lbl-short { display: inline; }
  .acct-btn.in .acct-label { font-size: 0.78rem; }
  .site-nav a[href$="learn-chess.html"] { display: none; }
}

/* ---------- site numbers (owner only), above the footer ---------- */
.live-stats { margin-top: 40px; padding: 18px 20px; border: 1px solid var(--ink-line); border-radius: 14px; background: var(--ink-raised); }
.live-stats h2 { margin: 0 0 12px; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass); font-family: inherit; }
.live-stats dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.live-stats dl > div { padding: 10px 12px; border-radius: 10px; background: var(--ink-raised-2); }
.live-stats dt { font-size: 0.82rem; color: var(--bone-dim); }
.live-stats dd { margin: 2px 0 0; font-size: 1.5rem; font-weight: 700; color: var(--bone); font-variant-numeric: tabular-nums; }
.live-stats .live-now dt::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #5fd38a; vertical-align: 1px; }
@media print { .live-stats { display: none; } }
@media (max-width: 420px) {
  /* small phones: the Google "G" alone, so the header still fits next to "Add to home" */
  .acct-btn:not(.in) { padding: 0 3px; }
  .acct-btn:not(.in) .acct-label { display: none; }
}
@media (max-width: 420px) {
  .site-header .wrap { gap: 8px; }
  .site-nav a { padding: 8px 9px; }
  .brand { gap: 6px; }
  .brand span { font-size: 1.3rem; }
}
