:root {
  --bg1: #e8f1ff;
  --bg2: #d9e9ff;
  --card: #ffffff;
  --ink: #1f3252;
  --ink-soft: #5f7393;
  --blue: #3b82f6;
  --blue-d: #2563eb;
  --blue-dd: #1d4ed8;
  --blue-l: #7eb0f7;
  --blue-xl: #eaf2ff;
  --gold: #f6c453;
  --line: #d4e3fb;
  --shadow: 0 10px 26px rgba(37, 99, 235, 0.16);
  --shadow-blue: 0 6px 16px rgba(37, 99, 235, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, var(--bg1), var(--bg2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== 图标系统 ===== */
.ic {
  width: 1em; height: 1em; flex: none;
  fill: currentColor; stroke: currentColor; stroke-width: 0;
  display: inline-block; vertical-align: middle;
}
.ic.line { stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

.topbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px;
}
.brand { font-size: 26px; font-weight: 800; letter-spacing: 1px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.brand .ic { width: 30px; height: 30px; color: var(--blue-d); }
.brand span { color: var(--blue-d); }
.status-pill {
  background: var(--card); padding: 8px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
  color: var(--ink); flex: 0 1 auto; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.top-actions { margin-left: auto; display: flex; gap: 10px; }
.chip {
  border: none; background: var(--card); color: var(--blue-d);
  padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow); transition: .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .ic { width: 18px; height: 18px; }
.chip:hover { transform: translateY(-1px); }
.chip.off { background: var(--blue-xl); color: var(--ink-soft); }

.layout { display: flex; gap: 16px; align-items: stretch; }
.sidebar {
  width: 300px; flex: 0 0 300px; display: flex; flex-direction: column; gap: 14px;
  transition: margin .25s ease, opacity .2s ease;
}
.sidebar.collapsed { display: none; }

.board-wrap {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  background: var(--card); border-radius: 24px; padding: 16px;
  box-shadow: var(--shadow);
  min-height: calc(100vh - 150px);
  height: calc(100vh - 150px);
  overflow: hidden;
}

.card {
  background: var(--card); border-radius: 20px; padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.card h3 .ic { width: 18px; height: 18px; color: var(--blue-d); }
.row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; }
.lbl { font-size: 14px; color: var(--ink-soft); font-weight: 600; }

.seg { display: inline-flex; background: var(--blue-xl); border-radius: 999px; padding: 3px; }
.seg button {
  border: none; background: transparent; color: var(--ink-soft);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.seg button.active { background: var(--blue); color: #fff; box-shadow: var(--shadow-blue); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0; background: #cdddf5;
  border-radius: 999px; transition: .2s;
}
.slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(20px); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  border: none; border-radius: 14px; padding: 11px 10px; font-size: 14px; font-weight: 700;
  background: var(--blue-xl); color: var(--blue-d); cursor: pointer; transition: .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.btn .ic { width: 20px; height: 20px; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--blue); color: #fff; grid-column: span 2; box-shadow: var(--shadow-blue); }
.btn.ok { background: var(--blue-d); color: #fff; grid-column: span 2; }
.btn.warn { background: #ffe6e6; color: #d96b6b; }

.capture-card { text-align: center; font-weight: 700; font-size: 14px; color: var(--ink-soft); }

/* 教学面板 */
.teaching .collapsible { cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; }
.teaching .chev { transition: transform .2s; font-size: 12px; color: var(--ink-soft); }
.teaching.collapsed .chev { transform: rotate(-90deg); }
.teaching.collapsed .teaching-body { display: none; }
.teaching-body { margin-top: 6px; }

.teaching .winrate { margin-bottom: 12px; }
.win-bar { height: 16px; background: #eef2f5; border-radius: 999px; overflow: hidden; }
.win-fill {
  height: 100%; width: 50%; border-radius: 999px;
  background: linear-gradient(90deg, var(--blue-l), var(--blue));
  transition: width .4s ease;
}
.win-text { font-size: 13px; font-weight: 700; margin-top: 6px; color: var(--ink); }

.sug-box {
  background: var(--blue-xl); border-radius: 14px; padding: 12px; margin-bottom: 12px;
  border: 1px dashed #b9d2fb;
}
.sug-title { font-size: 12px; color: var(--blue-d); font-weight: 700; margin-bottom: 4px; display: flex; align-items: center; gap: 5px; }
.sug-title .ic { width: 15px; height: 15px; }
.sug { font-size: 15px; line-height: 1.5; }
.sug .reason { font-size: 12px; color: var(--ink-soft); }

.mv-title { font-size: 12px; color: var(--ink-soft); font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.mv-title .ic { width: 15px; height: 15px; }
.movelist {
  max-height: 240px; overflow-y: auto; font-size: 13px;
  background: #f4f8ff; border-radius: 12px; padding: 8px;
}
.mv { display: flex; align-items: center; gap: 8px; padding: 3px 2px; }
.mv-no { color: #aab9d4; width: 22px; text-align: right; }
.mv-c { width: 20px; height: 20px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 11px; color: #fff; }
.mv-c.bk { background: #3a3a45; }
.mv-c.wt { background: #e7eef3; color: #1f3252; border: 1.5px solid #b9cbe6; }
.mv.empty { color: #aab9d4; justify-content: center; }

.foot { text-align: center; margin-top: 16px; font-size: 12px; color: var(--ink-soft); }

/* ===== 首页 / 进入页 ===== */
.home-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.home-card { background: var(--card); border-radius: 28px; padding: 34px 38px; box-shadow: var(--shadow); width: min(460px, 94vw); }
.home-brand { font-size: 34px; font-weight: 800; letter-spacing: 1px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px; }
.home-brand .ic { width: 38px; height: 38px; color: var(--blue-d); }
.home-brand span { color: var(--blue-d); }
.home-sub { text-align: center; color: var(--ink-soft); margin: 6px 0 22px; font-size: 14px; }
.home-group { margin: 16px 0; }
.home-label { font-size: 14px; color: var(--ink-soft); font-weight: 700; margin-bottom: 8px; }

/* 图形卡片式选项（便于小朋友看图识别） */
.opt-grid { display: flex; gap: 10px; }
.opt-grid .opt {
  flex: 1; border: 2px solid var(--line); background: var(--blue-xl);
  border-radius: 16px; padding: 12px 6px; cursor: pointer; transition: .15s;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink-soft);
}
.opt-grid .opt .opt-ic { font-size: 0; line-height: 0; color: var(--blue); transition: transform .15s; }
.opt-grid .opt .opt-ic .ic { width: 40px; height: 40px; }
.opt-grid .opt .opt-ic .stars { display: inline-flex; gap: 2px; }
.opt-grid .opt .opt-ic .stars .ic { width: 22px; height: 22px; color: var(--gold); }
.opt-grid .opt .opt-txt { font-size: 14px; font-weight: 800; }
.opt-grid .opt .opt-sub { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.opt-grid .opt:hover { transform: translateY(-2px); border-color: var(--blue-l); }
.opt-grid .opt.active {
  background: var(--blue); border-color: var(--blue-d); color: #fff;
  box-shadow: var(--shadow-blue);
}
.opt-grid .opt.active .opt-ic { color: #fff; transform: scale(1.08); }
.opt-grid .opt.active .opt-ic .stars .ic { color: #fff; }
.opt-grid .opt.active .opt-sub { color: rgba(255,255,255,.85); }

.home-start { width: 100%; margin-top: 22px; font-size: 17px; padding: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.home-start .ic { width: 22px; height: 22px; }
.home-tip { text-align: center; font-size: 11px; color: var(--ink-soft); margin: 16px 0 0; }

/* 对局页只读信息栏 */
.infobar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.info-item {
  background: var(--card); padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  color: var(--ink); box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 7px;
}
.info-item .ic { width: 18px; height: 18px; color: var(--blue-d); }
.info-item .dot { width: 16px; height: 16px; border-radius: 50%; display: inline-block; }
.info-item .dot.bk { background: #3a3a45; }
.info-item .dot.wt { background: #fff; border: 2px solid #b9cbe6; }
.info-item .stars { display: inline-flex; gap: 1px; vertical-align: middle; }
.info-item .stars .ic { color: var(--gold); width: 16px; height: 16px; }

/* 黑白双方实时胜率 */
.winrate-double { margin-bottom: 14px; }
.wr-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; margin: 10px 0 4px; }
.wr-tag.bk { color: #3a3a45; display: inline-flex; align-items: center; gap: 6px; }
.wr-tag.wt { color: #1f3252; display: inline-flex; align-items: center; gap: 6px; }
.wr-tag .dot { width: 15px; height: 15px; border-radius: 50%; display: inline-block; }
.wr-tag .dot.bk { background: #3a3a45; }
.wr-tag .dot.wt { background: #fff; border: 2px solid #b9cbe6; }
.wr-pct { font-variant-numeric: tabular-nums; }
.win-bar { height: 14px; background: #eef2f5; border-radius: 999px; overflow: hidden; }
.win-bar.black .win-fill { background: linear-gradient(90deg, #6b6b78, #2c2c34); }
.win-bar.white .win-fill { background: linear-gradient(90deg, #dfe7ee, #aebfcb); }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; }
  .board-wrap { min-height: 70vh; height: 70vh; }
}
