/* =====================================================================
   styles.css —— 一套样式，两个场景：iPad 横屏为主，竖屏/手机自动收
   原则：大字、大按钮、少装饰。孩子的手指比鼠标粗得多。
   ===================================================================== */

:root {
  --bg: #FFF8EE;
  --card: #FFFFFF;
  --ink: #3A2A1E;
  --ink-soft: #96806C;
  --red: #E5484D;
  --red-soft: #FFECEA;
  --green: #2F9E44;
  --line: #F0E2CE;
  --btn-shadow: 0 5px 0 #E7D3B7, 0 10px 20px rgba(180, 140, 90, 0.10);
  --cell: clamp(30px, 5vw, 58px);
  --safe: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.app { height: 100%; }

/* 通用图标按钮 */
.iconbtn {
  width: 52px; height: 52px;
  border: 0; border-radius: 16px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 28px; line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
}
.iconbtn:active { background: rgba(180, 140, 90, 0.12); }
.iconbtn--float { position: absolute; top: 18px; left: 18px; z-index: 5; }

/* ===================================================================
   屏幕容器
   =================================================================== */
.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: calc(14px + var(--safe)) calc(18px + var(--safe-r)) calc(14px + var(--safe-b)) calc(18px + var(--safe-l));
}
.screen[hidden] { display: none; }

/* ===================================================================
   主屏
   =================================================================== */
.screen { gap: clamp(6px, 1.4vh, 16px); }

.bar { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.bar__right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* 内容模块：只显示被 release 的那些。将来模块多了，这里横向可滑 */
.chips {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 18px;
  background: #F4E7D5;
  max-width: min(72vw, 640px);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  border: 0;
  border-radius: 14px;
  padding: 10px 20px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.chip.is-on {
  background: var(--ink);
  color: #FFF8EE;
  box-shadow: 0 2px 8px rgba(58, 42, 30, 0.22);
}

.stars { font-size: 18px; color: var(--ink-soft); padding: 0 6px; white-space: nowrap; }
.stars b { color: var(--ink); font-size: 20px; }

/* ---------------- 题干 + 算式 ---------------- */
.quiz {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.2vh, 14px);
  padding: clamp(10px, 1.6vh, 18px) 0 0;
}

.eq {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.16em;
  font-size: clamp(60px, 10vw, 116px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.eq__num { min-width: 1.05em; text-align: center; }
.eq__num.is-blank { color: #D6C1A8; }
.eq__num.is-revealed { color: var(--green); animation: pop 0.45s cubic-bezier(.34,1.56,.64,1); }
.eq__op { color: #BD9A76; font-size: 0.82em; font-weight: 600; }

@keyframes pop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.16); }
  100% { transform: scale(1); }
}

/* ---------------- 五个选项 ---------------- */
.options {
  display: flex;
  justify-content: center;
  gap: clamp(8px, 1.6vw, 18px);
  margin-top: clamp(10px, 1.8vh, 22px);
  flex-wrap: wrap;
}

.option {
  min-width: clamp(78px, 10vw, 126px);
  height: clamp(70px, 11vh, 108px);
  border: 0;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: clamp(30px, 4.2vw, 54px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--btn-shadow);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}
.option:active { transform: translateY(5px); box-shadow: 0 1px 0 #E7D3B7; }
.option.is-right {
  background: #E9FAEC; color: var(--green);
  box-shadow: 0 5px 0 #BFE8C8;
  animation: pop 0.4s cubic-bezier(.34,1.56,.64,1);
}
.option.is-wrong {
  background: var(--red-soft); color: #C92A2A;
  animation: shake 0.4s ease;
}

/* 答错但不罚：橙色提示，不用红 */
.option.is-soft {
  background: #FFF4E0; color: #B4551D;
  box-shadow: 0 5px 0 #F0D8AE;
}
.option:disabled { cursor: default; }
.option:disabled:active { transform: none; box-shadow: 0 5px 0 #F0D8AE; }

/* 揭示答案时，把错的选择压下去，别和正确答案抢注意力 */
.option.is-dim {
  opacity: 0.5;
  background: #F6F1E9;
  color: #A2907C;
  box-shadow: none;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  50% { transform: translateX(7px); }
  80% { transform: translateX(-4px); }
}

/* ---------------- 苹果场（道具版） ----------------
   左边一盘 / 右边一包。未知的那部分用不透明的袋子表示，
   永远不摆成"可数的苹果"，否则孩子数一数就得到答案了。
   -------------------------------------------------- */
.boardwrap {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  animation: fadeIn 0.25s ease;
}
.boardwrap[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.stage { --cell: 48px; width: 100%; }

.scene {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.4vw, 18px);
  width: 100%;
}

.zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.zone.is-hidden { display: none; }

.zone__tag {
  font-size: clamp(12px, 1.4vw, 16px);
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  min-height: 1.2em;
}

.zone__body {
  position: relative;
  padding: 9px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.75);
  border: 2px dashed var(--line);
  min-width: calc(var(--cell) + 18px);
  min-height: calc(var(--cell) + 18px);
  display: grid;
  place-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), var(--cell));
  gap: 7px;
  justify-content: center;
}

.apple {
  width: var(--cell);
  height: var(--cell);
  display: grid;
  place-items: center;
  color: var(--red);
  will-change: transform, opacity;
}
.apple svg { width: 100%; height: 100%; display: block; }
.apple.is-counted { color: #C92A2A; filter: drop-shadow(0 0 6px rgba(229, 72, 77, 0.45)); }
/* 演示"去掉原来的那部分"时压暗，剩下的才是答案 */
.apple.is-old { opacity: 0.28; filter: grayscale(0.65); transform: scale(0.82); transition: all 0.4s ease; }

/* 袋子：不透明，标 ?。它是"未知"的唯一表现形式 */
.bag {
  display: none;
  position: absolute;
  inset: 5px;
  border-radius: 15px;
  background: linear-gradient(#F5DCB4, #E5C08A);
  box-shadow: inset 0 -7px 0 rgba(138, 90, 32, 0.10), 0 3px 8px rgba(160, 120, 70, 0.18);
  place-items: center;
  z-index: 2;
}
.bag.is-closed, .bag.is-opening { display: grid; }
.bag b {
  font-size: calc(var(--cell) * 0.85);
  color: #8A5A20;
  font-weight: 800;
}
.bag.is-gone { display: none; }

.scene__op {
  font-size: clamp(26px, 3.4vw, 44px);
  font-weight: 800;
  color: #BD9A76;
}
.scene__op.is-hidden { display: none; }

/* ---------------- 底部按钮 ---------------- */
.foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: clamp(6px, 1.2vh, 12px);
}

.btn {
  border: 0;
  border-radius: 22px;
  padding: 0 clamp(20px, 3vw, 34px);
  height: clamp(58px, 8vh, 74px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: inherit;
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--btn-shadow);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 #E7D3B7; }
.btn[hidden] { display: none; }

.btn--apple { background: #FFF3E2; color: #B4551D; }
.btn--apple svg { width: 26px; height: 26px; color: var(--red); }

.btn--next { background: var(--green); color: #fff; box-shadow: 0 5px 0 #237A34; }
.btn--next:active { box-shadow: 0 1px 0 #237A34; }


/* ===================================================================
   星星
   =================================================================== */
.spark {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  color: #F5A524;
  font-size: 24px;
  will-change: transform, opacity;
}

/* ===================================================================
   竖屏 / 手机
   =================================================================== */
@media (max-width: 720px), (orientation: portrait) and (max-width: 900px) {
  .chip { padding: 9px 14px; font-size: 15px; }
  .stars { display: none; }
}
