/* ============================================================
   影子配对 — 样式（Chrome 61 基线，天蓝系）
   主题：观察力子系列 · 天蓝系（背景 #e8f4ff / 主色 #4aa8ff /
   选择橙 #ff9f43 / 成功绿 #12b76a / 错误红 #ff6b6b）
   约束：
   - 无 flex gap / aspect-ratio / clamp() / inset / 逻辑属性 / :has / @container / dvh
   - 动画双写 @-webkit-keyframes + @keyframes；温和（<=400ms，无频闪）
   - flex 三重前缀（-webkit-box / -webkit-flex / flex）；子项 min-width:0
   - 正方形卡片：width 与 padding-bottom 同百分比（无 gap，内层定位成间隔）
   - 安全区 env(safe-area-inset-*) 组合；按钮 hit area >= 48x48
   - 影子实现：.shd-svg 施加 filter:brightness(0) 双层前缀，纯黑剪影
   ============================================================ */

*, *::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: #e8f4ff;
  color: #2a3a4a;
  -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));
  overflow: hidden;
}

/* ---------- 三段式骨架 ---------- */

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

.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: 8px 16px;
}

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

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

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

.app-main {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-footer {
  -webkit-box-flex: 0;
  -webkit-flex: 0 0 auto;
  flex: 0 0 auto;
  padding: 6px 16px calc(8px + var(--safe-area-inset-bottom, 0px));
  text-align: center;
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 6px 16px 20px;
  width: 100%;
  min-width: 0;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  margin-bottom: 6px;
  min-height: 40px;
}

.topbar .level-title {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 auto;
  flex: 1 1 auto;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #2a3a4a;
  min-width: 0;
}

.top-timer {
  font-size: 13px;
  font-weight: 700;
  color: #e76f51;
  min-width: 58px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn-ghost-sm {
  padding: 8px 14px;
  min-height: 36px;
  border: none;
  border-radius: 10px;
  background: #e8f4ff;
  color: #4aa8ff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

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

/* ---------- 已配对计数 / 引导文案 ---------- */

.pair-indicator {
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: #4aa8ff;
  margin-bottom: 4px;
}

.hint {
  text-align: center;
  font-size: 12px;
  color: #8aa3bd;
  margin-bottom: 4px;
  min-height: 18px;
}

.hint.hint-active { color: #e76f51; font-weight: 600; }

/* ---------- 配对行 ---------- */

.row-label {
  font-size: 12px;
  font-weight: 700;
  color: #8aa3bd;
  margin-bottom: 4px;
  text-align: center;
}

.pair-row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 14px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(74, 168, 255, 0.14);
  padding: 6px;
  min-width: 0;
}

/* M 张卡一行：3 → 33.33%；4 → 25%；5 → 20%（正方形：width 与 padding-bottom 同百分比） */
.pair-row.m3 .pair-cell { width: 33.3333%; padding-bottom: 33.3333%; }
.pair-row.m4 .pair-cell { width: 25%;     padding-bottom: 25%; }
.pair-row.m5 .pair-cell { width: 20%;     padding-bottom: 20%; }

.pair-cell {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.pair-cell.locked { cursor: default; }

/* 格内间距（不用 flex gap）：内层比格子小，形成间隔 */
.pair-inner {
  position: absolute;
  left: 5px;
  top: 5px;
  right: 5px;
  bottom: 5px;
  background: #ffffff;
  border: 2px solid #e0effd;
  border-radius: 12px;
  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;
  overflow: visible;
}

.pair-inner svg {
  width: 82%;
  height: auto;
  display: block;
}

/* 影子卡：浅灰底，纯黑剪影（filter:brightness(0) 双层前缀） */
.shd-cell .pair-inner {
  background: #eef2f6;
}

.shd-cell .cell-svg {
  -webkit-filter: brightness(0);
  filter: brightness(0);
}

.pair-cell:active .pair-inner {
  border-color: #4aa8ff;
}

/* ---------- 选中（实物卡，橙色描边） ---------- */

.obj-cell.selected .pair-inner {
  border-color: #ff9f43;
  background: #fff7ee;
  box-shadow: 0 0 0 2px rgba(255, 159, 67, 0.25);
}

/* ---------- 配对成功：绿框 + ✓ 角标 + 淡出缩小（pop 350ms） ---------- */

.pair-cell.matched .pair-inner {
  border-color: #12b76a;
  background: #e8faf0;
  opacity: 0.72;
  -webkit-animation: matchedPop 0.35s ease;
  animation: matchedPop 0.35s ease;
}

.pair-cell.matched .pair-inner:after {
  content: '✓';
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  background: #12b76a;
  color: #ffffff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  -webkit-animation: checkPop 0.35s ease;
  animation: checkPop 0.35s ease;
}

@-webkit-keyframes matchedPop {
  0% { -webkit-transform: scale(1.08); transform: scale(1.08); }
  100% { -webkit-transform: scale(0.94); transform: scale(0.94); }
}
@keyframes matchedPop {
  0% { -webkit-transform: scale(1.08); transform: scale(1.08); }
  100% { -webkit-transform: scale(0.94); transform: scale(0.94); }
}

@-webkit-keyframes checkPop {
  0% { -webkit-transform: scale(0); transform: scale(0); }
  60% { -webkit-transform: scale(1.25); transform: scale(1.25); }
  100% { -webkit-transform: scale(1); transform: scale(1); }
}
@keyframes checkPop {
  0% { -webkit-transform: scale(0); transform: scale(0); }
  60% { -webkit-transform: scale(1.25); transform: scale(1.25); }
  100% { -webkit-transform: scale(1); transform: scale(1); }
}

/* ---------- 错配红闪（400ms） ---------- */

.shd-cell.wrong .pair-inner {
  border-color: #ff6b6b;
  background: #ffe9e6;
  -webkit-animation: wrongFlash 0.4s ease;
  animation: wrongFlash 0.4s ease;
}

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

/* ---------- 游戏页底栏 ---------- */

.game-footer {
  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;
}

.game-footer .btn-ghost-sm {
  margin: 0 5px;
  min-height: 40px;
}

.footer-errors {
  margin-left: 10px;
  font-size: 15px;
  font-weight: 800;
  color: #ff6b6b;
  min-width: 40px;
  text-align: left;
}

/* ---------- 首页：选难度 ---------- */

.page-title {
  font-size: 16px;
  font-weight: 700;
  margin: 8px 0 12px;
  text-align: center;
  color: #2a3a4a;
}

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

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

.diff-btn {
  display: block;
  width: 100%;
  min-height: 68px;
  border: none;
  border-radius: 14px;
  background: #ffffff;
  padding: 12px 18px;
  margin-bottom: 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(74, 168, 255, 0.14);
}

.diff-btn:active { background: #f0f7ff; }

.diff-head {
  display: block;
  font-size: 17px;
  font-weight: 800;
  color: #2a3a4a;
}

.diff-sub {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: #8aa3bd;
  font-weight: 600;
}

/* 底栏：打卡入口 / 返回 */

.btn-checkin {
  display: block;
  width: 100%;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: #4aa8ff;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-checkin:active { background: #3a97e8; }

/* ---------- 结算浮层 ---------- */

.overlay {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  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;
  z-index: 50;
  padding: 24px;
}

.overlay-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 26px 24px 24px;
  text-align: center;
  width: 100%;
  max-width: 340px;
  -webkit-animation: cardIn 0.25s ease;
  animation: cardIn 0.25s ease;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

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

.overlay-title {
  font-size: 26px;
  font-weight: 800;
  color: #2a3a4a;
}

.overlay-sub {
  margin-top: 6px;
  font-size: 14px;
  color: #8aa3bd;
}

.summary {
  margin: 16px 0 18px;
}

.summary .stars-line {
  font-size: 34px;
  letter-spacing: 6px;
  color: #f5a623;
  margin-bottom: 8px;
  -webkit-animation: starPop 0.35s ease;
  animation: starPop 0.35s ease;
}

@-webkit-keyframes starPop {
  0% { -webkit-transform: scale(0.4); transform: scale(0.4); opacity: 0; }
  60% { -webkit-transform: scale(1.25); transform: scale(1.25); }
  100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}
@keyframes starPop {
  0% { -webkit-transform: scale(0.4); transform: scale(0.4); opacity: 0; }
  60% { -webkit-transform: scale(1.25); transform: scale(1.25); }
  100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

.summary .checkin-line {
  margin-top: 6px;
  font-size: 13px;
  color: #4aa8ff;
  font-weight: 600;
}

.summary .record-badge {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 800;
  color: #12b76a;
}

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

.overlay-btns > * {
  margin: 4px 5px;
}

.btn-main {
  padding: 12px 30px;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: #4aa8ff;
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-main:active { background: #3a97e8; }

.btn-ghost {
  padding: 10px 22px;
  min-height: 48px;
  border: none;
  border-radius: 12px;
  background: #e8f4ff;
  color: #4aa8ff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:active { background: #d0e8fc; }

/* ---------- 打卡日历 ---------- */

.calendar {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(74, 168, 255, 0.14);
}

.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: #8aa3bd;
  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; }

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

/* ---------- 响应式：大屏微调 ---------- */

@media (min-width: 400px) {
  .topbar .level-title { font-size: 18px; }
}