/* ============================================================
   24点 — 样式（Chrome 61 基线层）
   约束：无 flex gap / aspect-ratio / clamp / inset / 逻辑属性 / :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: #f5f7fa;
  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: 480px; /* PC 打开居中、内容不超宽 */
  margin: 0 auto;
  min-width: 0;
}

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

.btn:active { opacity: 0.75; }
.btn-primary { background: #2f6feb; color: #ffffff; }

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

.home-hint {
  font-size: 12px;
  color: #8a919f;
  text-align: center;
  margin: -4px 0 12px;
}

.home-list { margin-top: 4px; }

.diff-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.diff-btn {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 10px;
  font-size: 18px;
  font-weight: 600;
  color: #1f2329;
  background: #f0f6ff;
  cursor: pointer;
}

.diff-btn:active { opacity: 0.7; }

.diff-meta {
  margin-top: 8px;
  font-size: 12px;
  color: #8a919f;
  text-align: center;
}

/* ---------- 模式切换 ---------- */
.mode-title {
  font-size: 14px;
  font-weight: 600;
  color: #4e5969;
  margin: 14px 0 8px;
  text-align: center;
}

.mode-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}

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

.mode-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;
}

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

/* ---------- 对局页：顶部状态栏 ---------- */
.game-top {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 12px;
}

.game-back {
  border: none;
  background: none;
  color: #2f6feb;
  font-size: 14px;
  min-height: 36px;
  padding: 0 8px 0 0;
  cursor: pointer;
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
}

.game-info {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.game-diffmode {
  font-size: 14px;
  font-weight: 600;
  color: #4e5969;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.game-timer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 700;
  color: #2f6feb;
  min-width: 62px;
  text-align: center;
}

.game-hint {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  border: none;
  background: #ffffff;
  color: #2f6feb;
  font-size: 13px;
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  margin-left: 6px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.game-hint:active { background: #eef4ff; }

/* ---------- 牌面区：2×2 ---------- */
.cards-grid {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin: -6px;
}

.card-cell {
  width: 50%;
  padding: 6px;
  min-width: 0;
}

.card-face {
  position: relative;
  display: block;
  width: 100%;
  height: 92px;
  border: none;
  border-radius: 14px;
  background: #ffffff;
  color: #1f2329;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  text-align: center;
  line-height: 92px;
}

.card-face:active { background: #eef4ff; }

.card-face:disabled {
  background: #f2f3f5;
  color: #c9cdd4;
  box-shadow: none;
  cursor: default;
}

.card-suit {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 14px;
  color: #c9cdd4;
  line-height: 1;
}

.card-num {
  font-size: 38px;
  font-weight: 800;
}

/* 正确反馈：牌面区绿色闪烁 + ✓ */
@-webkit-keyframes hitFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
@keyframes hitFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.cards-grid.cards-hit .card-face {
  -webkit-animation: hitFlash 0.45s ease;
  animation: hitFlash 0.45s ease;
}

.cards-grid.cards-hit::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  font-size: 64px;
  font-weight: 800;
  color: #12b76a;
  text-shadow: 0 2px 8px rgba(255, 255, 255, 0.95);
  z-index: 5;
  pointer-events: none;
  line-height: 1;
}

/* ---------- 表达式区 ---------- */
.expr-display {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  background: #ffffff;
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

.expr-text {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 20px;
  font-weight: 700;
  color: #1f2329;
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.expr-text.placeholder {
  font-size: 13px;
  font-weight: 400;
  color: #c9cdd4;
}

.expr-preview {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  margin-left: 8px;
  font-size: 18px;
  font-weight: 700;
  color: #4e5969;
}

.expr-preview.dim { color: #c9cdd4; font-weight: 400; }
.expr-preview.bad { color: #f04438; }
.expr-preview.hit { color: #12b76a; }

/* ---------- 运算符 / 工具按钮 ---------- */
.op-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 12px;
}

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

.op-btn {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  border: none;
  border-radius: 12px;
  background: #ffffff;
  color: #2f6feb;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

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

.util-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 10px;
}

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

.util-btn {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  background: #f0f6ff;
  color: #4e5969;
  font-size: 16px;
  cursor: pointer;
}

.util-btn:active { background: #dbe7ff; }

/* ---------- 提交行 ---------- */
.submit-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  margin-top: 14px;
}

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

/* ---------- 成绩列表 ---------- */
.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-right { text-align: right; }

.point-time { font-size: 16px; font-weight: 700; color: #2f6feb; }

.point-hint-mark {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px;
  color: #f5a623;
  border: 1px solid #f5a623;
  border-radius: 4px;
  padding: 0 4px;
}

.best-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.best-item {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

.best-item span { font-size: 11px; color: #8a919f; }

.best-item b {
  display: block;
  font-size: 15px;
  color: #2f6feb;
  margin-top: 2px;
}

/* ---------- 打卡日历 ---------- */
.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 #2f6feb; }

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

/* ---------- 结果浮层 / 提示浮层 ---------- */
.result-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(15, 23, 42, 0.5);
  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;
  padding: 24px;
}

.result-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);
}

.result-title { font-size: 14px; color: #4e5969; }

.result-time {
  font-size: 44px;
  font-weight: 800;
  color: #2f6feb;
  margin-top: 4px;
}

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

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

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

.result-stars {
  font-size: 22px;
  color: #f5a623;
  margin-top: 10px;
  letter-spacing: 4px;
}

.result-record {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #12b76a;
}

.result-note {
  margin-top: 10px;
  font-size: 12px;
  color: #8a919f;
}

.result-line {
  margin-top: 10px;
  font-size: 13px;
  color: #4e5969;
}

.result-ok {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 800;
  color: #12b76a;
}

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

.hint-box { max-width: 320px; }

.hint-expr {
  font-size: 22px;
  font-weight: 800;
  color: #1f2329;
  margin-top: 10px;
  word-break: break-all;
}

.hint-eq {
  font-size: 16px;
  font-weight: 700;
  color: #12b76a;
  margin-top: 4px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  background: rgba(31, 35, 41, 0.9);
  color: #ffffff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 1100;
  max-width: 78%;
  text-align: center;
  pointer-events: none;
  white-space: normal;
}

.toast-error { background: rgba(240, 68, 56, 0.95); }

/* ---------- 底栏 ---------- */
.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: #2f6feb;
  text-align: center;
  border-radius: 8px;
  background: #f2f3f5;
}

/* ---------- 安全区增强 ---------- */
@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)); }
}

/* ============================================================
   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 分享打卡（挑战结果浮层 → 全屏分享弹层）
   z-index 1000 覆盖在结果浮层（999）之上，关闭后返回结果浮层
   ============================================================ */
.share-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  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 防沉迷（首页限时设置行 + 到点提醒浮层）
   Chrome 61 基线：无 gap/aspect-ratio/clamp/:has/dvh/inset，flex 用 margin 分隔
   ============================================================ */
.limit-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
}

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

.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;
}

.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;
}

/* 到点提醒浮层：全屏 fixed；z-index 1001 高于结算(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%;
}
