/* ============================================================
   数学口算 — 样式（Chrome 61 基线层）
   约束：无 flex gap / aspect-ratio / clamp / 逻辑属性 / :has
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f2f3f5;
  color: #1f2329;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-flex-direction: column;
  flex-direction: column;
  height: 100vh;
  height: calc(var(--app-height, 100vh));
}

/* ---------- 顶栏 ---------- */
.app-header {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  background: #ffffff;
  border-bottom: 1px solid #e5e6eb;
}

.header-brand {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 10px 16px;
}

.header-icon {
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border-radius: 8px;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.header-title { font-size: 17px; font-weight: 600; }

.header-ver {
  margin-left: 6px;
  font-size: 10px;
  color: #c9cdd4;
}

/* ---------- 主体 ---------- */
.app-main {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.view { padding: 12px 16px; max-width: 720px; margin: 0 auto; }

/* ---------- 通用按钮 ---------- */
.btn {
  min-height: 48px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  color: #165dff;
  background: #eef3ff;
  cursor: pointer;
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
}

.btn:active { opacity: 0.7; }
.btn-primary { background: #165dff; color: #ffffff; }

/* ---------- 首页：选年级 ---------- */
.page-title {
  font-size: 16px;
  font-weight: 600;
  margin: 8px 0 12px;
  text-align: center;
}

.grade-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.grade-grid > * {
  width: 33.333%;
  padding: 5px;
}

.grade-btn {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  color: #1f2329;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ---------- 知识点列表 ---------- */
.point-list { margin-top: 4px; }

.point-item {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  padding: 14px 16px;
  background: #ffffff;
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.point-name { font-size: 15px; font-weight: 600; }

.point-meta { font-size: 12px; color: #8a919f; margin-top: 3px; }

.point-stars { font-size: 13px; color: #f5a623; }

/* ---------- 练习页 ---------- */
.quiz-top {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 10px;
}

.quiz-progress { font-size: 14px; color: #4e5969; }
.quiz-combo { font-size: 14px; color: #f5a623; font-weight: 600; min-width: 48px; text-align: right; }

.quiz-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  min-height: 160px;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.quiz-expression { font-size: 34px; font-weight: 700; letter-spacing: 2px; }

.quiz-answer-area { min-height: 48px; margin-top: 10px; }
.quiz-answer { font-size: 30px; font-weight: 700; color: #165dff; min-height: 42px; }

.quiz-feedback {
  min-height: 36px;
  margin-top: 8px;
  font-size: 16px;
  font-weight: 600;
}

.quiz-feedback.ok { color: #00a854; }
.quiz-feedback.bad { color: #f5222d; }

/* 数字键盘 */
.keypad {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 14px;
}

.keypad > * {
  width: 33.333%;
  padding: 5px;
}

.key-btn {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 600;
  background: #ffffff;
  color: #1f2329;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.key-btn:active { background: #eef3ff; }

/* ---------- 结果页 ---------- */
.result-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.result-score { font-size: 42px; font-weight: 800; color: #165dff; }

.result-stats {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  margin-top: 12px;
}

.result-stat {
  margin: 0 14px;
  font-size: 14px;
  color: #4e5969;
  text-align: center;
}

.result-stat b { display: block; font-size: 20px; color: #1f2329; }

.btn-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 12px;
}

.btn-row > * + * { margin-left: 10px; }

/* ---------- 底栏 ---------- */
.app-footer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 1px solid #e5e6eb;
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

.footer-nav {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 8px 12px 10px;
}

.footer-nav > * + * { margin-left: 10px; }

.footer-btn {
  min-width: 64px;
  padding: 9px 0;
  font-size: 13px;
  color: #165dff;
  text-align: center;
  border-radius: 8px;
  background: #f2f3f5;
}

/* ---------- 打卡日历 ---------- */
.calendar {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.calendar-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 8px;
}

.calendar-grid > * { width: 14.28%; padding: 4px; }

.cal-day {
  width: 100%;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  border-radius: 6px;
  color: #8a919f;
  background: #f7f8fa;
}

.cal-day.done { background: #ff9c1a; color: #ffffff; font-weight: 700; }

.cal-day.today { outline: 2px solid #165dff; }

.streak-info { text-align: center; margin-top: 10px; font-size: 14px; color: #4e5969; }
.streak-info b { color: #ff9c1a; }

/* 安全区增强 */
@supports ((padding-bottom: var(--safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom))) {
  .app-header { padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px)); }
  .app-footer { padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)); }
}

/* ---------- 计时挑战：倒计时 ---------- */
.quiz-timer {
  font-size: 14px;
  font-weight: 600;
  color: #165dff;
  min-width: 60px;
  text-align: center;
}

.quiz-timer.danger { color: #f5222d; }

/* ---------- 计时模式选择弹窗 ---------- */
.timer-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0; /* Chrome 61 回退用 top/right/bottom/left，新浏览器用 inset */
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.timer-box {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 24px;
  width: 82%;
  max-width: 320px;
  text-align: center;
}

.timer-box .btn {
  display: block;
  width: 100%;
  margin-top: 10px;
}

/* ---------- 勋章墙：3 列网格（不用 flex gap，用百分比宽度 + margin） ---------- */
.badge-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.badge-item {
  width: 30%;
  margin: 1.66%;
  box-sizing: border-box;
  background: #f7f8fa;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.badge-icon {
  font-size: 26px;
  margin-bottom: 4px;
}

.badge-name {
  font-size: 13px;
  font-weight: 600;
  color: #1f2329;
}

.badge-desc {
  font-size: 11px;
  color: #8a919f;
  margin-top: 2px;
}

/* ============================================================
   v1.1 进步曲线（成就页）
   ============================================================ */
.progress-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.progress-card .page-title { text-align: center; }

.line-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 8px;
}

.progress-hint {
  text-align: center;
  color: #8a919f;
  font-size: 14px;
  padding: 22px 0;
}

/* ============================================================
   v1.1 打印题卡（结果页 → window.print()）
   #print-sheet 为 body 子级打印容器：平时 display:none，仅 @media print 显示
   约束：Chrome 61 兼容（flex 双前缀写法 / page-break-inside）独立于屏幕样式
   ============================================================ */
#print-sheet { display: none; }

@media print {
  html, body {
    height: auto !important;
    background: #ffffff;
  }

  .app-header,
  .app-footer,
  #view { display: none !important; }

  #print-sheet {
    display: block !important;
    color: #000000;
    font-size: 15px;
    line-height: 1.6;
  }

  .print-head { margin-bottom: 14px; }

  .print-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
  }

  .print-meta {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    font-size: 13px;
  }

  .print-score {
    margin-top: 6px;
    font-size: 13px;
  }

  .print-body { margin-top: 8px; }

  .print-item {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    padding: 7px 0;
    border-bottom: 1px solid #d8d8d8;
    page-break-inside: avoid;
  }

  .print-no {
    width: 28px;
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 auto;
    flex: 0 0 auto;
    color: #4e5969;
  }

  .print-q {
    font-weight: 600;
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 auto;
    flex: 1 1 auto;
  }

  .print-ans {
    display: inline-block;
    width: 90px;
    height: 15px;
    border-bottom: 1px solid #000000;
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 auto;
    flex: 0 0 auto;
  }
}

/* ============================================================
   v1.1 分享打卡（结果页 → 全屏分享弹层）
   覆盖 .timer-overlay 模式：全屏 fixed 遮罩 + flex 居中
   ============================================================ */
.share-overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0; /* Chrome 61 回退用 top/right/bottom/left，新浏览器用 inset */
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.share-box {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  width: 88%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}

.share-card-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.share-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #8a919f;
}

.share-text {
  width: 100%;
  box-sizing: border-box;
  min-height: 60px;
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  color: #1f2329;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  background: #f7f8fa;
  resize: none;
  -webkit-user-select: text;
  user-select: text;
}

.share-feedback {
  min-height: 20px;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
}

.share-feedback.ok { color: #00a854; }
.share-feedback.bad { color: #f5222d; }

.share-btns {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 10px;
}

.share-btns > * + * { margin-left: 10px; }

/* ============================================================
   v1.2 防沉迷/自控力（V0.5 guard 通用能力接入）
   样式复用 24点 v1.2（limit-row/limit-btn/limit-overlay），Chrome 61 兼容
   ============================================================ */
.limit-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
}

.limit-row > * + * { margin-left: 10px; }

.limit-row .limit-btn {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #d5d9e0;
  border-radius: 10px;
  background: #ffffff;
  color: #4e5969;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
}

.limit-btn:active { background: #eef4ff; }

.limit-btn.active {
  background: #2f6feb;
  border-color: #2f6feb;
  color: #ffffff;
  font-weight: 600;
}

.limit-hint {
  font-size: 12px;
  color: #8a919f;
  text-align: center;
  margin-top: 8px;
  margin-bottom: 12px;
}

/* 到点提醒浮层：全屏 fixed；z-index 高于结算(999)/分享(1000) */
.limit-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1001;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  padding: 24px;
}

.limit-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.limit-title {
  font-size: 20px;
  font-weight: 700;
  color: #1f2329;
}

.limit-desc {
  font-size: 14px;
  color: #4e5969;
  margin-top: 10px;
}

.limit-btns {
  margin-top: 18px;
}

.limit-btns > * + * { margin-top: 10px; }

.limit-btns .btn {
  display: block;
  width: 100%;
}
