/* ============================================================
   划消训练 — 样式（Chrome 61 基线，专注力·天蓝系）
   约束：无 flex gap / aspect-ratio / clamp() / inset / 逻辑属性 / :has / dvh
   网格用 width + padding-bottom %（正方形卡片），间距用 margin / 内层 inset
   ============================================================ */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #e8f4ff;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: #2a3a4a;
  height: var(--app-height, 100vh);
  overflow: hidden;
}

#app-main {
  height: calc(100% - 118px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  min-height: 100%;
}

/* ---------- 头部 ---------- */
.app-header {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(74, 168, 255, 0.14);
  position: relative;
  z-index: 5;
}

.header-brand {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 16px;
}

.header-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  margin-right: 10px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: #2a3a4a;
}

.header-ver {
  margin-left: 8px;
  font-size: 12px;
  color: #7a8ea3;
  background: #eef5fb;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ---------- 通用按钮 ---------- */
button {
  font-family: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  -webkit-tap-highlight-color: transparent;
}

.btn-checkin {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 14px auto 0;
  padding: 12px 16px;
  background: #4aa8ff;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(74, 168, 255, 0.28);
}

.btn-checkin:active {
  background: #3a97e8;
  -webkit-transform: scale(0.98);
  transform: scale(0.98);
}

.btn-ghost-sm {
  padding: 8px 14px;
  font-size: 13px;
  color: #4aa8ff;
  background: #eef5fb;
  border-radius: 10px;
}

.btn-ghost-sm:active {
  background: #dcebfa;
}

/* ---------- 难度选择页 ---------- */
.page-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin: 22px 0 8px;
}

.home-hint {
  text-align: center;
  color: #7a8ea3;
  font-size: 14px;
  margin-bottom: 18px;
}

.diff-list {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.diff-btn {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(74, 168, 255, 0.1);
  text-align: left;
}

.diff-btn:active {
  background: #f4fafe;
  -webkit-transform: scale(0.99);
  transform: scale(0.99);
}

.diff-head {
  font-size: 16px;
  font-weight: 700;
  color: #2a3a4a;
}

.diff-sub {
  font-size: 12px;
  color: #7a8ea3;
  margin-top: 4px;
  display: block;
}

/* ---------- 游戏页 ---------- */
.topbar {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin-bottom: 10px;
}

.level-title {
  font-size: 16px;
  font-weight: 700;
  color: #2a3a4a;
}

.top-timer {
  font-size: 14px;
  color: #e76f51;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mark-round {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #4aa8ff;
  margin: 4px 0 8px;
}

/* 目标大卡 */
.mark-target {
  background: #fff;
  border-radius: 14px;
  padding: 10px 16px;
  margin-bottom: 6px;
  box-shadow: 0 3px 10px rgba(74, 168, 255, 0.16);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

.mark-target svg {
  width: 56px;
  height: 56px;
}

.mark-target-label {
  font-size: 14px;
  font-weight: 700;
  color: #4aa8ff;
  margin-right: 10px;
}

.game-status {
  text-align: center;
  font-size: 13px;
  color: #7a8ea3;
  min-height: 20px;
  margin-bottom: 10px;
}

/* 卡片网格（4 列） */
.mark-grid {
  width: 100%;
}

.mark-cell {
  float: left;
  width: 25%;
  padding: 3px;
  min-height: 48px;
}

.mark-inner {
  position: relative;
  background: #fff;
  border-radius: 10px;
  padding-bottom: 100%;
  height: 0;
  box-shadow: 0 2px 5px rgba(74, 168, 255, 0.1);
  border: 2px solid transparent;
}

.mark-inner svg {
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  width: calc(100% - 10px);
  height: calc(100% - 10px);
}

/* 划掉：红叉覆盖 + 图标淡化 */
.mark-cell.marked .mark-inner {
  background: #fff6f6;
  border-color: #ff9c9c;
  opacity: 0.75;
}

.mark-cell.marked .mark-inner:after {
  content: '✕';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 900;
  color: #ff5a5a;
  -webkit-animation: popMark 0.3s ease-out;
  animation: popMark 0.3s ease-out;
}

@-webkit-keyframes popMark {
  0% { -webkit-transform: scale(0.4); transform: scale(0.4); }
  60% { -webkit-transform: scale(1.2); transform: scale(1.2); }
  100% { -webkit-transform: scale(1); transform: scale(1); }
}

@keyframes popMark {
  0% { -webkit-transform: scale(0.4); transform: scale(0.4); }
  60% { -webkit-transform: scale(1.2); transform: scale(1.2); }
  100% { -webkit-transform: scale(1); transform: scale(1); }
}

/* 点错干扰项红闪（400ms） */
.mark-cell.wrong .mark-inner {
  border-color: #ff6b6b;
  background: #ffe9e6;
  -webkit-animation: wrongFlash 0.4s ease-out;
  animation: wrongFlash 0.4s ease-out;
}

@-webkit-keyframes wrongFlash {
  0% { background: #ffe9e6; }
  60% { background: #ffc9c4; }
  100% { background: #ffffff; }
}

@keyframes wrongFlash {
  0% { background: #ffe9e6; }
  60% { background: #ffc9c4; }
  100% { background: #ffffff; }
}

.mark-grid:after {
  content: '';
  display: block;
  clear: both;
}

/* ---------- 页脚 ---------- */
.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  box-shadow: 0 -2px 8px rgba(74, 168, 255, 0.1);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}

.game-footer {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
}

.game-footer .btn-ghost-sm {
  margin: 0 6px;
}

.footer-errors {
  margin-left: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #ff6b6b;
  min-width: 52px;
  text-align: center;
}

/* ---------- 结算浮层 ---------- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(20, 35, 55, 0.55);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.overlay-card {
  background: #fff;
  border-radius: 18px;
  padding: 24px 22px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(20, 35, 55, 0.25);
  -webkit-animation: popCard 0.3s ease-out;
  animation: popCard 0.3s ease-out;
}

@-webkit-keyframes popCard {
  0% { -webkit-transform: scale(0.85); transform: scale(0.85); opacity: 0; }
  100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

@keyframes popCard {
  0% { -webkit-transform: scale(0.85); transform: scale(0.85); opacity: 0; }
  100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

.overlay-title {
  font-size: 22px;
  font-weight: 700;
  color: #2a3a4a;
  margin-bottom: 6px;
}

.overlay-sub {
  font-size: 14px;
  color: #7a8ea3;
  margin-bottom: 10px;
}

.summary {
  margin-bottom: 14px;
}

.stars-line {
  font-size: 36px;
  line-height: 1.2;
  color: #f5a623;
  letter-spacing: 4px;
}

.record-badge {
  display: inline-block;
  margin-top: 8px;
  background: #e8faf0;
  color: #12b76a;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.checkin-line {
  margin-top: 8px;
  font-size: 13px;
  color: #12b76a;
  font-weight: 600;
}

.overlay-btns {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-justify-content: center;
  justify-content: center;
}

.overlay-btns .btn-main {
  background: #4aa8ff;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 12px;
  margin: 6px 5px;
  box-shadow: 0 4px 12px rgba(74, 168, 255, 0.3);
}

.overlay-btns .btn-ghost {
  background: #eef5fb;
  color: #4aa8ff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 12px;
  margin: 6px 5px;
}

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

.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: #7a8ea3;
  background: #f2f7fc;
}

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

.cal-day.today {
  outline: 2px solid #4aa8ff;
}

.streak-info {
  text-align: center;
  margin-top: 10px;
  font-size: 14px;
  color: #2a3a4a;
}

.streak-info b {
  color: #ff9c1a;
}