/* ===================== 基础 ===================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #2c3e50;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ===================== 首页 ===================== */
.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 40px 24px 48px;
}

.home .header {
  text-align: center;
  margin-top: 30px;
  margin-bottom: 50px;
}

.home .logo {
  width: 72px;
  height: 72px;
  line-height: 72px;
  margin: 0 auto 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, #2c3e50, #4a6582);
  color: #fff;
  font-size: 40px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(44, 62, 80, 0.25);
}

.home .title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #2c3e50;
}

.home .subtitle {
  margin-top: 10px;
  font-size: 15px;
  color: #8a94a6;
  letter-spacing: 1px;
}

.home .cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  display: flex;
  align-items: center;
  padding: 22px 20px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(44, 62, 80, 0.08);
  border-left: 6px solid var(--accent);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px rgba(44, 62, 80, 0.16);
}

.card:active {
  transform: translateY(1px) scale(0.99);
}

.card-icon {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 15px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-right: 16px;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-size: 19px;
  font-weight: 600;
  color: #2c3e50;
}

.card-desc {
  margin-top: 4px;
  font-size: 13px;
  color: #9aa3b2;
}

.card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.badge.ready {
  color: #e07a5f;
  background: #fbe9e2;
}

.badge.ready.blue {
  color: #3d5a80;
  background: #e4ebf3;
}

.badge.ready.purple {
  color: #6c5ce7;
  background: #ece9fb;
}

.chevron {
  font-size: 26px;
  color: #c5ccd6;
  line-height: 1;
}

.home .footer {
  margin-top: auto;
  padding-top: 36px;
  text-align: center;
  font-size: 13px;
  color: #b3bbc7;
}

/* ===================== 导航栏 ===================== */
.nav-bar {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: transparent;
}

.nav-bar .back {
  border: none;
  background: transparent;
  font-size: 16px;
  color: #2c3e50;
  cursor: pointer;
  padding: 8px 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  z-index: 1;
}

.nav-bar .back::before {
  content: "‹";
  font-size: 24px;
  line-height: 1;
  margin-top: -2px;
}

.nav-bar .nav-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: #2c3e50;
}

/* ===================== 通用游戏布局 ===================== */
.game {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 16px 32px;
}

.status {
  height: 34px;
  line-height: 34px;
  font-size: 15px;
  font-weight: 600;
  color: #2c3e50;
  letter-spacing: 1px;
  text-align: center;
}

.status.thinking {
  color: #3d5a80;
}

.status.check {
  color: #e07a5f;
}

.status.win {
  color: #e07a5f;
}

.status.lose {
  color: #8a94a6;
}

.status.draw {
  color: #6c757d;
}

/* 计时 */
.clocks {
  display: flex;
  gap: 14px;
  width: min(92vw, 540px);
  max-width: 540px;
  margin: 4px 0 10px;
}

.clock {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(44, 62, 80, 0.1);
  border: 2px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.clock.active {
  border-color: #e07a5f;
  box-shadow: 0 6px 20px rgba(224, 122, 95, 0.28);
}

.clock-label {
  font-size: 14px;
  font-weight: 600;
  color: #2c3e50;
}

.clock-time {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #3d5a80;
  letter-spacing: 1px;
}

.clock.active .clock-time {
  color: #e07a5f;
}

.turn-hint {
  font-size: 13px;
  color: #9aa3b2;
  margin: 12px 0;
  text-align: center;
}

/* 按钮 */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 540px;
  margin-top: 6px;
}

.btn {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  height: 48px;
  line-height: 48px;
  border: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
  padding: 0;
}

.btn:active {
  transform: translateY(2px) scale(0.98);
}

.btn.ghost {
  background: #e3edf9;
  color: #2f5681;
  box-shadow: 0 6px 16px rgba(61, 90, 128, 0.2);
}

.btn.danger {
  background: #fdecea;
  color: #e05545;
  box-shadow: 0 6px 16px rgba(224, 85, 69, 0.18);
}

.btn.primary {
  background: #e4f6ea;
  color: #1f9e57;
  box-shadow: 0 6px 16px rgba(46, 158, 91, 0.2);
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 设置弹层 */
.setup-mask {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.setup-card {
  width: 82vw;
  max-width: 420px;
  background: #ffffff;
  border-radius: 22px;
  padding: 28px 24px 24px;
  box-shadow: 0 20px 60px rgba(44, 62, 80, 0.28);
}

.setup-title {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
  text-align: center;
}

.setup-sub {
  font-size: 13px;
  color: #9aa3b2;
  text-align: center;
  margin-top: 6px;
}

.setup-options {
  display: flex;
  gap: 14px;
  margin: 22px 0 16px;
}

.opt {
  flex: 1;
  padding: 20px 12px;
  border-radius: 14px;
  background: #f4f7fb;
  border: 2px solid transparent;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.opt.on {
  background: linear-gradient(135deg, #3d5a80, #4a6fa5);
  border-color: #3d5a80;
}

.opt.on .opt-name,
.opt.on .opt-desc {
  color: #ffffff;
}

.opt-name {
  font-size: 18px;
  font-weight: 700;
  color: #2c3e50;
}

.opt-desc {
  font-size: 12px;
  color: #9aa3b2;
  margin-top: 6px;
}

.setup-start {
  width: 100%;
}

/* 结果弹窗 */
.result-mask {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.result-card {
  width: 78vw;
  max-width: 380px;
  background: #ffffff;
  border-radius: 22px;
  padding: 36px 24px 28px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(44, 62, 80, 0.32);
}

.result-emoji {
  font-size: 60px;
  line-height: 1;
}

.result-title {
  margin-top: 12px;
  font-size: 26px;
  font-weight: 800;
  color: #2c3e50;
}

.result-card.win .result-title {
  color: #2e9e5b;
}

.result-card.lose .result-title {
  color: #e05545;
}

.result-card.draw .result-title {
  color: #6c757d;
}

.result-text {
  margin-top: 8px;
  font-size: 15px;
  color: #7a8499;
}

.result-btns {
  display: flex;
  gap: 14px;
  margin-top: 24px;
}

/* ===================== 五子棋 ===================== */
.gomoku .board-wrap {
  position: relative;
  width: min(92vw, 540px);
  height: min(92vw, 540px);
  margin: 8px 0 12px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(44, 62, 80, 0.14);
  background: #fbf3e4;
  container-type: size;
}

.gomoku .grid {
  position: absolute;
  left: 6.25%;
  top: 6.25%;
  width: 87.5%;
  height: 87.5%;
  box-sizing: border-box;
  border: 1px solid #c9a36a;
  background-image: linear-gradient(to right, #c9a36a 1px, transparent 1px),
    linear-gradient(to bottom, #c9a36a 1px, transparent 1px);
  background-size: calc(100% / 14) calc(100% / 14);
}

.gomoku .star {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b08a4f;
  transform: translate(-50%, -50%);
}

.gomoku .board {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}

/* ===================== 中国象棋 ===================== */
.xq .board {
  position: relative;
  width: min(92vw, 540px);
  height: calc(min(92vw, 540px) * 10 / 9);
  border-radius: 12px;
  background: linear-gradient(160deg, #fdf6e3, #f7ecd2);
  box-shadow: 0 14px 36px rgba(44, 62, 80, 0.14), inset 0 0 0 1px rgba(185, 142, 85, 0.35);
  overflow: hidden;
  container-type: size;
}

.xq .grid {
  position: absolute;
  left: 5.5556%;
  top: 5%;
  width: 88.8889%;
  height: 90%;
}

.xq .hline,
.xq .vline {
  position: absolute;
  background: #b98e55;
}

.xq .hline {
  left: 0;
  width: 100%;
  height: 1px;
  transform: translateY(-50%);
}

.xq .vline {
  width: 1px;
  transform: translateX(-50%);
}

.xq .diag {
  position: absolute;
  left: 50%;
  width: 35.36%;
  height: 1px;
  background: #b98e55;
}

.xq .river {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  transform: translateY(-50%);
  display: flex;
  justify-content: space-around;
  font-size: 18px;
  color: rgba(160, 120, 70, 0.55);
  letter-spacing: 8px;
  font-weight: 600;
  pointer-events: none;
}

.xq .piece {
  position: absolute;
  width: 11%;
  height: 11%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6cqw;
  font-weight: 700;
  font-family: "STKaiti", "KaiTi", serif;
  background: radial-gradient(circle at 32% 28%, #fffdf5, #f3e2bd 68%, #dfc38c);
  box-shadow: 0 2px 6px rgba(80, 50, 10, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  z-index: 2;
  cursor: pointer;
}

.xq .piece.red {
  color: #c0392b;
  border: 1px solid rgba(192, 57, 43, 0.55);
}

.xq .piece.black {
  color: #2c3e50;
  border: 1px solid rgba(44, 62, 80, 0.55);
}

.xq .piece.sel {
  box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.85), 0 4px 10px rgba(80, 50, 10, 0.4);
  transform: translate(-50%, -56%) scale(1.06);
  z-index: 3;
}

.xq .piece.from {
  box-shadow: 0 0 0 4px rgba(224, 80, 70, 0.9), 0 0 12px 3px rgba(224, 80, 70, 0.6),
    inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  z-index: 4;
}

.xq .piece.last {
  box-shadow: 0 0 0 4px rgba(224, 80, 70, 0.95), 0 0 8px 2px rgba(224, 80, 70, 0.5),
    inset 0 0 0 2px rgba(255, 255, 255, 0.6);
  animation: lastPulse 1.1s ease-in-out infinite;
  z-index: 5;
}

@keyframes lastPulse {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(224, 80, 70, 0.95), 0 0 8px 2px rgba(224, 80, 70, 0.5),
      inset 0 0 0 2px rgba(255, 255, 255, 0.6);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(224, 80, 70, 1), 0 0 12px 4px rgba(224, 80, 70, 0.65),
      inset 0 0 0 2px rgba(255, 255, 255, 0.6);
  }
}

.xq .dot {
  position: absolute;
  width: 3.6%;
  height: 3.6%;
  border-radius: 50%;
  background: rgba(61, 90, 128, 0.55);
  transform: translate(-50%, -50%);
  z-index: 4;
  cursor: pointer;
}

.xq .dot.cap {
  width: 10%;
  height: 10%;
  background: transparent;
  border: 3px solid rgba(224, 122, 95, 0.9);
  box-sizing: border-box;
}

.xq .last-mark {
  position: absolute;
  width: 6%;
  height: 6%;
  border: 3px solid rgba(224, 80, 70, 0.95);
  transform: translate(-50%, -50%) rotate(45deg);
  z-index: 1;
}

.xq .last-mark.to {
  width: 11%;
  height: 11%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* ===================== 国际象棋 ===================== */
.ch .board {
  width: min(92vw, 540px);
  height: min(92vw, 540px);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(44, 62, 80, 0.16);
  display: flex;
  flex-direction: column;
  transition: transform 0.35s ease;
  container-type: size;
}

.ch .board.flipped {
  transform: rotate(180deg);
}

.ch .board.flipped .pc {
  transform: rotate(180deg);
}

.ch .rank {
  flex: 1;
  display: flex;
}

.ch .sq {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ch .sq.light {
  background: #f0d9b5;
}

.ch .sq.dark {
  background: #b58863;
}

.ch .sq.last::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(155, 199, 0, 0.28);
}

.ch .sq.sel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(108, 92, 231, 0.32);
}

.ch .sq.chk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(231, 76, 60, 0.7) 15%, rgba(231, 76, 60, 0) 75%);
}

.ch .pc {
  font-size: 8.6cqw;
  line-height: 1;
  z-index: 1;
  pointer-events: none;
}

.ch .pc.w {
  color: #ffffff;
  text-shadow: 0 0 1px #555, 0 1px 2px rgba(0, 0, 0, 0.45);
}

.ch .pc.b {
  color: #35322e;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.ch .mdot {
  position: absolute;
  width: 3cqw;
  height: 3cqw;
  border-radius: 50%;
  background: rgba(44, 62, 80, 0.35);
  z-index: 2;
}

.ch .mring {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 3px solid rgba(224, 122, 95, 0.85);
  box-sizing: border-box;
  z-index: 2;
}

/* 升变选择弹窗 */
.promo-mask {
  position: fixed;
  inset: 0;
  background: rgba(44, 62, 80, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.promo-card {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(44, 62, 80, 0.3);
}

.promo-card .promo-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: #2c3e50;
}

.promo-opts {
  display: flex;
  gap: 12px;
}

.promo-opts .promo-btn {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: none;
  background: #f0d9b5;
  font-size: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-opts .promo-btn:active {
  transform: scale(0.95);
}
