* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: #ece3d3;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 620px at 12% -12%, rgba(200, 163, 91, 0.16), transparent 62%),
    radial-gradient(900px 520px at 104% 108%, rgba(178, 58, 46, 0.14), transparent 62%),
    #13100c;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 26px 10px;
  flex: none;
}
.brand { display: flex; align-items: center; gap: 13px; }
.seal {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-family: "Kaiti SC", "KaiTi", "STKaiti", serif;
  font-size: 23px;
  color: #f8e8c9;
  background: linear-gradient(160deg, #b23a2e, #7a1d16);
  box-shadow: 0 8px 20px rgba(178, 58, 46, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.16em;
}
.brand-text p {
  margin: 3px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.2em;
  color: #968a76;
}
.top-meta {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #968a76;
}

/* ---------------- 主区域 ---------------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 22px;
  padding: 6px 24px 22px;
}

.board-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board {
  display: block;
  border-radius: 18px;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.5), 0 2px 0 rgba(255, 255, 255, 0.05) inset;
  touch-action: manipulation;
}

/* ---------------- 侧栏 ---------------- */
.panel {
  width: 300px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
  border: 1px solid rgba(255, 255, 255, 0.075);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.38);
  overflow: hidden;
}

.status-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(200, 163, 91, 0.16);
}
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.status-sub {
  margin-top: 7px;
  font-size: 12px;
  color: #978a75;
  letter-spacing: 0.05em;
  line-height: 1.5;
}
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex: none;
  background: #c2402f;
  box-shadow: 0 0 0 3px rgba(194, 64, 47, 0.18);
}
.dot.black { background: #dccdb4; box-shadow: 0 0 0 3px rgba(220, 205, 180, 0.14); }
.dot.thinking { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

.group-title {
  font-size: 11.5px;
  letter-spacing: 0.18em;
  color: #83775f;
  margin-bottom: 8px;
}

.seg {
  display: flex;
  gap: 5px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.26);
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: #b3a58e;
  font-size: 13px;
  font-family: inherit;
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
  transition: 0.18s ease;
}
.seg button:hover { color: #f2e8d6; }
.seg button.on {
  background: linear-gradient(180deg, #d3ad68, #a9823f);
  color: #241a0b;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(200, 163, 91, 0.26);
}

.actions { display: flex; gap: 8px; }
.btn {
  flex: 1;
  padding: 11px 10px;
  border-radius: 12px;
  border: 1px solid rgba(200, 163, 91, 0.34);
  background: rgba(200, 163, 91, 0.14);
  color: #eedcb6;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.18s ease;
}
.btn:hover:not(:disabled) { background: rgba(200, 163, 91, 0.24); }
.btn:disabled { opacity: 0.32; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.11);
  color: #a3977e;
}

.moves {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.move-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.move-list::-webkit-scrollbar { width: 6px; }
.move-list::-webkit-scrollbar-thumb {
  background: rgba(200, 163, 91, 0.28);
  border-radius: 3px;
}
.move-list .empty {
  color: #6d6251;
  font-size: 12.5px;
  text-align: center;
  padding: 16px 0;
}
.mv {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 7px;
}
.mv:nth-child(odd) { background: rgba(255, 255, 255, 0.032); }
.mv .no { color: #6b6152; font-size: 11.5px; }
.mv .r { color: #e6b3a2; letter-spacing: 0.02em; }
.mv .b { color: #bcc9d2; letter-spacing: 0.02em; }
.mv .cur { font-weight: 600; }

/* ---------------- 遮罩 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(10, 8, 5, 0.68);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 5;
  padding: 18px;
}
.overlay.hidden { display: none; }
.card {
  width: min(370px, 100%);
  padding: 26px 24px 22px;
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(180deg, #241b13, #1a1310);
  border: 1px solid rgba(200, 163, 91, 0.24);
  box-shadow: 0 34px 70px rgba(0, 0, 0, 0.55);
  animation: rise 0.28s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.card h2 {
  margin: 0 0 8px;
  font-family: "Kaiti SC", "KaiTi", "STKaiti", serif;
  font-size: 26px;
  letter-spacing: 0.16em;
  color: #f1ddb5;
  font-weight: 600;
}
.card h2.win { color: #e7c477; }
.card h2.lose { color: #c68a7e; }
.card p {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.8;
  color: #9a8d78;
}
.pick { display: flex; gap: 10px; margin-bottom: 14px; }
.pick-btn {
  flex: 1;
  padding: 14px 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  color: #b6a992;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.pick-btn .glyph {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Kaiti SC", "KaiTi", serif;
  font-size: 21px;
  background: radial-gradient(circle at 35% 30%, #fffaf0, #e6cda2);
  border: 2px solid rgba(150, 44, 32, 0.5);
}
.pick-btn .glyph.red { color: #a5291d; }
.pick-btn .glyph.black { color: #241f1a; border-color: rgba(40, 34, 28, 0.5); }
.pick-btn em { font-style: normal; letter-spacing: 0.08em; }
.pick-btn:hover { border-color: rgba(200, 163, 91, 0.5); color: #eddbb8; }
.pick-btn.on {
  border-color: rgba(200, 163, 91, 0.75);
  background: rgba(200, 163, 91, 0.13);
  color: #f0dfbd;
  box-shadow: 0 0 0 1px rgba(200, 163, 91, 0.25) inset;
}
.primary {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border: 0;
  border-radius: 13px;
  font-family: inherit;
  font-size: 14.5px;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: #241a0b;
  background: linear-gradient(180deg, #dfbc76, #b48a44);
  cursor: pointer;
  box-shadow: 0 12px 26px rgba(180, 138, 68, 0.28);
  transition: 0.18s ease;
}
.primary:hover { filter: brightness(1.06); }
.link {
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: #8d8069;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.card .seg { margin-top: 2px; }

/* ---------------- 移动端 ---------------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100%; }
  .topbar { padding: 14px 16px 6px; }
  .stage {
    flex-direction: column;
    gap: 14px;
    padding: 4px 14px 20px;
  }
  .board-wrap { height: calc(100vh - 320px); min-height: 340px; }
  .panel { width: auto; }
  .moves { max-height: 180px; }
}
