/* 围棋小课堂 —— 温暖木质风，浅色主题 */
:root {
  --bg: #f6f1e7;
  --bg2: #efe7d8;
  --card: #fffdf8;
  --ink: #3a3226;
  --ink2: #6b6152;
  --ink3: #9a9083;
  --line: #e6ddcc;
  --brown: #8b5e34;
  --brown-d: #6d4523;
  --green: #4a7c59;
  --red: #c0503f;
  --shadow-s: 0 1px 2px rgba(90, 70, 40, .06), 0 2px 8px rgba(90, 70, 40, .05);
  --shadow-m: 0 4px 12px rgba(90, 70, 40, .08), 0 12px 32px rgba(90, 70, 40, .07);
  --shadow-l: 0 12px 40px rgba(90, 70, 40, .18);
  --radius: 18px;
  --wood1: #edc68d;
  --wood2: #ddab63;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #fffdf6 0%, var(--bg) 45%, var(--bg2) 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

button { font-family: inherit; }
[hidden] { display: none !important; }

.app { max-width: 1240px; margin: 0 auto; padding: 20px 20px 40px; }

/* ── 顶栏 ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 14px;
  background: radial-gradient(circle at 32% 28%, #6b6b6b, #141414 70%);
  display: grid; place-items: center; font-size: 20px; color: #fff;
  box-shadow: var(--shadow-s), inset 0 -2px 6px rgba(0,0,0,.35);
}
.brand-text h1 { margin: 0; font-size: 21px; letter-spacing: .5px; }
.brand-text p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink3); }
.topbar-actions { display: flex; gap: 8px; }

/* ── 布局 ── */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 22px; align-items: start;
}

/* ── 棋盘 ── */
.board-area { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.board-frame {
  background: linear-gradient(180deg, #fffdf8, #f7f1e4);
  border: 1px solid var(--line);
  border-radius: 24px; padding: 14px;
  box-shadow: var(--shadow-m);
}
.board-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; }
#board { width: 100%; height: 100%; display: block; border-radius: 14px; touch-action: manipulation; cursor: pointer; }

.thinking {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px;
  background: rgba(58, 50, 38, .86); color: #fff;
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px;
  box-shadow: var(--shadow-m); backdrop-filter: blur(6px);
  animation: pop .25s ease;
}
.thinking em { font-style: normal; margin-left: 6px; }
.thinking .dot {
  width: 6px; height: 6px; border-radius: 50%; background: #ffe0a3;
  animation: bounce 1.1s infinite ease-in-out;
}
.thinking .dot:nth-child(2) { animation-delay: .15s; }
.thinking .dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .5 } 30% { transform: translateY(-5px); opacity: 1 } }

/* ── 复盘条 ── */
.replay-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 12px; box-shadow: var(--shadow-s);
}
.move-counter { margin-left: auto; font-size: 12.5px; color: var(--ink3); font-variant-numeric: tabular-nums; }

/* ── 卡片 ── */
.side { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-s);
  animation: rise .35s ease both;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }

/* 状态卡 */
.status-card { display: flex; flex-direction: column; gap: 12px; }
.turn-row { display: flex; align-items: center; gap: 12px; }
.stone-indicator {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  background: radial-gradient(circle at 32% 28%, #5c5c5c, #111 72%);
  box-shadow: var(--shadow-s), inset 0 -2px 5px rgba(0,0,0,.4);
  transition: background .35s ease, transform .35s ease;
}
.stone-indicator.white {
  background: radial-gradient(circle at 32% 28%, #fff, #d9d0bf 78%);
  box-shadow: var(--shadow-s), inset 0 -2px 5px rgba(150,130,100,.35);
}
.stone-indicator.bump { transform: scale(1.12); }
.turn-title { font-size: 16px; font-weight: 600; }
.turn-sub { font-size: 12.5px; color: var(--ink3); margin-top: 2px; }
.score-mini { font-size: 12.5px; color: var(--ink2); background: #faf6ec; border-radius: 10px; padding: 8px 12px; line-height: 1.6; }
.score-mini b { color: var(--brown-d); }

/* 教学卡 */
.teach-body { font-size: 13.5px; line-height: 1.75; color: var(--ink2); min-height: 62px; }
.teach-body b { color: var(--brown-d); }
.teach-body .hl { color: var(--green); font-weight: 600; }
.teach-body .warn { color: var(--red); font-weight: 600; }
.coach-line {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(139, 94, 52, 0.07), rgba(139, 94, 52, 0.04));
  border: 1px dashed rgba(139, 94, 52, 0.28);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink2);
  animation: fadeUp 0.28s ease;
}
.coach-line::before {
  content: '教练说：';
  color: #8b5e34;
  font-weight: 600;
}
.coach-line.loading { color: var(--ink3); font-style: italic; }
.coach-line.loading::before { content: ''; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.result-coach {
  font-size: 13px;
  line-height: 1.85;
  color: var(--ink2);
  background: #fdfaf2;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 16px;
  text-align: left;
  white-space: pre-line;
}
.teach-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: #f2ead9; color: var(--brown-d); border: 1px solid #e8dcc4;
}
.tag.green { background: #e8f2ea; color: var(--green); border-color: #d6e8dc; }
.tag.red { background: #fbeae7; color: var(--red); border-color: #f2d5cf; }

/* 表单控件 */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; color: var(--ink3); margin-bottom: 7px; }
.seg { display: flex; background: #f3ecdd; border-radius: 12px; padding: 3px; gap: 3px; }
.seg-btn {
  flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 9px;
  font-size: 13px; color: var(--ink2); cursor: pointer; transition: all .2s ease;
}
.seg-btn.active { background: #fff; color: var(--brown-d); font-weight: 600; box-shadow: var(--shadow-s); }
.hint { font-size: 11.5px; color: var(--ink3); margin: 7px 0 0; line-height: 1.6; }

.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.level-btn {
  border: 1px solid var(--line); background: #fdfaf2; border-radius: 12px;
  padding: 8px 2px; cursor: pointer; text-align: center; transition: all .2s ease;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.level-btn .e { font-size: 17px; line-height: 1; }
.level-btn .n { font-size: 11px; color: var(--ink2); }
.level-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-s); }
.level-btn.active {
  background: linear-gradient(180deg, #fff, #fdf3e2);
  border-color: var(--brown); box-shadow: 0 0 0 2px rgba(139,94,52,.15);
}
.level-btn.active .n { color: var(--brown-d); font-weight: 600; }

.toggles { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brown); }

.switch { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.switch input { display: none; }
.switch span {
  width: 36px; height: 20px; border-radius: 999px; background: #e3dac8; position: relative; transition: background .2s;
}
.switch span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-s); transition: transform .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch em { font-style: normal; font-size: 12px; color: var(--ink3); }

/* 按钮 */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 10px 14px; font-size: 13.5px; cursor: pointer;
  transition: all .18s ease; box-shadow: var(--shadow-s);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-m); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { background: linear-gradient(180deg, #6f8f6f, #4a7c59); border-color: #43704f; color: #fff; }
.btn-danger { color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink2); }
.btn-ghost:hover { background: #f3ecdd; }
.btn-icon { padding: 8px 11px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.actions { display: flex; flex-direction: column; gap: 9px; }
.btn-row { display: flex; gap: 9px; }
.btn-row .btn { flex: 1; }

/* 棋谱 */
.badge { font-size: 11.5px; color: var(--ink3); background: #f3ecdd; padding: 3px 9px; border-radius: 999px; }
.moves { max-height: 190px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.move-item {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 8px;
  font-size: 12px; cursor: pointer; color: var(--ink2); transition: background .15s;
}
.move-item:hover { background: #f6f0e2; }
.move-item.current { background: #f2e6cd; color: var(--brown-d); font-weight: 600; }
.move-item .no { color: var(--ink3); font-variant-numeric: tabular-nums; min-width: 22px; }
.move-item .st { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.move-item .st.b { background: radial-gradient(circle at 30% 30%, #5c5c5c, #111); }
.move-item .st.w { background: radial-gradient(circle at 30% 30%, #fff, #cfc6b4); border: 1px solid #d8d0c0; }
.move-item .cap { font-size: 10.5px; color: var(--red); }

/* ── 模态 ── */
.modal {
  position: fixed; inset: 0; background: rgba(50, 40, 28, .45); backdrop-filter: blur(4px);
  display: grid; place-items: center; z-index: 60; padding: 20px; animation: fade .2s ease;
}
.modal-card {
  background: var(--card); border-radius: 24px; padding: 30px 28px; max-width: 400px; width: 100%;
  text-align: center; box-shadow: var(--shadow-l); animation: pop .3s cubic-bezier(.2,1.2,.3,1);
}
.modal-card h2 { margin: 0 0 10px; font-size: 20px; }
.result-emoji { font-size: 46px; line-height: 1; margin-bottom: 8px; animation: pop .5s .1s backwards; }
.result-score { font-size: 14px; color: var(--ink2); margin: 6px 0; font-variant-numeric: tabular-nums; }
.result-desc { font-size: 13px; color: var(--ink3); line-height: 1.7; margin: 4px 0 18px; }
.modal-desc { font-size: 13px; color: var(--ink2); line-height: 1.75; margin: 0 0 18px; text-align: left; }
.modal-actions { display: flex; flex-direction: column; gap: 9px; }

/* ── 抽屉 ── */
.drawer {
  position: fixed; inset: 0; background: rgba(50, 40, 28, .4); z-index: 70;
  display: flex; justify-content: flex-end; animation: fade .2s ease;
}
.drawer-inner {
  width: min(520px, 100%); background: var(--bg); height: 100%; overflow-y: auto;
  padding: 22px; box-shadow: var(--shadow-l); animation: slideIn .3s cubic-bezier(.2,.9,.3,1);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.lessons { display: flex; flex-direction: column; gap: 12px; }
.lesson {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  box-shadow: var(--shadow-s);
}
.lesson h4 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.lesson p { margin: 0 0 8px; font-size: 13px; line-height: 1.8; color: var(--ink2); }
.lesson .demo {
  background: #f7f1e4; border-radius: 12px; padding: 12px; margin-top: 10px;
  font-size: 12.5px; color: var(--ink2); line-height: 1.8;
}
.lesson .demo b { color: var(--brown-d); }

/* ── 概念弹卡 ── */
.concept-pop {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 80;
  width: min(420px, calc(100% - 40px)); animation: pop .35s cubic-bezier(.2,1.2,.3,1);
}
.concept-card {
  background: linear-gradient(180deg, #fffdf6, #fdf6e9);
  border: 1px solid #e9dcbf; border-radius: 20px; padding: 18px 20px;
  box-shadow: var(--shadow-l); display: flex; flex-direction: column; gap: 10px;
}
.concept-card h3 { margin: 0; font-size: 16px; }
.concept-card p { margin: 0; font-size: 13.5px; line-height: 1.8; color: var(--ink2); }
.concept-emoji { font-size: 30px; }
.concept-text { display: flex; flex-direction: column; gap: 6px; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ── 动画 ── */
@keyframes rise { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: scale(.9) } to { opacity: 1; transform: scale(1) } }
@keyframes slideIn { from { transform: translateX(30px); opacity: .4 } to { transform: none; opacity: 1 } }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-4px) } 75% { transform: translateX(4px) } }
.shake { animation: shake .3s ease; }

/* ── 响应式 ── */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .side { order: 2; }
  .board-area { order: 1; }
  .app { padding: 14px 14px 32px; }
  .topbar { margin-bottom: 14px; }
  .brand-text h1 { font-size: 18px; }
  .moves { max-height: 150px; }
}
@media (max-width: 520px) {
  .board-frame { padding: 8px; border-radius: 18px; }
  .levels { grid-template-columns: repeat(5, 1fr); }
  .level-btn .n { font-size: 10px; }
  .topbar-actions .btn { padding: 8px 10px; }
}
