/* ============================================================
 * 小棋手乐园 · 儿童围棋视觉样式
 * ============================================================ */
:root {
  --cream: #fff6e6;
  --ink: #5a4636;
  --ink-soft: #8a7460;
  --green: #7bc47f;
  --green-d: #58a664;
  --orange: #ffb457;
  --orange-d: #ef9a3c;
  --blue: #73a8ff;
  --blue-d: #5689e0;
  --board-wood: #e2b06c;
  --board-line: #5c4327;
  --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: 52px;
  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; }
.go-board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 10px 26px rgba(90, 60, 25, .22);
  background:
    repeating-linear-gradient(91deg, rgba(120, 75, 30, .05) 0 3px, rgba(120, 75, 30, 0) 3px 8px),
    radial-gradient(circle at 32% 26%, #f0c686, #ddaa63 72%, #cf974f);
}

/* 网格层 */
.go-grid { position: absolute; inset: 5.6%; }
.go-vline {
  position: absolute; top: 0; bottom: 0; width: 1.4px;
  background: var(--board-line); transform: translateX(-50%);
}
.go-hline {
  position: absolute; left: 0; right: 0; height: 1.4px;
  background: var(--board-line); transform: translateY(-50%);
}
.go-star {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--board-line); transform: translate(-50%, -50%);
}

/* 棋子 */
.go-stones { position: absolute; inset: 0; pointer-events: none; }
.go-stone {
  position: absolute;
  width: 10.6%;
  height: 10.6%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.go-stone-black {
  background: radial-gradient(circle at 34% 30%, #6b6b6b 0%, #2c2c2c 45%, #0a0a0a 100%);
  box-shadow: 0 2px 4px rgba(40, 25, 10, .5), inset 0 -1px 2px rgba(0, 0, 0, .6);
}
.go-stone-white {
  background: radial-gradient(circle at 34% 30%, #ffffff 0%, #f2ede2 55%, #cfc7b8 100%);
  box-shadow: 0 2px 4px rgba(90, 60, 25, .4), inset 0 -1px 2px rgba(160, 145, 120, .6);
}
.go-lastmark {
  position: absolute; inset: 0; margin: auto;
  width: 30%; height: 30%; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .85);
}
.go-stone-white .go-lastmark { border-color: rgba(90, 60, 30, .65); }

/* 命中区（透明、略放大方便孩子点） */
.go-hits { position: absolute; inset: 0; }
.go-hit {
  position: absolute;
  width: 12%;
  height: 12%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

/* 落子 / 提子 / 抖动 */
.go-new { animation: go-pop .22s ease; }
@keyframes go-pop {
  0% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(.94); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.go-captured {
  opacity: 0;
  transform: translate(-50%, -50%) scale(.4);
  transition: opacity .16s, transform .16s;
}
.go-shake { animation: go-shake .38s; }
@keyframes go-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* ---------------- 闯关总览 ---------------- */
.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: 18px; 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; }
.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-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; }
.caps-info { margin-left: auto; font-size: 13px; font-weight: 700; opacity: .85; }
.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; } }
@media (max-width: 380px) {
  .home-title { font-size: 27px; }
  .big-card { padding: 15px; gap: 10px; }
  .bc-emoji { font-size: 32px; }
  .story-body { font-size: 16px; }
}
