:root {
  --xq-brand-a: #22d3ee;
  --xq-brand-b: #8b5cf6;
  --xq-brand-600: #0891b2;
  --xq-ink: #243f5e;
  --xq-surface: #fffbeb;
  --xq-surface-muted: #fef3c7;
  --xq-border: rgba(148, 163, 184, 0.45);
  --xq-text: #0f172a;
  --xq-text-muted: #475569;
  --xq-shadow: 0 18px 40px -18px rgba(15, 23, 42, 0.45);
  --xq-radius-lg: 16px;
  --xq-radius-md: 12px;
  --xq-radius-sm: 10px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--xq-text);
  text-align: center;
  background: #f3efe6;
  --xq-board-fill: 0.7;
  --xq-canvas-w: 523;
  --xq-canvas-h: 580;
  --xq-board-width: min(
    calc(var(--xq-board-fill) * 100vw),
    calc(var(--xq-board-fill) * 100svh * var(--xq-canvas-w) / var(--xq-canvas-h))
  );
}

body.xq-skin-stype1 {
  --xq-canvas-w: 325;
  --xq-canvas-h: 402;
  background: #f5f0e8;
}

body.xq-skin-stype2 {
  --xq-canvas-w: 523;
  --xq-canvas-h: 580;
  background: #f5f0e8;
}

body.xq-skin-stype3 {
  --xq-canvas-w: 530;
  --xq-canvas-h: 567;
  background: #f5f0e8;
}

.chess_box,
.menu_dy,
.menu_qj {
  display: none;
}

.chess_box {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100svh;
  padding: 16px 0;
}

/* 隐藏 audio 元素以免在 flex 布局里把棋盘挤离视觉中心 */
.chess_box audio {
  display: none;
}

.xq-board-stage {
  position: relative;
  width: fit-content;
  max-width: min(100%, calc(var(--xq-board-width) + 44px));
  margin: 0 auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.xq-board-glow {
  display: none;
}

.xq-board-frame {
  position: relative;
  z-index: 1;
  padding: 10px;
  border-radius: var(--xq-radius-lg);
  background: linear-gradient(180deg, #8b5a2b 0%, #5c3a1e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 247, 237, 0.28),
    inset 0 -10px 18px rgba(0, 0, 0, 0.18),
    0 16px 28px -18px rgba(69, 26, 3, 0.55);
}

.xq-board-frame::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: calc(var(--xq-radius-md) + 2px);
  border: 1px solid rgba(255, 247, 237, 0.16);
  pointer-events: none;
}

#chess {
  display: block;
  max-width: calc(var(--xq-board-fill) * 100vw);
  margin: 0 auto;
  border-radius: var(--xq-radius-md);
  box-shadow: none;
}

.menu_box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(100% - 24px, 360px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 24px 0 28px;
  background: transparent;
}

.menu_init,
.menu_dy,
.menu_qj {
  overflow: hidden;
  border: 1px solid var(--xq-border);
  border-radius: var(--xq-radius-lg);
  background: var(--xq-surface);
  box-shadow: var(--xq-shadow);
}

.menu_init {
  padding: 18px 16px 16px;
  background: linear-gradient(180deg, #243f5e 0%, #304d6e 100%);
}

.menu_title {
  margin: 0 0 14px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f8fafc;
  text-shadow: 0 2px 12px rgba(2, 6, 23, 0.35);
}

.menu_init a,
#playBtn,
#clasliBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 10px 16px;
  border-radius: var(--xq-radius-md);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.menu_init a {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.menu_init a:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

#stypeBtn {
  background: rgba(15, 23, 42, 0.22);
}

.menu_dy,
.menu_qj {
  padding: 0;
  background: var(--xq-surface);
}

.menu_info {
  position: relative;
  width: auto;
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.35);
  background: linear-gradient(180deg, #fffdf5 0%, var(--xq-surface) 100%);
  color: var(--xq-text);
  text-align: left;
}

.menu_info label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: var(--xq-radius-md);
  background: rgba(255, 255, 255, 0.82);
  color: var(--xq-text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.menu_info label:last-of-type {
  margin-bottom: 0;
}

.menu_info label:hover {
  border-color: rgba(8, 145, 178, 0.45);
  background: #ffffff;
}

.menu_info input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--xq-brand-600);
  flex-shrink: 0;
}

.menu_info input[type="radio"]:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.65);
  outline-offset: 2px;
}

.menu_info input[type="radio"]:checked + *,
.menu_info label:has(input[type="radio"]:checked) {
  border-color: rgba(8, 145, 178, 0.75);
  background: linear-gradient(90deg, rgba(254, 243, 199, 0.95) 0%, rgba(255, 255, 255, 0.96) 100%);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.18);
}

.menu_fh,
.menu_gb {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9) url(../img/btn_fh.png) center / 14px 14px no-repeat;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.menu_fh:hover,
.menu_gb:hover {
  transform: translateY(-1px);
  border-color: rgba(8, 145, 178, 0.45);
  background-color: #ffffff;
}

#playBtn,
#clasliBtn {
  margin: 0;
  border: 0;
  background: linear-gradient(135deg, var(--xq-brand-a) 0%, var(--xq-brand-b) 100%);
  color: #ffffff;
  box-shadow: 0 10px 24px -12px rgba(8, 145, 178, 0.8);
}

#playBtn:hover,
#clasliBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -12px rgba(124, 58, 237, 0.55);
}

.menu_dy > #playBtn,
.menu_qj > #clasliBtn {
  width: calc(100% - 32px);
  margin: 16px;
}

.bn_box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: min(100%, calc(var(--xq-board-width) + 44px));
  margin: 14px auto 0;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--xq-radius-lg);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 28px -18px rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
}

.bn_box input {
  appearance: none;
  min-width: 104px;
  min-height: 42px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: var(--xq-radius-md);
  background: #ffffff;
  color: var(--xq-text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.bn_box input:hover {
  transform: translateY(-1px);
  border-color: rgba(8, 145, 178, 0.45);
  background: #f8fafc;
}

.bn_box input:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.65);
  outline-offset: 2px;
}

#restartBtn {
  border-color: transparent;
  background: linear-gradient(135deg, var(--xq-brand-a) 0%, var(--xq-brand-b) 100%);
  color: #ffffff;
  box-shadow: 0 10px 24px -14px rgba(8, 145, 178, 0.75);
}

#restartBtn:hover {
  background: linear-gradient(135deg, #67e8f9 0%, #a78bfa 100%);
}

#regretBtn {
  background: #fff7ed;
  border-color: rgba(251, 191, 36, 0.45);
  color: #9a3412;
}

#regretBtn:hover {
  background: #ffedd5;
  border-color: rgba(245, 158, 11, 0.55);
}

#gohomeBtn {
  background: rgba(248, 250, 252, 0.96);
  color: var(--xq-text-muted);
}

#gohomeBtn:hover {
  color: var(--xq-text);
  background: #ffffff;
}

@media (max-width: 420px) {
  .menu_box {
    width: min(100% - 16px, 360px);
    margin-top: 16px;
  }

  .menu_title {
    font-size: 22px;
  }

  .bn_box {
    padding: 10px;
  }

  .bn_box input {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }
}

html[data-bc-theme="dark"] {
  --xq-surface: #304d6e;
  --xq-surface-muted: #3c5c7e;
  --xq-border: rgba(148, 163, 184, 0.22);
  --xq-text: #e2e8f0;
  --xq-text-muted: #94a3b8;
  --xq-shadow: 0 18px 40px -18px rgba(2, 6, 23, 0.65);
}

html[data-bc-theme="dark"] body,
html[data-bc-theme="dark"] body.xq-skin-stype1,
html[data-bc-theme="dark"] body.xq-skin-stype2,
html[data-bc-theme="dark"] body.xq-skin-stype3 {
  background:
    radial-gradient(circle at 50% 0%, rgba(34, 211, 238, 0.08), transparent 42%),
    linear-gradient(180deg, #243f5e 0%, #304d6e 52%, #1a3148 100%);
  color: var(--xq-text);
}

html[data-bc-theme="dark"] .xq-board-stage {
  background: transparent;
  border: 0;
  box-shadow: none;
}

html[data-bc-theme="dark"] .menu_init,
html[data-bc-theme="dark"] .menu_dy,
html[data-bc-theme="dark"] .menu_qj {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(36, 63, 94, 0.96);
  box-shadow: var(--xq-shadow);
}

html[data-bc-theme="dark"] .menu_init {
  background: linear-gradient(180deg, #243f5e 0%, #304d6e 100%);
}

html[data-bc-theme="dark"] .menu_info {
  border-bottom-color: rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, #3c5c7e 0%, #243f5e 100%);
  color: var(--xq-text);
}

html[data-bc-theme="dark"] .menu_info label {
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.72);
  color: var(--xq-text);
}

html[data-bc-theme="dark"] .menu_info label:hover {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(30, 41, 59, 0.88);
}

html[data-bc-theme="dark"] .menu_info label:has(input[type="radio"]:checked) {
  border-color: rgba(34, 211, 238, 0.45);
  background: linear-gradient(90deg, rgba(8, 145, 178, 0.18) 0%, rgba(15, 23, 42, 0.92) 100%);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.12);
}

html[data-bc-theme="dark"] .menu_fh,
html[data-bc-theme="dark"] .menu_gb {
  border-color: rgba(148, 163, 184, 0.22);
  background-color: rgba(15, 23, 42, 0.88);
}

html[data-bc-theme="dark"] .menu_fh:hover,
html[data-bc-theme="dark"] .menu_gb:hover {
  border-color: rgba(34, 211, 238, 0.35);
  background-color: rgba(30, 41, 59, 0.92);
}

html[data-bc-theme="dark"] .bn_box {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 12px 28px -18px rgba(2, 6, 23, 0.75);
}

html[data-bc-theme="dark"] .bn_box input {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.88);
  color: var(--xq-text);
}

html[data-bc-theme="dark"] .bn_box input:hover {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(51, 65, 85, 0.92);
}

html[data-bc-theme="dark"] #regretBtn {
  background: rgba(120, 53, 15, 0.35);
  border-color: rgba(251, 191, 36, 0.28);
  color: #fde68a;
}

html[data-bc-theme="dark"] #regretBtn:hover {
  background: rgba(146, 64, 14, 0.45);
  border-color: rgba(251, 191, 36, 0.4);
}

html[data-bc-theme="dark"] #gohomeBtn {
  background: rgba(30, 41, 59, 0.82);
  color: var(--xq-text-muted);
}

html[data-bc-theme="dark"] #gohomeBtn:hover {
  color: var(--xq-text);
  background: rgba(51, 65, 85, 0.92);
}
