:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --line: #e3ddd0;
  --ink: #2a2622;
  --dim: #8a8177;
  --red: #b23b2e;
  --red-soft: #e8c4bd;
  --black: #2f2f33;
  --green: #2e7d4f;
  --wood: #efd9a8;
  --wood-2: #e6c98f;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  background: linear-gradient(145deg, #b23b2e, #8e2a1f);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; font-family: "KaiTi", "STKaiti", serif;
  box-shadow: 0 4px 12px rgba(178, 59, 46, .28);
}
h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--dim); }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--dim); flex: none; }

.user-chip { display: inline-flex; align-items: center; gap: 8px; }
.user-chip .uname { color: var(--ink); font-weight: 600; font-size: 13px; }
.user-chip .urec { font-size: 12px; }

.grid { display: grid; grid-template-columns: minmax(0, 560px) minmax(300px, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.resumebar {
  display: flex; align-items: center; gap: 10px;
  background: #fff8e6; border: 1px solid #f0dfae; color: #7a6220;
  border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 10px;
}
.resumebar button { margin-left: auto; }

.board-wrap {
  position: relative;
  background: linear-gradient(160deg, var(--wood), var(--wood-2));
  border-radius: 14px; padding: 6px;
  box-shadow: 0 10px 26px rgba(90, 70, 40, .18), inset 0 0 0 1px rgba(120, 90, 40, .18);
}
#board { display: block; max-width: 100%; height: auto; border-radius: 10px; cursor: pointer; touch-action: manipulation; }

.banner {
  position: absolute; inset: 6px; border-radius: 10px;
  background: rgba(28, 24, 20, .72); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font-size: 26px; font-weight: 700; letter-spacing: 2px;
  backdrop-filter: blur(3px);
}

.statusbar {
  display: flex; align-items: center; gap: 9px;
  margin: 12px 2px 10px; font-size: 14px; min-height: 22px;
}
.turn-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(178,59,46,.15); }
.turn-dot.black { background: var(--black); box-shadow: 0 0 0 3px rgba(47,47,51,.14); }
.turn-dot.gray { background: #bbb; box-shadow: none; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.save-text { margin-left: auto; font-size: 12px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  font-family: inherit;
}
button:hover { background: #faf7f0; border-color: #d6cebd; }
button:active { transform: translateY(1px); }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover { background: #9e3327; }
button.ghost { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.field { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
select, input[type="text"], input[type="password"], .auth-form input {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 10px; border-radius: 9px; font-size: 13px; font-family: inherit;
}
.check { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 5px; cursor: pointer; }

.panel { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; box-shadow: 0 2px 10px rgba(80, 70, 50, .05);
}
.card h2 { font-size: 13px; margin: 0 0 10px; letter-spacing: .5px; color: #6d6459; font-weight: 600; }
.card.grow .moves { max-height: 210px; overflow-y: auto; }

.winrow { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.tag { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; }
.tag.red { background: var(--red); }
.tag.black { background: var(--black); }
.bar { flex: 1; height: 12px; border-radius: 8px; background: #efe9dd; overflow: hidden; }
.fill { height: 100%; transition: width .45s cubic-bezier(.2,.7,.3,1); }
.fill.red { background: linear-gradient(90deg, #d4645a, #b23b2e); }
.fill.black { background: linear-gradient(90deg, #6b6b73, #2f2f33); }
.pct { width: 44px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: #5c544a; }
.eval { margin-top: 4px; font-size: 13px; color: var(--dim); }

.suggests { list-style: none; margin: 0; padding: 0; }
.suggests li {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px;
  font-size: 14px; border: 1px solid transparent;
}
.suggests li:hover { background: #faf7f0; }
.suggests li .idx { width: 18px; color: var(--dim); font-size: 12px; }
.suggests li .mv { font-family: "KaiTi", "STKaiti", serif; font-size: 17px; font-weight: 600; }
.suggests li .sc { margin-left: auto; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.suggests li .play { padding: 3px 9px; font-size: 12px; border-radius: 7px; }

/* 推荐着法 */
.recommend { padding: 8px 10px; border-radius: 9px; background: #f4faf5; border: 1px solid #d6eadd; }
.recommend .rec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recommend .rec-mv { font-family: "KaiTi", "STKaiti", serif; font-size: 22px; font-weight: 700; color: var(--green); }
.recommend .rec-score { margin-top: 4px; font-size: 12px; color: #5c7a63; }
.taglist { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.mtag {
  display: inline-block; padding: 1px 6px; border-radius: 5px; font-size: 11px;
  background: #e7f2ea; color: #2e7d4f; border: 1px solid #cfe5d7; white-space: nowrap;
}
.mtag.small { font-size: 10px; padding: 0 5px; }
.mtag.warn { background: #fdeeea; color: #b23b2e; border-color: #f2cfc7; }
.pvline { margin: 7px 0 2px; font-size: 12px; color: var(--dim); line-height: 1.7; }
.pvline .mv { font-family: "KaiTi", "STKaiti", serif; font-size: 14px; color: #6d6459; }

.verdicts { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow-y: auto; }
.verdicts li { padding: 7px 0; border-bottom: 1px dashed #eee7da; font-size: 13px; line-height: 1.55; }
.verdicts li:last-child { border-bottom: none; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; color: #fff; margin-right: 5px; vertical-align: 1px; }
.v-best { background: #2e7d4f; }
.v-good { background: #4a8f3c; }
.v-ok { background: #c08a1e; }
.v-bad { background: #d2691e; }
.v-blunder { background: #b23b2e; }
.verdicts .mv { font-family: "KaiTi", "STKaiti", serif; font-size: 15px; }
.verdicts .tip { color: var(--dim); }

.moves { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.moves li { display: flex; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.moves li:nth-child(odd) { background: #faf7f0; }
.moves li .n { width: 24px; color: var(--dim); font-variant-numeric: tabular-nums; }
.moves li .m { font-family: "KaiTi", "STKaiti", serif; font-size: 15px; }
.moves li.red .m { color: var(--red); }
.moves li.black .m { color: var(--black); }

.leaderboard { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.leaderboard li { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-bottom: 1px dashed #f0ebe0; }
.leaderboard li:last-child { border-bottom: none; }
.leaderboard .rk { width: 20px; color: var(--dim); font-variant-numeric: tabular-nums; }
.leaderboard .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard .rec { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.leaderboard li.me { background: #fdf6ee; border-radius: 7px; }
.leaderboard li.me .nm { font-weight: 700; }

/* ---------- auth overlay ---------- */
.auth-wrap {
  position: fixed; inset: 0; z-index: 50;
  background: linear-gradient(160deg, rgba(38, 30, 22, .92), rgba(60, 42, 28, .95));
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(4px);
}
.auth-card {
  width: 100%; max-width: 380px; background: #fffdf8; border-radius: 16px;
  padding: 26px 24px 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  animation: pop .22s ease-out;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.auth-logo {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  background: linear-gradient(145deg, #b23b2e, #8e2a1f); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-family: "KaiTi", "STKaiti", serif;
}
.auth-card h2 { text-align: center; font-size: 17px; margin: 0 0 16px; font-weight: 600; }
.tabs { display: flex; gap: 6px; background: #f2ece0; border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.tab {
  flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 8px;
  font-size: 14px; color: var(--dim); cursor: pointer;
}
.tab.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.auth-form { display: flex; flex-direction: column; gap: 11px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #5c544a; }
.auth-form input { width: 100%; padding: 10px 12px; font-size: 14px; }
.auth-form label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--dim); }
.auth-form label.check input { width: auto; }
button.block { width: 100%; padding: 11px 0; font-size: 15px; border-radius: 10px; margin-top: 4px; }
.auth-msg { min-height: 20px; margin-top: 10px; font-size: 13px; color: #b23b2e; text-align: center; }
.auth-msg.ok { color: var(--green); }
.auth-note { margin-top: 6px; font-size: 12px; color: var(--dim); line-height: 1.6; text-align: center; }
