/* ============================================================
   第10讲·综合复习大闯关：五个小程序共用主题
   - 可点区：主 56px / 关键 64px / 次 44px（R1/R3）
   - 壳高：100vh → 100dvh → 100svh；安全区四边
   - 动画只用 transform / opacity；reduced-motion 保留流程
   ============================================================ */

@font-face {
  font-family: 'Baloo2';
  src: url('fonts/baloo2-800.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #20304f;
  --ink-soft: #42557f;
  --cream: #fffcee;
  --cream-2: #fff4d6;
  --line: #20304f;
  --sky-1: #7ed2ff;
  --sky-2: #d9f4ff;
  --sky-3: #eafbff;

  --key: #ffb01f;
  --key-2: #ffd84d;
  --pink: #ff77a9;
  --teal: #3fd6c2;
  --purple: #a98bff;
  --orange: #ff9f45;
  --green: #7ddb92;

  --ok: #2fbf71;
  --bad: #ff6b6b;

  --radius: 26px;
  --radius-sm: 18px;
  --bw: 3px;
  --shadow: 0 7px 0 var(--ink);
  --shadow-soft: 0 16px 30px rgba(32, 48, 79, 0.16);

  --safe: max(12px, env(safe-area-inset-top), env(safe-area-inset-right), env(safe-area-inset-bottom), env(safe-area-inset-left));
  --font: 'Baloo2', 'PingFang SC', 'HarmonyOS Sans SC', 'MiSans', 'Microsoft YaHei', 'Noto Sans SC', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* 五个程序各自的强调色 */
body[data-app='calc']   { --key: #ffb01f; --key-2: #ffe27a; }
body[data-app='number'] { --key: #2fc9b4; --key-2: #b8f4ea; }
body[data-app='picture']{ --key: #ff77a9; --key-2: #ffd0e1; }
body[data-app='shape']  { --key: #5bc0eb; --key-2: #c8ecfa; }
body[data-app='hq']     { --key: #a98bff; --key-2: #e2d8ff; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 46%, var(--sky-3) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before,
body::after {
  content: '';
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0.5;
}
body::before { width: 190px; height: 190px; right: -60px; top: -70px; background: radial-gradient(circle at 38% 34%, #fff7c2, var(--key-2) 60%, transparent 62%); }
body::after { width: 260px; height: 130px; left: -70px; bottom: -30px; background: radial-gradient(ellipse at center, #b9f0c4, transparent 70%); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
:focus-visible { outline: 4px solid var(--purple); outline-offset: 3px; }

h1, h2, h3, p { margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------- 壳 ---------------- */
.app {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  padding: calc(var(--safe) + 2px) calc(var(--safe) + 2px) calc(var(--safe) + 14px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 2px;
}

.brand {
  font-size: clamp(20px, 4.6vw, 28px);
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.brand__emoji { font-size: 1.15em; }
.brand__sub { font-size: 0.55em; color: var(--ink-soft); font-weight: 600; }

.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 52px; height: 52px;
  display: inline-grid; place-items: center;
  font-size: 24px;
  border: var(--bw) solid var(--ink);
  border-radius: 16px;
  background: var(--cream);
  box-shadow: 0 5px 0 var(--ink);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.icon-btn.is-off { opacity: 0.55; }

/* ---------------- 按钮 ---------------- */
.btn {
  min-height: 56px;
  padding: 12px 22px;
  border: var(--bw) solid var(--ink);
  border-radius: 18px;
  background: var(--cream);
  color: var(--ink);
  font-size: clamp(17px, 3.6vw, 21px);
  font-weight: 800;
  box-shadow: 0 6px 0 var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn--primary { background: linear-gradient(180deg, var(--key-2), var(--key)); }
.btn--ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn--lg { min-height: 64px; padding: 14px 28px; font-size: clamp(19px, 4.2vw, 24px); border-radius: 22px; }
.btn--good { background: linear-gradient(180deg, #c8f7d8, var(--ok)); color: #fff; }
.btn--bad { background: linear-gradient(180deg, #ffd1d1, var(--bad)); color: #fff; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--cream);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: clamp(14px, 3vw, 24px);
}
.card--tight { padding: 12px; }
.card__title { font-size: clamp(20px, 4.4vw, 26px); font-weight: 800; }
.card__text { color: var(--ink-soft); font-size: clamp(15px, 3.2vw, 18px); line-height: 1.55; margin-top: 6px; }

.screen { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.screen[hidden], [hidden] { display: none !important; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fff;
  font-size: 14px; font-weight: 700; color: var(--ink-soft);
}

/* ---------------- HUD ---------------- */
.hud { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hud__label { font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--ink);
  background: #fff;
}
.dot.is-done { background: var(--ok); }
.dot.is-bad { background: var(--bad); }
.dot.is-now { background: var(--key); transform: scale(1.18); }
.hud__spacer { flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink-soft); }

/* ---------------- 题目 ---------------- */
.prompt {
  font-size: clamp(20px, 4.4vw, 28px);
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  padding: 4px 6px;
}
.prompt--sm { font-size: clamp(17px, 3.8vw, 22px); font-weight: 700; }

.eq {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(6px, 2vw, 14px);
  flex-wrap: wrap;
  font-size: clamp(38px, 11vw, 64px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 8px 0;
}
.eq .tok {
  min-width: 1.4em; text-align: center;
  padding: 2px 10px; border-radius: 14px;
  background: #fff;
  border: var(--bw) solid var(--ink);
}
.eq .slot {
  min-width: 1.6em; min-height: 1.3em;
  display: inline-grid; place-items: center;
  border-radius: 14px;
  border: var(--bw) dashed var(--ink-soft);
  background: #fffef7;
  color: var(--ink-soft);
}
.eq .slot.is-ok { border-style: solid; border-color: var(--ok); color: var(--ok); }
.eq .slot.is-bad { border-style: solid; border-color: var(--bad); color: var(--bad); }
.eq .op { color: var(--ink-soft); }

/* 十格阵（5×2） */
.tenframe {
  --cell: clamp(30px, 7vw, 44px);
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  gap: 6px;
  justify-content: center;
  padding: 10px;
  border: var(--bw) solid var(--ink);
  border-radius: 18px;
  background: #fff;
  width: max-content;
  margin: 0 auto;
  position: relative;
}
.tf-cell {
  width: var(--cell); height: var(--cell);
  border-radius: 8px;
  border: 2px solid #d9e2ef;
  background: #f7fbff;
  position: relative;
}
.tf-cell.is-on::after {
  content: '';
  position: absolute; inset: 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffd9a0, var(--orange) 70%);
  border: 2px solid var(--ink);
}
.tf-cell.is-ten::after { background: radial-gradient(circle at 34% 30%, #b8f4ea, var(--teal) 70%); }
.tf-cell.is-move { outline: 3px dashed var(--purple); }
.tenframe__seam {
  position: absolute; left: 50%; top: 8px; bottom: 8px;
  width: 3px; background: var(--ink); opacity: 0.28; border-radius: 2px;
  transform: translateX(-50%);
}
.tenframe__hint {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 8px;
}

/* 数轴 */
.numline { display: block; width: 100%; max-width: 640px; margin: 0 auto; }
.numline text { font-family: var(--font); font-size: 13px; fill: var(--ink-soft); font-weight: 700; }

/* ---------------- 选项 ---------------- */
.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 14px);
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.choice {
  min-height: 64px;
  padding: 10px 6px;
  border: var(--bw) solid var(--ink);
  border-radius: 20px;
  background: #fff;
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 800;
  box-shadow: 0 6px 0 var(--ink);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.choice.is-ok { background: #d8f8e4; border-color: var(--ok); }
.choice.is-bad { background: #ffe1e1; border-color: var(--bad); }
.choice.is-dim { opacity: 0.45; }
.choice small { display: block; font-size: 0.48em; font-weight: 700; color: var(--ink-soft); margin-top: 2px; }

/* 数字卡（拖拽/点选列式用） */
.cards { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.numcard {
  min-width: 64px; min-height: 64px;
  padding: 6px 14px;
  display: inline-grid; place-items: center;
  border: var(--bw) solid var(--ink);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, var(--cream-2));
  font-size: 30px; font-weight: 800;
  box-shadow: 0 6px 0 var(--ink);
}
.numcard.is-selected { background: var(--key-2); transform: translateY(-3px); }
.numcard.is-used { opacity: 0.35; pointer-events: none; }

/* ---------------- 反馈 ---------------- */
.fb {
  border: var(--bw) solid var(--ink);
  border-radius: 20px;
  padding: 12px 16px;
  background: #fff;
  display: flex; gap: 12px; align-items: flex-start;
  box-shadow: var(--shadow-soft);
}
.fb.is-ok { background: #e9fbef; border-color: var(--ok); }
.fb.is-bad { background: #fff0f0; border-color: var(--bad); }
.fb__ico { font-size: 28px; line-height: 1; }
.fb__title { font-size: clamp(17px, 3.6vw, 21px); font-weight: 800; }
.fb__text { font-size: clamp(15px, 3.2vw, 18px); color: var(--ink-soft); line-height: 1.5; margin-top: 2px; }

/* ---------------- 弹层 ---------------- */
.wf-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(16, 26, 46, 0.45);
  opacity: 0; transition: opacity 160ms ease;
}
.wf-overlay.is-on { opacity: 1; }
.wf-modal {
  width: min(520px, 100%);
  background: var(--cream);
  border: var(--bw) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 4vw, 26px);
  display: flex; flex-direction: column; gap: 12px;
  transform: translateY(8px) scale(0.98);
  transition: transform 160ms ease;
  max-height: min(86vh, 720px);
  overflow: auto;
}
.wf-overlay.is-on .wf-modal { transform: none; }
.wf-modal__title { font-size: clamp(20px, 4.4vw, 26px); font-weight: 800; }
.wf-modal__text { font-size: clamp(15px, 3.4vw, 18px); color: var(--ink-soft); line-height: 1.6; }
.wf-modal__actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.wf-toast {
  position: fixed; left: 50%; bottom: calc(var(--safe) + 18px);
  transform: translate(-50%, 14px);
  z-index: 70;
  background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 15px; font-weight: 700;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  max-width: 86vw; text-align: center;
}
.wf-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.wf-confetti-layer { position: fixed; inset: 0; z-index: 80; pointer-events: none; overflow: hidden; }
.wf-confetti {
  position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 3px;
  animation: wf-fall 1.5s ease-in forwards;
}
@keyframes wf-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(88vh) rotate(520deg); opacity: 0.9; }
}

/* ---------------- 报告 ---------------- */
.wf-report { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.wf-report__emoji { font-size: clamp(40px, 10vw, 56px); }
.wf-report__title { font-size: clamp(22px, 5vw, 30px); font-weight: 800; }
.wf-report__subtitle { color: var(--ink-soft); font-size: clamp(15px, 3.2vw, 17px); }
.wf-bars { display: flex; flex-direction: column; gap: 8px; text-align: left; margin-top: 4px; }
.wf-bar { display: grid; grid-template-columns: 6.4em 1fr auto; gap: 8px; align-items: center; }
.wf-bar__label { font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.wf-bar__track { height: 20px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.wf-bar__fill { display: block; height: 100%; background: var(--key); width: 0; transition: width 500ms ease; }
.wf-bar__fill.is-good { background: var(--ok); }
.wf-bar__fill.is-mid { background: var(--key); }
.wf-bar__fill.is-low { background: var(--bad); }
.wf-bar__num { font-size: 14px; font-variant-numeric: tabular-nums; }
.wf-rows { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 6px 0 0; text-align: left; }
.wf-rows dt { font-size: 14px; color: var(--ink-soft); }
.wf-rows dd { margin: 0; font-size: 14px; font-weight: 800; text-align: right; }
.wf-report__note { font-size: 14px; color: var(--ink-soft); line-height: 1.55; }
.wf-report__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.wf-star { font-size: 30px; color: #d8dee9; line-height: 1; }
.wf-star.is-on { color: var(--key); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }

/* ---------------- 小工具 ---------------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }
.grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 380px) {
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand { font-size: 19px; }
  .card { border-radius: 20px; }
}

@media (min-width: 760px) {
  body[data-wide='two'] .two-col { display: grid; grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr); gap: 16px; align-items: start; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .app { gap: 8px; }
  .topbar { padding: 0; }
  .brand { font-size: 18px; }
  .icon-btn { width: 46px; height: 46px; }
  .eq { font-size: clamp(30px, 6vw, 44px); }
  .btn { min-height: 48px; }
  .choices .choice { min-height: 56px; }
}

/* ---------------- 关卡列表 ---------------- */
.track-card { display: flex; flex-direction: column; }
.level-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 64px;
  margin-top: 8px;
  padding: 10px 86px 10px 14px;
  border: var(--bw) solid var(--ink);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 3px 0 var(--ink);
  text-align: left;
}
.level-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.level-btn__main { font-size: clamp(16px, 3.4vw, 19px); font-weight: 800; }
.level-btn__note {
  font-size: 13px; color: var(--ink-soft); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.level-btn__right { position: absolute; right: 12px; top: 12px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.level-btn__stars { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 2px; }
.level-btn__stars .wf-star { font-size: 15px; }

@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.numcard--dot {
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  font-size: 20px;
  color: #1f8f7c;
  line-height: 1;
}
.numcard--static { pointer-events: none; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
