/* 中国象棋 · 全站样式 v2 —— 古典木质风 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #b3271d; --primary-dark: #8e1f17;
  --gold: #d9a441; --gold-soft: #f0d9a7;
  --bg: #f3ecdd; --card: #fffdf8; --line: #e4dac5;
  --text: #2b2620; --muted: #8a7f6e; --green: #2e7d32;
  --ink: #26211b;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text); min-height: 100vh;
  background:
    radial-gradient(1100px 460px at 50% -120px, rgba(217,164,65,.16), transparent 62%),
    linear-gradient(180deg, #f7f1e3 0%, #efe5d0 100%);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(179,39,29,.16); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d8cbae; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 顶部导航 ---------- */
.navbar {
  background: linear-gradient(180deg, #2d271f, #1e1913);
  color: #f2ead8; display: flex; align-items: center; gap: 22px;
  padding: 0 26px; height: 58px; position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid rgba(217,164,65,.28);
  box-shadow: 0 2px 14px rgba(30,20,5,.28);
}
.navbar .logo {
  font-size: 20px; font-weight: 700; letter-spacing: 2px;
  display: flex; align-items: center; gap: 10px;
  font-family: "KaiTi", "STKaiti", serif;
}
.navbar .logo .dot {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #e2543f, var(--primary) 60%, #7c150e);
  border: 2px solid var(--gold-soft); box-shadow: 0 0 10px rgba(217,164,65,.45);
}
.navbar .logo .sub { font-weight: 400; font-size: 12px; opacity: .6; letter-spacing: 0; }
.navbar .links { display: flex; gap: 18px; font-size: 14px; }
.navbar .links a { position: relative; padding: 4px 0; opacity: .82; transition: opacity .15s, color .15s; }
.navbar .links a:hover { opacity: 1; color: var(--gold-soft); }
.navbar .links a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: -2px; height: 2px;
  background: var(--gold); border-radius: 1px; transition: right .22s;
}
.navbar .links a:hover::after { right: 0; }
.navbar .spacer { flex: 1; }
.navbar .userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar {
  width: 27px; height: 27px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #d94f38, var(--primary) 65%);
  color: #fff7ea; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; border: 1.5px solid rgba(240,217,167,.55);
}

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 8px; padding: 9px 20px; font-size: 14px; font-weight: 500;
  background: linear-gradient(180deg, #c23a28, var(--primary) 55%, #a02015);
  color: #fff; transition: transform .12s, box-shadow .12s, filter .12s;
  box-shadow: 0 2px 6px rgba(140,25,15,.28), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(140,25,15,.32), inset 0 1px 0 rgba(255,255,255,.18); }
.btn:active { transform: translateY(0); filter: brightness(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: grayscale(.3); }
.btn.ghost { background: transparent; color: inherit; border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover { border-color: var(--gold); color: var(--primary); filter: none; }
.btn.warn { background: linear-gradient(180deg, #c96a2b, #a4571e);
  box-shadow: 0 2px 6px rgba(150,70,20,.28), inset 0 1px 0 rgba(255,255,255,.15); }
.btn.small { padding: 5px 13px; font-size: 13px; border-radius: 7px; }

/* ---------- 布局 ---------- */
.container { max-width: 1100px; margin: 20px auto; padding: 0 16px; }
.game-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; box-shadow: 0 2px 12px rgba(90,60,20,.07);
  animation: rise .4s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 页头 ---------- */
.hero { text-align: center; padding: 22px 0 14px; }
.hero h1 {
  font-family: "KaiTi", "STKaiti", serif; font-size: 36px; font-weight: 700;
  letter-spacing: 12px; text-indent: 12px; color: var(--ink);
  text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
.hero .tagline { color: var(--muted); font-size: 13.5px; margin-top: 8px; letter-spacing: 1.5px; }
.hero .hero-ornament { color: var(--gold); letter-spacing: 6px; font-size: 12px; margin-top: 10px; opacity: .9; }
.engine-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); background: #fffdf8; border-radius: 999px;
  padding: 3px 12px; margin-left: 8px; vertical-align: 1px;
}
.engine-pill .dot2 { width: 8px; height: 8px; border-radius: 50%; background: #23a24a;
  box-shadow: 0 0 6px #23a24a; }
.engine-pill.off .dot2 { background: #c23a28; box-shadow: none; }
.footer { text-align: center; color: var(--muted); font-size: 12px;
  padding: 26px 0 18px; letter-spacing: 1px; opacity: .85; }

/* ---------- 棋盘 ---------- */
.board-wrap {
  position: relative; padding: 10px; border-radius: 14px;
  background: linear-gradient(148deg, #63452a 0%, #4a3218 50%, #38260f 100%);
  box-shadow: 0 12px 34px rgba(55,35,8,.38), inset 0 1px 0 rgba(255,255,255,.10),
              inset 0 -1px 0 rgba(0,0,0,.35);
}
#board {
  display: block; border-radius: 6px; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(30,15,0,.45), 0 3px 10px rgba(30,15,0,.3);
  max-width: 100%; height: auto; touch-action: manipulation;
}
.thinking-badge {
  position: absolute; top: 18px; right: 18px; z-index: 2;
  background: rgba(28,22,15,.88); color: var(--gold-soft);
  font-size: 12px; letter-spacing: 1px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid rgba(217,164,65,.35); display: none; align-items: center; gap: 4px;
}
.thinking-badge.on { display: inline-flex; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- 侧栏 ---------- */
.side { width: 330px; flex: 1; min-width: 280px; display: flex; flex-direction: column; gap: 16px; }
.side h3 { font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 10px; letter-spacing: 1px; }
.side .row { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.side-group label { font-size: 13px; color: var(--muted); width: 44px; flex: none; }
.level-group { display: flex; gap: 6px; flex-wrap: wrap; }
.level-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; transition: all .15s;
}
.level-btn:hover { border-color: var(--gold); }
.level-btn.active {
  background: linear-gradient(180deg, #c23a28, var(--primary)); color: #fff;
  border-color: var(--primary-dark); box-shadow: 0 2px 8px rgba(140,25,15,.3);
}
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }

/* ---------- 状态行 ---------- */
.status-line {
  font-size: 14px; padding: 10px 14px; background: #faf6ec; border-radius: 8px;
  border-left: 4px solid var(--gold); transition: background .2s, border-color .2s;
}
.status-line.you { border-left-color: var(--green); }
.status-line.danger { border-left-color: var(--primary); background: #fbeeec; }
.status-line.over { border-left-color: #9a938a; background: #f4f1ea; }

/* ---------- 着法记录 ---------- */
.moves-box { max-height: 252px; overflow-y: auto; font-size: 13.5px; padding-right: 2px; }
.moves-box .mvrow { display: flex; gap: 8px; padding: 1px 6px; border-radius: 6px; align-items: baseline; }
.moves-box .mvrow:hover { background: #f6efdd; }
.moves-box .mvnum { color: var(--muted); width: 32px; text-align: right; flex: none; font-size: 12px; }
.moves-box .mv { line-height: 2; }
.moves-box .mv.engine { color: #6b5f4c; }
.moves-box .mv.player { color: var(--text); font-weight: 600; }

/* ---------- 表单 ---------- */
.form-card { max-width: 380px; margin: 60px auto; }
.form-card h2 {
  margin-bottom: 18px; font-size: 24px; text-align: center;
  font-family: "KaiTi", "STKaiti", serif; letter-spacing: 4px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fffefb;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,164,65,.18); }
.form-tip { font-size: 13px; color: var(--muted); margin-top: 12px; text-align: center; }
.form-tip a { color: var(--primary); }
.err { color: var(--primary); font-size: 13px; margin-top: 8px; min-height: 18px; text-align: center; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(24,16,8,.55); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-mask.on { display: flex; }
.modal {
  background: var(--card); border: 1px solid var(--gold-soft); border-radius: 14px;
  padding: 28px 32px; width: 360px; text-align: center;
  box-shadow: 0 24px 70px rgba(40,20,0,.4);
  animation: pop .24s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.86) translateY(12px); } to { opacity: 1; transform: none; } }
.modal h2 {
  margin-bottom: 8px; font-size: 26px; letter-spacing: 3px;
  font-family: "KaiTi", "STKaiti", serif;
}
.modal p { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 9px 10px;
  border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #efe8d6; white-space: nowrap; }
tr:hover td { background: #faf5e8; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ---------- 统计卡片 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  box-shadow: 0 2px 10px rgba(90,60,20,.06); animation: rise .4s ease both;
}
.stat .num { font-size: 27px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 1.5px 9px; border-radius: 999px; font-size: 12px; }
.tag.win { background: #e6f4e6; color: var(--green); }
.tag.loss { background: #fbe9e7; color: var(--primary); }
.tag.draw { background: #f0f0f0; color: #666; }
.tag.active { background: #e8f0fb; color: #1565c0; }
.tag.abandoned { background: #f0f0f0; color: #999; }
.tag.red { background: #fbe9e7; color: var(--primary); }
.tag.black { background: #eceff1; color: #37474f; }
.tag.admin { background: #fff3cd; color: #8a6d00; }
.tag.banned { background: #fbe9e7; color: var(--primary); }
.tag.ok { background: #e6f4e6; color: var(--green); }

/* ---------- 页签 ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 2px solid var(--line); }
.tab { padding: 10px 20px; font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer;
  transition: color .15s, border-color .15s; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); font-weight: 600; border-color: var(--primary); }

/* ---------- 回放 ---------- */
.replay-controls { display: flex; gap: 8px; align-items: center; justify-content: center;
  margin: 12px 0; flex-wrap: wrap; }
.guest-tip {
  background: linear-gradient(180deg, #fff9e8, #fdf2d2); border: 1px solid #ecd9a0;
  color: #7a6410; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
}
.guest-tip a { color: var(--primary); font-weight: 600; }
.muted { color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  .game-layout { flex-direction: column; align-items: stretch; }
  .side { width: 100%; }
  .navbar { padding: 0 12px; gap: 10px; }
  .navbar .logo .sub { display: none; }
  .hero h1 { font-size: 28px; letter-spacing: 8px; }
  .board-wrap { padding: 6px; }
}
