/* ==========================================================================
   PuzzleMosaic — design system
   Palette: deep slate "study room" + boxwood amber + jade.
   Type: Spectral (display + long-form), IBM Plex Sans (UI), IBM Plex Mono (data).
   ========================================================================== */

:root {
  color-scheme: dark;
  --pattern: rgba(217, 164, 65, .085);
  --pattern-size: 520px;

  --bg:          #0e1518;
  --bg-deep:     #0a1013;
  --surface:     #152024;
  --surface-2:   #1d2b30;
  --surface-3:   #24343a;
  --line:        #2a3b41;
  --line-soft:   #203035;
  --text:        #e9efed;
  --text-strong: #ffffff;
  --muted:       #94a8ab;
  --muted-dim:   #6d8186;

  --boxwood:     #d9a441;
  --boxwood-lo:  #b8862c;
  --boxwood-tint:rgba(217, 164, 65, .12);
  --jade:        #4fa88b;
  --jade-tint:   rgba(79, 168, 139, .13);
  --lacquer:     #c4483f;
  --lacquer-tint:rgba(196, 72, 63, .14);

  /* board materials, shared by every game */
  --wood:        #d5a869;
  --wood-dark:   #8e6034;
  --wood-line:   rgba(62, 38, 12, .72);
  --felt:        #12414a;
  --felt-dark:   #0a2b33;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.34);
  --shadow:     0 8px 24px rgba(0,0,0,.30);
  --shadow-lg:  0 22px 60px rgba(0,0,0,.42);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;

  --sans:  "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Spectral", Charter, "Iowan Old Style", Georgia, serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --wrap: 1180px;
  --read: 68ch;
}

html[data-theme="light"] {
  color-scheme: light;
  --pattern: rgba(20, 40, 46, .07);
  --bg:          #eceeed;
  --bg-deep:     #e2e6e5;
  --surface:     #ffffff;
  --surface-2:   #f5f7f6;
  --surface-3:   #e9eded;
  --line:        #ccd5d4;
  --line-soft:   #dee4e3;
  --text:        #121a1d;
  --text-strong: #000000;
  --muted:       #55696d;
  --muted-dim:   #75898d;
  --boxwood:     #8a6415;
  --boxwood-lo:  #6d4e0c;
  --boxwood-tint:rgba(138, 100, 21, .10);
  --jade:        #2c7861;
  --jade-tint:   rgba(44, 120, 97, .10);
  --lacquer:     #a5352d;
  --lacquer-tint:rgba(165, 53, 45, .10);
  --shadow-sm:  0 1px 2px rgba(18,26,29,.10);
  --shadow:     0 8px 22px rgba(18,26,29,.10);
  --shadow-lg:  0 20px 50px rgba(18,26,29,.14);
}

/* --------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
/* Puzzle-piece wallpaper. Drawn once as an SVG and used as a mask so the
   pattern takes its colour from the theme and stays crisp at any zoom. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-color: var(--pattern);
  -webkit-mask-image: url(/assets/img/puzzle-bg.svg);
  mask-image: url(/assets/img/puzzle-bg.svg);
  -webkit-mask-repeat: repeat; mask-repeat: repeat;
  -webkit-mask-size: var(--pattern-size) var(--pattern-size);
  mask-size: var(--pattern-size) var(--pattern-size);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 90% 60% at 50% 0%, transparent 40%, var(--bg) 100%);
}
@media (max-width: 640px) { :root { --pattern-size: 360px; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv05" 1;
  overflow-x: hidden;
}
img, svg, canvas { max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:where(a, button, select, input, [tabindex]):focus-visible {
  outline: 2px solid var(--boxwood);
  outline-offset: 2px;
  border-radius: 3px;
}
.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;
}
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--boxwood); color: #10171a; padding: 10px 16px;
  border-radius: var(--r-sm); font-weight: 600; text-decoration: none;
  transition: top .16s ease;
}
.skip-link:focus { top: 12px; }

/* ------------------------------------------------------------ typography */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.14;
  letter-spacing: -.012em;
  color: var(--text-strong);
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(2.05rem, 1.35rem + 2.5vw, 3.4rem); letter-spacing: -.022em; }
h2 { font-size: clamp(1.55rem, 1.2rem + 1.3vw, 2.3rem); }
h3 { font-size: clamp(1.2rem, 1.06rem + .55vw, 1.5rem); }
h4 { font-size: 1.05rem; }
p  { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }
strong, b { font-weight: 600; color: var(--text-strong); }
small { font-size: .82rem; }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }
kbd {
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: .08em .42em; background: var(--surface-2); font-size: .82em;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 2.4rem 0; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 60ch; }

/* ------------------------------------------------------------- structure */
.wrap { width: min(var(--wrap), 100% - 2.5rem); margin-inline: auto; }
.wrap-narrow { width: min(860px, 100% - 2.5rem); margin-inline: auto; }
@media (max-width: 640px) {
  .wrap, .wrap-narrow { width: min(100% - 1.75rem, 100%); }
}
main { display: block; padding-bottom: 4rem; }
section + section { margin-top: 3.75rem; }

/* ---------------------------------------------------------------- header */
.masthead {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.masthead__inner {
  display: flex; align-items: center; gap: 1.25rem;
  min-height: 66px;
}
.logo {
  display: inline-flex; align-items: center; gap: .6rem;
  text-decoration: none; color: var(--text-strong); flex: none;
}
.logo img {
  width: 34px; height: 34px; border-radius: 9px; display: block;
  box-shadow: var(--shadow-sm);
}
.logo__word {
  font-family: var(--serif); font-size: 1.12rem; font-weight: 600;
  letter-spacing: -.015em; line-height: 1;
}
.logo__word em { font-style: normal; color: var(--boxwood); }
.mainnav { display: flex; gap: 1.4rem; margin-inline-start: auto; }
.mainnav a {
  text-decoration: none; color: var(--muted); font-size: .93rem; font-weight: 500;
  padding: .35rem 0; border-bottom: 2px solid transparent;
}
.mainnav a:hover, .mainnav a[aria-current="page"] { color: var(--text-strong); border-bottom-color: var(--boxwood); }
.masthead__tools { display: flex; align-items: center; gap: .5rem; margin-inline-start: 1rem; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
}
.icon-btn:hover { border-color: var(--boxwood); color: var(--boxwood); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[data-state="off"] { color: var(--muted-dim); border-color: var(--line-soft); }
.nav-toggle { display: none; }

@media (max-width: 860px) {
  .mainnav {
    position: fixed; inset: 66px 0 auto; z-index: 39;
    flex-direction: column; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: .5rem 1.25rem 1.1rem; margin: 0;
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .mainnav[data-open="true"] { display: flex; }
  .mainnav a { padding: .8rem 0; border-bottom: 1px solid var(--line-soft); font-size: 1rem; }
  .mainnav a:hover, .mainnav a[aria-current="page"] { border-bottom-color: var(--line-soft); color: var(--boxwood); }
  .nav-toggle { display: grid; margin-inline-start: auto; order: 3; }
  .masthead__tools { margin-inline-start: 0; }
}

/* ---------------------------------------------------------------- footer */
.sitefoot {
  border-top: 1px solid var(--line); background: var(--bg-deep);
  padding: 3rem 0 2rem; margin-top: 4rem;
}
.sitefoot__grid {
  display: grid; grid-template-columns: 1.5fr repeat(3, 1fr); gap: 2.2rem;
}
.sitefoot h2 {
  font-family: var(--sans); font-size: .78rem; font-weight: 600;
  letter-spacing: .04em; color: var(--muted-dim); margin-bottom: .85rem;
}
.sitefoot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.sitefoot a { color: var(--muted); text-decoration: none; font-size: .92rem; }
.sitefoot a:hover { color: var(--boxwood); }
.sitefoot__blurb { color: var(--muted); font-size: .92rem; max-width: 34ch; margin-top: .8rem; }
.sitefoot__base {
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between;
  align-items: center; margin-top: 2.6rem; padding-top: 1.4rem;
  border-top: 1px solid var(--line); color: var(--muted-dim); font-size: .85rem;
}
.linkish { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.linkish:hover { color: var(--boxwood); }
@media (max-width: 780px) { .sitefoot__grid { grid-template-columns: 1fr 1fr; gap: 1.8rem; } }
@media (max-width: 460px) { .sitefoot__grid { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); color: var(--text);
  padding: .62rem 1.05rem; font-size: .94rem; font-weight: 500;
  text-decoration: none; min-height: 42px;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--line); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary {
  background: var(--boxwood); border-color: var(--boxwood); color: #14191b; font-weight: 600;
}
.btn--primary:hover { background: #e6b459; border-color: #e6b459; }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 34px; padding: .35rem .7rem; font-size: .84rem; }
.btn--block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .55rem; }

.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; background: transparent;
  color: var(--muted); padding: .34rem .8rem; font-size: .83rem; font-weight: 500;
  min-height: 34px; text-decoration: none; display: inline-flex; align-items: center;
}
.chip:hover { color: var(--text-strong); border-color: var(--boxwood); }
.chip[aria-pressed="true"], .chip.is-active {
  background: var(--boxwood-tint); border-color: var(--boxwood); color: var(--boxwood);
}

.field { display: grid; gap: .3rem; }
.field > span { font-size: .78rem; color: var(--muted); font-weight: 500; }
select.control, input.control {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); padding: .5rem .6rem; min-height: 40px;
}

/* ----------------------------------------------------------------- cards */
.card {
  background: color-mix(in srgb, var(--surface) 93%, transparent); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.4rem;
}
.grid { display: grid; gap: 1rem; }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 940px) { .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid--3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 620px) { .grid--4, .grid--3, .grid--2 { grid-template-columns: 1fr; } }

/* section headers */
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.4rem; }
.sec-head p { color: var(--muted); margin: .5rem 0 0; max-width: 58ch; }
.sec-head a { color: var(--boxwood); text-decoration: none; font-size: .92rem; font-weight: 500; white-space: nowrap; }
.sec-head a:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 620px) { .sec-head { display: block; } .sec-head a { display: inline-block; margin-top: .8rem; } }

/* ------------------------------------------------------------ breadcrumb */
.crumbs { font-size: .84rem; color: var(--muted-dim); padding: 1.1rem 0 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.crumbs li::after { content: "/"; margin-inline-start: .4rem; color: var(--line); }
.crumbs li:last-child::after { content: none; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--boxwood); }

/* ------------------------------------------------------------- ad slots */
.ad {
  margin: 2.4rem auto; text-align: center; max-width: 100%;
  min-height: 100px; display: flex; align-items: center; justify-content: center;
}
".ad--rail { margin: 0; min-height: 250px; }
.ad--gametop { margin: 0 0 1.3rem; min-height: 100px; }

.keywords {
  margin-top: 1.6rem; padding: 1.3rem 1.4rem;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  border: 1px solid var(--line); border-radius: var(--r-lg);
}
.keywords h2 {
  font-family: var(--sans); font-size: .95rem; font-weight: 600;
  margin: 0 0 .9rem; color: var(--text-strong);
}
.keywords .chip { text-decoration: none; }
.keywords p { margin: .9rem 0 0; font-size: .82rem; color: var(--muted-dim); }

.ad--banner {
  margin: 0; min-height: 92px; padding: .7rem 0 0;
  border-bottom: 1px solid var(--line-soft);
}
.ad--banner .ad__frame { min-height: 90px; }
@media (max-width: 700px) { .ad--banner, .ad--banner .ad__frame { min-height: 60px; } }
.ad__frame {
  width: 100%; border: 1px dashed var(--line); border-radius: var(--r);
  background: var(--surface-2); color: var(--muted-dim);
  display: grid; place-items: center; min-height: 100px; padding: 1rem;
  font-size: .74rem; letter-spacing: .05em;
}
.ad--rail .ad__frame { min-height: 250px; }
.ad ins.adsbygoogle { display: block; width: 100%; }
.ad__label { display: block; font-size: .68rem; color: var(--muted-dim); letter-spacing: .08em; margin-bottom: .35rem; }

/* =========================================================== HOME: hero */
.hero { padding: clamp(2.5rem, 5vw, 4.5rem) 0 1rem; }
.hero__inner {
  display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
  gap: clamp(2rem, 4vw, 4rem); align-items: center;
}
.hero h1 { margin-bottom: 1rem; }
.hero__sub { font-size: 1.14rem; color: var(--muted); max-width: 46ch; margin-bottom: 1.8rem; }
.hero__meta {
  display: flex; flex-wrap: wrap; gap: 1.6rem; margin-top: 2.2rem;
  padding-top: 1.5rem; border-top: 1px solid var(--line);
}
.hero__meta div { min-width: 0; }
.hero__meta dt { font-size: .78rem; color: var(--muted-dim); margin-bottom: .2rem; }
.hero__meta dd { margin: 0; font-family: var(--mono); font-size: 1.32rem; color: var(--text-strong); }

/* The board mosaic — the site's signature element.
   Seven shards, each a true fragment of one of the seven boards. */
.mosaic {
  display: grid; gap: 6px;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  aspect-ratio: 1;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.shard {
  position: relative; overflow: hidden; text-decoration: none;
  border-radius: var(--r-sm); border: 1px solid rgba(0,0,0,.35);
  display: block; min-width: 0; min-height: 0;
  transition: transform .18s cubic-bezier(.2,.8,.3,1), box-shadow .18s ease;
}
.shard:hover, .shard:focus-visible { transform: scale(1.035); z-index: 3; box-shadow: 0 10px 26px rgba(0,0,0,.45); }
.shard__name {
  position: absolute; inset: auto 0 0; z-index: 2;
  padding: .5rem .55rem .4rem;
  background: linear-gradient(to top, rgba(6,10,12,.92), rgba(6,10,12,0));
  color: #fff; font-size: .74rem; font-weight: 600; letter-spacing: .01em;
}
.shard svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.shard--chess   { grid-column: 1 / 4; grid-row: 1 / 4; }
.shard--sudoku  { grid-column: 4 / 7; grid-row: 1 / 3; }
.shard--go      { grid-column: 4 / 6; grid-row: 3 / 5; }
.shard--mahjong { grid-column: 6 / 7; grid-row: 3 / 5; }
.shard--2048    { grid-column: 1 / 3; grid-row: 4 / 7; }
.shard--checkers{ grid-column: 3 / 5; grid-row: 5 / 7; }
.shard--gomoku  { grid-column: 5 / 7; grid-row: 5 / 7; }
@media (max-width: 900px) {
  .hero__inner { grid-template-columns: 1fr; }
  .mosaic { max-width: 460px; margin-inline: auto; }
  .shard__name { font-size: .68rem; }
}

/* ------------------------------------------------------- game index grid */
.gamecard {
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden; text-decoration: none;
  transition: border-color .16s ease, transform .16s cubic-bezier(.2,.8,.3,1);
}
.gamecard:hover { border-color: var(--boxwood); transform: translateY(-3px); }
.gamecard__art { aspect-ratio: 16 / 9; background: var(--bg-deep); position: relative; }
.gamecard__art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.gamecard__body { padding: 1.1rem 1.2rem 1.25rem; }
.gamecard__body h3 { margin-bottom: .35rem; }
.gamecard__body p { color: var(--muted); font-size: .9rem; margin: 0; }
.gamecard__foot {
  padding: .8rem 1.2rem; border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; align-items: center;
  font-size: .8rem; color: var(--muted-dim);
}
.gamecard__foot b { color: var(--boxwood); font-weight: 600; }
.tags { display: flex; gap: .35rem; flex-wrap: wrap; }
.tag {
  font-size: .68rem; color: var(--muted); border: 1px solid var(--line);
  padding: .1rem .45rem; border-radius: 4px;
}

/* ========================================================== GAME PAGES */
.gamehead { padding: 1.2rem 0 1.6rem; }
.gamehead h1 { margin-bottom: .5rem; }
.gamehead p { color: var(--muted); max-width: 62ch; margin: 0; }

.stage-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 296px;
  gap: 1.3rem; align-items: start;
}
@media (max-width: 1020px) { .stage-layout { grid-template-columns: 1fr; } }

.stage {
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(3px); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: clamp(.85rem, 2.2vw, 1.5rem);
}
.stage__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap; padding-bottom: .9rem; margin-bottom: 1rem;
  border-bottom: 1px solid var(--line-soft);
}
.stage__bar h2 { font-size: 1.15rem; }
.readout { display: flex; gap: 1.1rem; align-items: center; }
.readout div { text-align: center; }
.readout dt { font-size: .68rem; color: var(--muted-dim); }
.readout dd { margin: 0; font-family: var(--mono); font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.stage__foot {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center;
  padding-top: 1rem; margin-top: 1.1rem; border-top: 1px solid var(--line-soft);
}
.statusbar {
  margin-top: 1rem; padding: .7rem .9rem; border-radius: var(--r-sm);
  background: var(--surface-2); border-inline-start: 3px solid var(--boxwood);
  color: var(--muted); font-size: .92rem; min-height: 44px;
  display: flex; align-items: center;
}
.statusbar b { color: var(--text-strong); }
.statusbar[data-tone="win"]  { border-inline-start-color: var(--jade); background: var(--jade-tint); }
.statusbar[data-tone="warn"] { border-inline-start-color: var(--lacquer); background: var(--lacquer-tint); }

.rail { display: grid; gap: 1rem; }
.rail__panel {
  background: color-mix(in srgb, var(--surface) 93%, transparent); border: 1px solid var(--line);
  border-radius: var(--r); padding: 1rem 1.05rem;
}
.rail__panel h3 { font-family: var(--sans); font-size: .8rem; font-weight: 600; letter-spacing: .03em; color: var(--muted-dim); margin-bottom: .7rem; }
.rail__panel p { font-size: .88rem; color: var(--muted); }
.optgrid { display: grid; gap: .4rem; }
.optgrid button {
  text-align: start; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: transparent; color: var(--text); padding: .55rem .7rem; font-size: .88rem;
}
.optgrid button:hover { border-color: var(--boxwood); }
.optgrid button[aria-pressed="true"] { background: var(--boxwood-tint); border-color: var(--boxwood); color: var(--boxwood); font-weight: 600; }
.keyhelp { display: grid; gap: .4rem; font-size: .83rem; color: var(--muted); }
.keyhelp div { display: flex; gap: .6rem; align-items: baseline; }
.keyhelp kbd { flex: none; }

/* ---------------------------------------------------- shared board chrome */
.boardwrap { display: grid; place-items: center; }
.board-frame {
  --frame: 10px;
  position: relative; margin-inline: auto;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  touch-action: manipulation;
}

/* Sudoku ------------------------------------------------------------- */
.sudoku {
  display: grid; grid-template-columns: repeat(9, 1fr);
  width: min(100%, 552px); aspect-ratio: 1; margin-inline: auto;
  background: #f6f3ea; border: 3px solid #0b1114;
  border-radius: 5px; overflow: hidden; box-shadow: var(--shadow-lg);
  direction: ltr;
}
.sudoku .sq {
  box-sizing: border-box; margin: 0; padding: 0; min-width: 0;
  border: 0 solid #0b1114;
  border-right-width: 1px; border-bottom-width: 1px;
  border-right-color: #aab4b2; border-bottom-color: #aab4b2;
  background: #f6f3ea; color: #2c3f46;
  display: grid; place-items: center; position: relative;
  font-family: var(--serif); font-size: clamp(15px, 3.6vw, 27px); font-weight: 500;
  cursor: pointer; line-height: 1;
}
/* thick lines on the 3x3 block boundaries */
.sudoku .sq[data-br="1"] { border-right-width: 2px; border-right-color: #0b1114; }
.sudoku .sq[data-bb="1"] { border-bottom-width: 2px; border-bottom-color: #0b1114; }
.sudoku .sq:nth-child(9n) { border-right-width: 0; }
.sudoku .sq:nth-last-child(-n+9) { border-bottom-width: 0; }

.sudoku .sq.fixed { background: #e2dccb; color: #101a1e; font-weight: 700; }
.sudoku .sq.peer  { background: #ebe6d6; }
.sudoku .sq.peer.fixed { background: #d8d1be; }
.sudoku .sq.same  { background: #c6dacd; }
.sudoku .sq.bad   { background: #e8b6ae; color: #7a1f16; }
.sudoku .sq.hinted{ background: #a9d8c1; }
/* outline never disturbs the grid lines */
.sudoku .sq.sel   { background: var(--boxwood); color: #1a1206; }
.sudoku .sq.sel::after,
.sudoku .sq.hinted::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 3px #7a5410; pointer-events: none;
}
.sudoku .sq.hinted::after { box-shadow: inset 0 0 0 3px #2f7a62; }
.sudoku .marks {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 96%; height: 96%; font-family: var(--sans); font-size: clamp(6px, 1.35vw, 10px);
  font-weight: 600; color: #5d7078; place-items: center; line-height: 1;
}
.padgrid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px;
  width: min(100%, 552px); margin: .9rem auto 0;
}
.padgrid button {
  min-height: 48px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); font-family: var(--serif); font-size: 1.15rem; font-weight: 600;
}
.padgrid button:hover { border-color: var(--boxwood); color: var(--boxwood); }
.padgrid button[data-full="1"] { opacity: .38; }
@media (max-width: 560px) { .padgrid { grid-template-columns: repeat(5, 1fr); } }

/* Chess & Checkers --------------------------------------------------- */
.board8 {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: min(100%, 620px); aspect-ratio: 1; margin-inline: auto;
  border: 10px solid #2b1f16; border-radius: 6px; overflow: hidden;
  box-shadow: var(--shadow-lg); touch-action: manipulation;
}
.board8 .sq {
  border: 0; padding: 0; min-width: 0; position: relative;
  display: grid; place-items: center; cursor: pointer; aspect-ratio: 1;
}
.board8 .sq.l { background: #ebdcbe; }
.board8 .sq.d { background: #5b7f92; }
.board8[data-felt="walnut"] .sq.l { background: #e8d7b4; }
.board8[data-felt="walnut"] .sq.d { background: #8a6141; }
.board8[data-felt="jade"] .sq.l { background: #e6e5c9; }
.board8[data-felt="jade"] .sq.d { background: #4d7d65; }
.board8 .sq.sel { box-shadow: inset 0 0 0 4px var(--boxwood); }
.board8 .sq.last { box-shadow: inset 0 0 0 4px rgba(217,164,65,.42); }
.board8 .sq.chk { box-shadow: inset 0 0 0 4px var(--lacquer); }
.board8 .sq .dot {
  position: absolute; width: 26%; aspect-ratio: 1; border-radius: 50%;
  background: rgba(20,30,34,.34); pointer-events: none;
}
.board8 .sq .ring {
  position: absolute; inset: 6%; border-radius: 50%;
  border: 4px solid rgba(196,72,63,.75); pointer-events: none;
}
.board8 .pc { width: 88%; height: 88%; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.board8 .coord {
  position: absolute; font-family: var(--mono); font-size: .5rem; font-weight: 600;
  opacity: .55; pointer-events: none; color: #15201f;
}
.board8 .sq.d .coord { color: #ecdfc6; }
.board8 .coord.f { inset: auto 3px 1px auto; }
.board8 .coord.r { inset: 1px auto auto 3px; }

.checker {
  width: 76%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  display: grid; place-items: center;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.22), inset 3px 3px 5px rgba(255,255,255,.22), 0 3px 5px rgba(0,0,0,.34);
}
.checker.a { background: radial-gradient(circle at 34% 28%, #f0f0e6, #d3cfbf 58%, #a19c8b); }
.checker.b { background: radial-gradient(circle at 34% 28%, #4a5b64, #1d2b31 58%, #0d1418); }
.checker .crown { width: 56%; height: 56%; pointer-events: none; }
.checker.king { box-shadow: inset 0 -5px 0 rgba(0,0,0,.22), inset 3px 3px 5px rgba(255,255,255,.22),
                0 0 0 2px var(--boxwood), 0 3px 6px rgba(0,0,0,.4); }

/* Go & Gomoku -------------------------------------------------------- */
/* The point grid and the drawn lines share one coordinate system: every
   stone sits at the centre of its cell, and the lines are drawn through
   those same centres, so stones land exactly on the intersections. */
.goban {
  --n: 9;
  position: relative; width: min(100%, 620px); aspect-ratio: 1; margin-inline: auto;
  padding: clamp(6px, 1.4vw, 12px);
  background:
    repeating-linear-gradient(94deg, rgba(255,255,255,.05) 0 1px, transparent 1px 9px),
    linear-gradient(150deg, #e2bc7e, #cd9c58 58%, #b8843f);
  border: 9px solid #7d5326; border-radius: 5px;
  box-shadow: var(--shadow-lg), inset 0 0 0 2px rgba(255,246,224,.35);
  touch-action: manipulation; direction: ltr;
}
.goban__grid { position: relative; width: 100%; height: 100%; }
.goban__lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.goban__pts { position: absolute; inset: 0; display: grid; }
.pt {
  position: relative; border: 0; background: transparent; padding: 0;
  min-width: 0; min-height: 0; cursor: pointer; display: grid; place-items: center;
}
.pt .stone {
  width: 94%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  box-shadow: inset -4px -4px 6px rgba(0,0,0,.36), inset 3px 3px 4px rgba(255,255,255,.28),
              0 2px 3px rgba(0,0,0,.35);
}
.pt .stone.b { background: radial-gradient(circle at 34% 28%, #62696e, #171e22 56%, #05090b); }
.pt .stone.w { background: radial-gradient(circle at 32% 26%, #fffefa, #e6e4dc 58%, #a5a69f); }
.pt .mark {
  position: absolute; width: 24%; aspect-ratio: 1; border-radius: 50%;
  background: var(--lacquer); z-index: 2;
}
.pt .mark.on-b { background: #f2f0e6; }
.pt .win { position: absolute; inset: 6%; border: 3px solid var(--lacquer); border-radius: 50%; z-index: 3; }
.pt:not(:disabled):hover::after {
  content: ""; position: absolute; width: 62%; aspect-ratio: 1; border-radius: 50%;
  background: rgba(20,30,34,.22);
}
.pt:has(.stone):hover::after { display: none; }

/* 2048 ---------------------------------------------------------------- */
.t2048 {
  position: relative; width: min(100%, 470px); aspect-ratio: 1; margin-inline: auto;
  background: #1b2529; border: 8px solid #1b2529; border-radius: var(--r);
  box-shadow: var(--shadow-lg); touch-action: none;
}
.t2048__cells, .t2048__tiles { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2.6%; padding: 2.6%; }
.t2048__cells div { background: rgba(255,255,255,.05); border-radius: 6px; }
.t2048__tiles { display: block; padding: 0; }
.tile {
  position: absolute; display: grid; place-items: center; border-radius: 6px;
  font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums;
  transition: transform .11s ease-out;
}
.tile.pop { animation: tilePop .16s ease-out; }
.tile.new { animation: tileNew .14s ease-out; }
@keyframes tilePop { 0% { transform: scale(1);} 50% { transform: scale(1.13);} 100% { transform: scale(1);} }
@keyframes tileNew { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.t2048__over {
  position: absolute; inset: 0; display: none; place-items: center; text-align: center;
  background: rgba(10,16,19,.86); border-radius: 4px; z-index: 5; padding: 1rem;
}
.t2048__over.show { display: grid; }
.t2048__over strong { font-family: var(--serif); font-size: clamp(1.4rem, 5vw, 2.1rem); display: block; }
.dpad { display: grid; grid-template-columns: repeat(3, 54px); gap: .4rem; justify-content: center; margin-top: 1rem; }
.dpad button { min-height: 46px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.dpad button[data-dir="up"] { grid-column: 2; }
.dpad button[data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad button[data-dir="down"] { grid-column: 2; grid-row: 2; }
.dpad button[data-dir="right"] { grid-column: 3; grid-row: 2; }
@media (min-width: 861px) { .dpad { display: none; } }

/* Mahjong ------------------------------------------------------------- */
.mahjong {
  --tw: clamp(34px, 6.6vw, 62px); --th: calc(var(--tw) * 1.32);
  position: relative; width: min(100%, 860px); margin-inline: auto;
  min-height: calc(var(--th) * 5.6);
  padding: calc(var(--th) * .35) calc(var(--tw) * .5);
  background:
    radial-gradient(ellipse at 50% 20%, rgba(60,150,160,.30), transparent 62%),
    repeating-linear-gradient(122deg, rgba(255,255,255,.022) 0 1px, transparent 1px 7px),
    var(--felt-dark);
  border: 9px solid #0d3540; border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), inset 0 0 0 2px rgba(150,215,215,.18);
  overflow: hidden;
}
.mtile {
  position: absolute; padding: 0; display: grid; place-items: center;
  width: var(--tw); height: var(--th);
  left: calc(var(--x) * var(--tw) * .5 + var(--z) * 5px);
  top:  calc(var(--y) * var(--th) * .5 - var(--z) * 5px);
  z-index: calc(var(--z) * 100 + var(--y) * 4 + var(--x));
  border: 1px solid #b9c2b6; border-radius: 6px;
  background: linear-gradient(146deg, #fffdf2 0%, #e9e7d6 62%, #c8ccbd 100%);
  box-shadow: 0 3px 0 #4c7268, 0 6px 9px rgba(0,0,0,.4), inset 0 0 0 2px rgba(255,255,255,.6);
  cursor: pointer;
  transition: transform .13s ease, filter .13s ease, box-shadow .13s ease;
}
.mtile__face {
  font-family: "Noto Serif SC", var(--serif); line-height: 1;
  font-size: calc(var(--tw) * .62); text-shadow: 0 1px 0 rgba(255,255,255,.75);
}
.mtile[data-suit="bamboo"]    .mtile__face { color: #17634a; }
.mtile[data-suit="character"] .mtile__face { color: #a32936; }
.mtile[data-suit="circle"]    .mtile__face { color: #1c4f7a; }
.mtile[data-suit="wind"]      .mtile__face { color: #16232a; }
.mtile[data-suit="dragon"]    .mtile__face { color: #8a5a10; }
.mtile[data-suit="season"]    .mtile__face { color: #6d385a; }
.mtile.blocked { filter: saturate(.62) brightness(.82); cursor: default; }
.mtile.free:hover { transform: translateY(-4px); }
.mtile.sel { box-shadow: 0 3px 0 #4c7268, 0 0 0 3px var(--boxwood), 0 8px 12px rgba(0,0,0,.42); transform: translateY(-4px); }
.mtile.hint { animation: mjHint .85s ease-in-out infinite alternate; }
.mtile.gone { display: none; }
@keyframes mjHint { to { box-shadow: 0 3px 0 #4c7268, 0 0 0 4px var(--jade), 0 8px 14px rgba(0,0,0,.4); } }

/* --------------------------------------------------------- move history */
.movelist {
  font-family: var(--mono); font-size: .84rem; line-height: 1.75;
  max-height: 220px; overflow: auto; color: var(--muted);
  display: grid; grid-template-columns: 2.4rem 1fr 1fr; gap: 0 .4rem;
}
.movelist span.n { color: var(--muted-dim); }
.movelist span.m { color: var(--text); }
.movelist span.m.cur { color: var(--boxwood); font-weight: 600; }
.movelist:empty::after { content: "No moves yet."; font-family: var(--sans); color: var(--muted-dim); }

/* =========================================================== ARTICLES */
.article { padding-top: 1rem; }
.article__head { max-width: var(--read); margin-bottom: 2rem; }
.article__kicker { font-size: .82rem; color: var(--boxwood); font-weight: 600; margin-bottom: .7rem; }
.article__head h1 { margin-bottom: .9rem; }
.article__standfirst { font-family: var(--serif); font-size: 1.18rem; line-height: 1.55; color: var(--muted); }
.article__meta {
  display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.2rem; padding-top: 1rem;
  border-top: 1px solid var(--line); font-size: .84rem; color: var(--muted-dim);
}
.article__body { max-width: var(--read); font-family: var(--serif); font-size: 1.05rem; line-height: 1.72; }
.article__body h2 { margin: 2.5rem 0 .9rem; font-size: clamp(1.35rem, 1.1rem + .9vw, 1.75rem); }
.article__body h3 { margin: 1.9rem 0 .7rem; font-size: 1.16rem; }
.article__body ul, .article__body ol { margin: 0 0 1.15em; padding-inline-start: 1.3em; }
.article__body li { margin-bottom: .45em; }
.article__body li::marker { color: var(--boxwood); }
.article__body a { color: var(--boxwood); text-underline-offset: 3px; }
.article__body table { width: 100%; border-collapse: collapse; margin: 1.4rem 0; font-family: var(--sans); font-size: .92rem; }
.article__body th, .article__body td { text-align: start; padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
.article__body th { color: var(--muted-dim); font-weight: 600; font-size: .8rem; }
.article__body blockquote {
  margin: 1.6rem 0; padding: .2rem 0 .2rem 1.2rem;
  border-inline-start: 3px solid var(--boxwood); color: var(--muted); font-style: italic;
}

.toc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.1rem 1.25rem; margin-bottom: 2rem; max-width: var(--read); font-family: var(--sans);
}
.toc h2 { font-family: var(--sans); font-size: .8rem; font-weight: 600; color: var(--muted-dim); margin: 0 0 .6rem; }
.toc ol { margin: 0; padding-inline-start: 1.15rem; display: grid; gap: .3rem; font-size: .92rem; }
.toc a { color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--boxwood); text-decoration: underline; text-underline-offset: 3px; }

.callout {
  margin: 1.7rem 0; padding: 1.1rem 1.25rem; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
  border-inline-start: 3px solid var(--jade); font-family: var(--sans); font-size: .95rem;
}
.callout h3 { font-family: var(--sans); font-size: .95rem; margin: 0 0 .45rem; }
.callout--warn { border-inline-start-color: var(--lacquer); }
.callout--tip  { border-inline-start-color: var(--boxwood); }
.callout p:last-child { margin-bottom: 0; }

.figure { margin: 1.9rem 0; max-width: var(--read); }
.figure__board { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; display: grid; place-items: center; }
.figure svg { width: min(100%, 340px); height: auto; display: block; }
.figure figcaption { margin-top: .6rem; font-family: var(--sans); font-size: .84rem; color: var(--muted); line-height: 1.5; }

.faq { max-width: var(--read); margin-top: 2.5rem; }
.faq details {
  border: 1px solid var(--line); border-radius: var(--r); margin-bottom: .6rem;
  background: var(--surface); font-family: var(--sans);
}
.faq summary {
  padding: .95rem 1.1rem; cursor: pointer; font-weight: 500; font-size: .98rem;
  list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--boxwood); font-size: 1.2rem; flex: none; }
.faq details[open] summary::after { content: "\2212"; }
.faq details[open] summary { border-bottom: 1px solid var(--line-soft); }
.faq .faq__a { padding: .9rem 1.1rem 1.1rem; color: var(--muted); font-size: .95rem; }
.faq .faq__a p:last-child { margin-bottom: 0; }

.keytakeaways {
  max-width: var(--read); margin: 2.2rem 0; padding: 1.3rem 1.4rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); font-family: var(--sans);
}
.keytakeaways h2 { font-family: var(--sans); font-size: .95rem; margin: 0 0 .8rem; }
.keytakeaways ul { margin: 0; padding-inline-start: 1.15rem; display: grid; gap: .5rem; font-size: .95rem; color: var(--muted); }
.keytakeaways li::marker { color: var(--jade); }

.cta-play {
  max-width: var(--read); margin: 2.6rem 0; padding: 1.4rem 1.5rem;
  border-radius: var(--r-lg); border: 1px solid var(--boxwood);
  background: var(--boxwood-tint);
  display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; flex-wrap: wrap;
}
.cta-play p { margin: .3rem 0 0; color: var(--muted); font-size: .93rem; max-width: 44ch; }
.cta-play h2 { font-size: 1.2rem; }

/* article index list */
.artlist { display: grid; gap: 0; border-top: 1px solid var(--line); }
.artlist a {
  display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center;
  padding: 1.1rem .3rem; border-bottom: 1px solid var(--line); text-decoration: none;
}
.artlist a:hover { background: var(--surface); }
.artlist b { display: block; font-family: var(--serif); font-size: 1.08rem; font-weight: 600; color: var(--text-strong); }
.artlist span { display: block; color: var(--muted); font-size: .89rem; margin-top: .2rem; }
.artlist em { font-style: normal; font-size: .78rem; color: var(--muted-dim); white-space: nowrap; font-family: var(--mono); }

.pill-nav { display: flex; flex-wrap: wrap; gap: .45rem; margin: 1.4rem 0 2rem; }

/* prev/next */
.seq { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 3rem; max-width: var(--read); }
.seq a { text-decoration: none; border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; background: var(--surface); }
.seq a:hover { border-color: var(--boxwood); }
.seq small { color: var(--muted-dim); font-size: .76rem; }
.seq b { display: block; font-family: var(--serif); font-weight: 600; margin-top: .25rem; font-size: .98rem; }
.seq a:last-child { text-align: end; }
@media (max-width: 560px) { .seq { grid-template-columns: 1fr; } .seq a:last-child { text-align: start; } }

/* ------------------------------------------------------------- consent */
.consent {
  position: fixed; inset: auto 1rem 1rem; z-index: 90; max-width: 720px; margin-inline: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.4rem 1.5rem; box-shadow: var(--shadow-lg);
}
.consent[hidden], .consent-scrim[hidden], .consent-modal[hidden] { display: none !important; }
.consent h2 { font-size: 1.15rem; margin-bottom: .5rem; }
.consent p { color: var(--muted); font-size: .92rem; margin-bottom: 1rem; }
.consent__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.consent__actions .btn { flex: 1 1 auto; min-width: 130px; }
.consent-scrim { position: fixed; inset: 0; z-index: 89; background: rgba(4,8,10,.6); }
.consent-modal {
  position: fixed; z-index: 91; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  width: min(94vw, 560px); max-height: 86vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 1.5rem; box-shadow: var(--shadow-lg);
}
.consent-opt { display: flex; gap: .8rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.consent-opt input { width: 18px; height: 18px; margin-top: .28rem; flex: none; accent-color: var(--boxwood); }
.consent-opt p { font-size: .88rem; color: var(--muted); margin: .2rem 0 0; }
.consent-opt label { font-weight: 600; }

/* --------------------------------------------------------------- toast */
.winmodal { position: fixed; inset: 0; z-index: 95; display: none; place-items: center; padding: 1.5rem; background: rgba(5,9,11,.72); }
.winmodal.show { display: grid; }
.winmodal__panel {
  background: var(--surface); border: 1px solid var(--boxwood); border-radius: var(--r-xl);
  padding: 2rem; text-align: center; max-width: 420px; box-shadow: var(--shadow-lg);
}
.winmodal__panel strong { display: block; font-family: var(--serif); font-size: 2rem; color: var(--boxwood); }
.winmodal__panel p { color: var(--muted); margin: .6rem 0 1.2rem; }

/* --------------------------------------------------------------- misc */
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem 1.35rem; color: var(--muted); font-size: .93rem; }
.legal { max-width: var(--read); }
.legal h2 { margin: 2.2rem 0 .8rem; }
.legal ul { padding-inline-start: 1.2rem; }
.legal li { margin-bottom: .4rem; color: var(--muted); }
.legal p { color: var(--muted); }
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.stat-strip div { background: var(--surface); padding: 1.2rem 1.1rem; }
.stat-strip dt { font-size: .78rem; color: var(--muted-dim); margin-bottom: .3rem; }
.stat-strip dd { margin: 0; font-family: var(--mono); font-size: 1.35rem; color: var(--text-strong); }
@media (max-width: 700px) { .stat-strip { grid-template-columns: 1fr 1fr; } }

@media print {
  .masthead, .sitefoot, .ad, .rail, .consent, .consent-scrim, .stage__foot, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
  .article__body { max-width: none; }
}
