:root {
  --ink: #1b1e23;
  --muted: #3e4651;
  --paper: #f2f3f5;
  --surface: #ffffff;
  --line: #d0d5dc;
  --blue: #1b3a6b;
  --blue-hover: #152f58;
  --wash: #e7eef8;
  --flag: #f6e3a1;
  --sq-light: #e9edf2;
  --sq-dark: #9fb0c6;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 450 17px/1.6 var(--sans);
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; margin: 0 0 0.5em; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.6rem); letter-spacing: -0.035em; line-height: 1.05; font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--blue); text-underline-offset: 3px; }
a:hover { color: var(--blue-hover); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
code { font: 500 0.9em var(--mono); background: var(--wash); padding: 0.1em 0.35em; border-radius: 4px; overflow-wrap: anywhere; }

.wrap { width: min(1120px, 100% - 40px); margin-inline: auto; }
.wrap-narrow { width: min(720px, 100% - 40px); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* header */
.site-header { position: sticky; top: 0; z-index: 5; background: rgba(242, 243, 245, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; }
.mark { height: 30px; width: auto; }
.site-header nav { display: flex; gap: clamp(12px, 3vw, 28px); }
.site-header nav a { color: var(--ink); text-decoration: none; font-size: 0.95rem; font-weight: 550; padding: 6px 0; white-space: nowrap; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--blue); box-shadow: 0 2px 0 var(--blue); }
@media (max-width: 520px) { .site-header nav a:first-child { display: none; } }

/* buttons */
.btn { display: inline-block; font: 650 1rem/1.2 var(--sans); padding: 14px 22px; border-radius: 8px; text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 28px 0 12px; }
.cta-note { color: var(--muted); font-size: 0.95rem; }

/* hero */
.hero { padding: clamp(40px, 8vw, 96px) 0 clamp(40px, 6vw, 72px); }
.hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
.hero .lede { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--muted); max-width: 34em; }
.sites { color: var(--muted); font-size: 0.95rem; margin-top: 20px; }
@media (max-width: 860px) { .hero-grid { grid-template-columns: 1fr; } }

/* the corner panel illustration */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: 10px 10px 0 var(--blue); width: min(360px, 100%); margin-inline: auto; }
.panel figcaption { color: var(--muted); font-size: 0.8rem; margin-top: 12px; }
figure { margin: 0; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.board i { display: grid; place-items: center; font-style: normal; container-type: inline-size; }
.board .l { background: var(--sq-light); }
.board .d { background: var(--sq-dark); }
.pc { font-size: 78cqw; line-height: 1; font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; }
.pc.b { color: var(--ink); }
.pc.w { color: #fff; -webkit-text-stroke: 1.2px var(--ink); paint-order: stroke fill; }
.panel-name { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; margin: 14px 0 2px; }
.panel-sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 10px; }
.rows { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.rows th, .rows td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); font-weight: 450; }
.rows th { color: var(--muted); width: 34%; }
.rows td.mv { font-weight: 700; }
.chip { display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: 0.8rem; white-space: nowrap; }
.rows tr.left td, .rows tr.left th { background: #fdf6dc; }
.rows tr.left .chip { background: var(--flag); border-color: #d9bd55; }

/* sections */
section { padding: clamp(40px, 6vw, 80px) 0; }
.band { background: var(--surface); border-block: 1px solid var(--line); }
.section-head { max-width: 40em; margin-bottom: 32px; }
.section-head p { color: var(--muted); font-size: 1.08rem; }
.kicker { color: var(--blue); font-weight: 650; font-size: 0.9rem; margin: 0 0 8px; display: block; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; list-style: none; padding: 0; margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; list-style: none; padding: 0; margin: 0; }
@media (max-width: 860px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.band .card { background: var(--paper); }
.card p:last-child { margin-bottom: 0; }
.card p { color: var(--muted); }
.num { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--blue); color: #fff; font-weight: 700; margin-bottom: 14px; }

.openings { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; }
.openings li { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font-size: 0.95rem; }

/* tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 0 0 1.4em; }
table.compare { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.95rem; }
.compare th, .compare td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.compare thead th { background: var(--wash); font-weight: 650; }
.compare tbody th { font-weight: 600; width: 24%; }
.compare tr:last-child > * { border-bottom: 0; }

/* faq */
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 20px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 650; padding: 16px 0; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--blue); font-weight: 700; font-size: 1.2rem; line-height: 1; }
.faq details[open] summary::after { content: "–"; }
.faq details > :not(summary) { color: var(--muted); }
.faq details > :last-child { padding-bottom: 16px; margin-bottom: 0; }

/* halfchess */
.games { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 860px) { .games { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .games { grid-template-columns: 1fr; } }
.games a { display: block; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; text-decoration: none; color: var(--ink); }
.games a:hover { border-color: var(--blue); }
.games strong { display: block; font-size: 1.05rem; margin-bottom: 4px; color: var(--blue); }
.games span { color: var(--muted); font-size: 0.93rem; }

/* closing */
.closing { text-align: center; }
.closing .cta-row { justify-content: center; }
.closing p { color: var(--muted); }

/* blog */
.post-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 960px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .post-grid { grid-template-columns: 1fr; } }
.post-card a { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; text-decoration: none; color: var(--ink); }
.post-card a:hover { border-color: var(--blue); }
.post-card p { color: var(--muted); font-size: 0.95rem; flex: 1; }
.post-card .more { color: var(--blue); font-weight: 650; font-size: 0.95rem; }

.page-head { padding: clamp(36px, 6vw, 64px) 0 0; }
.page-head h1 { font-size: clamp(2rem, 4.4vw, 3rem); }
.page-head p { color: var(--muted); font-size: 1.12rem; max-width: 38em; }

.post, .prose { padding: clamp(28px, 5vw, 56px) 0 clamp(40px, 6vw, 72px); }
.post h1 { font-size: clamp(1.9rem, 4.2vw, 2.8rem); }
.post h2, .prose h2 { margin-top: 1.8em; font-size: clamp(1.35rem, 2.4vw, 1.7rem); }
.post h3, .prose h3 { margin-top: 1.5em; }
.post li, .prose li { margin-bottom: 0.45em; }
.post ul, .post ol, .prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.byline { color: var(--muted); font-size: 0.93rem; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 20px; }
.crumbs a { color: var(--muted); }
.tldr, .notice { background: var(--wash); border-radius: 10px; padding: 16px 20px; }
.tldr p:last-child, .tldr ul:last-child { margin-bottom: 0; }
.post-cta { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; margin-top: 48px; box-shadow: 8px 8px 0 var(--blue); }
.post-cta h2 { margin-top: 0; }
.post-cta p:last-child { margin-bottom: 0; }
.related { padding: 40px 0 0; }
.related h2 { font-size: 1.15rem; }
.note { color: var(--muted); font-size: 0.92rem; }

/* install steps */
.steps { list-style: none; counter-reset: step; padding: 0 !important; }
.steps li { counter-increment: step; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 16px 62px; margin-bottom: 10px; }
.steps li::before { content: counter(step); position: absolute; left: 16px; top: 15px; width: 30px; height: 30px; border-radius: 6px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* footer */
.site-footer { background: var(--ink); color: #c9ced6; padding: 48px 0 28px; font-size: 0.95rem; }
.site-footer a { color: #fff; }
.site-footer .brand { color: #fff; margin-bottom: 10px; }
.site-footer .mark .case { fill: #6f95d6; }
.site-footer .mark .hoof { fill: #6f95d6; stroke: #6f95d6; }
.foot { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
@media (max-width: 720px) { .foot { grid-template-columns: 1fr 1fr; } .foot > div { grid-column: 1 / -1; } }
.foot nav { display: flex; flex-direction: column; gap: 8px; }
.foot nav a { text-decoration: none; }
.foot nav a:hover { text-decoration: underline; }
.foot h2 { font-size: 0.9rem; color: #9aa3af; font-weight: 600; letter-spacing: 0; margin-bottom: 4px; }
.foot p { max-width: 28em; }
.legal { border-top: 1px solid #3a4049; margin-top: 32px; padding-top: 20px; font-size: 0.85rem; color: #9aa3af; }
.legal p { margin-bottom: 6px; }

/* ==========================================================
   Home page: dark, with the 3D board
   ========================================================== */
body.dark {
  --ink: #f4f1e8;
  --muted: #a7b0c0;
  --paper: #0a0d14;
  --surface: #121826;
  --line: #242d40;
  --blue: #f0c24b;
  --blue-hover: #ffd774;
  --wash: #1a2233;
  --sq-light: #c9d1df;
  --sq-dark: #3b5a92;
  color-scheme: dark;
  background:
    radial-gradient(1100px 600px at 85% -5%, rgba(47, 84, 150, 0.35), transparent 60%),
    radial-gradient(700px 500px at -10% 30%, rgba(240, 194, 75, 0.08), transparent 60%),
    var(--paper);
  background-attachment: fixed;
}
body.dark .site-header { background: rgba(10, 13, 20, 0.72); border-bottom-color: rgba(255, 255, 255, 0.07); }
body.dark .btn-primary { background: linear-gradient(180deg, #ffd774, #f0c24b); color: #151309; box-shadow: 0 8px 30px -8px rgba(240, 194, 75, 0.55); }
body.dark .btn-primary:hover { background: #ffe08f; color: #151309; transform: translateY(-1px); }
body.dark .btn-secondary { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.16); backdrop-filter: blur(6px); }
body.dark .btn { transition: transform 0.15s, background 0.15s, border-color 0.15s; }
body.dark .num, body.dark .steps li::before { color: #151309; }
body.dark .band { background: rgba(255, 255, 255, 0.025); border-color: rgba(255, 255, 255, 0.06); }
body.dark .card, body.dark .band .card, body.dark .post-card a, body.dark .games a, body.dark .faq details, body.dark .openings li {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  border-color: rgba(255, 255, 255, 0.09);
}
body.dark .card, body.dark .post-card a, body.dark .games a { transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s; }
body.dark .card:hover, body.dark .post-card a:hover, body.dark .games a:hover {
  transform: translateY(-4px);
  border-color: rgba(240, 194, 75, 0.5);
  box-shadow: 0 18px 50px -20px rgba(240, 194, 75, 0.35);
}
body.dark .table-scroll { background: rgba(255, 255, 255, 0.03); border-color: rgba(255, 255, 255, 0.09); }
body.dark .compare thead th { background: rgba(255, 255, 255, 0.05); }
body.dark .compare td:nth-child(2), body.dark .compare thead th:nth-child(2) { color: var(--blue); }
body.dark .panel { box-shadow: 10px 10px 0 var(--blue); }
body.dark .rows tr.left td, body.dark .rows tr.left th { background: rgba(240, 194, 75, 0.12); }
body.dark .rows tr.left .chip { background: var(--blue); border-color: var(--blue); color: #151309; }
body.dark .pc.b { color: #0c0f16; }
body.dark .pc.w { -webkit-text-stroke-color: #0c0f16; }
body.dark .mark rect, body.dark .site-footer .mark rect { fill: var(--blue); }
body.dark .site-footer { background: #06080d; border-top: 1px solid rgba(255, 255, 255, 0.06); }
body.dark h2 { font-size: clamp(1.7rem, 3.6vw, 2.7rem); letter-spacing: -0.03em; }
body.dark .closing h2 { font-size: clamp(2rem, 5vw, 3.6rem); }

/* hero */
.hero3d { position: relative; overflow: hidden; min-height: min(calc(100svh - 61px), 900px); display: flex; align-items: center; padding: 56px 0; }
.hero3d .stage { position: absolute; inset: 0 0 0 auto; width: 60%; }
.hero3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.2s ease; }
.hero3d.is-3d canvas { opacity: 1; }
.hero3d .stage::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(90deg, var(--paper) 2%, transparent 30%), linear-gradient(0deg, var(--paper) 0%, transparent 14%); }
.hero3d .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; transition: opacity 0.4s; }
.hero3d.is-3d .fallback { opacity: 0; visibility: hidden; }
.hero-copy { position: relative; z-index: 2; }
.hero-copy > * { max-width: 600px; }
.hero-copy h1 { font-size: clamp(2.7rem, 6.2vw, 5.1rem); line-height: 0.98; letter-spacing: -0.045em; margin-bottom: 24px; }
.hero-copy h1 em { font-style: normal; display: block; background: linear-gradient(100deg, #ffe08f 10%, #f0c24b 45%, #c98a1e 100%); -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: 0.08em; }
.hero-copy .lede { font-size: clamp(1.08rem, 1.5vw, 1.25rem); color: var(--muted); max-width: 31em; }
.eyebrow { display: inline-block; font-size: 0.85rem; font-weight: 600; color: var(--blue); border: 1px solid rgba(240, 194, 75, 0.35); background: rgba(240, 194, 75, 0.08); border-radius: 999px; padding: 6px 14px; margin-bottom: 22px; }
.proof { list-style: none; display: flex; flex-wrap: wrap; gap: 12px 32px; padding: 0; margin: 28px 0 0; color: var(--muted); font-size: 0.92rem; }
.proof strong { display: block; color: var(--ink); font-size: 1.6rem; letter-spacing: -0.03em; line-height: 1.1; }

.hud { position: absolute; z-index: 2; right: max(20px, calc((100vw - 1120px) / 2)); bottom: 44px; width: min(330px, calc(100% - 40px)); padding: 16px 18px; border-radius: 14px; background: rgba(13, 18, 30, 0.62); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(14px) saturate(1.4); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.8); opacity: 0; transform: translateY(12px); transition: opacity 0.6s 0.8s, transform 0.6s 0.8s; }
.hero3d.is-3d .hud { opacity: 1; transform: none; }
.hud p { margin: 0; }
.hud-eyebrow { font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-bottom: 6px !important; }
.hud .dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.hud-name { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; min-height: 1.25em; }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.hud-san { font: 600 1rem var(--mono); }
.hud .chip { border-color: rgba(127, 166, 234, 0.5); color: #b9cffa; background: rgba(127, 166, 234, 0.12); transition: background 0.25s, color 0.25s; }
.hud .chip.is-left { background: var(--blue); border-color: var(--blue); color: #151309; font-weight: 650; }
.hud-note { font-size: 0.85rem; color: var(--muted); margin-top: 10px !important; min-height: 2.7em; }

@media (max-width: 900px) {
  .hero3d { display: block; padding: 32px 0 0; min-height: 0; }
  .hero3d .stage { position: relative; inset: auto; width: 100%; height: min(92vw, 520px); margin-top: 8px; }
  .hero3d .stage::before { background: linear-gradient(180deg, var(--paper) 0%, transparent 14%), linear-gradient(0deg, var(--paper) 0%, transparent 22%); }
  .hero3d { display: flex; flex-direction: column-reverse; }
  .hud { right: 20px; left: 20px; bottom: 12px; width: auto; }
  .hud-note { min-height: 0; }
  .hero3d:not(.is-3d) .stage { height: auto; }
  .hero3d:not(.is-3d) .fallback { position: relative; }
}

/* marquee of opening names */
.marquee { overflow: hidden; border-block: 1px solid rgba(255, 255, 255, 0.07); padding: 16px 0; -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee .track { display: flex; width: max-content; animation: slide 60s linear infinite; }
.marquee span { white-space: nowrap; padding: 0 22px; color: var(--muted); font-weight: 600; letter-spacing: -0.01em; }
.marquee span::after { content: "♞"; margin-left: 44px; color: var(--blue); opacity: 0.7; }
@keyframes slide { to { transform: translateX(-50%); } }

/* scroll reveal (only when JS has run) */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .marquee .track, .hud .dot { animation: none; }
  .hero3d canvas, .hud { transition: none; }
}
