/* ============================================================
 * 小棋手王国 · 儿童卡通视觉样式
 * ============================================================ */
:root {
  --cream: #fff6e6;
  --ink: #5a4636;
  --ink-soft: #8a7460;
  --green: #7bc47f;
  --green-d: #58a664;
  --orange: #ffb457;
  --orange-d: #ef9a3c;
  --blue: #73a8ff;
  --blue-d: #5689e0;
  --red: #ff8a80;
  --board-light: #f7e8cc;
  --board-dark: #cda571;
  --board-sel: #ffe28a;
  --board-last: #d9eab0;
  --board-check: #ef857c;
  --radius: 18px;
  --shadow: 0 6px 18px rgba(120, 85, 45, .14);
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI',
    'Microsoft YaHei', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, #ffe9c7 0, transparent 42%),
    radial-gradient(circle at 88% 90%, #e3f0ff 0, transparent 40%),
    var(--cream);
  background-attachment: fixed;
  line-height: 1.6;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }

#app { min-height: 100vh; }

.page-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 16px 40px;
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(255, 246, 230, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(150, 110, 60, .12);
}
.topbar-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  text-align: center;
  flex: 1;
}
.icon-btn {
  min-width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(.93); }

/* ---------------- 通用按钮 ---------------- */
.btn {
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  transition: transform .12s, filter .12s;
}
.btn:active { transform: scale(.95); }
.btn-primary {
  background: linear-gradient(180deg, var(--green), var(--green-d));
  color: #fff;
  box-shadow: 0 5px 0 var(--green-d), var(--shadow);
}
.btn-primary:active { box-shadow: 0 2px 0 var(--green-d); transform: translateY(3px); }
.btn-ghost {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---------------- 首页 ---------------- */
.home {
  max-width: 680px;
  margin: 0 auto;
  padding: 26px 18px 40px;
}
.home-hero {
  position: relative;
  text-align: center;
  padding: 26px 16px 30px;
}
.home-crown {
  width: 96px;
  height: 96px;
  margin: 0 auto 10px;
  border-radius: 28px;
  background: linear-gradient(160deg, var(--green), var(--green-d));
  color: #fff;
  font-size: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(88, 166, 100, .35);
  transform: rotate(-4deg);
}
.home-title { margin: 8px 0 2px; font-size: 32px; font-weight: 900; letter-spacing: 2px; }
.home-sub { margin: 0 0 14px; color: var(--ink-soft); font-size: 16px; }
.star-badge {
  display: inline-block;
  padding: 8px 20px;
  background: #fff;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.star-badge span { color: var(--orange-d); }

.home-cards { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.big-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 22px;
  color: #fff;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform .14s;
}
.big-card:active { transform: scale(.97); }
.bc-green { background: linear-gradient(135deg, var(--green), var(--green-d)); }
.bc-orange { background: linear-gradient(135deg, var(--orange), var(--orange-d)); }
.bc-blue { background: linear-gradient(135deg, var(--blue), var(--blue-d)); }
.bc-emoji { font-size: 38px; }
.bc-name { font-size: 21px; font-weight: 800; }
.bc-meta {
  grid-column: 2 / 4;
  font-size: 14px;
  opacity: .92;
}

/* ---------------- 单元标题 ---------------- */
.unit-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 10px;
  font-size: 17px;
  font-weight: 800;
}
.unit-title::after {
  content: '';
  flex: 1;
  height: 2px;
  border-radius: 2px;
  background: rgba(150, 110, 60, .16);
}

/* ---------------- 课程卡片 ---------------- */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
  transition: transform .14s;
}
.lesson-card:active { transform: scale(.98); }
.lesson-card.locked { opacity: .55; }
.lc-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.lc-text { display: flex; flex-direction: column; }
.lc-name { font-weight: 800; font-size: 16px; }
.lc-status { font-size: 13px; color: var(--ink-soft); }

/* ---------------- 课程学习 ---------------- */
.lesson-stage { min-height: 240px; }
.story-card, .demo-card {
  background: #fff;
  border-radius: 22px;
  padding: 24px 22px;
  box-shadow: var(--shadow);
}
.story-title { margin: 0 0 12px; font-size: 20px; font-weight: 800; }
.story-body { font-size: 17px; }
.story-body b { color: var(--green-d); }
.demo-text { margin: 0 0 16px; color: var(--ink-soft); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.pager-dots { display: flex; gap: 7px; }
.pager-dots .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(150, 110, 60, .25);
}
.pager-dots .dot.on { background: var(--green-d); width: 22px; border-radius: 999px; }

/* ---------------- 棋盘 ---------------- */
.board-wrap {
  width: min(100%, 560px);
  margin: 0 auto;
}
.ck-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(90, 60, 25, .22);
  user-select: none;
}
.ck-squares {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}
.ck-sq { position: relative; }
.ck-light { background: var(--board-light); }
.ck-dark { background: var(--board-dark); }
.ck-sq.ck-selected { background: var(--board-sel); }
.ck-sq.ck-last { background: var(--board-last); }
.ck-sq.ck-check { background: var(--board-check); }

.ck-rank, .ck-file {
  position: absolute;
  font-size: 11px;
  font-weight: 800;
  opacity: .75;
}
.ck-rank { top: 2px; left: 4px; }
.ck-file { bottom: 2px; right: 4px; }
.ck-light .ck-rank, .ck-light .ck-file { color: #9a7145; }
.ck-dark .ck-rank, .ck-dark .ck-file { color: #f3e2c4; }

.ck-hints { position: absolute; inset: 0; pointer-events: none; }
.ck-hint {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ck-dot::after {
  content: '';
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(74, 52, 30, .32);
}
.ck-ring::after {
  content: '';
  width: 88%;
  height: 88%;
  border-radius: 50%;
  border: 5px solid rgba(74, 52, 30, .3);
}

.ck-pieces { position: absolute; inset: 0; pointer-events: none; }
.ck-piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  padding: 2%;
  pointer-events: none;
  transition: top .22s ease, left .22s ease, opacity .2s, transform .2s;
}
.piece-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ck-piece.ck-captured { opacity: 0; transform: scale(.3); }

.ck-shake { animation: ck-shake .38s; }
@keyframes ck-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------------- 升变选择 ---------------- */
.ck-promo-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(60, 40, 20, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ck-promo-box {
  background: #fff;
  border-radius: 20px;
  padding: 18px;
  text-align: center;
  max-width: 92%;
}
.ck-promo-title { margin: 0 0 12px; font-weight: 800; }
.ck-promo-btns { display: flex; gap: 8px; }
.ck-promo-btn {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--cream);
  padding: 6px;
  transition: transform .12s;
}
.ck-promo-btn:active { transform: scale(.92); }

/* ---------------- 闯关总览 ---------------- */
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.puzzle-cell {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform .14s;
}
.puzzle-cell:active { transform: scale(.96); }
.puzzle-cell.locked { opacity: .5; }
.pz-num { font-size: 20px; font-weight: 900; }
.pz-stars { color: var(--orange); font-size: 15px; letter-spacing: 2px; }

/* ---------------- 单题 ---------------- */
.ask-card {
  background: #fff;
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.ask-level { font-size: 14px; }
.ask-text { margin: 6px 0 0; font-size: 19px; font-weight: 800; }
.puzzle-tools {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}
.hint-text {
  text-align: center;
  min-height: 26px;
  margin: 8px 0 4px;
  font-weight: 700;
  color: var(--orange-d);
}

/* ---------------- 对战大厅 ---------------- */
.battle .mode-switch {
  display: flex;
  gap: 10px;
}
.battle .mode-switch.wrap { flex-wrap: wrap; }
.mode-btn, .opt-btn {
  flex: 1;
  padding: 13px 10px;
  border-radius: 14px;
  background: #fff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.mode-switch.wrap .opt-btn { flex: 1 1 45%; }
.mode-btn:active, .opt-btn:active { transform: scale(.95); }
.mode-btn.on, .opt-btn.on {
  background: linear-gradient(180deg, var(--blue), var(--blue-d));
  color: #fff;
}

.ai-list { display: flex; flex-direction: column; gap: 10px; }
.ai-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 15px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  border: 3px solid transparent;
}
.ai-card.on { border-color: var(--blue); background: #f2f7ff; }
.ai-icon { font-size: 32px; }
.ai-info { flex: 1; display: flex; flex-direction: column; }
.ai-name { font-weight: 800; }
.ai-desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.ai-wins {
  font-size: 13px;
  font-weight: 800;
  color: var(--green-d);
  background: #edf8ee;
  padding: 5px 10px;
  border-radius: 999px;
}
.big-start {
  width: 100%;
  margin-top: 26px;
  padding: 16px;
  font-size: 19px;
}

/* ---------------- 对局页 ---------------- */
.player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
}
.player-bar.pb-black { background: #4a3a2c; color: #f6e8d2; }
#barBottom { margin: 10px 0 0; }
.pb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(120, 90, 60, .14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.pb-name { font-weight: 800; }
.play-tools {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

/* ---------------- 弹窗 ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(60, 40, 20, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in .2s;
}
.modal-box {
  background: #fff;
  border-radius: 24px;
  padding: 28px 24px 22px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  animation: pop-in .28s cubic-bezier(.2, 1.4, .4, 1);
}
.modal-emoji { font-size: 56px; line-height: 1; }
.modal-title { margin: 10px 0 6px; font-size: 23px; font-weight: 900; }
.modal-body { margin: 0 0 18px; color: var(--ink-soft); }
.modal-btns { display: flex; flex-direction: column; gap: 10px; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in {
  from { opacity: 0; transform: scale(.8) translateY(16px); }
}

/* ---------------- 响应式 ---------------- */
@media (min-width: 720px) {
  .home { padding-top: 40px; }
  .ck-promo-btn { width: 76px; height: 76px; }
}
@media (max-width: 380px) {
  .home-title { font-size: 27px; }
  .big-card { padding: 15px; gap: 10px; }
  .bc-emoji { font-size: 32px; }
  .story-body, .story-body { font-size: 16px; }
}
