:root {
  color-scheme: light;
  --bg: #f5f5f3;
  --ink: #101010;
  --muted: #6f6f6f;
  --line: #d8d8d3;
  --soft: #ecece8;
  --panel: #ffffff;
  --black: #0b0b0b;
  --white: #ffffff;
  --danger: #b42318;
  --ok: #14532d;
  --ability: #b83b12;
  --ability-soft: #fff0ea;
  --board-light: #f3eadb;
  --board-dark: #9b6a42;
  --board-light-ink: #101010;
  --board-dark-ink: #ffffff;
  --button-hover: #242424;
  --shadow: 0 18px 55px rgba(16, 16, 16, .08);
}

body.dark {
  color-scheme: dark;
  --bg: #171615;
  --ink: #f4f0ea;
  --muted: #aaa39a;
  --line: #3a3632;
  --soft: #24211f;
  --panel: #201d1b;
  --black: #f4f0ea;
  --white: #171615;
  --danger: #ff8b7f;
  --ok: #7fdaa1;
  --ability: #ff8a3d;
  --ability-soft: rgba(255, 138, 61, .18);
  --board-light: #e7d3b1;
  --board-dark: #7b4f30;
  --board-light-ink: #101010;
  --board-dark-ink: #ffffff;
  --button-hover: #ded6ca;
  --shadow: 0 18px 55px rgba(0, 0, 0, .25);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
input,
select {
  font: inherit;
}

button,
.button {
  min-height: 40px;
  border: 1px solid var(--black);
  border-radius: 7px;
  padding: 0 15px;
  background: var(--black);
  color: var(--white);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  touch-action: manipulation;
}

button:hover,
.button:hover {
  background: var(--button-hover);
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
#playBoard:focus-visible,
#replayBoard:focus-visible {
  outline: 3px solid var(--ability);
  outline-offset: 2px;
}

button:disabled,
.button[aria-disabled="true"] {
  cursor: default;
  opacity: .45;
}

button.secondary,
.button.secondary {
  background: var(--panel);
  color: var(--black);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--soft);
}

button.ghost,
.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
}

button.ghost:hover,
.button.ghost:hover {
  border-color: var(--line);
  background: var(--soft);
}

button.danger {
  border-color: var(--danger);
  background: transparent;
  color: var(--danger);
}

button.danger:hover {
  background: var(--danger);
  color: var(--white);
}

button.icon-button {
  width: 40px;
  padding: 0;
}

button svg,
.button svg,
.brand-mark svg,
.notice svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 11px;
  background: var(--bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 9px 12px;
  border-radius: 6px;
  background: var(--black);
  color: var(--white);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

.site-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  min-height: 70px;
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -.02em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 29px;
  height: 29px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
}

.brand-mark svg {
  width: 16px;
  height: 16px;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.site-nav a {
  min-height: 38px;
  padding: 8px 11px;
  border-radius: 6px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--soft);
  color: var(--ink);
}

.page-main {
  padding-top: 48px;
  padding-bottom: 70px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hero {
  min-height: min(680px, calc(100vh - 70px));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, .75fr);
  align-items: center;
  gap: clamp(36px, 7vw, 96px);
  padding-top: 45px;
  padding-bottom: 70px;
}

.hero h1,
.page-heading h1,
.setup-copy h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(42px, 7.2vw, 86px);
  line-height: .98;
  letter-spacing: -.055em;
  font-weight: 850;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 620px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
}

.hero-actions,
.completion-actions,
.form-actions,
.detail-actions,
.game-actions,
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 26px;
}

.hero-actions .button {
  min-height: 48px;
  padding: 0 20px;
}

.rule-stack {
  position: relative;
  min-height: 410px;
  display: grid;
  align-content: center;
}

.rule-card {
  width: min(360px, calc(100% - 38px));
  min-height: 115px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 19px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.rule-card + .rule-card {
  margin-top: -8px;
}

.rule-card:nth-child(2) {
  margin-left: 36px;
}

.rule-card:nth-child(3) {
  margin-left: 12px;
}

.rule-card.active {
  border-color: var(--ability);
  box-shadow: 0 0 0 4px var(--ability-soft), var(--shadow);
}

.rule-number {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font: 750 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.rule-card.active .rule-number {
  border-color: var(--ability);
  background: var(--ability);
  color: var(--white);
}

.rule-card strong {
  display: block;
  margin-top: 10px;
  font-size: 16px;
}

.rule-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.content-section {
  padding: 75px 0;
  border-top: 1px solid var(--line);
}

.invite-main {
  min-height: calc(100vh - 70px);
  min-height: calc(100dvh - 70px);
  padding: 32px 20px;
  display: grid;
  place-items: center;
}

.invite-card {
  width: min(560px, 100%);
  border-top: 1px solid var(--ink);
  padding: 30px 2px;
}

.invite-card h1 {
  margin: 0;
  font-size: clamp(38px, 7vw, 64px);
  line-height: 1;
  letter-spacing: -.05em;
}

.invite-message {
  max-width: 470px;
  min-height: 48px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.invite-message.error {
  color: var(--danger);
}

.invite-continue {
  margin-top: 12px;
}

.section-heading {
  max-width: 650px;
  margin-bottom: 34px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.05;
  letter-spacing: -.04em;
}

.section-heading p {
  margin: 14px 0 0;
  color: var(--muted);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.feature {
  min-height: 180px;
  border-top: 1px solid var(--ink);
  padding: 17px 4px 10px;
}

.feature .feature-index {
  color: var(--muted);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.feature h3 {
  margin: 28px 0 8px;
  font-size: 18px;
}

.feature p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.footer-inner {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}

.page-heading h1,
.setup-copy h1 {
  font-size: clamp(38px, 6vw, 68px);
}

.page-heading p,
.setup-copy > p {
  max-width: 570px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 20px;
  background: var(--panel);
}

.panel-title {
  margin: 0 0 16px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.setup-layout {
  min-height: calc(100vh - 180px);
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(440px, 1fr);
  align-items: center;
  gap: clamp(35px, 8vw, 110px);
}

.setup-card {
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 15px;
}

.field > label,
.fieldset-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.field-help {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

fieldset {
  min-width: 0;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 7px;
}

.choice-grid.clock-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.choice {
  position: relative;
  min-width: 0;
}

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.choice label {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 7px;
  display: grid;
  place-content: center;
  gap: 2px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  font-weight: 750;
}

.choice label small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.choice input:checked + label {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  background: var(--panel);
}

.choice input:focus-visible + label {
  outline: 3px solid var(--ability);
  outline-offset: 2px;
}

.check-row {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.check-row input {
  width: 17px;
  min-height: 17px;
  margin-top: 2px;
  accent-color: var(--black);
}

.check-row strong {
  color: var(--ink);
}

.advanced-settings {
  margin: 4px 0 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.advanced-settings summary {
  padding: 12px 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}

.advanced-settings.is-enabled summary::after {
  content: "On";
  border: 1px solid var(--ability);
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--ability);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
  float: right;
}

.advanced-settings-body {
  padding: 2px 0 15px;
}

.advanced-enable {
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  cursor: pointer;
}

.advanced-enable input {
  width: 17px;
  min-height: 17px;
  margin-top: 2px;
  accent-color: var(--black);
}

.advanced-enable strong,
.advanced-enable small {
  display: block;
}

.advanced-enable strong {
  font-size: 13px;
}

.advanced-enable small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.advanced-number-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.advanced-number-grid .field {
  min-width: 0;
}

.advanced-settings:not(.is-enabled) .advanced-value {
  opacity: .52;
}

.form-actions button {
  flex: 1;
}

.message {
  min-height: 21px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

.message.ok {
  color: var(--ok);
}

.notice {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.notice strong {
  color: var(--ink);
}

.game-page {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 12px 18px 24px;
}

.game-layout {
  --play-board-size: min(820px, calc(100vh - 96px), calc(100vw - 596px));
  --play-board-size: min(820px, calc(100dvh - 96px), calc(100vw - 596px));
  display: grid;
  grid-template-columns:
    minmax(280px, 1fr)
    minmax(0, var(--play-board-size))
    minmax(280px, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  justify-content: center;
  align-items: stretch;
  gap: 6px 18px;
}

.game-column {
  display: contents;
}

.game-layout > .game-console {
  grid-column: 3;
  grid-row: 3;
  width: min(320px, 100%);
  justify-self: start;
  align-self: start;
}

.game-layout > .game-column > .board-frame {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: start;
}

.game-layout .player-strip.top {
  grid-column: 3;
  grid-row: 1;
}

.game-layout .game-status {
  grid-column: 3;
  grid-row: 2;
}

.game-layout .player-strip.bottom {
  grid-column: 3;
  grid-row: 4;
}

.game-layout #gameMessage {
  grid-column: 3;
  grid-row: 5;
}

.player-strip {
  width: min(320px, 100%);
  min-height: 46px;
  border: 0;
  padding: 5px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: transparent;
  justify-self: start;
}

.player-strip.top {
  border-radius: 0;
}

.player-strip.bottom {
  border-radius: 0;
}

.player-identity {
  min-width: 0;
}

.player-identity strong,
.player-identity span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-identity strong {
  font-size: 14px;
}

.player-identity span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.clock {
  min-width: 94px;
  border-radius: 4px;
  padding: 6px 8px;
  background: var(--soft);
  font: 780 22px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
  letter-spacing: -.04em;
}

.player-strip.active .clock {
  background: var(--black);
  color: var(--white);
}

.clock.low {
  background: var(--danger) !important;
  color: #fff !important;
}

.board-frame {
  padding: 0;
}

.board-wrap {
  position: relative;
  width: min(100%, var(--play-board-size, 820px));
  max-width: 820px;
  margin: 0 auto;
  border-radius: 5px;
}

#playBoard,
#replayBoard {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  position: relative;
  display: block;
  border-radius: 5px;
}

#playBoard {
  touch-action: none;
}

#playBoard cg-board {
  touch-action: none;
}

#replayBoard,
#replayBoard cg-board {
  touch-action: pan-y;
}

#playBoard cg-board,
#replayBoard cg-board {
  border-radius: 5px;
  background-color: var(--board-light);
  background-image: conic-gradient(
    var(--board-dark) 25%,
    var(--board-light) 0 50%,
    var(--board-dark) 0 75%,
    var(--board-light) 0
  );
  background-position: 0 0;
  background-size: 25% 25%;
}

#playBoard cg-board square.selected {
  background: rgba(184, 59, 18, .34);
}

#playBoard cg-board square.move-dest {
  background: radial-gradient(rgba(16, 16, 16, .38) 0 18%, transparent 20%);
}

#playBoard cg-board square.move-dest.oc {
  background: radial-gradient(
    transparent 0 68%,
    rgba(16, 16, 16, .38) 70% 82%,
    transparent 84%
  );
}

#playBoard cg-board square.last-move,
#replayBoard cg-board square.last-move {
  background: rgba(16, 16, 16, .28);
}

#playBoard cg-board square.double-highlight,
#replayBoard cg-board square.double-highlight {
  background-image: repeating-linear-gradient(
    135deg,
    rgba(184, 59, 18, .30) 0 5px,
    rgba(0, 0, 0, .13) 5px 10px
  ) !important;
  box-shadow:
    inset 0 0 0 4px var(--white),
    inset 0 0 0 7px var(--ability) !important;
}

#playBoard cg-board square.keyboard-cursor {
  box-shadow: inset 0 0 0 4px var(--ability);
}

#playBoard cg-board square.keyboard-origin {
  background: rgba(184, 59, 18, .34);
  box-shadow: inset 0 0 0 3px var(--ability);
}

#playBoard coords,
#replayBoard coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
  opacity: .82;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
}

#playBoard coords.files,
#replayBoard coords.files {
  bottom: 2px;
  left: 4px;
  width: calc(100% - 8px);
  height: 12px;
}

#playBoard coords.ranks,
#playBoard coords.ranks.left,
#replayBoard coords.ranks,
#replayBoard coords.ranks.left {
  top: 0;
  left: 3px;
  width: 10px;
  height: 100%;
  align-items: flex-start;
}

#playBoard coords .coord-light,
#replayBoard coords .coord-light {
  color: var(--board-light-ink);
}

#playBoard coords .coord-dark,
#replayBoard coords .coord-dark {
  color: var(--board-dark-ink);
}

.game-status {
  width: min(320px, 100%);
  min-height: 36px;
  margin: 0;
  padding: 1px 2px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  justify-self: start;
}

.status-copy {
  min-width: 0;
}

.status-copy strong,
.status-copy span {
  display: block;
}

.status-copy strong {
  font-size: 14px;
}

.status-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-copy span:empty {
  display: none;
}

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  animation: thinking 1.1s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) {
  animation-delay: .13s;
}

.thinking-dots i:nth-child(3) {
  animation-delay: .26s;
}

@keyframes thinking {
  0%,
  70%,
  100% {
    opacity: .25;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.ability-control {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  display: grid;
  grid-template-columns: auto 1fr auto;
  justify-items: start;
  text-align: left;
}

.ability-control::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 6px;
  border: 2px solid var(--ability);
  border-radius: 4px;
  background: var(--ability);
  opacity: 0;
  transform: scale(.35);
  transform-origin: center;
  transition: transform 180ms ease, opacity 120ms ease;
}

.ability-control:hover {
  border-color: var(--ability);
  background: var(--ability-soft);
}

.ability-control[aria-pressed="true"] {
  border-color: var(--ability);
  background: var(--panel);
  color: var(--white);
}

.ability-control[aria-pressed="true"]::before {
  opacity: 1;
  transform: scale(1);
  box-shadow: 0 0 14px color-mix(in srgb, var(--ability) 70%, transparent);
}

.ability-control svg {
  width: 20px;
  height: 20px;
}

.ability-control small {
  opacity: .72;
  font-weight: 650;
}

.game-console {
  display: grid;
  gap: 8px;
}

.ability-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.ability-panel .ability-control {
  border-color: transparent;
}

.side-stack {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 0;
  max-height: min(470px, 100%);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  overflow-y: auto;
}

.game-section {
  min-width: 0;
}

.side-stack > .game-actions,
.side-stack > .result-card {
  border-top: 1px solid var(--line);
}

.play-replay-controls {
  display: grid;
  grid-template-columns: 34px 34px minmax(56px, 1fr) 34px 34px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-top: 1px solid var(--line);
  padding: 6px;
}

.play-replay-controls .icon-button {
  width: 34px;
  min-width: 34px;
  height: 30px;
}

.play-replay-controls .replay-counter {
  text-align: center;
}

.move-token.current {
  background: var(--soft);
  outline: 2px solid var(--ability);
  outline-offset: -1px;
}

#resignButton {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

#resignButton > * {
  position: relative;
  z-index: 1;
}

#resignButton.is-confirming::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  background: color-mix(in srgb, var(--danger) 26%, transparent);
  transform-origin: left center;
  animation: resign-window 3s linear forwards;
}

@keyframes resign-window {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.move-record {
  max-height: min(330px, 38vh);
  overflow: auto;
  border: 0;
  background: transparent;
}

.move-record ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.move-table-head,
.move-pair {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  column-gap: 6px;
}

.move-table-head {
  position: sticky;
  z-index: 2;
  top: 0;
  min-height: 28px;
  border-bottom: 1px solid var(--line);
  padding: 7px 6px 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.move-pair {
  min-height: 30px;
  border-bottom: 1px solid var(--line);
  padding: 3px 6px;
}

.move-pair:last-child {
  border-bottom: 0;
}

.move-pair.empty .move-cell {
  grid-column: 2 / -1;
  color: var(--muted);
}

.move-index {
  padding-top: 4px;
  color: var(--muted);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.move-cell {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 3px;
}

.move-token {
  min-height: 22px;
  border: 0;
  border-radius: 4px;
  padding: 2px 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: transparent;
  color: var(--ink);
  font: 500 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: left;
}

button.move-token {
  width: auto;
  height: auto;
  cursor: pointer;
}

button.move-token:hover,
button.move-token.current {
  background: var(--soft);
}

button.move-token.current {
  outline: 2px solid var(--ability);
  outline-offset: -1px;
}

.move-token strong {
  font: inherit;
  font-weight: 750;
}

.move-token.is-double {
  color: var(--ability);
}

.game-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 2px;
  margin-top: 0;
  padding: 5px;
}

.game-actions button {
  min-width: 0;
  min-height: 34px;
  border-color: transparent;
  padding: 0 7px;
  gap: 5px;
  font-size: 11px;
}

.result-card {
  border: 0;
  border-radius: 0;
  padding: 14px;
  box-shadow: none;
}

.result-mark {
  margin: 0;
  font: 850 clamp(32px, 5vw, 50px)/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -.08em;
}

.result-card h2 {
  margin: 12px 0 4px;
}

.result-card p {
  margin: 0;
  color: var(--muted);
}

.result-card .completion-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 14px;
}

.result-card .completion-actions .button:first-child {
  grid-column: 1 / -1;
}

body.active-game .site-header,
body.active-game .header-inner {
  min-height: 54px;
}

body.active-game .site-footer {
  display: none;
}

dialog {
  width: min(520px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .28);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .52);
}

.dialog-body {
  padding: 22px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 22px;
}

.dialog-head button {
  flex: 0 0 auto;
}

.rule-list {
  margin: 22px 0 0;
  padding-left: 20px;
}

.rule-list li + li {
  margin-top: 12px;
}

.rule-list strong {
  display: block;
}

.rule-list span {
  color: var(--muted);
  font-size: 14px;
}

.promotion-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 20px;
}

.promotion-grid button {
  min-height: 58px;
  font-size: 17px;
  text-transform: uppercase;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.rules-page {
  max-width: 1160px;
}

.rules-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 760px);
  justify-content: center;
  align-items: start;
  gap: 18px;
}

.rules-index {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 2px;
  padding: 10px;
}

.rules-index a {
  border-radius: 5px;
  padding: 8px 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rules-index a:hover {
  background: var(--soft);
  color: var(--ink);
}

.rules-document {
  padding: clamp(20px, 4vw, 42px);
}

.rules-document section {
  scroll-margin-top: 88px;
}

.rules-document section + section {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 30px;
}

.rules-document h2 {
  margin: 2px 0 12px;
  font-size: clamp(22px, 3vw, 30px);
}

.rules-document p,
.rules-document li,
.rule-definitions dd {
  color: var(--muted);
  line-height: 1.65;
}

.rules-document strong {
  color: var(--ink);
}

.rule-kicker {
  margin: 0 !important;
  color: var(--ability) !important;
  font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
}

.rule-definitions {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
}

.rule-definitions > div {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr);
  gap: 14px;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.rule-definitions dt {
  font-weight: 800;
}

.rule-definitions dd {
  margin: 0;
}

.fen-table {
  display: grid;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.fen-table > div {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 12px;
}

.fen-table > div + div {
  border-top: 1px solid var(--line);
}

.fen-table code {
  color: var(--ability);
  font-weight: 800;
}

.archive-card {
  min-height: 176px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 17px;
  background: var(--panel);
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}

.archive-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.archive-result {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.archive-result strong {
  font: 800 22px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.archive-players {
  align-self: center;
  margin: 18px 0;
}

.archive-player {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 720;
}

.archive-player:last-child {
  border-bottom: 0;
}

.archive-meta,
.detail-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  font-size: 12px;
}

.empty-state {
  min-height: 250px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  padding: 32px;
  display: grid;
  place-content: center;
  text-align: center;
}

.empty-state h2 {
  margin: 0;
}

.empty-state p {
  max-width: 430px;
  margin: 8px auto 20px;
  color: var(--muted);
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(430px, 720px) minmax(300px, 390px);
  align-items: start;
  gap: 18px;
}

.replay-panel {
  padding: 12px;
}

.replay-controls {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  gap: 7px;
  align-items: center;
  margin-top: 12px;
}

.replay-counter {
  color: var(--muted);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.detail-result {
  margin: 0 0 6px;
  font: 850 38px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -.06em;
}

.detail-title {
  margin: 0 0 14px;
  font-size: 20px;
}

.detail-players {
  margin: 18px 0;
}

.detail-player {
  min-height: 47px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-player:last-child {
  border-bottom: 1px solid var(--line);
}

.detail-player span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.loading {
  min-height: 260px;
  display: grid;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.spinner {
  width: 24px;
  height: 24px;
  margin: 0 auto 12px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 999px;
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1200px) {
  .game-page {
    width: min(856px, 100%);
  }

  .game-layout {
    --play-board-size: min(820px, calc(100vw - 36px));
    grid-template-columns: minmax(0, var(--play-board-size));
    grid-template-rows: repeat(6, auto);
    justify-content: center;
    gap: 6px;
  }

  .game-layout > .game-column > .board-frame {
    grid-column: 1;
    grid-row: 2;
  }

  .game-layout .player-strip.top {
    grid-column: 1;
    grid-row: 1;
  }

  .game-layout .player-strip.bottom {
    grid-column: 1;
    grid-row: 3;
  }

  .game-layout .game-status {
    grid-column: 1;
    grid-row: 4;
  }

  .game-layout > .game-console {
    grid-column: 1;
    grid-row: 5;
    width: 100%;
    justify-self: stretch;
  }

  .game-layout #gameMessage {
    grid-column: 1;
    grid-row: 6;
  }

  .player-strip,
  .game-status {
    width: 100%;
  }

  .move-record {
    max-height: 250px;
  }
}

@media (max-width: 1000px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .rule-stack {
    min-height: 350px;
    width: min(600px, 100%);
  }

  .setup-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    align-items: start;
  }

  .setup-copy {
    max-width: 700px;
  }

  .detail-layout {
    grid-template-columns: minmax(0, 780px);
  }

  .detail-layout > * {
    grid-column: 1;
  }

  .archive-grid {
    grid-template-columns: 1fr;
  }

  .rules-layout {
    grid-template-columns: 1fr;
  }

  .rules-index {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .site-shell,
  .game-page {
    padding-right: 10px;
    padding-left: 10px;
  }

  .site-header,
  .header-inner {
    min-height: 60px;
  }

  .brand {
    font-size: 15px;
  }

  .brand-mark {
    width: 26px;
    height: 26px;
  }

  .site-nav a {
    padding: 7px 8px;
    font-size: 12px;
  }

  .page-main {
    padding-top: 32px;
    padding-bottom: 45px;
  }

  .hero {
    padding-top: 42px;
  }

  .hero h1 {
    font-size: clamp(42px, 15vw, 68px);
  }

  .rule-card:nth-child(2) {
    margin-left: 26px;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .feature {
    min-height: 135px;
  }

  .footer-inner,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .setup-card,
  .panel {
    padding: 14px;
  }

  .choice-grid.clock-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .advanced-number-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-layout {
    gap: 5px;
  }

  .board-frame {
    padding: 0;
  }

  .player-strip {
    min-height: 48px;
    padding: 5px 9px;
  }

  .clock {
    min-width: 86px;
    font-size: 21px;
  }

  .game-console {
    gap: 7px;
  }

  .move-record {
    max-height: 250px;
  }

  .game-status {
    margin-bottom: 0;
  }

  .archive-grid {
    gap: 8px;
  }

  .rules-index {
    display: none;
  }

  .rules-document {
    padding: 18px;
  }

  .rule-definitions > div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .replay-controls {
    grid-template-columns: repeat(4, auto);
  }

  .replay-counter {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

@media (max-width: 430px) {
  body:not(.active-game) .site-nav a:not([aria-current="page"]):not(:first-of-type) {
    display: none;
  }

  .choice-grid.clock-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .advanced-number-grid {
    grid-template-columns: 1fr;
  }

  .clock {
    min-width: 78px;
    font-size: 19px;
  }

  .player-identity strong {
    font-size: 12px;
  }
}

@media (orientation: landscape) and (max-height: 700px) {
  body.active-game .site-header,
  body.active-game .header-inner {
    min-height: 52px;
  }

  .game-page {
    padding: 8px 10px;
  }

  .game-layout {
    --play-board-size: min(820px, calc(100vh - 78px), calc(100vw - 36px));
    --play-board-size: min(820px, calc(100dvh - 78px), calc(100vw - 36px));
  }

  .game-status {
    min-height: 32px;
  }

  .player-strip {
    min-height: 40px;
  }

  .side-stack .panel {
    padding: 10px;
  }

  .move-record {
    max-height: min(190px, 34vh);
  }
}

@media (orientation: landscape) and (max-height: 700px) and (min-width: 1201px) {
  .game-layout {
    --play-board-size: min(820px, calc(100vh - 78px), calc(100vw - 596px));
    --play-board-size: min(820px, calc(100dvh - 78px), calc(100vw - 596px));
  }

  .side-stack {
    max-height: min(370px, 100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
