:root {
  /*
   * Game UI tokens = site chrome tokens (--fpb-*).
   * One source of truth so room overlay / sidebar / board chrome stay consistent.
   * (globals.css defines --fpb-*; resolved at compute time.)
   */
  --color-bg: var(--fpb-page, #f2ede3);
  --color-fg: var(--fpb-ink, #26221b);
  --color-muted: var(--fpb-muted, #6b6353);
  --color-primary: var(--fpb-accent, #8a5a2b);
  --color-primary-hover: color-mix(in srgb, var(--color-primary) 82%, #000);
  --color-primary-soft: color-mix(in srgb, var(--color-primary) 14%, var(--color-card));
  --color-border: var(--fpb-line, #ded5c4);
  --color-card: var(--fpb-card, #fffdf8);
  --color-header-bg: var(--fpb-chrome, #faf7f0);
  --color-footer-bg: var(--fpb-chrome, #faf7f0);
  --color-subtle: var(--fpb-page, #f2ede3);
  --color-on-primary: var(--fpb-accent-ink, #fffdf8);
  /* Status tokens — warm parlor family (not Tailwind green/amber/red) */
  --color-success: #3f6b45;
  --color-success-soft: color-mix(in srgb, var(--color-success) 14%, var(--color-card));
  --color-warning: #9a6b24;
  --color-warning-soft: color-mix(in srgb, var(--color-warning) 16%, var(--color-card));
  --color-danger: #a34432;
  --color-danger-hover: #873628;
  --color-danger-soft: color-mix(in srgb, var(--color-danger) 12%, var(--color-card));
  --shadow-card: 0 4px 16px rgba(38, 34, 27, 0.06);

  --font-fallback: var(--font-fpb-body), system-ui, -apple-system, sans-serif;
  --font-sans: var(--font-fallback);
  --font-display: var(--font-fpb-display), Georgia, serif;

  --radius-card: 16px;
  --radius-input: 12px;
  --header-height: 64px;
  --footer-height: 56px;
  --content-max: 1200px;

  --fpb-board-chrome: 18rem;
  /* svh instead of dvh: dvh changes as the mobile address bar hides/shows,
     which made in-page boards resize while scrolling. Fullscreen overlays
     are unaffected by page scroll and keep using dvh. */
  --fpb-board-max-h: calc(100svh - var(--header-height) - var(--fpb-board-chrome));
}

/* Chrome mobile would otherwise wash the whole board blue on every tap. */
canvas[class*="-board-canvas"],
.fpb-army-chess-canvas {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 1023px) {
  :root {
    /* Mobile: reserve less vertical space for chrome so the board can use
       the full screen width (was 22rem, which shrank boards to ~240px). */
    --fpb-board-chrome: 10rem;
  }
}

@media (max-width: 1023px) and (max-height: 700px) {
  :root {
    --fpb-board-chrome: 12rem;
  }
}

@media (min-width: 1024px) {
  :root {
    --fpb-board-chrome: 16rem;
  }
}

@media (min-width: 1024px) and (min-height: 820px) {
  :root {
    --fpb-board-chrome: 13rem;
  }
}

@media (min-width: 1024px) and (min-height: 900px) {
  :root {
    --fpb-board-chrome: 11rem;
  }
}

@media (min-width: 1024px) and (min-height: 1080px) {
  :root {
    --fpb-board-chrome: 9rem;
  }
}

[data-fpb-mode="dark"] {
  /* --color-bg/fg/primary… already alias --fpb-* (inherited); only retune status + hover */
  --color-primary-hover: color-mix(in srgb, var(--color-primary) 78%, #fff);
  --color-primary-soft: color-mix(in srgb, var(--color-primary) 18%, var(--color-card));
  --color-success: #7cb083;
  --color-success-soft: color-mix(in srgb, var(--color-success) 18%, var(--color-card));
  --color-warning: #d4a24a;
  --color-warning-soft: color-mix(in srgb, var(--color-warning) 18%, var(--color-card));
  --color-danger: #d47862;
  --color-danger-hover: #e09280;
  --color-danger-soft: color-mix(in srgb, var(--color-danger) 16%, var(--color-card));
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* —— Shared CTAs: room overlay + sidebar must use the same classes —— */
.fpb-ui-btn-primary {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 0.75rem;
  background: var(--color-primary);
  color: var(--color-on-primary);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  transition: background-color 0.15s ease;
}
.fpb-ui-btn-primary:hover {
  background: var(--color-primary-hover);
}
.fpb-ui-btn-secondary {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: var(--color-bg);
  color: var(--color-fg);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.fpb-ui-btn-secondary:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.fpb-ui-btn-danger {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: transparent;
  color: var(--color-danger);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.fpb-ui-btn-danger:hover {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
}
.fpb-ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}
.fpb-ui-badge--ok {
  background: var(--color-success-soft);
  color: var(--color-success);
}
.fpb-ui-badge--warn {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

@theme inline {
  --color-bg: var(--color-bg);
  --color-fg: var(--color-fg);
  --color-muted: var(--color-muted);
  --color-primary: var(--color-primary);
  --color-primary-hover: var(--color-primary-hover);
  --color-primary-soft: var(--color-primary-soft);
  --color-border: var(--color-border);
  --color-card: var(--color-card);
  --color-subtle: var(--color-subtle);
  --color-success: var(--color-success);
  --color-success-soft: var(--color-success-soft);
  --color-warning: var(--color-warning);
  --color-warning-soft: var(--color-warning-soft);
  --color-danger: var(--color-danger);
  --color-danger-hover: var(--color-danger-hover);
  --color-danger-soft: var(--color-danger-soft);
  --color-on-primary: var(--color-on-primary);
  --font-sans: var(--font-sans);
  --font-display: var(--font-display);
  --radius-card: 16px;
  --radius-input: 12px;
}

* {
  border-color: var(--color-border);
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans), var(--font-fallback);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  width: 100%;
}

.text-hero {
  font-size: 36px;
  line-height: 1.2;
  font-weight: 700;
}
@media (max-width: 640px) {
  .text-hero {
    font-size: 30px;
  }
}
.text-section {
  font-size: 24px;
  line-height: 1.3;
  font-weight: 700;
}
.text-card-title {
  font-size: 16px;
  line-height: 1.4;
  font-weight: 600;
}
.text-body {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}
.text-ui {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 500;
}
.text-logo {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
}

@layer base {
  a {
    color: inherit;
    text-decoration: none;
  }
  h1,
  h2,
  h3,
  h4 {
    font-family: var(--font-display), var(--font-fallback);
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  button:not(:disabled),
  [role="button"]:not(:disabled),
  a[href],
  label[for],
  summary,
  select:not(:disabled),
  [onclick] {
    cursor: pointer;
  }
  button:disabled,
  [role="button"][aria-disabled="true"],
  :disabled {
    cursor: default;
  }
}

.font-display {
  font-family: var(--font-display), var(--font-fallback);
}

.card-cover {
  transition: transform 0.3s ease;
}
.group:hover .card-cover {
  transform: scale(1.05) translateY(-2px);
}

.fpb-acc-icon {
  transition: transform 0.2s ease;
}
details[open] .fpb-acc-icon {
  transform: rotate(180deg);
}
details > summary::-webkit-details-marker {
  display: none;
}

.tag-board {
  background: #dcfce7;
  color: #166534;
}
[data-fpb-mode="dark"] .tag-board {
  background: #064e3b;
  color: #86efac;
}
.tag-puzzle {
  background: #dbeafe;
  color: #1e40af;
}
[data-fpb-mode="dark"] .tag-puzzle {
  background: #1e3a8a;
  color: #93c5fd;
}
.tag-arcade {
  background: #ccfbf1;
  color: #0f766e;
}
[data-fpb-mode="dark"] .tag-arcade {
  background: #134e4a;
  color: #5eead4;
}
.tag-word {
  background: #f3e8ff;
  color: #7e22ce;
}
[data-fpb-mode="dark"] .tag-word {
  background: #3b0764;
  color: #d8b4fe;
}
.tag-card {
  background: #fef9c3;
  color: #a16207;
}
[data-fpb-mode="dark"] .tag-card {
  background: #713f12;
  color: #fde047;
}

*:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px var(--color-primary);
  border-radius: 8px;
}

::selection {
  background: var(--color-primary);
  color: #ffffff;
}

/* RTL（阿拉伯语）：文字方向右→左，但站点框架/游戏区布局与 LTR 保持一致 */
[dir="rtl"] .fpb-layout-ltr,
[dir="rtl"] #fpb-game-board,
[dir="rtl"] .fpb-game-layout {
  direction: ltr;
}

/* 英文回退 SEO 正文：避免 RTL 导致标点、换行错位 */
[dir="rtl"] .fpb-content-ltr {
  direction: ltr;
  text-align: left;
}

[dir="rtl"] .fpb-content-ltr ul {
  padding-inline-start: 1.25rem;
  padding-inline-end: 0;
}

/* LTR 框架内的阿拉伯语 UI（分享按钮、TOC 标题等） */
[dir="rtl"] .fpb-ui-rtl {
  direction: rtl;
  text-align: right;
}

.container-site {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding-inline: 16px;
}
@media (min-width: 768px) {
  .container-site {
    padding-inline: 24px;
  }
}
@media (min-width: 1024px) {
  .container-site {
    padding-inline: 32px;
  }
}
@media (min-width: 1536px) {
  .container-site {
    max-width: 1440px;
  }
}

.theme-icon-dark {
  display: none;
}
[data-fpb-mode="dark"] .theme-icon-light {
  display: none;
}
[data-fpb-mode="dark"] .theme-icon-dark {
  display: block;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.fpb-hscroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.fpb-thin-scroll {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-border) 85%, transparent) transparent;
}
.fpb-thin-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.fpb-thin-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.fpb-thin-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--color-border) 85%, transparent);
  border-radius: 999px;
}
.fpb-thin-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--color-muted);
}

@keyframes fpb-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}
.animate-soft-pulse {
  animation: fpb-pulse 1.6s ease-in-out infinite;
}

/* Hint controls: stay visually steady even when the turn lock disables them. */
.fpb-hint-btn {
  animation: none !important;
}
.fpb-hint-btn:disabled,
.fpb-hint-btn[disabled],
.fpb-hint-btn[aria-disabled="true"] {
  opacity: 1 !important;
  cursor: not-allowed;
}

@keyframes fpb-fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.animate-fade-up {
  animation: fpb-fade-up 0.3s ease-out;
}

/* 非全屏棋盘画布区边距（与国际象棋 p-4 / md:p-8 一致） */
.fpb-board-well {
  min-height: 0;
  padding: 1rem;
}
@media (min-width: 768px) {
  .fpb-board-well {
    padding: 2rem;
  }
}

.fpb-gomoku-board {
  border: 4px solid #c89b5f;
  border-radius: 4px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #e2b77b;
}
.fpb-gomoku-board-host {
  position: absolute;
  inset: 0;
}
.fpb-gomoku-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-gomoku-board-canvas.is-disabled {
  cursor: default;
}
.fpb-stone {
  border-radius: 9999px;
  display: block;
}
.fpb-stone-black {
  background: radial-gradient(circle at 35% 25%, #666 0%, #222 40%, #050505 100%);
  box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.15),
    2px 5px 8px rgba(0, 0, 0, 0.6);
}
.fpb-stone-white {
  background: radial-gradient(
    circle at 35% 25%,
    #ffffff 0%,
    #f0f0f0 40%,
    #d4d4d4 100%
  );
  box-shadow: inset -2px -2px 5px rgba(0, 0, 0, 0.1), 2px 5px 8px rgba(0, 0, 0, 0.4);
}

.fpb-star {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 9999px;
}

.fpb-c6-board {
  border: 4px solid #c89b5f;
  border-radius: 4px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #e2b77b;
}
.fpb-c6-board-host {
  position: absolute;
  inset: 0;
}
.fpb-c6-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-c6-board-canvas.is-disabled {
  cursor: default;
}

.fpb-fs-board {
  width: min(96vw, calc(100dvh - 148px - env(safe-area-inset-top, 0px)));
  height: min(96vw, calc(100dvh - 148px - env(safe-area-inset-top, 0px)));
}

.fpb-fs-status {
  width: min(96vw, calc(100dvh - 148px - env(safe-area-inset-top, 0px)));
  max-width: 100%;
}

@media (min-width: 640px) {
  .fpb-fs-board {
    width: min(85vw, calc(100dvh - 200px));
    height: min(85vw, calc(100dvh - 200px));
  }

  .fpb-fs-status {
    width: min(85vw, calc(100dvh - 200px));
  }
}

:root {
  --fpb-square-board-cap: 32rem;
  --fpb-square-board-cap-md: 36rem;
  --fpb-square-board-cap-lg: 42rem;
  /* Landscape boards share this inset so none sit flush on the play well. */
  --fpb-wide-board-gutter: 1rem;
}
@media (min-width: 1024px) {
  :root {
    --fpb-square-board-cap: 36rem;
    --fpb-square-board-cap-md: 40rem;
    --fpb-square-board-cap-lg: 44rem;
    --fpb-wide-board-gutter: 3rem;
  }
}
@media (min-width: 1024px) and (min-height: 900px) {
  :root {
    --fpb-square-board-cap: 40rem;
    --fpb-square-board-cap-md: 44rem;
    --fpb-square-board-cap-lg: 48rem;
  }
}
@media (min-width: 1024px) and (min-height: 1080px) {
  :root {
    --fpb-square-board-cap: 44rem;
    --fpb-square-board-cap-md: 48rem;
    --fpb-square-board-cap-lg: 52rem;
  }
}
.fpb-square-board-normal {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap)
  );
}
.fpb-square-board-normal--md {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-md)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-md)
  );
}
.fpb-square-board-normal--lg {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
}
body.fpb-scroll-lock {
  overflow: hidden;
}

/* Ludo classic canvas — square parent (width + aspect-ratio 1/1; host absolute inset) */
.fpb-ld-board {
  position: relative;
  container-type: inline-size;
  container-name: ludo-board;
  border: 4px solid #cbb38c;
  border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #f4ede1;
}
.fpb-ld-board-host {
  position: absolute;
  inset: 0;
}
.fpb-ld-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-ld-board-canvas.is-disabled {
  cursor: default;
}
/* Legacy class kept for die overlay / roll animation helpers */
.fpb-ludo-board {
  container-type: inline-size;
  container-name: ludo-board;
  background-color: #f4ede1;
  border: 4px solid #cbb38c;
  border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
/* Center die slot/face — square by construction (width-only % + aspect-ratio). */
.fpb-ludo-center-slot {
  container-type: size;
  aspect-ratio: 1 / 1;
  height: auto;
}
.fpb-ludo-center-die {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: min(72cqw, 72cqh);
  height: min(72cqw, 72cqh);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
  align-self: center;
  min-height: 0;
  padding: 9%;
  border-radius: 18%;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.15s ease;
}
.fpb-ludo-center-die--ready {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: fpb-ludo-die-ready 1.1s ease-in-out infinite;
}
.fpb-ludo-center-die--ready:hover {
  transform: scale(1.05);
}
.fpb-ludo-center-die--ready:active {
  transform: scale(0.95);
}
.fpb-ludo-center-die--idle {
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1), 0 6px 18px rgba(0, 0, 0, 0.35);
}
.fpb-ludo-die-face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
}
.fpb-ludo-die-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}
.fpb-ludo-die-pip {
  width: 58%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 9999px;
  background: #1f2937;
}
@keyframes fpb-ludo-die-ready {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
.fpb-match-stage {
  container-type: inline-size;
  container-name: match-stage;
}
/*
 * Fit the board-well box (width AND height). Using stage cqw alone made the
 * square taller than the well → top clipped under the toolbar, bottom gap.
 */
.fpb-ld-normal,
.fpb-ludo-normal {
  width: min(100%, var(--fpb-square-board-cap-md));
  max-width: 100%;
  max-height: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  margin-inline: auto;
}
.fpb-app--focus .fpb-board-well {
  container-type: size;
  container-name: board-well;
  /*
   * Floor the fit token: on the first flex pass 100cqh can be 0 (before the
   * well has a definite block size). A 0/--negative fit collapses absolute
   * canvas hosts (xiangqi etc.) and trips "board host never got a usable size".
   */
  --fpb-board-fit-v: max(12rem, calc(100cqh - 2.5rem));
  padding: 0;
  box-shadow: none !important;
  /* Kill Tailwind min-h-[350px]/md:min-h-[500px] that fight flex shrink. */
  min-height: 0 !important;
}
.fpb-app--focus .fpb-match-active > .fpb-match-card,
.fpb-app--focus .fpb-match-active > .flex-1 {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.fpb-app--focus .fpb-match-stage,
.fpb-app--focus .fpb-chess-stage,
.fpb-app--focus .fpb-xq-stage,
.fpb-app--focus .fpb-board-well {
  background: transparent !important;
}

/*
 * Focus match: largest board that fits the well (no viewport / rem caps).
 * Direct child only — shogi wraps board+hands in .fpb-sg-stack.
 * !important beats Tailwind `w-full` / `max-w-[…]` on board nodes.
 */
.fpb-app--focus .fpb-board-well > .fpb-square-board-normal,
.fpb-app--focus .fpb-board-well > .fpb-square-board-normal--md,
.fpb-app--focus .fpb-board-well > .fpb-square-board-normal--lg,
.fpb-app--focus .fpb-board-well > .fpb-chess-normal,
.fpb-app--focus .fpb-board-well > .fpb-ld-normal,
.fpb-app--focus .fpb-board-well > .fpb-ludo-normal,
.fpb-app--focus .fpb-board-well > .fpb-dnb-normal {
  width: min(100cqw, var(--fpb-board-fit-v)) !important;
  height: min(100cqw, var(--fpb-board-fit-v)) !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  aspect-ratio: 1 / 1;
  margin-inline: auto;
}
.fpb-app--focus .fpb-board-well > .fpb-go-board,
.fpb-app--focus .fpb-board-well > .fpb-gomoku-board,
.fpb-app--focus .fpb-board-well > .fpb-c6-board {
  width: min(100cqw, var(--fpb-board-fit-v)) !important;
  height: min(100cqw, var(--fpb-board-fit-v)) !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
}

/* Shogi: left/right hands + center board fills the well */
.fpb-app--focus .fpb-board-well > .fpb-sg-stack {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 0.45rem;
  height: 100%;
  max-height: var(--fpb-board-fit-v);
  width: min(100cqw, calc(var(--fpb-board-fit-v) + 7.5rem));
  max-width: 100%;
  margin-inline: auto;
}
.fpb-app--focus .fpb-sg-stack .fpb-sg-board-col {
  flex: 1 1 0;
  min-width: 0;
  max-height: var(--fpb-board-fit-v);
}
.fpb-app--focus .fpb-sg-stack .fpb-square-board-normal {
  width: min(100%, var(--fpb-board-fit-v)) !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  aspect-ratio: 1 / 1;
}

/* Xiangqi 9:10 */
.fpb-app--focus .fpb-board-well > .fpb-xq-normal {
  width: min(100cqw, calc(var(--fpb-board-fit-v) * 9 / 10)) !important;
  height: min(var(--fpb-board-fit-v), calc(100cqw * 10 / 9)) !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}

/* Four in a Row 7:6 — fill the play well, same landscape gutter as other wide boards. */
.fpb-app--focus .fpb-board-well > .fpb-fiar-board {
  width: min(calc(100cqw - var(--fpb-wide-board-gutter)), calc(var(--fpb-board-fit-v) * 7 / 6)) !important;
  height: min(var(--fpb-board-fit-v), calc((100cqw - var(--fpb-wide-board-gutter)) * 6 / 7)) !important;
  max-width: calc(100% - var(--fpb-wide-board-gutter)) !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
  aspect-ratio: 7 / 6;
}

/* Jungle / Army Chess tall boards */
.fpb-app--focus .fpb-board-well > .fpb-aq-normal {
  width: min(100cqw, calc(var(--fpb-board-fit-v) * 7 / 9)) !important;
  height: min(var(--fpb-board-fit-v), calc(100cqw * 9 / 7)) !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}
.fpb-app--focus .fpb-board-well > .fpb-army-chess-normal {
  width: min(100cqw, calc(var(--fpb-board-fit-v) * 9 / 12.8)) !important;
  height: min(var(--fpb-board-fit-v), calc(100cqw * 12.8 / 9)) !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}

/* Backgammon ~1.18:1 */
.fpb-app--focus .fpb-board-well > .fpb-bg-board {
  width: min(calc(100cqw - var(--fpb-wide-board-gutter)), calc(var(--fpb-board-fit-v) * 1.18)) !important;
  height: min(var(--fpb-board-fit-v), calc((100cqw - var(--fpb-wide-board-gutter)) / 1.18)) !important;
  max-width: calc(100% - var(--fpb-wide-board-gutter)) !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}

/* Mancala: wide tray — same landscape gutter, cap by height */
.fpb-app--focus .fpb-board-well > .fpb-mc-board,
.fpb-app--focus .fpb-board-well > .fpb-mancala-normal {
  width: min(calc(100cqw - var(--fpb-wide-board-gutter)), calc(var(--fpb-board-fit-v) * 2.35)) !important;
  height: min(var(--fpb-board-fit-v), calc((100cqw - var(--fpb-wide-board-gutter)) / 2.35)) !important;
  max-width: calc(100% - var(--fpb-wide-board-gutter)) !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}

/* Banqi 4×8 = 2:1 */
.fpb-app--focus .fpb-board-well > .fpb-bq-normal,
.fpb-app--focus .fpb-online-board-stack > .fpb-bq-normal {
  width: min(calc(100cqw - var(--fpb-wide-board-gutter)), calc(var(--fpb-board-fit-v) * 2)) !important;
  height: min(var(--fpb-board-fit-v), calc((100cqw - var(--fpb-wide-board-gutter)) * 1 / 2)) !important;
  max-width: calc(100% - var(--fpb-wide-board-gutter)) !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}

/* Royal Game of Ur ~2:1 board + dice tray under (fill play well like other boards) */
.fpb-ur-board-wrap {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.25rem 0;
}
.fpb-ur-board {
  display: block;
  /* viewBox ~624×336 → ~1.86:1 */
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h, 100svh) * 1.86),
    calc((100svh - var(--header-height) - 12rem) * 1.86)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  height: auto;
  max-height: min(
    var(--fpb-board-max-h, 70vh),
    calc(100svh - var(--header-height) - 12rem)
  );
  aspect-ratio: 624 / 336;
}
.fpb-ur-dice {
  width: min(calc(100% - var(--fpb-wide-board-gutter)), 36rem);
}
.fpb-app--focus .fpb-board-well > .fpb-ur-board-wrap {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}
.fpb-app--focus .fpb-ur-board-wrap .fpb-ur-board {
  /* Reserve ~6.75rem for dice tray + gaps inside the well */
  width: min(
    calc(100cqw - var(--fpb-wide-board-gutter)),
    calc((var(--fpb-board-fit-v) - 6.75rem) * 1.86)
  ) !important;
  max-width: calc(100% - var(--fpb-wide-board-gutter)) !important;
  max-height: calc(var(--fpb-board-fit-v) - 6.75rem) !important;
  height: auto !important;
  aspect-ratio: 624 / 336;
}
.fpb-ur-board-wrap--fs {
  width: min(96vw, 72rem);
  max-height: calc(100dvh - 10rem - env(safe-area-inset-top, 0px));
}
.fpb-ur-board-wrap--fs .fpb-ur-board,
.fpb-ur-board-fs {
  width: min(96vw, calc((100dvh - 14rem) * 1.86), 1100px);
  max-width: 100%;
  max-height: calc(100dvh - 14rem - env(safe-area-inset-top, 0px));
  height: auto;
  aspect-ratio: 624 / 336;
}

/* Senet 10×3 board + stick tray (viewBox 592×248) */
.fpb-senet-board-wrap {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.25rem 0;
}
.fpb-senet-board {
  display: block;
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h, 100svh) * 2.39),
    calc((100svh - var(--header-height) - 12rem) * 2.39)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  height: auto;
  max-height: min(
    var(--fpb-board-max-h, 70vh),
    calc(100svh - var(--header-height) - 12rem)
  );
  aspect-ratio: 592 / 248;
}
.fpb-senet-dice {
  width: min(calc(100% - var(--fpb-wide-board-gutter)), 36rem);
}
.fpb-app--focus .fpb-board-well > .fpb-senet-board-wrap {
  flex: 1 1 auto;
  align-self: stretch;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: var(--fpb-board-fit-v) !important;
  margin-inline: auto;
}
.fpb-app--focus .fpb-senet-board-wrap .fpb-senet-board {
  width: min(
    calc(100cqw - var(--fpb-wide-board-gutter)),
    calc((var(--fpb-board-fit-v) - 6.75rem) * 2.39)
  ) !important;
  max-width: calc(100% - var(--fpb-wide-board-gutter)) !important;
  max-height: calc(var(--fpb-board-fit-v) - 6.75rem) !important;
  height: auto !important;
  aspect-ratio: 592 / 248;
}
.fpb-senet-board-wrap--fs {
  width: min(96vw, 72rem);
  max-height: calc(100dvh - 10rem - env(safe-area-inset-top, 0px));
}
.fpb-senet-board-wrap--fs .fpb-senet-board,
.fpb-senet-board-fs {
  width: min(96vw, calc((100dvh - 14rem) * 2.39), 1100px);
  max-width: 100%;
  max-height: calc(100dvh - 14rem - env(safe-area-inset-top, 0px));
  height: auto;
  aspect-ratio: 592 / 248;
}
.fpb-ludo-token {
  border-width: 2px;
  border-style: solid;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}
.fpb-ludo-pick {
  animation: fpb-ludo-pick 1s ease-in-out infinite;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 2px 6px rgba(0, 0, 0, 0.4);
}
@keyframes fpb-ludo-pick {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.18);
  }
}
.fpb-ludo-rolling {
  animation: fpb-ludo-roll 0.45s ease-in-out infinite;
}
@keyframes fpb-ludo-roll {
  0% {
    transform: rotate(-12deg) scale(0.96);
  }
  50% {
    transform: rotate(12deg) scale(1.04);
  }
  100% {
    transform: rotate(-12deg) scale(0.96);
  }
}

.fpb-aq-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 7 / 9;
  background: #e9d9b0;
  border: 4px solid #9c7b45;
  border-radius: 6px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #e9d9b0;
}
.fpb-aq-board-host {
  position: absolute;
  inset: 0;
}
.fpb-aq-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-aq-board-canvas.is-disabled {
  cursor: default;
}
.fpb-aq-stage {
  container-type: inline-size;
  container-name: aq-stage;
}
/* 非全屏：高度驱动 + 容器宽度约束（对齐象棋/军棋 tall-board 方案） */
.fpb-aq-normal {
  --fpb-aq-board-max-h: min(
    calc(var(--fpb-board-max-h) + 2rem),
    calc(100svh - var(--header-height) - 6.5rem)
  );
  height: min(var(--fpb-aq-board-max-h), calc(100cqw * 9 / 7));
  max-height: var(--fpb-aq-board-max-h);
  width: auto;
  max-width: min(460px, 100%);
  margin-inline: auto;
}
@media (max-width: 1023px) {
  .fpb-aq-normal {
    /* 移动端固定底栏 (~3.5rem) 额外扣除，避免最底行棋子被遮挡 */
    --fpb-aq-board-max-h: min(
      calc(var(--fpb-board-max-h) - 1rem),
      calc(100svh - var(--header-height) - var(--fpb-board-chrome) - 3.5rem)
    );
  }
}
.fpb-aq-fs {
  --fpb-aq-fs-max-h: calc(
    100dvh - 148px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
  );
  height: min(var(--fpb-aq-fs-max-h), calc((100vw - 2rem) * 9 / 7));
  max-height: var(--fpb-aq-fs-max-h);
  max-width: min(calc(100vw - 2rem), calc(var(--fpb-aq-fs-max-h) * 7 / 9));
  width: auto;
}
@media (min-width: 640px) {
  .fpb-aq-fs {
    --fpb-aq-fs-max-h: calc(
      100dvh - 200px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
    );
  }
}
.fpb-aq-cell {
  border: 1px solid rgba(120, 90, 45, 0.32);
  background: #efe1c0;
}
.fpb-aq-water {
  background: repeating-linear-gradient(
    45deg,
    #8fc1e8,
    #8fc1e8 6px,
    #9fcaec 6px,
    #9fcaec 12px
  );
}
.fpb-aq-trap {
  background: #e3c98c;
}
.fpb-aq-trap-mark {
  position: absolute;
  font-weight: 800;
  font-size: 7cqw;
  color: rgba(120, 70, 20, 0.5);
  pointer-events: none;
}
.fpb-aq-den {
  background: color-mix(in srgb, var(--den) 26%, #efe1c0);
}
.fpb-aq-den-mark {
  position: absolute;
  font-size: 8cqw;
  opacity: 0.75;
  pointer-events: none;
}
.fpb-aq-piece {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 12cqw;
  height: 12cqw;
  border-radius: 9999px;
  border-width: 0.5cqw;
  border-style: solid;
  box-shadow: 0 0.4cqw 0.8cqw rgba(0, 0, 0, 0.35);
}
.fpb-aq-emoji {
  font-size: 7cqw;
  line-height: 1;
}
.fpb-aq-capture {
  animation: fpb-ck-capture 0.3s ease-in forwards;
}
.fpb-aq-anim {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(100% / 7);
  height: calc(100% / 9);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  will-change: transform;
  animation: fpb-piece-slide 320ms cubic-bezier(0.33, 1.05, 0.42, 1) both;
}
.fpb-aq-piece-sm {
  width: 11cqw;
  height: 11cqw;
}

.fpb-bq-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 2 / 1;
  background: #e9d9b0;
  border: 4px solid #9c7b45;
  border-radius: 6px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  background-color: #e9d9b0;
}
.fpb-bq-board-host {
  position: absolute;
  inset: 0;
}
.fpb-bq-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-bq-board-canvas.is-disabled {
  cursor: default;
}
.fpb-bq-stage {
  container-type: inline-size;
  container-name: bq-stage;
}
.fpb-bq-normal {
  --fpb-bq-board-max-h: min(
    calc(var(--fpb-board-max-h) + 2rem),
    calc(100svh - var(--header-height) - 6.5rem)
  );
  /* Width-first 2:1 — shared landscape gutter. */
  width: min(calc(100% - var(--fpb-wide-board-gutter)), calc(var(--fpb-bq-board-max-h) * 2));
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  height: auto;
  aspect-ratio: 2 / 1;
  max-height: var(--fpb-bq-board-max-h);
  margin-inline: auto;
}
@media (max-width: 1023px) {
  .fpb-bq-normal {
    --fpb-bq-board-max-h: min(
      calc(var(--fpb-board-max-h) - 1rem),
      calc(100svh - var(--header-height) - var(--fpb-board-chrome) - 3.5rem)
    );
  }
}
.fpb-bq-fs {
  --fpb-bq-fs-max-h: calc(
    100dvh - 148px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
  );
  height: min(var(--fpb-bq-fs-max-h), calc((100vw - 2rem) * 1 / 2));
  max-height: var(--fpb-bq-fs-max-h);
  max-width: min(calc(100vw - 2rem), calc(var(--fpb-bq-fs-max-h) * 2));
  width: auto;
}
@media (min-width: 640px) {
  .fpb-bq-fs {
    --fpb-bq-fs-max-h: calc(
      100dvh - 200px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
    );
  }
}
.fpb-bq-cell {
  border: 1px solid rgba(120, 90, 45, 0.32);
  background: #efe1c0;
}
.fpb-bq-hidden {
  width: 72%;
  height: 72%;
  border-radius: 9999px;
  background: radial-gradient(circle at 32% 28%, #d8bf91, #c4a574 55%, #8a6a3c);
  border: 2px solid #8a6a3c;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}
.fpb-bq-piece-img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.fpb-army-chess-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 9 / 12.8;
  border: 4px solid #8b7355;
  border-radius: 8px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  background: #deb887;
}

.fpb-army-chess-stage {
  container-type: inline-size;
  container-name: army-chess-stage;
}

.fpb-army-chess-normal {
  --fpb-army-board-max-h: min(
    calc(var(--fpb-board-max-h) + 2rem),
    calc(100svh - var(--header-height) - 6.5rem)
  );
  height: min(var(--fpb-army-board-max-h), calc(100cqw * 12.8 / 9));
  max-height: var(--fpb-army-board-max-h);
  width: auto;
  max-width: 100%;
  margin-inline: auto;
}
.fpb-army-chess-fs-wrap {
  --fpb-fs-board-gutter: 1.25rem;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding-block: var(--fpb-fs-board-gutter);
  box-sizing: border-box;
  overflow: visible;
}
.fpb-army-chess-fs {
  aspect-ratio: 9 / 12.8;
  flex-shrink: 0;
  width: min(
    100cqw,
    calc((100cqh - var(--fpb-fs-board-gutter, 1.25rem) * 2) * 9 / 12.8),
    calc(100vw - 2rem)
  );
  height: auto;
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 5rem - var(--fpb-fs-board-gutter, 1.25rem) * 2);
}
@supports not (width: 1cqh) {
  .fpb-army-chess-fs {
    height: min(
      calc(100dvh - 5rem - var(--fpb-fs-board-gutter, 1.25rem) * 2),
      calc((100vw - 2rem) * 12.8 / 9)
    );
    width: auto;
  }
}
.fpb-army-chess-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation;
}
.fpb-board-move-log {
  list-style: none;
  margin: 0;
  padding: 0;
}
.fpb-board-move-log li {
  padding: 5px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--color-fg);
  border-bottom: 1px dashed color-mix(in srgb, var(--color-border) 70%, transparent);
  word-break: break-word;
}
.fpb-board-move-log-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.fpb-board-move-log-row-inner {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: flex-start;
  gap: 0.5rem;
}
.fpb-board-move-log-num {
  flex-shrink: 0;
  min-width: 1.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
  font-weight: 600;
}
.fpb-board-move-log-dot {
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.35rem;
  flex-shrink: 0;
  border-radius: 9999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.fpb-board-move-log-side-red {
  color: #c0392b;
  font-weight: 650;
}
.fpb-board-move-log-side-blue {
  color: #1e4a8a;
  font-weight: 650;
}
[data-fpb-mode="dark"] .fpb-board-move-log-side-red {
  color: #f87171;
}
[data-fpb-mode="dark"] .fpb-board-move-log-side-blue {
  color: #7dd3fc;
}
.fpb-board-move-log li:last-child {
  border-bottom: none;
}
.fpb-board-move-log-empty {
  list-style: none;
  border-bottom: none;
}
.fpb-army-chess-log-dot {
  width: 0.5rem;
  height: 0.5rem;
  margin-top: 0.35rem;
  flex-shrink: 0;
  border-radius: 9999px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.fpb-army-chess-log-red {
  color: #c0392b;
  font-weight: 650;
}
.fpb-army-chess-log-blue {
  color: #1e4a8a;
  font-weight: 650;
}
[data-fpb-mode="dark"] .fpb-army-chess-log-red {
  color: #f87171;
}
[data-fpb-mode="dark"] .fpb-army-chess-log-blue {
  color: #7dd3fc;
}

.fpb-go-board {
  border: 5px solid #c8995a;
  border-radius: 4px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #e3b574;
}
.fpb-go-board-host {
  position: absolute;
  inset: 0;
}
.fpb-go-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-go-board-canvas.is-disabled {
  cursor: default;
}
.fpb-go-stone {
  position: relative;
  border-radius: 9999px;
  display: block;
}
.fpb-intersection-overlay {
  z-index: 0;
}
.fpb-intersection-overlay line {
  stroke: rgba(60, 30, 8, 0.58);
  stroke-width: 0.22;
}
.fpb-intersection-overlay text {
  fill: rgba(60, 30, 8, 0.48);
  font-size: 1.65px;
  font-family: var(--fpb-font-body);
  font-weight: 400;
}
.fpb-go-black {
  background: radial-gradient(circle at 34% 26%, #6a6a6a 0%, #232323 42%, #050505 100%);
  box-shadow: inset -2px -2px 5px rgba(255, 255, 255, 0.14), 2px 4px 7px rgba(0, 0, 0, 0.55);
}
.fpb-go-white {
  background: radial-gradient(circle at 34% 26%, #ffffff 0%, #eef0f0 42%, #cfd2d2 100%);
  box-shadow: inset -2px -2px 5px rgba(0, 0, 0, 0.12), 2px 4px 7px rgba(0, 0, 0, 0.38);
}
.fpb-go-star {
  background: rgba(40, 20, 5, 0.8);
  border-radius: 9999px;
}
@keyframes fpb-go-pop {
  0% {
    transform: scale(0.3);
    opacity: 0.5;
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.fpb-go-pop {
  animation: fpb-go-pop 0.22s ease-out;
}
@keyframes fpb-go-capture {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
}
.fpb-go-capture {
  z-index: 5;
  animation: fpb-go-capture 0.42s ease-in forwards;
}

.fpb-sg-frame {
  container-type: inline-size;
  display: grid;
  grid-template-columns: 1fr min-content;
  grid-template-rows: min-content 1fr;
  background: #d4b483;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(93, 64, 55, 0.05) 0,
    rgba(93, 64, 55, 0.05) 1px,
    transparent 1px,
    transparent 9px
  );
  border-radius: 8px;
  padding: 2.6%;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.45);
}

.fpb-sg-fs {
  width: min(86vw, calc(100dvh - 170px));
  max-width: calc(100vw - 1.5rem);
}

.fpb-sg-files {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  align-items: end;
  padding-bottom: 0.25rem;
}
.fpb-sg-files span {
  text-align: center;
  font-size: 2.4cqw;
  font-weight: 600;
  color: rgba(93, 64, 55, 0.65);
}
.fpb-sg-corner {
  grid-column: 2;
  grid-row: 1;
}

.fpb-sg-ranks {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(9, 1fr);
  align-items: center;
  justify-items: center;
  padding-left: 0.25rem;
}
.fpb-sg-ranks span {
  font-size: 2.4cqw;
  font-weight: 600;
  color: rgba(93, 64, 55, 0.65);
}
/* Side komadai: opponent left, player right */
.fpb-sg-stack {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
}
.fpb-sg-stack--fs {
  max-width: min(96vw, calc(100dvh - 120px + 7.5rem));
}
.fpb-sg-board-col {
  /* Must claim row space — otherwise w-full board collapses to 0 in a flex row. */
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fpb-sg-board-col > .fpb-sg-frame {
  width: min(100%, var(--fpb-square-board-cap));
  max-width: 100%;
}
.fpb-sg-hand-col {
  flex: 0 0 auto;
  width: 3.4rem;
  display: flex;
  align-items: stretch;
}
.fpb-sg-hand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  align-self: stretch;
  padding: 0.4rem 0.3rem;
  border-radius: 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  box-sizing: border-box;
}
.fpb-sg-hand-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-muted);
  text-align: center;
  line-height: 1.2;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-border);
  width: 100%;
}
.fpb-sg-hand-pieces {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding-top: 0.15rem;
}
@media (min-width: 640px) {
  .fpb-sg-hand-col {
    width: 3.75rem;
  }
}

/* Shogi mobile: horizontal komadai above/below board (side columns steal ~7.5rem). */
@media (max-width: 899px) {
  .fpb-sg-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    width: 100%;
    max-width: 100%;
  }
  .fpb-sg-hand-col {
    width: 100%;
    flex: 0 0 auto;
  }
  .fpb-sg-hand {
    flex-direction: row;
    align-items: center;
    padding: 0.35rem 0.5rem;
    min-height: 2.75rem;
  }
  .fpb-sg-hand-label {
    border-bottom: none;
    border-right: 1px solid var(--color-border);
    padding-bottom: 0;
    padding-right: 0.5rem;
    width: auto;
    flex-shrink: 0;
  }
  .fpb-sg-hand-pieces {
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    justify-content: flex-start;
    padding-top: 0;
  }
  .fpb-app--focus .fpb-board-well > .fpb-sg-stack {
    flex-direction: column;
    width: min(100cqw, var(--fpb-board-fit-v));
    max-width: 100%;
    max-height: none;
    height: auto;
  }
  .fpb-app--focus .fpb-sg-stack .fpb-square-board-normal {
    width: min(100cqw, var(--fpb-board-fit-v)) !important;
    max-width: 100% !important;
  }
}

.fpb-sg-board {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  background-color: var(--fpb-board-surface);
  border: 1.5px solid var(--fpb-board-line);
  overflow: hidden;
}
.fpb-sg-board-host {
  position: absolute;
  inset: 0;
}
.fpb-sg-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-sg-board-canvas.is-disabled {
  cursor: default;
}
.fpb-sg-cell {
  border-right: 1px solid rgba(93, 64, 55, 0.5);
  border-bottom: 1px solid rgba(93, 64, 55, 0.5);
}

.fpb-sg-zone-top {
  position: absolute;
  inset: 0 0 auto 0;
  height: 33.333%;
  background: rgba(139, 94, 60, 0.1);
  pointer-events: none;
  z-index: 0;
}
.fpb-sg-zone-bottom {
  position: absolute;
  inset: auto 0 0 0;
  height: 33.333%;
  background: rgba(139, 94, 60, 0.05);
  pointer-events: none;
  z-index: 0;
}

.fpb-sg-star {
  position: absolute;
  width: 1.6cqw;
  height: 1.6cqw;
  border-radius: 50%;
  background: #5d4037;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}

.fpb-sg-piece {
  position: relative;
  width: 88%;
  height: 88%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "Kaiti TC", serif;
  font-weight: 700;
  font-size: 6.6cqw;
  line-height: 1;
  user-select: none;
  filter: drop-shadow(0 0.4cqw 0.5cqw rgba(0, 0, 0, 0.28));
  --sg-side: #1e88e5;
  color: var(--sg-side);
}

.fpb-sg-piece::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 1%, 80% 22%, 90% 100%, 10% 100%, 20% 22%);
  background: #8b7355;
  z-index: 0;
}

.fpb-sg-piece::after {
  content: "";
  position: absolute;
  inset: 4%;
  clip-path: polygon(50% 1%, 80% 22%, 90% 100%, 10% 100%, 20% 22%);
  background: linear-gradient(180deg, #f9f3e5 0%, #e6d5b8 100%);
  z-index: 1;
}
.fpb-sg-glyph {
  position: relative;
  z-index: 2;
}

.fpb-sg-bar {
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: 56%;
  height: 4%;
  min-height: 2px;
  border-radius: 2px;
  background: var(--sg-side);
  opacity: 0.85;
  z-index: 2;
}
.fpb-sg-blue {
  --sg-side: #1e88e5;
}
.fpb-sg-red {
  --sg-side: #e53935;
}
.fpb-sg-board .fpb-sg-piece {
  font-size: 7cqw;
}
@keyframes fpb-sg-pop {
  0% {
    transform: scale(0.4);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}
.fpb-sg-piece.fpb-sg-pop {
  animation: fpb-sg-pop 0.2s ease-out;
}

.fpb-sg-hand-piece {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.3rem;
  /* Match ShogiGridBase #31 board glyph stack */
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Hiragino Sans", serif;
  font-weight: 700;
  font-size: 1rem;
  --sg-side: #1e88e5;
  color: var(--sg-side);
}
.fpb-sg-hand-piece::before {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 1%, 80% 22%, 90% 100%, 10% 100%, 20% 22%);
  background: #8b7355;
  z-index: 0;
}
.fpb-sg-hand-piece::after {
  content: "";
  position: absolute;
  inset: 5%;
  clip-path: polygon(50% 1%, 80% 22%, 90% 100%, 10% 100%, 20% 22%);
  background: linear-gradient(180deg, #f9f3e5 0%, #e6d5b8 100%);
  z-index: 1;
}
.fpb-sg-hand-piece .fpb-sg-glyph {
  position: relative;
  z-index: 2;
}

.fpb-chess-board {
  container-type: inline-size;
  border: 1px solid color-mix(in srgb, var(--fpb-board-line) 38%, transparent);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.22);
  /* No start.svg / is-idle — canvas paints directly. */
  --fpb-chess-sq-light: var(--fpb-board-surface);
  --fpb-chess-sq-dark: var(--fpb-board-surface-2);
  background-color: var(--fpb-chess-sq-light);
  background-image: repeating-conic-gradient(
    from 90deg at 50% 50%,
    var(--fpb-chess-sq-dark) 0deg 90deg,
    var(--fpb-chess-sq-light) 90deg 180deg
  );
  background-size: 25% 25%;
}
.fpb-chess-board-host {
  position: absolute;
  inset: 0;
}
.fpb-chess-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-chess-board-canvas.is-disabled {
  cursor: default;
}
@media (max-width: 899px) {
  .fpb-chess-board {
    border-width: 1px;
    border-radius: 4px;
  }
}
.fpb-chess-stage {
  container-type: inline-size;
  container-name: chess-stage;
}
/* 非全屏：高度驱动 + 容器宽度约束（对齐象棋/军棋 tall-board 方案） */
.fpb-chess-normal {
  --fpb-chess-board-max-h: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem)
  );
  height: min(var(--fpb-chess-board-max-h), 100cqw);
  max-height: var(--fpb-chess-board-max-h);
  width: auto;
  max-width: min(100%, var(--fpb-square-board-cap));
  margin-inline: auto;
}
@media (max-width: 1023px) {
  .fpb-chess-normal {
    /* 移动端固定底栏 (~3.5rem) + 卡片内工具栏/内边距 额外扣除，避免最底行棋子被遮挡 */
    --fpb-chess-board-max-h: min(
      calc(var(--fpb-board-max-h) - 1rem),
      calc(
        100svh - var(--header-height) - var(--fpb-board-chrome) - 3.5rem - 3rem
      )
    );
  }
}
.fpb-sq-light {
  background-color: var(--fpb-board-surface);
}
.fpb-sq-dark {
  background-color: var(--fpb-board-surface-2);
}
/* 棋子为 cburnett SVG（public/chess-pieces/，维基百科/lichess 同款经典造型），
   全平台形状、颜色、大小完全一致，不受系统字体影响。 */
.fpb-chess-piece {
  width: 88%;
  height: 88%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
}

@keyframes fpb-piece-slide {
  from {
    transform: translate(var(--fx), var(--fy));
  }
  to {
    transform: translate(var(--tx), var(--ty));
  }
}
.fpb-chess-anim {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  will-change: transform;
  animation: fpb-piece-slide 360ms cubic-bezier(0.33, 1.08, 0.42, 1) both;
}

@keyframes fpb-check-pulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 2px rgba(220, 38, 38, 0.55),
      inset 0 0 14px 4px rgba(220, 38, 38, 0.35);
  }
  50% {
    box-shadow: inset 0 0 0 3px rgba(220, 38, 38, 0.95),
      inset 0 0 24px 9px rgba(220, 38, 38, 0.65);
  }
}
.fpb-check-sq {
  background-color: rgba(239, 68, 68, 0.34);
  animation: fpb-check-pulse 0.85s ease-in-out infinite;
}

@keyframes fpb-check-flash {
  0% {
    opacity: 0;
  }
  16% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
.fpb-check-flash {
  box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.95),
    inset 0 0 46px 12px rgba(239, 68, 68, 0.5);
  animation: fpb-check-flash 0.85s ease-out forwards;
}

@keyframes fpb-check-badge {
  0% {
    transform: translate(-50%, -8px) scale(0.7);
    opacity: 0;
  }
  55% {
    transform: translate(-50%, 0) scale(1.08);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
  }
}
.fpb-check-badge {
  animation: fpb-check-badge 0.4s cubic-bezier(0.34, 1.4, 0.5, 1) both;
}

.fpb-ttt-board {
  container-type: inline-size;
  background-color: #f4f4f5;
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.28);
  /* No start.svg / is-idle — canvas paints directly. */
}
[data-theme="dark"] .fpb-ttt-board {
  background-color: #27272a;
  border-color: rgba(255, 255, 255, 0.1);
}
.fpb-ttt-board-host {
  position: absolute;
  inset: 0;
}
.fpb-ttt-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-ttt-board-canvas.is-disabled {
  cursor: default;
}

.fpb-fiar-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 7 / 6;
  background-color: #f4d1a1;
  border: 2px solid #5d4037;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.22);
  /* No start.svg / is-idle — canvas paints directly. */
}
[data-theme="dark"] .fpb-fiar-board {
  /* Stay shogi-bright even under dark chrome */
  background-color: #f4d1a1;
  border-color: #5d4037;
}
/* Width-driven 7:6 — height comes from aspect-ratio; caps match other boards. */
.fpb-fiar-board-normal {
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h, 100svh) * 7 / 6),
    calc((100svh - var(--header-height) - 6.5rem) * 7 / 6),
    calc(var(--fpb-square-board-cap-md) * 7 / 6)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  height: auto;
}
.fpb-fiar-board-host {
  position: absolute;
  inset: 0;
}
.fpb-fiar-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-fiar-board-canvas.is-disabled {
  cursor: default;
}

.fpb-nmm-board {
  container-type: inline-size;
  background-color: #e8d4a8;
  border: 2px solid rgba(92, 64, 48, 0.35);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .fpb-nmm-board {
  background-color: #3a2a1c;
  border-color: rgba(232, 212, 168, 0.2);
}
.fpb-nmm-board-host {
  position: absolute;
  inset: 0;
}
.fpb-nmm-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-nmm-board-canvas.is-disabled {
  cursor: default;
}
.fpb-nmm-board-canvas.must-remove {
  cursor: crosshair;
}

.fpb-rv-board {
  container-type: inline-size;
  background-color: var(--fpb-board-surface);
  border: 1px solid color-mix(in srgb, var(--fpb-board-line) 38%, transparent);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 14px -8px rgba(0, 0, 0, 0.22);
  /* No start.svg / is-idle — canvas paints directly. */
  background-image: repeating-conic-gradient(
    from 90deg at 50% 50%,
    var(--fpb-board-surface-2) 0deg 90deg,
    var(--fpb-board-surface) 90deg 180deg
  );
  background-size: 25% 25%;
}
.fpb-rv-board-host {
  position: absolute;
  inset: 0;
}
.fpb-rv-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-rv-board-canvas.is-disabled {
  cursor: default;
}

/* Makruk board — solid field + grid lines (Wikipedia lattice), colours from board skin. */
.fpb-mk-board.fpb-chess-board {
  background-color: var(--fpb-board-surface);
  background-image: none;
  border-color: color-mix(in srgb, var(--fpb-board-line) 70%, #000);
}
.fpb-mk-sq {
  background-color: var(--fpb-board-surface);
  box-shadow: inset 0 0 0 1px var(--fpb-board-line);
}

/* Makruk slide flyer — Fulmene SVGs; match canvas pad (~94% of cell). */
.fpb-mk-anim,
.fpb-mk-capture {
  position: absolute;
  z-index: 15;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.fpb-mk-anim {
  will-change: left, top;
  /* No transition until .is-moving — otherwise first paint interpolates from 0/prev (looks like flying up from the bottom). */
}
.fpb-mk-anim.is-moving {
  transition: left 0.26s cubic-bezier(0.33, 1.05, 0.42, 1),
    top 0.26s cubic-bezier(0.33, 1.05, 0.42, 1);
}
.fpb-mk-capture {
  z-index: 14;
  animation: fpb-ck-capture 0.3s ease-in forwards;
}
.fpb-mk-anim .fpb-chess-piece,
.fpb-mk-capture .fpb-chess-piece {
  width: 94%;
  height: 94%;
}

/* DOM board helpers (online board + chrome disc chips) */
.fpb-rv-cell {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28);
}
.fpb-rv-disc {
  border-radius: 9999px;
  transform-style: preserve-3d;
}
.fpb-rv-disc-board {
  position: absolute;
  inset: 11%;
}
.fpb-rv-black {
  background: radial-gradient(circle at 34% 30%, #5a5a5a, #161616 62%, #000 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 -2px 3px rgba(0, 0, 0, 0.6);
}
.fpb-rv-white {
  background: radial-gradient(circle at 34% 30%, #ffffff, #e2e2e2 62%, #c2c2c2 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 -2px 3px rgba(0, 0, 0, 0.18);
}
@keyframes fpb-rv-pop {
  0% {
    transform: scale(0);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}
.fpb-rv-pop {
  animation: fpb-rv-pop 0.22s cubic-bezier(0.34, 1.4, 0.5, 1) both;
}
@keyframes fpb-rv-flip {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(180deg);
  }
}
.fpb-rv-flip {
  animation: fpb-rv-flip 0.3s ease-in-out both;
}

.fpb-ck-board {
  container-type: inline-size;
  border: 4px solid #5b3a1d;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
  /* No start.svg / is-idle — canvas paints directly. */
  --fpb-ck-sq-light: #e9cfa3;
  --fpb-ck-sq-dark: #9c6b3c;
  background-color: var(--fpb-ck-sq-light);
  background-image: repeating-conic-gradient(
    from 90deg at 50% 50%,
    var(--fpb-ck-sq-dark) 0deg 90deg,
    var(--fpb-ck-sq-light) 90deg 180deg
  );
  background-size: 25% 25%;
}
.fpb-ck-board-host {
  position: absolute;
  inset: 0;
}
.fpb-ck-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-ck-board-canvas.is-disabled {
  cursor: default;
}
.fpb-ck-light {
  background-color: #e9cfa3;
}
.fpb-ck-dark {
  background-color: #9c6b3c;
}
.fpb-ck-disc {
  position: absolute;
  inset: 12%;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fpb-ck-black {
  background: radial-gradient(circle at 34% 30%, #4a4a4a, #1a1a1a 62%, #000 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), inset 0 -2px 3px rgba(0, 0, 0, 0.6),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.fpb-ck-white {
  background: radial-gradient(circle at 34% 30%, #fff7ec, #ecdcc4 62%, #d6c2a3 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.2);
}

.fpb-ck-crown {
  color: #f5c518;
  font-size: 7.5cqw;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
@keyframes fpb-ck-pop {
  0% {
    transform: scale(0);
  }
  70% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}
.fpb-ck-pop {
  animation: fpb-ck-pop 0.22s cubic-bezier(0.34, 1.4, 0.5, 1) both;
}

@keyframes fpb-ck-capture {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(0.2);
    opacity: 0;
  }
}
.fpb-ck-capture {
  animation: fpb-ck-capture 0.32s ease-in forwards;
}

.fpb-ck-anim {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  will-change: transform;
  animation: fpb-piece-slide 320ms cubic-bezier(0.33, 1.05, 0.42, 1) both;
}
.fpb-ck-anim .fpb-ck-disc {
  position: static;
  width: 76%;
  height: 76%;
}

.fpb-idr-board {
  container-type: inline-size;
  border: 4px solid #4a2f18;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
  --fpb-idr-sq-light: #e8d2a8;
  --fpb-idr-sq-dark: #8b5a2b;
  background-color: var(--fpb-idr-sq-light);
  background-image: repeating-conic-gradient(
    from 90deg at 50% 50%,
    var(--fpb-idr-sq-dark) 0deg 90deg,
    var(--fpb-idr-sq-light) 90deg 180deg
  );
  background-size: 20% 20%;
}
.fpb-idr-board-host {
  position: absolute;
  inset: 0;
}
.fpb-idr-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-idr-board-canvas.is-disabled {
  cursor: default;
}
.fpb-idr-light {
  background-color: #e8d2a8;
}
.fpb-idr-dark {
  background-color: #8b5a2b;
}
.fpb-idr-disc {
  position: absolute;
  inset: 14%;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fpb-idr-black {
  background: radial-gradient(circle at 34% 30%, #4a4a4a, #1a1a1a 62%, #000 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.55), inset 0 -2px 3px rgba(0, 0, 0, 0.6),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.fpb-idr-white {
  background: radial-gradient(circle at 34% 30%, #fff7ec, #ecdcc4 62%, #d6c2a3 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 -2px 3px rgba(0, 0, 0, 0.2);
}
.fpb-idr-crown {
  color: #f5c518;
  font-size: 6cqw;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
@keyframes fpb-idr-pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.fpb-idr-pop {
  animation: fpb-idr-pop 0.22s cubic-bezier(0.34, 1.4, 0.5, 1) both;
}
@keyframes fpb-idr-capture {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(0.2); opacity: 0; }
}
.fpb-idr-capture {
  animation: fpb-idr-capture 0.32s ease-in forwards;
}
.fpb-idr-anim {
  position: absolute;
  left: 0;
  top: 0;
  width: 10%;
  height: 10%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  will-change: transform;
  animation: fpb-piece-slide 320ms cubic-bezier(0.33, 1.05, 0.42, 1) both;
}
.fpb-idr-anim .fpb-idr-disc {
  position: static;
  width: 72%;
  height: 72%;
}

.fpb-cc-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 16px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #faf3e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.fpb-cc-board-host {
  position: absolute;
  inset: 0;
}
.fpb-cc-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-cc-board-canvas.is-disabled {
  cursor: default;
}
.fpb-cc-stage {
  container-type: inline-size;
  container-name: cc-stage;
}
/* Width-driven square parent so absolute host isn't 0×0 */
.fpb-cc-normal {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  margin-inline: auto;
}
.fpb-cc-fs {
  width: min(92vmin, 560px);
  max-width: 100%;
  max-height: 100%;
  margin-inline: auto;
}
.fpb-cc-line {
  stroke: rgba(93, 64, 55, 0.3);
  stroke-width: 0.25;
  stroke-linecap: round;
}
.fpb-cc-trail {
  stroke: #FB8C00;
  stroke-width: 0.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1.5 1.5;
}
.fpb-cc-hole {
  position: absolute;
  inset: 16%;
  border-radius: 9999px;
  background-color: #EFE3C8;
  border: 1px solid rgba(93, 64, 55, 0.45);
}
.fpb-cc-hole-top {
  background-color: #FBE4E2;
}
.fpb-cc-hole-bottom {
  background-color: #E0EEFB;
}
.fpb-cc-marble {
  position: absolute;
  inset: 18%;
  border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.fpb-cc-marble::after {
  content: "";
  position: absolute;
  top: 15%;
  left: 20%;
  width: 40%;
  height: 25%;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transform: rotate(-15deg);
}
.fpb-cc-red {
  background: radial-gradient(circle at 30% 30%, #FF8A80 0%, #E53935 60%, #B71C1C 100%);
}
.fpb-cc-blue {
  background: radial-gradient(circle at 30% 30%, #82B1FF 0%, #1E88E5 60%, #0D47A1 100%);
}
/* Backgammon classic canvas — landscape parent (aspect 1.18; host absolute inset) */
.fpb-bg-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1.18 / 1;
  border-radius: 14px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #5c3a22;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.fpb-bg-normal {
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h) * 1.18),
    calc((100svh - var(--header-height) - 6.5rem) * 1.18)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  margin-inline: auto;
}
.fpb-bg-fs {
  width: min(96vw, calc((100dvh - 200px) * 1.18), 960px);
  max-width: 100%;
  max-height: calc(100dvh - 180px);
  margin-inline: auto;
}
.fpb-bg-board-host {
  position: absolute;
  inset: 0;
}
.fpb-bg-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-bg-board-canvas.is-disabled {
  cursor: default;
}
/* Mancala classic canvas — wide landscape parent (width + aspect-ratio; host absolute inset) */
.fpb-mc-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 2.35 / 1;
  border-radius: 28px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #5a3422;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.fpb-mc-stage {
  container-type: inline-size;
  container-name: mc-stage;
}
.fpb-mc-normal {
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h) * 2.35),
    calc((100svh - var(--header-height) - 6.5rem) * 2.35)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  margin-inline: auto;
}
.fpb-mc-fs {
  width: min(96vw, calc((100dvh - 200px) * 2.35), 960px);
  max-width: 100%;
  max-height: calc(100dvh - 180px);
  margin-inline: auto;
}
.fpb-mc-board-host {
  position: absolute;
  inset: 0;
}
.fpb-mc-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-mc-board-canvas.is-disabled {
  cursor: default;
}
.fpb-db-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #fdf6e3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
/* Width-driven square parent so absolute host isn't 0×0 */
.fpb-db-board.fpb-dnb-normal {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  margin-inline: auto;
}
.fpb-db-board-host {
  position: absolute;
  inset: 0;
}
.fpb-db-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-db-board-canvas.is-disabled {
  cursor: default;
}
.fpb-db-fs {
  width: min(95vw, calc(100dvh - 200px), 800px);
  max-width: 100%;
  max-height: 100%;
  margin-inline: auto;
}

.fpb-cc-marble-active {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 213, 79, 0.6);
  transform: scale(1.04);
}
.fpb-cc-marble-last {
  box-shadow: 0 0 0 2px rgba(251, 140, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.2);
}
.fpb-cc-target {
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  border: 2px dashed #43A047;
  pointer-events: none;
}
.fpb-cc-selected {
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  border: 3px solid #FFD54F;
  pointer-events: none;
}

.fpb-hm-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 16px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #faf3e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}
.fpb-hm-board-host {
  position: absolute;
  inset: 0;
}
.fpb-hm-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-hm-board-canvas.is-disabled {
  cursor: default;
}
.fpb-hm-stage {
  container-type: inline-size;
  container-name: hm-stage;
}
/* Width-driven square parent so absolute host isn't 0×0 */
.fpb-hm-normal {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  margin-inline: auto;
}
.fpb-hm-fs {
  width: min(92vmin, 560px);
  max-width: 100%;
  max-height: 100%;
  margin-inline: auto;
}
.fpb-hm-line {
  stroke: rgba(93, 64, 55, 0.3);
  stroke-width: 0.25;
  stroke-linecap: round;
}
.fpb-hm-trail {
  stroke: #FB8C00;
  stroke-width: 0.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1.5 1.5;
}
.fpb-hm-hole {
  position: absolute;
  inset: 16%;
  border-radius: 9999px;
  background-color: #EFE3C8;
  border: 1px solid rgba(93, 64, 55, 0.45);
}
.fpb-hm-hole-top {
  background-color: #FBE4E2;
}
.fpb-hm-hole-bottom {
  background-color: #E0EEFB;
}
.fpb-hm-marble {
  position: absolute;
  inset: 18%;
  border-radius: 9999px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.fpb-hm-marble::after {
  content: "";
  position: absolute;
  top: 15%;
  left: 20%;
  width: 40%;
  height: 25%;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transform: rotate(-15deg);
}
.fpb-hm-red {
  background: radial-gradient(circle at 30% 30%, #FF8A80 0%, #E53935 60%, #B71C1C 100%);
}
.fpb-hm-blue {
  background: radial-gradient(circle at 30% 30%, #82B1FF 0%, #1E88E5 60%, #0D47A1 100%);
}
/* Backgammon classic canvas — landscape parent (aspect 1.18; host absolute inset) */
.fpb-bg-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1.18 / 1;
  border-radius: 14px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #5c3a22;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.fpb-bg-normal {
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h) * 1.18),
    calc((100svh - var(--header-height) - 6.5rem) * 1.18)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  margin-inline: auto;
}
.fpb-bg-fs {
  width: min(96vw, calc((100dvh - 200px) * 1.18), 960px);
  max-width: 100%;
  max-height: calc(100dvh - 180px);
  margin-inline: auto;
}
.fpb-bg-board-host {
  position: absolute;
  inset: 0;
}
.fpb-bg-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-bg-board-canvas.is-disabled {
  cursor: default;
}
/* Mancala classic canvas — wide landscape parent (width + aspect-ratio; host absolute inset) */
.fpb-mc-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 2.35 / 1;
  border-radius: 28px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #5a3422;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.fpb-mc-stage {
  container-type: inline-size;
  container-name: mc-stage;
}
.fpb-mc-normal {
  width: min(
    calc(100% - var(--fpb-wide-board-gutter)),
    calc(var(--fpb-board-max-h) * 2.35),
    calc((100svh - var(--header-height) - 6.5rem) * 2.35)
  );
  max-width: calc(100% - var(--fpb-wide-board-gutter));
  margin-inline: auto;
}
.fpb-mc-fs {
  width: min(96vw, calc((100dvh - 200px) * 2.35), 960px);
  max-width: 100%;
  max-height: calc(100dvh - 180px);
  margin-inline: auto;
}
.fpb-mc-board-host {
  position: absolute;
  inset: 0;
}
.fpb-mc-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-mc-board-canvas.is-disabled {
  cursor: default;
}
.fpb-db-board {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  /* No start.svg / is-idle — canvas paints directly. */
  background-color: #fdf6e3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
/* Width-driven square parent so absolute host isn't 0×0 */
.fpb-db-board.fpb-dnb-normal {
  width: min(
    100%,
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  max-width: min(
    var(--fpb-board-max-h),
    calc(100svh - var(--header-height) - 6.5rem),
    var(--fpb-square-board-cap-lg)
  );
  margin-inline: auto;
}
.fpb-db-board-host {
  position: absolute;
  inset: 0;
}
.fpb-db-board-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}
.fpb-db-board-canvas.is-disabled {
  cursor: default;
}
.fpb-db-fs {
  width: min(95vw, calc(100dvh - 200px), 800px);
  max-width: 100%;
  max-height: 100%;
  margin-inline: auto;
}

.fpb-hm-marble-active {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 213, 79, 0.6);
  transform: scale(1.04);
}
.fpb-hm-marble-last {
  box-shadow: 0 0 0 2px rgba(251, 140, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.2);
}
.fpb-hm-target {
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  border: 2px dashed #43A047;
  pointer-events: none;
}
.fpb-hm-selected {
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  border: 3px solid #FFD54F;
  pointer-events: none;
}

.fpb-xq-board-host {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.fpb-xq-board-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}
.fpb-xq-board-canvas.is-disabled {
  cursor: default;
}
.fpb-xq-board {
  /* Domestic wood-board palette — classic boot reads these via getComputedStyle */
  --fpb-xq-wood: var(--fpb-board-surface);
  --fpb-xq-grid: var(--fpb-board-line);
  --fpb-xq-lacquer: var(--fpb-board-accent);
  --fpb-xq-raised: var(--fpb-board-raised);
  container-type: inline-size;
  position: relative;
  aspect-ratio: 9 / 10;
  /* 允许棋子超出线格区域（首尾行棋子以交点为中心，会探出棋盘背景） */
  overflow: visible;
  border-radius: 5px;
  /* Canvas paints the wood surface; CSS fill is a first-paint fallback */
  background: var(--fpb-board-surface);
  box-shadow: 0 4px 12px rgba(103, 64, 24, 0.18);
}
[data-fpb-mode="dark"] .fpb-xq-board {
  /* Keep reading site board-skin tokens in dark mode too */
}
.fpb-xq-grid {
  overflow: visible;
}
.fpb-xq-grid-lines {
  fill: none;
  stroke: #6b5035;
  stroke-linecap: square;
  stroke-width: 0.3;
  vector-effect: non-scaling-stroke;
}
.fpb-xq-river {
  fill: #e5b872;
}
.fpb-xq-river-label {
  fill: #795938;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  font-size: 5.1px;
  font-weight: 700;
  letter-spacing: 1.6px;
  paint-order: stroke;
  stroke: #e5b872;
  stroke-width: 0.55px;
  stroke-linejoin: round;
}
.fpb-xq-stage {
  container-type: inline-size;
  container-name: xq-stage;
}

.fpb-xq-normal {
  --fpb-xq-board-max-h: min(
    calc(var(--fpb-board-max-h) + 2rem),
    calc(100svh - var(--header-height) - 6.5rem)
  );
  /* Width-first: canvas host is position:absolute and no longer gives in-flow size.
     Avoid height: … 100cqw on self (circular with container-type + collapsed width). */
  width: min(100%, calc(var(--fpb-xq-board-max-h) * 9 / 10));
  max-width: 100%;
  height: auto;
  aspect-ratio: 9 / 10;
  max-height: var(--fpb-xq-board-max-h);
  margin-inline: auto;
}

.fpb-xq-fs-wrap {
  /* 全屏 flex 子区：按实际可用宽高动态适配（对齐军旗 fs 思路） */
  --fpb-fs-board-gutter: 1.25rem;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding-block: var(--fpb-fs-board-gutter);
  box-sizing: border-box;
  overflow: visible;
}
.fpb-xq-fs {
  aspect-ratio: 9 / 10;
  flex-shrink: 0;
  /* 在 flex 容器内：扣除上下 gutter 后再取最大盘面 */
  width: min(
    100cqw,
    calc((100cqh - var(--fpb-fs-board-gutter, 1.25rem) * 2) * 9 / 10),
    calc(100vw - 2rem)
  );
  height: auto;
  max-width: calc(100vw - 2rem);
  /* 无 container 上下文时的回退（军旗同款 dvh 算法，比例改为 9:10） */
  max-height: calc(100dvh - 5rem - var(--fpb-fs-board-gutter, 1.25rem) * 2);
}
@supports not (width: 1cqh) {
  .fpb-xq-fs {
    height: min(
      calc(100dvh - 5rem - var(--fpb-fs-board-gutter, 1.25rem) * 2),
      calc((100vw - 2rem) * 10 / 9)
    );
    width: auto;
  }
}

.fpb-xq-inner {
  position: relative;
  width: 100%;
  height: 100%;
}
/* 棋子为 pychess hnz 套装 SVG（public/xiangqi-pieces/） */
.fpb-xq-piece {
  position: relative;
  z-index: 1;
  width: 11.2cqw;
  height: 11.2cqw;
  border-radius: 9999px;
  user-select: none;
}

.fpb-xq-sel {
  outline: 0.55cqw solid var(--fpb-xq-lacquer, #b33a2b);
  outline-offset: -0.25cqw;
}
.fpb-xq-pop {
  animation: fpb-ck-pop 0.22s cubic-bezier(0.34, 1.4, 0.5, 1) both;
}
.fpb-xq-capture {
  animation: fpb-ck-capture 0.3s ease-in forwards;
}
.fpb-xq-anim {
  position: absolute;
  z-index: 15;
  width: 11.2cqw;
  height: 11.2cqw;
  transform: translate(-50%, -50%);
  pointer-events: none;
  will-change: left, top;
  transition: left 0.26s cubic-bezier(0.33, 1.05, 0.42, 1),
    top 0.26s cubic-bezier(0.33, 1.05, 0.42, 1);
}

@keyframes fpb-xq-check {
  0%,
  100% {
    outline-width: 0.4cqw;
    outline-color: rgba(220, 38, 38, 0.95);
  }
  50% {
    outline-width: 1.7cqw;
    outline-color: rgba(220, 38, 38, 0);
  }
}
.fpb-xq-check {
  outline-style: solid;
  outline-offset: 0;
  animation: fpb-xq-check 0.85s ease-out infinite;
}

:root {
  --cw-shell-bg: var(--color-card);
  --cw-panel-bg: color-mix(in srgb, var(--color-subtle) 38%, #ffffff);
  --cw-inset-bg: var(--color-subtle);
  --cw-board-well: color-mix(in srgb, var(--color-subtle) 62%, var(--color-card));
  --cw-shell-ring: color-mix(in srgb, var(--color-border) 90%, transparent);
  --cw-panel-ring: color-mix(in srgb, var(--color-border) 75%, transparent);
}
[data-fpb-mode="dark"] {
  --cw-shell-bg: var(--color-card);
  --cw-panel-bg: color-mix(in srgb, #ffffff 5%, var(--color-card));
  --cw-inset-bg: color-mix(in srgb, #000 28%, var(--color-card));
  --cw-board-well: color-mix(in srgb, #000 18%, var(--color-card));
  --cw-shell-ring: color-mix(in srgb, #94a3b8 28%, transparent);
  --cw-panel-ring: color-mix(in srgb, #94a3b8 22%, transparent);
}
.fpb-cw-accent {
  color: #8b5e3c;
}
[data-fpb-mode="dark"] .fpb-cw-accent {
  color: #d4b896;
}
.fpb-cw-accent-bg {
  background: #8b5e3c;
  color: #fff;
}
[data-fpb-mode="dark"] .fpb-cw-accent-bg {
  background: #9a7348;
}
.fpb-cw-shell {
  background: var(--cw-shell-bg);
  border: 1px solid var(--cw-shell-ring);
  box-shadow: var(--shadow-card);
}
[data-fpb-mode="dark"] .fpb-cw-shell {
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.fpb-cw-panel {
  background: var(--cw-panel-bg);
  border: 1px solid var(--cw-panel-ring);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
[data-fpb-mode="dark"] .fpb-cw-panel {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.fpb-cw-surface {
  background: var(--cw-inset-bg);
  border: 1px solid var(--cw-panel-ring);
}
.fpb-cw-board-well {
  background: var(--cw-board-well);
  border: 1px solid var(--cw-panel-ring);
  border-radius: 12px;
}
.fpb-cw-toolbar {
  background: var(--cw-panel-bg);
  border: 1px solid var(--cw-panel-ring);
  box-shadow: 0 -1px 0 var(--cw-shell-ring);
}
[data-fpb-mode="dark"] .fpb-cw-toolbar {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 4px 16px rgba(0, 0, 0, 0.2);
}
.fpb-cw-muted {
  color: var(--color-muted);
}
.fpb-cw-text {
  color: var(--color-fg);
}
.fpb-cw-mode-on {
  background: color-mix(in srgb, #f59e0b 20%, var(--cw-panel-bg));
  color: var(--color-fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #f59e0b 35%, transparent);
}
[data-fpb-mode="dark"] .fpb-cw-mode-on {
  background: color-mix(in srgb, #f59e0b 18%, var(--cw-inset-bg));
}
.fpb-cw-clue-on {
  background: color-mix(in srgb, #f59e0b 22%, var(--cw-panel-bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #f59e0b 30%, transparent);
}
.fpb-cw-clue-done .fpb-cw-text {
  color: var(--color-muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--color-muted) 70%, transparent);
}
.fpb-cw-clue-done:not(.fpb-cw-clue-on) {
  opacity: 0.82;
}
[data-fpb-mode="dark"] .fpb-cw-clue-on {
  background: color-mix(in srgb, #f59e0b 16%, var(--cw-inset-bg));
}
.fpb-cw-clue-hover:hover {
  background: color-mix(in srgb, var(--color-fg) 6%, var(--cw-panel-bg));
}
.fpb-cw-cur-clue {
  border: 1px solid color-mix(in srgb, #f59e0b 45%, var(--color-border));
  background: color-mix(in srgb, #f59e0b 14%, var(--cw-panel-bg));
}
[data-fpb-mode="dark"] .fpb-cw-cur-clue {
  background: color-mix(in srgb, #f59e0b 12%, var(--cw-inset-bg));
}
.fpb-cw-progress-track {
  background: var(--color-border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}
.fpb-cw-progress-fill {
  background: #8b5e3c;
}
[data-fpb-mode="dark"] .fpb-cw-progress-fill {
  background: #c4a574;
}
.fpb-cw-tab-on {
  color: #8b5e3c;
}
[data-fpb-mode="dark"] .fpb-cw-tab-on {
  color: #d4b896;
}
.fpb-cw-spinner {
  border: 2px solid color-mix(in srgb, #8b5e3c 80%, transparent);
  border-top-color: transparent;
}
[data-fpb-mode="dark"] .fpb-cw-spinner {
  border-color: color-mix(in srgb, #d4b896 80%, transparent);
  border-top-color: transparent;
}
.fpb-cw-grid {
  border: 2px solid #1a1a1a;
  background: #fff;
  color: #1a1a1a;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(0, 0, 0, 0.06);
}
[data-fpb-mode="dark"] .fpb-cw-grid {
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}
.fpb-cw-cell {
  border: 1px solid #333;
  background: #fff;
  color: #1a1a1a;
}
.fpb-cw-cell-in-word {
  background: #eef5ff;
}
.fpb-cw-cell-selected {
  border: 2px solid #f59e0b;
  background: #fffbea;
  box-shadow: inset 0 0 0 1px #fcd34d, 0 0 8px 2px rgba(245, 158, 11, 0.35);
}
.fpb-cw-cell-hover:hover {
  background: #faf7f0;
}
.fpb-cw-cell-wrong {
  background: #ffe8e8 !important;
  color: #c0392b !important;
}

.fpb-cw-archive-card {
  border-color: var(--cw-panel-ring, var(--color-border));
  background: var(--color-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.fpb-cw-archive-card:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.fpb-cw-archive-done {
  border-color: #b8ddb8;
}
.fpb-cw-archive-badge {
  background: #f5f1ea;
  color: #8b6914;
}
[data-fpb-mode="dark"] .fpb-cw-archive-badge {
  background: rgba(255, 255, 255, 0.06);
  color: #d4a853;
}
.fpb-cw-archive-badge-done {
  background: #e8f5e9;
  color: #27ae60;
}
[data-fpb-mode="dark"] .fpb-cw-archive-badge-done {
  background: rgba(39, 174, 96, 0.15);
  color: #6ee7a0;
}
.fpb-cw-archive-ribbon {
  background: #27ae60;
}
.fpb-cw-archive-cta {
  color: #8b6914;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}
[data-fpb-mode="dark"] .fpb-cw-archive-cta {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}

.fpb-cw-history-item {
  border-color: var(--cw-panel-ring, var(--color-border));
  background: var(--color-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fpb-cw-history-item:hover {
  border-color: #d8cdb8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.fpb-cw-history-badge {
  background: #f5f1ea;
  color: #8b6914;
}
[data-fpb-mode="dark"] .fpb-cw-history-badge {
  background: rgba(255, 255, 255, 0.06);
  color: #d4a853;
}
.fpb-cw-stat-mid {
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

.fpb-cw-win-mask {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 16px;
}
.fpb-cw-win-card {
  width: min(400px, 90vw);
  border-radius: 18px;
  background: var(--color-card, #faf8f5);
  padding: 40px 32px 28px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: fpb-cw-win-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fpb-cw-win-pop {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.fpb-cw-win-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: #e8f5e9;
  border: 2px solid #27ae60;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fpb-cw-win-icon svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: #27ae60;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fpb-cw-win-title {
  margin: 0 0 8px;
  font-size: 30px;
  font-weight: 700;
  color: #2c2416;
}
[data-fpb-mode="dark"] .fpb-cw-win-title {
  color: #fff;
}
.fpb-cw-win-sub {
  margin: 0 0 28px;
  font-size: 14px;
  line-height: 1.5;
  color: #8d6e63;
}
.fpb-cw-win-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.fpb-cw-win-stat {
  background: #fff;
  border: 1px solid #ece6d8;
  border-radius: 12px;
  padding: 14px 0;
}
.fpb-cw-win-stat-lbl {
  font-size: 11px;
  color: #8d6e63;
  margin-bottom: 4px;
}
.fpb-cw-win-stat-num {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #2c2416;
}
.fpb-cw-win-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.fpb-cw-win-again,
.fpb-cw-win-back {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 12px 0;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fpb-cw-win-again {
  background: #8b5e3c;
  color: #fff;
}
.fpb-cw-win-back {
  background: #fff;
  border: 1px solid #ece6d8;
  color: #2c2416;
}
.fpb-cw-win-again:hover,
.fpb-cw-win-back:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}
.fpb-cw-win-again:active,
.fpb-cw-win-back:active {
  transform: translateY(0);
}
.fpb-cw-win-share-note {
  font-size: 12px;
  line-height: 1.6;
  color: #8d6e63;
  margin: 0 0 10px;
}
.fpb-cw-win-share-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.fpb-cw-win-share-btn {
  border: 1px solid #ece6d8;
  background: #fff;
  color: #8b5e3c;
  font-size: 13px;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}
.fpb-cw-win-share-btn.primary {
  background: #8b5e3c;
  border-color: #8b5e3c;
  color: #fff;
}
.fpb-cw-win-share-btn:hover {
  opacity: 0.92;
}


/* ---- Janggi (octagon Cho/Han discs; riverless board) ---- */
.fpb-jg-board-host {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.fpb-jg-board-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}
.fpb-jg-board-canvas.is-disabled {
  cursor: default;
}
.fpb-jg-board {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 9 / 10;
  overflow: visible;
  border-radius: 5px;
  background: var(--fpb-board-surface);
  box-shadow: 0 4px 12px rgba(60, 80, 40, 0.16);
  --fpb-jg-wood: var(--fpb-board-surface);
  --fpb-jg-grid: var(--fpb-board-line);
  --fpb-jg-lacquer: var(--fpb-board-accent);
  --fpb-jg-raised: var(--fpb-board-raised);
}
[data-fpb-mode="dark"] .fpb-jg-board {
  background: var(--fpb-board-surface);
}
.fpb-jg-stage {
  container-type: inline-size;
  container-name: jg-stage;
}
.fpb-jg-normal {
  --fpb-jg-board-max-h: min(
    calc(var(--fpb-board-max-h) + 2rem),
    calc(100svh - var(--header-height) - 6.5rem)
  );
  width: min(100%, calc(var(--fpb-jg-board-max-h) * 9 / 10));
  max-width: 100%;
  height: auto;
  aspect-ratio: 9 / 10;
  max-height: var(--fpb-jg-board-max-h);
  margin-inline: auto;
}
.fpb-jg-fs-wrap {
  --fpb-fs-board-gutter: 1.25rem;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding-block: var(--fpb-fs-board-gutter);
  box-sizing: border-box;
  overflow: visible;
}
.fpb-jg-fs {
  aspect-ratio: 9 / 10;
  flex-shrink: 0;
  width: min(100cqw, calc((100cqh - 2 * var(--fpb-fs-board-gutter)) * 9 / 10));
  max-height: calc(100cqh - 2 * var(--fpb-fs-board-gutter));
}
.fpb-jg-disc--cho {
  background: #e8f5e9;
  color: #1b5e20;
  box-shadow: inset 0 0 0 0.22cqw #2e7d32, 0 0.15cqw 0.35cqw rgba(40, 60, 30, 0.22);
}
.fpb-jg-disc--han {
  background: #ffe8e6;
  color: #b71c1c;
  box-shadow: inset 0 0 0 0.22cqw #c62828, 0 0.15cqw 0.35cqw rgba(80, 30, 20, 0.2);
}
.fpb-jg-disc--lg {
  --fpb-jg-disc: 9.8cqw;
}
.fpb-jg-disc--md {
  --fpb-jg-disc: 8.7cqw;
}
.fpb-jg-disc--sm {
  --fpb-jg-disc: 7.4cqw;
}
.fpb-jg-piece,
.fpb-jg-anim {
  position: absolute;
  z-index: 15;
  box-sizing: border-box;
  width: var(--fpb-jg-disc, 10.2cqw);
  height: var(--fpb-jg-disc, 10.2cqw);
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  /* octagon */
  clip-path: polygon(
    30% 0%,
    70% 0%,
    100% 30%,
    100% 70%,
    70% 100%,
    30% 100%,
    0% 70%,
    0% 30%
  );
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", serif;
  font-weight: 700;
  font-size: calc(var(--fpb-jg-disc, 10.2cqw) * 0.52);
  line-height: 1;
}
.fpb-jg-anim {
  will-change: left, top;
  transition: left 0.26s cubic-bezier(0.33, 1.05, 0.42, 1),
    top 0.26s cubic-bezier(0.33, 1.05, 0.42, 1);
}
.fpb-jg-capture {
  animation: fpb-ck-capture 0.3s ease-in forwards;
  z-index: 14;
}
.fpb-jg-chip {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  clip-path: polygon(
    30% 0%,
    70% 0%,
    100% 30%,
    100% 70%,
    70% 100%,
    30% 100%,
    0% 70%,
    0% 30%
  );
  font-family: "KaiTi", "STKaiti", "Kaiti SC", "Songti SC", serif;
  font-weight: 700;
  font-size: 0.7rem;
  line-height: 1;
  user-select: none;
}
.fpb-jg-chip.fpb-jg-disc--cho {
  box-shadow: inset 0 0 0 1.5px #2e7d32;
}
.fpb-jg-chip.fpb-jg-disc--han {
  box-shadow: inset 0 0 0 1.5px #c62828;
}
.fpb-jg-chip--btn {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.75rem;
}
@keyframes fpb-jg-check {
  0%,
  100% {
    outline-width: 0.4cqw;
    outline-color: rgba(198, 40, 40, 0.95);
  }
  50% {
    outline-width: 1.7cqw;
    outline-color: rgba(198, 40, 40, 0);
  }
}
.fpb-jg-check {
  outline-style: solid;
  outline-offset: 0;
  animation: fpb-jg-check 0.85s ease-out infinite;
}
.fpb-app--focus .fpb-match-active > .flex-1 .fpb-jg-stage {
  min-height: 0;
}
.fpb-match-card > .fpb-jg-stage,
.fpb-app--focus .fpb-jg-stage {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.fpb-app--focus .fpb-jg-stage > .fpb-match-toolbar {
  flex-shrink: 0;
}
.fpb-app--focus .fpb-jg-stage > .fpb-board-well {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fpb-app--focus .fpb-jg-board,
.fpb-app--focus .fpb-board-well > .fpb-jg-normal {
  width: min(100%, calc(var(--fpb-jg-board-max-h, 72svh) * 9 / 10));
}
.fpb-app--focus .fpb-online-board-stack > .fpb-jg-normal {
  width: min(100%, calc(var(--fpb-jg-board-max-h, 72svh) * 9 / 10));
}
