/* Shatranj. One ground, one ink, one accent; the two armies take the glazes of the twelfth-century set. No gradients, no resting shadows, no hairlines outside the board. */
:root {
  color-scheme: dark;
  --ground: #12161d;
  --ground-2: #1a2029;
  --board: #232c3a;
  --board-line: #55606f;
  --ink: #e9e7e1;
  --ink-2: #a9b0bb;
  --accent: #e3b341;
  --accent-ink: #1b1505;
  --turq: #5cc2b0; --turq-d: #2a7a70;
  --mang: #b88c80; --mang-d: #66453f;
  --alarm: #e2603f;
  --display: "El Messiri", "Palatino Linotype", Palatino, serif;
  --text: "Alegreya Sans", "Gill Sans", "Trebuchet MS", sans-serif;
  --gut: clamp(16px, 3vw, 32px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--text); font-size: 17px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
h1, h2 { font-size: clamp(2rem, 3.4vw, 3rem); }
h3 { font-size: 1.5rem; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.bar { display: flex; align-items: center; gap: 24px; padding: 14px max(var(--gut), env(safe-area-inset-right, 0px)) 14px max(var(--gut), env(safe-area-inset-left, 0px)); }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 1.5rem; text-decoration: none; display: flex; align-items: baseline; gap: 10px; }
.wordmark span { color: var(--accent); }
.bar nav { display: flex; gap: 22px; margin-left: auto; }
.bar nav a { text-decoration: none; }
.bar nav a:hover { text-decoration: underline; }
@media (max-width: 640px) { .bar nav { display: none; } .bar .btn { margin-left: auto; } }

.btn { font: inherit; font-weight: 700; color: var(--ink); background: var(--ground-2); border: 0; border-radius: 0; padding: 11px 16px; cursor: pointer; transition: transform 120ms var(--ease), background-color 120ms var(--ease); }
.btn:hover { background: #26303d; }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #f0c458; }
.btn.quiet { background: transparent; font-weight: 500; padding-left: 0; text-decoration: underline; text-underline-offset: 3px; }
.btn.quiet:hover { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }

/* First screen: the table and the panel. */
.stage { display: grid; grid-template-columns: minmax(0, min(72vh, 700px)) minmax(0, 1fr); gap: clamp(20px, 4vw, 56px); align-items: start; padding: 8px max(var(--gut), env(safe-area-inset-right, 0px)) 72px max(var(--gut), env(safe-area-inset-left, 0px)); }
@media (max-width: 900px) { .stage { grid-template-columns: minmax(0, 1fr); } .table { max-width: 620px; width: 100%; margin: 0 auto; } }
.table { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.seat { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 44px; }
.seat .who { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.seat .who::before { content: ""; width: 14px; height: 14px; background: var(--side); }
.seat .taken { display: flex; flex-wrap: wrap; align-items: center; min-width: 0; color: var(--ink-2); font-size: 0.85rem; }
.seat .taken svg { width: 22px; height: 22px; margin-right: -4px; }
.seat .taken b { margin-left: 10px; color: var(--ink); font-variant-numeric: tabular-nums; }
.clock { font-family: var(--display); font-weight: 700; font-size: 1.5rem; font-variant-numeric: tabular-nums; background: var(--ground-2); color: var(--ink-2); padding: 2px 12px; min-width: 4.4ch; text-align: right; transition: background-color 160ms var(--ease), color 160ms var(--ease); }
.clock.run { background: var(--ink); color: var(--ground); }
.clock.low.run { background: var(--alarm); color: var(--ink); }
.clock:empty { display: none; }

.board { position: relative; aspect-ratio: 1; width: 100%; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); background: var(--board); touch-action: none; user-select: none; -webkit-user-select: none; }
/* taste-skill-ignore: the board's own ruled squares (a real interface, marked data-ui) */
.sq { position: relative; border: 0; border-right: 1px solid var(--board-line); border-bottom: 1px solid var(--board-line); background: transparent; padding: 0; margin: 0; display: grid; place-items: center; min-width: 0; cursor: pointer; color: inherit; font: inherit; }
.sq:nth-child(8n) { border-right: 0; }
.sq:nth-child(n+57) { border-bottom: 0; }
.sq.last { background: #33405a; }
.sq.sel { background: #3d5a63; }
.sq.shah { background: #7a3324; }
.sq.go::after { content: ""; position: absolute; width: 24%; height: 24%; border-radius: 50%; background: var(--accent); }
.sq.take::after { content: ""; position: absolute; inset: 6%; border: 4px solid var(--accent); border-radius: 50%; }
.sq .co { position: absolute; font-size: 0.85rem; line-height: 1; color: var(--ink-2); pointer-events: none; }
.sq .co.f { right: 4px; bottom: 3px; } .sq .co.r { left: 4px; top: 3px; }
.man { width: 86%; height: 86%; display: block; pointer-events: none; }
.man .body { stroke-width: 1.5; stroke-linejoin: round; }
.man .cut { fill: none; stroke-width: 1.3; stroke-linecap: round; }
.man.w .body { fill: var(--turq); stroke: var(--turq-d); } .man.w .cut { stroke: var(--turq-d); }
.man.b .body { fill: var(--mang); stroke: var(--mang-d); } .man.b .cut { stroke: var(--mang-d); }
.drag { position: fixed; z-index: 20; pointer-events: none; width: var(--sqpx); height: var(--sqpx); display: grid; place-items: center; transform: translate(-50%, -50%) scale(1.12); }
.sq.lifted .man { opacity: 0.25; }
.board.review .sq { cursor: default; }

.panel { display: flex; flex-direction: column; gap: 20px; min-width: 0; max-width: 520px; }
.lede { max-width: 40ch; }
.setup, .live { display: flex; flex-direction: column; gap: 18px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
legend { padding: 0; font-weight: 700; margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 9px 14px; background: var(--ground-2); transition: background-color 120ms var(--ease), color 120ms var(--ease); }
.seg input:checked + span { background: var(--ink); color: var(--ground); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg .soon span { opacity: 0.45; }
.aside { color: var(--ink-2); font-size: 0.85rem; }
.status { font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1.2; }
.result { background: var(--ink); color: var(--ground); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.result .verdict { font-family: var(--display); font-weight: 700; font-size: 1.5rem; line-height: 1.05; }
.result .btn { background: var(--ground); color: var(--ink); } .result .btn.primary { background: var(--accent); color: var(--accent-ink); }
.moves { list-style: none; margin: 0; padding: 12px; background: var(--ground-2); max-height: 210px; overflow-y: auto; display: grid; grid-template-columns: 2.4em minmax(0, 1fr) minmax(0, 1fr); gap: 2px 8px; font-variant-numeric: tabular-nums; }
.moves:empty::before { content: "No moves yet."; color: var(--ink-2); grid-column: 1 / -1; }
.moves .n { color: var(--ink-2); }
.moves button { font: inherit; color: inherit; background: transparent; border: 0; padding: 2px 6px; text-align: left; cursor: pointer; }
.moves button:hover { background: #26303d; }
.moves button.at { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* Below the table */
.band { padding: clamp(72px, 10vw, 150px) 0; }
.band.set { background: var(--ground-2); }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(var(--gut), env(safe-area-inset-left, 0px)); padding-right: max(var(--gut), env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 40px; }
.wrap.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 56px clamp(32px, 6vw, 96px); }
.wrap.two > div { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.wrap.two p { max-width: 62ch; }
.hero-pic { margin: 0; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1fr); gap: 24px; align-items: end; }
.hero-pic figcaption { color: var(--ink-2); font-size: 0.85rem; max-width: 30ch; }
@media (max-width: 760px) { .hero-pic { grid-template-columns: minmax(0, 1fr); } }
.men { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 48px 40px; }
.men article { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 18px; align-items: start; }
.men .pic { aspect-ratio: 4 / 5; background: var(--ground); overflow: hidden; display: grid; place-items: center; }
.men .pic img { width: 100%; height: 100%; object-fit: cover; transition: transform 500ms var(--ease); }
.men article:hover .pic img { transform: scale(1.06); }
.men .pic .man { width: 70%; height: 70%; }
.men .txt { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.men .name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.men .name span { font-family: var(--display); color: var(--accent); font-size: 1.5rem; }
.men .gloss { color: var(--ink-2); font-size: 0.85rem; }
.men .how { display: flex; align-items: center; gap: 12px; }
.men .how .man { width: 44px; height: 44px; flex: none; }
.mini { display: grid; grid-template-columns: repeat(5, 11px); grid-template-rows: repeat(5, 11px); gap: 2px; flex: none; }
.mini i { background: var(--board); }
.mini i.me { background: var(--ink); } .mini i.to { background: var(--accent); } .mini i.x { background: var(--alarm); }
ul.rules { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; max-width: 62ch; }
ul.rules b { font-weight: 700; }
.foot { padding: 80px 0 max(40px, env(safe-area-inset-bottom, 0px)); }
.foot .wrap { gap: 18px; }
.foot .close { font-family: var(--display); font-weight: 700; font-size: clamp(4rem, 17vw, 15rem); line-height: 0.85; letter-spacing: -0.03em; color: var(--accent); }
.foot p:not(.close) { color: var(--ink-2); font-size: 0.85rem; max-width: 90ch; }

/* Motion: parts rise as their section arrives; nothing stays hidden without script. */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal { opacity: 0; transform: translateY(24px); transition: opacity 600ms var(--ease), transform 600ms var(--ease); transition-delay: var(--d, 0ms); }
  .js .reveal.in { opacity: 1; transform: none; }
  .clock.low.run { animation: beat 1s steps(2, jump-none) infinite; }
  @keyframes beat { 50% { opacity: 0.7; } }
}
