:root {
  --bg-page: #f6f8f1;
  --dot-color: #dce5d4;
  --green-dark: #2c5e42;
  --green-main: #357a56;
  --green-shadow: #23543a;
  --green-soft: #ebf2e6;
  --green-border: #c5d9bd;
  --sand-main: #b4a06d;
  --sand-shadow: #8e7d50;
  --yellow-main: #f8dc8f;
  --yellow-shadow: #d9b65b;
  --text-main: #2a4a38;
  --text-sub: #7a8d80;
  --card-bg: #ffffff;
  --card-border: #e5ece0;
  --radius-lg: 24px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  background-color: var(--bg-page);
  background-image: radial-gradient(var(--dot-color) 2.2px, transparent 2.2px);
  background-size: 36px 36px;
  overscroll-behavior: none;
}

#app {
  max-width: 460px;
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
}

.view {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  padding: 18px 18px 28px;
}

.view.active {
  display: flex;
}

/* ==================== 首页 ==================== */
.home-header {
  text-align: center;
  margin-top: 18px;
}

.en-subtitle {
  font-size: 12px;
  letter-spacing: 5px;
  color: #7b8f82;
  margin-bottom: 4px;
}

.brand-title {
  font-size: 42px;
  font-weight: 900;
  color: var(--green-dark);
  letter-spacing: 6px;
  text-shadow: 0 3px 0 rgba(44, 94, 66, 0.14);
}

.brand-slogan {
  font-size: 15px;
  color: var(--text-sub);
  margin-top: 8px;
}

.home-stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 34px;
  gap: 8px;
}

.side-right-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.side-action {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--green-dark);
  cursor: pointer;
  padding: 6px;
  transition: transform 0.15s ease;
}

.side-action:active {
  transform: scale(0.92);
}

.side-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.side-icon svg {
  width: 30px;
  height: 30px;
}

.side-label {
  font-size: 13px;
  font-weight: 700;
}

.side-sub {
  font-size: 11px;
  color: var(--text-sub);
}

/* 首页中央双棋子视觉 */
.hero-board-wrap {
  position: relative;
  width: 210px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-plate {
  position: absolute;
  bottom: 14px;
  width: 196px;
  height: 54px;
  border-radius: 50%;
  background: #dfebd5;
  transform: rotate(-4deg);
}

.hero-mini-board {
  position: relative;
  width: 152px;
  height: 108px;
  border-radius: 16px;
  background-color: #ebd5a7;
  background-image:
    linear-gradient(to right, rgba(164, 134, 82, 0.28) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(164, 134, 82, 0.28) 1px, transparent 1px);
  background-size: 22px 22px;
  border: 4px solid #dfc18a;
  box-shadow: 0 10px 0 #d2b174, 0 16px 24px rgba(44, 94, 66, 0.12);
  transform: rotate(-6deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-piece {
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 8px 16px rgba(34, 58, 45, 0.22);
}

.hero-piece img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-piece.piece-p1 {
  left: -10px;
  top: 8px;
  border: 4px solid var(--green-dark);
  background: #2f433a;
}

.hero-piece.piece-p2 {
  right: -12px;
  top: -16px;
  border: 4px solid #ffffff;
  background: #ffffff;
}

.sparkle {
  position: absolute;
  font-size: 20px;
  pointer-events: none;
}
.sparkle.s1 {
  top: 12px;
  left: 6px;
  color: #e0be59;
}
.sparkle.s2 {
  bottom: 36px;
  right: 2px;
  color: #7ab08d;
  font-size: 22px;
}

/* 首页模式主按钮 */
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: auto;
}

.mode-btn {
  width: 100%;
  border: none;
  border-radius: 20px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.mode-btn:active {
  transform: translateY(3px);
}

.mode-btn-primary {
  background: var(--green-main);
  color: #ffffff;
  box-shadow: 0 5px 0 var(--green-shadow);
}

.mode-btn-secondary {
  background: var(--sand-main);
  color: #2f2818;
  box-shadow: 0 5px 0 var(--sand-shadow);
}

.mode-btn-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mode-avatar-pair {
  display: flex;
  align-items: center;
}

.mini-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: #fff;
}

.mini-avatar.overlap {
  margin-left: -10px;
}

.vs-dot {
  margin-left: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mode-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.mode-title {
  font-size: 18px;
  font-weight: 800;
}

.mode-desc {
  font-size: 12px;
  opacity: 0.82;
}

.mode-arrow {
  font-size: 20px;
  font-weight: 700;
}

.home-footer-tip {
  text-align: center;
  font-size: 13px;
  color: #8c9c90;
  margin-top: 24px;
}

/* ==================== 公共顶部栏 ==================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(44, 94, 66, 0.14);
  color: var(--green-dark);
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.top-title-wrap {
  text-align: center;
  flex: 1;
}

.top-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--green-dark);
}

.top-meta {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.pill-mini-btn,
.tag-badge {
  font-size: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  border: 1px solid var(--green-border);
  font-weight: 600;
}

.pill-mini-btn {
  cursor: pointer;
}

/* ==================== 对弈页 ==================== */
.players-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.player-card {
  flex: 1;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  opacity: 0.72;
}

.player-card.active {
  opacity: 1;
  border-color: var(--green-main);
  background: #f2f8ee;
  box-shadow: 0 4px 12px rgba(53, 122, 86, 0.12);
}

.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
}

.player-avatar.p1-ring {
  border: 2.5px solid var(--green-dark);
}

.player-avatar.p2-ring {
  border: 2.5px solid #c5b690;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.player-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-tag {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

.player-card.active .player-tag {
  color: var(--green-main);
  font-weight: 600;
}

.vs-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
}

/* 棋盘容器 */
.board-shell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  padding: 10px;
  background: #eef4e6;
  border: 1px solid rgba(44, 94, 66, 0.12);
  box-shadow: 0 8px 24px rgba(44, 94, 66, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 16px;
}

.board-shell canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
  touch-action: manipulation;
  cursor: pointer;
}

.game-controls {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.ctrl-btn {
  flex: 1;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1.5px solid var(--green-border);
  background: #ffffff;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.ctrl-btn:active {
  transform: scale(0.97);
}

.ctrl-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ctrl-btn-accent {
  background: var(--green-main);
  border-color: var(--green-main);
  color: #ffffff;
}

/* ==================== 我的棋谱 & 排行 ==================== */
.stats-card {
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  border-radius: 20px;
  padding: 18px 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  margin-bottom: 18px;
}

.stat-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--green-dark);
}

.stat-label {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
}

.section-heading {
  font-size: 15px;
  font-weight: 800;
  color: var(--green-dark);
  margin-bottom: 10px;
}

.filter-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-tab {
  flex: 1;
  padding: 9px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: #ffffff;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--green-soft);
  border-color: #8ab38f;
  color: var(--green-dark);
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.record-item {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 3px 10px rgba(44, 94, 66, 0.04);
  cursor: pointer;
}

.record-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.result-chip {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}

.chip-win {
  background: #e1f0dc;
  color: #2f6d43;
}

.chip-lose {
  background: #f0e8df;
  color: #846f5c;
}

.chip-draw {
  background: #e6ecf0;
  color: #5b6d78;
}

.chip-rank {
  background: #f7d98b;
  color: #6b5218;
}

.record-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.record-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 3px;
}

.record-action {
  font-size: 13px;
  font-weight: 700;
  color: var(--green-main);
}

.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-sub);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  border: 1px dashed var(--green-border);
}

.list-footnote {
  text-align: center;
  font-size: 12px;
  color: #93a397;
  margin: 18px 0 82px;
}

.bottom-fixed-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-page) 75%, transparent);
}

.yellow-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 15px;
  font-size: 16px;
  font-weight: 800;
  color: #463a19;
  background: var(--yellow-main);
  box-shadow: 0 4px 0 var(--yellow-shadow);
  cursor: pointer;
}

.yellow-btn:active {
  transform: translateY(2px);
}

/* ==================== 排行榜 ==================== */
.rank-type-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.rank-tab {
  flex: 1;
  padding: 11px;
  border-radius: 16px;
  border: 1.5px solid var(--card-border);
  background: #ffffff;
  color: var(--text-sub);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.rank-tab.active {
  background: var(--green-soft);
  border-color: #8ab38f;
  color: var(--green-dark);
}

.my-rank-card {
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.my-rank-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--green-dark);
}

.my-rank-val strong {
  font-size: 20px;
  color: var(--green-dark);
}

/* ==================== 复盘页 ==================== */
.replay-kicker {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 2px;
}

.replay-badge-wrap {
  text-align: center;
  margin-bottom: 10px;
}

.replay-pill {
  display: inline-block;
  padding: 6px 20px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.replay-meta {
  text-align: center;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 14px;
}

/* ==================== 弹窗 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 38, 30, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 360px;
  background: #fdfef9;
  border-radius: 26px;
  padding: 26px 20px 22px;
  position: relative;
  text-align: center;
  box-shadow: 0 20px 44px rgba(18, 38, 28, 0.24);
}

.modal-sm {
  max-width: 320px;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #7c8d82;
  font-size: 18px;
  cursor: pointer;
}

.modal-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 8px;
  color: #6b916f;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--green-dark);
}

.modal-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 4px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 14px;
}

.theme-option {
  background: #ffffff;
  border: 2px solid #e5ece0;
  border-radius: 16px;
  padding: 8px 6px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.theme-option.active {
  border-color: #6e9c76;
  background: #f2f7ee;
}

.theme-preview {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  background-size: 14px 14px;
}

.theme-preview-green {
  background-color: #dce7ce;
  background-image:
    linear-gradient(to right, rgba(114, 144, 102, 0.32) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(114, 144, 102, 0.32) 1px, transparent 1px);
}

.theme-preview-wood {
  background-color: #ebd5a7;
  background-image:
    linear-gradient(to right, rgba(154, 121, 68, 0.34) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(154, 121, 68, 0.34) 1px, transparent 1px);
}

.theme-preview-blue {
  background-color: #6f838a;
  background-image:
    linear-gradient(to right, rgba(220, 232, 236, 0.3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(220, 232, 236, 0.3) 1px, transparent 1px);
}

.check-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #5b825d;
  color: #ffffff;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
}

.theme-option.active .check-dot {
  display: flex;
}

.tp-p1,
.tp-p2 {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.tp-p1 {
  top: 26%;
  left: 22%;
  border: 2px solid var(--green-dark);
}

.tp-p2 {
  bottom: 22%;
  right: 20%;
  border: 2px solid #ffffff;
}

.theme-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-note {
  background: #f1f5ec;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
  color: #64786b;
  margin-bottom: 16px;
}

.primary-pill-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 14px;
  background: var(--green-main);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--green-shadow);
  cursor: pointer;
}

.primary-pill-btn:active {
  transform: translateY(2px);
}

.modal-tiny-tip {
  font-size: 11px;
  color: #93a397;
  margin-top: 10px;
}

/* 难度选择 */
.diff-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.diff-btn {
  border: 1.5px solid var(--green-border);
  background: #ffffff;
  border-radius: 16px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.diff-btn:active {
  background: var(--green-soft);
}

.diff-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--green-dark);
}

.diff-desc {
  font-size: 12px;
  color: var(--text-sub);
}

/* 结算弹窗 */
.result-avatar-wrap {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 10px;
  border: 3px solid var(--green-main);
  box-shadow: 0 6px 14px rgba(44, 94, 66, 0.16);
}

.result-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-sub-actions {
  display: flex;
  gap: 10px;
}
