/* ============================================================
 * YEDC · 桠琪侦探社  style.css —— 全站样式（设计书 §4 UI / §13）
 * 深蓝主色 #1F2A44 + 金色点缀 #D4A017；9 岁孩子大字号大按钮
 * iPad 触控 ≥44pt；safe-area 适配手势条
 * ============================================================ */

:root {
  --brand: #1F2A44;
  --brand-soft: #2A3A63;
  --gold: #D4A017;
  --gold-soft: #F2B632;
  --paper: #F6F3EA;
  --card: #FFFFFF;
  --ink: #2B2B2B;
  --ink-soft: #6B6B6B;
  --ok: #2E9E5B;
  --warn: #E08A00;
  --danger: #D64545;
  --radius: 18px;
  --shadow: 0 4px 14px rgba(31, 42, 68, 0.14);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}
#app { min-height: 100%; padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand);
  color: #fff;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}
.topbar-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.logo-badge { font-size: 22px; }
.logo-name { letter-spacing: 1px; }
.topbar-sub { font-size: 14px; opacity: 0.85; }
.topbar-right { font-size: 14px; opacity: 0.9; }
.topbar-close {
  color: #fff; font-size: 20px; padding: 6px 12px; border-radius: 10px;
  background: rgba(255,255,255,0.12);
}
.topbar-close:active { background: rgba(255,255,255,0.25); }

/* ============ 底部导航 ============ */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex;
  background: #fff;
  border-top: 1px solid #E3DFD2;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -3px 10px rgba(31,42,68,0.10);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 8px; color: var(--ink-soft); font-size: 12px;
}
.bn-ico { font-size: 22px; line-height: 1; }
.bn-item.active { color: var(--brand); font-weight: 700; }
.bn-item.active .bn-ico { transform: scale(1.12); }
.safe-bottom { height: calc(78px + env(safe-area-inset-bottom)); }

/* ============ 通用卡片与按钮 ============ */
.page { padding: 18px 20px; }
.sec-title { font-size: 19px; font-weight: 800; color: var(--brand); margin: 20px 0 12px; }
.sec-sub { font-size: 15px; color: var(--ink-soft); margin-bottom: 14px; }
.cta-row { display: flex; gap: 12px; margin-top: 22px; justify-content: center; flex-wrap: wrap; }
.empty-tip {
  background: #fff; border: 2px dashed #C9C4B4; color: var(--ink-soft);
  border-radius: var(--radius); padding: 22px 16px; text-align: center; font-size: 15px;
}

.btn-primary {
  background: var(--brand); color: #fff; font-size: 18px; font-weight: 700;
  padding: 16px 30px; border-radius: 999px; box-shadow: var(--shadow);
  min-height: 52px;
}
.btn-primary:active { background: var(--brand-soft); transform: scale(0.97); }
.btn-big { font-size: 20px; padding: 18px 34px; min-height: 60px; }
.btn-ghost {
  background: #fff; color: var(--brand); border: 2px solid var(--brand);
  font-size: 17px; font-weight: 600; padding: 14px 26px; border-radius: 999px; min-height: 52px;
}
.btn-ghost:active { background: #EEF0F8; }
.btn-small {
  background: var(--gold); color: #fff; font-size: 14px; font-weight: 700;
  padding: 8px 16px; border-radius: 999px;
}
.btn-x { color: var(--ink-soft); font-size: 18px; padding: 4px 10px; }

/* ============ 右上角紧凑气泡（答题中专用） ============ */
.hud-bubble {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); right: 14px; z-index: 90;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600;
  padding: 10px 16px; border-radius: 14px; box-shadow: var(--shadow);
  max-width: 78vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  animation: pop-in 0.25s ease;
}
@keyframes pop-in { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============ 自动播进度条（6pt 角色色） ============ */
.autoplay-bar {
  position: fixed; top: 0; left: 0; height: 6px; width: 0; z-index: 95;
  border-radius: 0 0 6px 0; transition: width 0.1s linear;
}

/* ============ 大厅 ============ */
.door { text-align: center; padding: 34px 16px 10px; }
.door-title {
  font-family: "Times New Roman", "Songti SC", serif;
  font-size: 46px; font-weight: 800; color: var(--brand);
  letter-spacing: 6px; text-shadow: 0 2px 0 rgba(212,160,23,0.35);
}
.door-sub { font-size: 15px; color: var(--ink-soft); margin-top: 6px; }
.door-tag { font-size: 14px; color: var(--gold); font-weight: 700; margin-top: 2px; }
.caseboard { margin-top: 10px; }
.case-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 14px; width: 100%; text-align: left;
  border-left: 8px solid var(--gold);
}
.case-card:active { transform: scale(0.98); background: #FBF7EA; }
.case-no { font-size: 13px; color: var(--gold); font-weight: 800; letter-spacing: 1px; }
.case-title { font-size: 21px; font-weight: 800; color: var(--ink); }
.case-gem { font-size: 16px; }
.case-kp { font-size: 14px; color: var(--ink-soft); }
.mode-tip {
  background: #FFF6DE; border: 1px solid #F0DCA0; color: #8A6414;
  border-radius: 12px; padding: 10px 14px; margin: 8px 0; font-size: 15px;
}

/* ============ 双语对白卡 ============ */
.dialog-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin: 12px 0; cursor: pointer;
}
.dialog-card:active { background: #F3F1E9; }
.avatar {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid #ccc; background: #F0EDE2;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.dialog-body { flex: 1; min-width: 0; }
.dialog-role {
  display: inline-block; font-size: 13px; font-weight: 800;
  padding: 2px 10px; border-radius: 999px; margin-bottom: 6px;
}
.dialog-en { font-size: 22px; font-weight: 700; line-height: 1.4; }
.dialog-zh { font-size: 15px; color: var(--ink-soft); margin-top: 2px; }

/* ============ 社员证 ============ */
.member-page { padding-top: 28px; }
.member-card {
  background: linear-gradient(160deg, #fffdf3, #fdf3d3);
  border: 3px solid var(--gold); border-radius: 22px;
  text-align: center; padding: 26px 18px; box-shadow: var(--shadow);
  max-width: 420px; margin: 0 auto;
}
.member-head { font-size: 16px; font-weight: 800; color: var(--gold); letter-spacing: 2px; }
.member-avatar { font-size: 64px; margin: 14px 0 6px; }
.member-name { font-size: 30px; font-weight: 900; color: var(--brand); }
.member-row { font-size: 16px; color: var(--ink-soft); margin-top: 4px; }
.member-seal {
  display: inline-block; margin-top: 14px; font-size: 15px; font-weight: 800;
  color: #B03030; border: 2px solid #B03030; border-radius: 10px; padding: 6px 16px;
  transform: rotate(-8deg); letter-spacing: 2px;
}

/* ============ 案件开场 / 预告函 ============ */
.case-intro .case-title { font-size: 26px; font-weight: 900; color: var(--brand); text-align: center; }
.letter-page { padding-top: 22px; }
.letter-stamp {
  text-align: center; font-size: 13px; font-weight: 800; color: var(--gold);
  letter-spacing: 2px; margin-bottom: 10px;
}
.letter-sheet {
  background: #FFFDF2; border: 2px solid #E4D9B0; border-radius: var(--radius);
  padding: 22px 18px; box-shadow: var(--shadow); position: relative;
}
.letter-title { font-size: 20px; font-weight: 900; color: var(--brand); margin-bottom: 10px; text-align: center; }
.letter-en { font-size: 21px; font-weight: 700; line-height: 1.5; }
.letter-zh { font-size: 15px; color: var(--ink-soft); margin-top: 8px; }
.letter-sign { text-align: right; font-size: 16px; font-weight: 800; color: var(--brand); margin-top: 14px; }
.letter-seal {
  position: absolute; right: 14px; top: 14px;
  border: 3px solid #B03030; color: #B03030; border-radius: 50%;
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; transform: rotate(-14deg); opacity: 0.85;
}

/* ============ 柯南金句闪卡 ============ */
.flash-konan {
  min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px;
}
.flash-avatar { font-size: 72px; }
.flash-name { font-size: 18px; font-weight: 800; color: var(--brand); }
.flash-en { font-size: 30px; font-weight: 900; color: var(--brand); line-height: 1.4; }
.flash-zh { font-size: 16px; color: var(--ink-soft); }
.duel-fail { text-align: center; font-size: 19px; font-weight: 700; color: var(--danger); padding: 30px 0 10px; }

/* ============ 答题区 ============ */
.quiz-page { padding-top: 14px; }
.quiz-title { font-size: 18px; font-weight: 800; color: var(--brand); text-align: center; margin-bottom: 8px; }
.quiz-head { min-height: 64px; }
.quiz-prompt { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 800; }
.quiz-icon { font-size: 26px; }
.quiz-prompt-text { flex: 1; }
.quiz-body { margin-top: 14px; }
.quiz-combo { min-height: 26px; font-size: 15px; font-weight: 800; text-align: center; }
.quiz-combo.chase { color: #E08A00; }
.quiz-combo.rush { color: #D64545; }
.quiz-combo.peak { color: #7B2FD0; }
.quiz-help-row { margin-top: 12px; text-align: center; }
.btn-help {
  background: #fff; border: 2px solid var(--gold); color: #8A6414;
  font-size: 15px; font-weight: 700; padding: 10px 22px; border-radius: 999px;
}
.listen-btn {
  display: block; margin: 6px auto 14px;
  background: var(--brand); color: #fff; font-size: 19px; font-weight: 800;
  padding: 16px 28px; border-radius: 999px; box-shadow: var(--shadow); min-height: 56px;
}
.listen-btn:active { background: var(--brand-soft); }
.tap-sentence {
  font-size: 24px; font-weight: 800; text-align: center; padding: 14px 0 6px;
  color: var(--brand); letter-spacing: 1px;
}
.quiz-options { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.opt-btn {
  background: var(--card); border: 2px solid #E3DFD2; border-radius: 16px;
  font-size: 21px; font-weight: 700; padding: 16px; min-height: 58px;
  box-shadow: var(--shadow); text-align: center;
}
.opt-btn:active { border-color: var(--brand); background: #EEF0F8; transform: scale(0.98); }

/* 拼词 */
.spell-word, .sort-sentence { font-size: 17px; font-weight: 700; color: var(--ink-soft); text-align: center; }
.spell-slots, .sort-slots {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
  margin: 12px 0; min-height: 52px;
}
.spell-slot {
  width: 44px; height: 50px; border-radius: 10px; border: 2px dashed #C9C4B4;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 900; background: #F7F4EA;
}
.spell-slot.filled { border-style: solid; border-color: var(--brand); background: #fff; color: var(--brand); }
.sort-slot {
  min-width: 60px; padding: 8px 14px; border-radius: 10px;
  border: 2px solid var(--brand); background: #fff; color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800;
}
.sort-slot.filled { background: #EEF0F8; }
.spell-blocks, .sort-blocks {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 10px;
  margin: 10px 0;
}
.letter-btn, .word-btn {
  min-width: 46px; height: 50px; border-radius: 12px;
  background: #fff; border: 2px solid #C9C4B4;
  font-size: 22px; font-weight: 900; color: var(--ink);
  box-shadow: var(--shadow);
}
.letter-btn:active, .word-btn:active { border-color: var(--brand); background: #EEF0F8; transform: scale(0.96); }
.spell-actions { display: flex; justify-content: center; gap: 14px; margin-top: 12px; }
.btn-undo {
  background: #fff; border: 2px solid #C9C4B4; color: var(--ink-soft);
  font-size: 16px; font-weight: 700; padding: 12px 22px; border-radius: 999px; min-height: 48px;
}
.btn-check {
  background: var(--ok); color: #fff; font-size: 17px; font-weight: 800;
  padding: 12px 24px; border-radius: 999px; min-height: 48px;
}

/* ============ 讲解卡 ============ */
.explain-page { padding-top: 20px; }
.explain-result {
  font-size: 26px; font-weight: 900; text-align: center; padding: 10px 0;
}
.explain-result.good { color: var(--ok); }
.explain-result.bad { color: var(--danger); }
.explain-text {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; font-size: 19px; font-weight: 700; line-height: 1.6;
}
.explain-hook {
  background: #FFF6DE; border: 1px solid #F0DCA0; color: #8A6414;
  border-radius: 12px; padding: 10px 14px; margin: 12px 0; font-size: 16px;
}
.explain-ex { margin-top: 12px; }
.explain-ex-title { font-size: 15px; font-weight: 800; color: var(--ink-soft); margin-bottom: 8px; }
.explain-ex-item {
  display: block; width: 100%; text-align: left;
  background: #fff; border: 2px solid #E3DFD2; border-radius: 14px;
  padding: 14px; margin-bottom: 10px; font-size: 18px; font-weight: 700;
}
.explain-ex-item:active { border-color: var(--brand); background: #EEF0F8; }

/* ============ 结案 ============ */
.closed-page { text-align: center; padding-top: 40px; }
.closed-stamp {
  display: inline-block; font-size: 42px; font-weight: 900; color: #B03030;
  border: 6px solid #B03030; border-radius: 16px; padding: 14px 26px;
  transform: rotate(-8deg); letter-spacing: 4px;
  animation: stamp-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}
@keyframes stamp-in { from { transform: rotate(-8deg) scale(1.8); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
.closed-meta { font-size: 14px; color: var(--ink-soft); margin-top: 18px; }
.closed-gem { font-size: 24px; font-weight: 800; color: var(--brand); margin-top: 6px; }
.dossier-page { padding-top: 16px; }
.dossier-head {
  font-size: 14px; font-weight: 800; color: var(--gold); letter-spacing: 2px; text-align: center;
}
.dossier-title { font-size: 24px; font-weight: 900; color: var(--brand); text-align: center; margin-bottom: 6px; }
.closing-ex-title { font-size: 17px; font-weight: 800; color: var(--brand); margin: 18px 0 8px; }
.closing-ex {
  display: block; width: 100%; text-align: left;
  background: #fff; border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 6px;
  font-size: 28px; font-weight: 800; color: var(--brand); letter-spacing: 1px;
}
.closing-ex:active { background: #EEF0F8; }
.closing-exz { font-size: 15px; color: var(--ink-soft); padding: 0 6px 10px; }

/* ============ 词场 / 破译 / 回炉 ============ */
.stage-btn {
  display: block; width: 100%; text-align: left;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border-left: 8px solid var(--brand);
  padding: 16px 18px; margin-bottom: 12px;
  font-size: 19px; font-weight: 800; color: var(--ink);
}
.stage-btn.active { border-left-color: var(--gold); background: #FBF7EA; }
.stage-btn:active { transform: scale(0.98); background: #F3F1E9; }
.stage-note { font-size: 14px; color: var(--ink-soft); text-align: center; margin: 14px 0; }
.read-page { text-align: center; padding-top: 26px; }
.read-word { font-size: 56px; font-weight: 900; color: var(--brand); letter-spacing: 2px; }
.read-mean { font-size: 20px; color: var(--ink-soft); margin: 6px 0 18px; }
.read-listen {
  background: #fff; border: 2px solid var(--brand); color: var(--brand);
  font-size: 18px; font-weight: 800; padding: 14px 26px; border-radius: 999px; min-height: 52px;
}
.rec-btn {
  display: block; margin: 26px auto 8px;
  background: var(--danger); color: #fff; font-size: 22px; font-weight: 800;
  width: 150px; height: 150px; border-radius: 50%;
  box-shadow: 0 6px 18px rgba(214,69,69,0.4);
  border: 6px solid #fff; outline: 3px solid var(--danger);
}
.rec-btn:active { transform: scale(0.95); }
.self-eval { margin-top: 30px; }
.self-eval-title { font-size: 17px; font-weight: 800; color: var(--brand); text-align: center; margin-bottom: 12px; }
.eval-btn {
  display: block; width: 100%; background: #fff; border: 2px solid #E3DFD2;
  border-radius: 14px; padding: 14px; margin-bottom: 10px; font-size: 18px; font-weight: 700;
}
.eval-btn:active { border-color: var(--brand); background: #EEF0F8; }
.decode-word { font-size: 34px; font-weight: 900; color: var(--brand); text-align: center; padding: 12px 0; }
.decode-q { font-size: 17px; font-weight: 700; text-align: center; margin: 10px 0; }
.backlog-btn {
  display: block; width: 100%; text-align: left;
  background: #fff; border: 2px solid #F0DCA0; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px; font-size: 17px; font-weight: 700;
}
.backlog-btn:active { background: #FFF6DE; }

/* ============ 看板 ============ */
.dash-page { padding-top: 16px; }
.dash-head { font-size: 13px; font-weight: 800; color: var(--gold); letter-spacing: 2px; text-align: center; }
.dash-sub { font-size: 17px; font-weight: 800; color: var(--brand); text-align: center; margin-bottom: 12px; }
.dash-stats { display: flex; gap: 10px; margin: 12px 0; }
.dash-stat {
  flex: 1; background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 6px; text-align: center;
}
.dash-stat-val { font-size: 22px; font-weight: 900; color: var(--brand); }
.dash-stat-label { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.usage-box {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 16px; margin: 10px 0; font-size: 15px;
}
.usage-row { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.usage-bar { height: 12px; border-radius: 999px; background: #E8E4D8; overflow: hidden; }
.usage-fill { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.4s ease; }
.usage-fill.warn { background: var(--danger); }
.usage-note { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.backup-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.backup-chip {
  font-size: 14px; font-weight: 700; padding: 8px 14px; border-radius: 999px;
}
.chip-ok { background: #E2F4E8; color: var(--ok); }
.chip-warn { background: #FCEFD9; color: var(--warn); }
.chip-red { background: #FBE3E3; color: var(--danger); }
.backup-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #FBE3E3; border: 1px solid #F0B8B8; color: #8E2626;
  border-radius: 14px; padding: 12px 14px; margin: 10px 0; font-size: 15px; font-weight: 700;
}
.migrate-card {
  display: block; width: 100%; text-align: left;
  background: #fff; border: 2px solid #E3DFD2; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px; font-size: 16px; font-weight: 700;
}
.migrate-card:active { border-color: var(--gold); background: #FBF7EA; }

/* ============ 导出 / 导入 ============ */
.export-page { padding-top: 14px; }
.export-code-area { margin: 12px 0; }
.code-box {
  background: #1E2436; color: #E8EAF2; font-family: "SF Mono", Menlo, monospace;
  font-size: 13px; border-radius: 12px; padding: 14px;
  word-break: break-all; max-height: 220px; overflow-y: auto;
}
.code-note { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

/* ============ PIN 门 ============ */
.pin-page { text-align: center; padding-top: 60px; }
.pin-logo { font-size: 64px; }
.pin-title { font-size: 20px; font-weight: 800; color: var(--brand); margin: 10px 0 20px; }
.pin-input {
  font-size: 26px; letter-spacing: 10px; text-align: center;
  width: 200px; padding: 12px; border: 3px solid var(--brand); border-radius: 14px;
  margin-bottom: 20px;
}

/* ============ 收工卡 ============ */
.endday { text-align: center; padding-top: 70px; }
.endday-title { font-size: 32px; font-weight: 900; color: var(--brand); }
.endday-sub { font-size: 18px; color: var(--ink-soft); margin-top: 10px; }
.endday-count {
  margin: 30px auto; width: 90px; height: 90px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 44px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
}

/* ============ 首次启动 intro 页 ============ */
.intro-page { padding-top: 8px; }
.intro-card { cursor: pointer; }
