/* ================= 通用 ================= */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f1e8; color: #333; min-height: 100vh;
  max-width: 720px; margin: 0 auto; padding: 0 12px 60px;
}
header { text-align: center; padding: 18px 0 10px; }
header h1 { font-size: 22px; }
header h1 a { color: inherit; text-decoration: none; }
header p { font-size: 12px; color: #999; margin-top: 4px; }
nav { display: flex; gap: 6px; margin: 12px 0 16px; flex-wrap: wrap; }
nav a {
  flex: 1; min-width: 60px; text-align: center; padding: 10px 0; font-size: 14px;
  border-radius: 10px; background: #e8e0d0; color: #666; text-decoration: none;
}
nav a.active { background: #c0392b; color: #fff; font-weight: bold; }
h2.group-title {
  font-size: 15px; margin: 18px 0 8px; padding-left: 8px;
  border-left: 4px solid #c0392b; color: #555;
}
.hint { font-size: 12px; color: #aaa; text-align: center; margin: 6px 0; }
.panel { background: #fff; border-radius: 12px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
select, .btn {
  padding: 9px 14px; font-size: 14px; border-radius: 8px; border: 1px solid #ddd;
  background: #fff; cursor: pointer;
}
.btn.primary { background: #c0392b; color: #fff; border: none; font-weight: bold; }
.btn.ghost { background: #f5f1e8; border: none; }
.feedback { text-align: center; min-height: 28px; font-size: 16px; margin-top: 12px; font-weight: bold; }
.feedback.ok { color: #27ae60; }
.feedback.bad { color: #c0392b; }

/* ---- 上下结构分数 ---- */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.15; font-size: .78em; }
.frac .fn { border-bottom: 1.5px solid currentColor; padding: 0 4px; }
.frac .fd { padding: 0 4px; }
.quiz-q .frac { font-size: .6em; }

/* ================= 首页 ================= */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.home-card {
  background: #fff; border-radius: 12px; padding: 22px 16px; display: block;
  text-decoration: none; color: #333; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.home-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.12); }
.home-card .t { font-size: 18px; font-weight: bold; margin-bottom: 6px; }
.home-card .d { font-size: 13px; color: #999; line-height: 1.6; }

/* ================= 背诵卡片 ================= */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.card {
  background: #fff; border-radius: 10px; padding: 14px 6px; text-align: center;
  cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08); user-select: none;
  min-height: 62px; display: flex; flex-direction: column; justify-content: center;
}
.card .front { font-size: 17px; font-weight: bold; }
.card .back { font-size: 17px; font-weight: bold; color: #c0392b; display: none; }
.card.flipped { background: #fdf3e7; }
.card.flipped .front { display: none; }
.card.flipped .back { display: block; }

/* ================= 对照总表 ================= */
.ref-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ref-cell {
  background: #fff; border-radius: 10px; padding: 12px 6px; font-size: 16px; font-weight: bold;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.ref-cell .ref-eq { color: #bbb; font-weight: normal; }
.ref-cell .frac { color: #c0392b; }

/* ================= 随机测验 ================= */
.quiz-q { font-size: 34px; font-weight: bold; text-align: center; padding: 26px 0 10px; }
.quiz-sub { text-align: center; color: #999; font-size: 13px; margin-bottom: 14px; }
.quiz-input { display: flex; gap: 8px; }
.quiz-input input {
  flex: 1; padding: 12px; font-size: 20px; text-align: center;
  border: 2px solid #ddd; border-radius: 10px; outline: none;
}
.quiz-input input:focus { border-color: #c0392b; }
.quiz-input button { padding: 0 22px; font-size: 16px; }
.stats { text-align: center; font-size: 13px; color: #888; margin-top: 8px; }
.wrongbook { margin-top: 16px; }
.wrongbook .item {
  display: flex; justify-content: space-between; padding: 8px 12px; font-size: 15px;
  background: #fdf3e7; border-radius: 8px; margin-bottom: 6px;
}

/* ================= 表格默写 ================= */
table.recite { width: 100%; border-collapse: collapse; background: #fff; }
table.recite td {
  border: 1px solid #ccc; text-align: center; padding: 4px 2px; font-size: 14px; width: 10%;
}
table.recite td.q { background: #faf6ee; font-weight: bold; }
table.recite input {
  width: 100%; border: none; outline: none; text-align: center;
  font-size: 14px; padding: 8px 0; background: transparent;
}
table.recite td.right { background: #e8f8ee; }
table.recite td.wrong { background: #fdecea; }
table.recite td .ans { font-size: 11px; color: #c0392b; margin-top: 2px; }
.timer { font-size: 13px; color: #888; }

/* ================= 练习记录 ================= */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.stat-card { background: #faf6ee; border-radius: 10px; padding: 12px 4px; text-align: center; }
.stat-card .num { font-size: 20px; font-weight: bold; color: #c0392b; }
.stat-card .label { font-size: 11px; color: #999; margin-top: 2px; }
#hist-chart { width: 100%; height: 160px; background: #faf6ee; border-radius: 10px; }
.hist-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 12px; background: #faf6ee; border-radius: 8px; margin-bottom: 6px; font-size: 13px;
}
.hist-item .tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; color: #fff; margin-right: 8px; }
.tag-quiz { background: #c0392b; }
.tag-recite { background: #2980b9; }
.tag-game { background: #8e44ad; }
.hist-item .score { font-weight: bold; white-space: nowrap; }
.hist-empty { text-align: center; color: #aaa; padding: 30px 0; font-size: 14px; }

/* ================= 趣味闯关 ================= */
.game-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.game-tab {
  flex: 1; padding: 10px 4px; border: none; border-radius: 8px;
  background: #f5f1e8; color: #777; font-size: 14px; cursor: pointer;
}
.game-tab.active { background: #c0392b; color: #fff; font-weight: bold; }
.game-controls { margin-bottom: 6px; }
.game-meta, .sprint-score {
  display: flex; justify-content: space-around; gap: 8px; text-align: center;
  padding: 10px 4px; margin: 8px 0 12px; border-radius: 8px;
  background: #faf6ee; color: #777; font-size: 13px;
}
.game-meta b, .sprint-score b { color: #c0392b; font-size: 17px; }
.game-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.game-tile {
  min-width: 0; min-height: 78px; padding: 8px 3px; border: 2px solid transparent;
  border-radius: 10px; background: #faf6ee; color: #333; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  font-size: 18px; font-weight: bold; cursor: pointer; transition: transform .15s, background .15s, border-color .15s;
}
.game-tile:hover { transform: translateY(-2px); }
.game-tile.selected { border-color: #c0392b; background: #fdf3e7; }
.game-tile.correct, .sprint-option.correct { border-color: #27ae60; background: #e8f8ee; color: #208a4b; }
.game-tile.wrong, .sprint-option.wrong { border-color: #c0392b; background: #fdecea; color: #c0392b; }
.game-tile.eliminated { visibility: hidden; }
.game-tile:disabled { opacity: 1; cursor: default; }
.memory-tile { background: #c0392b; color: #fff; }
.memory-back { font-size: 28px; }
.memory-value { display: none; }
.memory-tile.flipped, .memory-tile.matched { background: #faf6ee; color: #333; }
.memory-tile.flipped .memory-back, .memory-tile.matched .memory-back { display: none; }
.memory-tile.flipped .memory-value, .memory-tile.matched .memory-value { display: block; }
.memory-tile.matched { border-color: #27ae60; background: #e8f8ee; }
.sprint-wrap { min-height: 280px; }
.sprint-score { margin-top: 0; }
.sprint-score #sprint-time { color: #8e44ad; }
.sprint-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sprint-option {
  min-height: 58px; border: 2px solid #e5ddcc; background: #faf6ee;
  font-size: 20px; font-weight: bold; opacity: 1;
}
.sprint-option:disabled { opacity: 1; }
.sprint-option .frac { font-size: .8em; }
.game-result {
  margin-top: 16px; padding: 18px 12px; border-radius: 10px;
  background: #e8f8ee; text-align: center; color: #27794a;
}
.game-result[hidden] { display: none; }
.result-title { font-size: 21px; font-weight: bold; margin-bottom: 6px; }
.game-result p { font-size: 14px; margin-bottom: 14px; }

@media (max-width: 480px) {
  .game-board { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .game-tile { min-height: 70px; font-size: 16px; }
  .game-tab { font-size: 13px; }
  .game-meta, .sprint-score { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .game-tile { transition: none; }
  .game-tile:hover { transform: none; }
}
