/* ============================================================
   棒球乐园 · 设计系统
   面向 7 岁儿童 · iPad 触屏优先 · 明亮卡通
   ============================================================ */

:root {
  /* 主色板：草地 / 天空 / 泥土 / 阳光 / 棒球红线 */
  --grass: #3fa34d;
  --grass-dark: #2f7d3a;
  --grass-light: #7ed07a;
  --sky: #4fc3f7;
  --sky-dark: #039be5;
  --sky-light: #b3e5fc;
  --dirt: #d99f6c;
  --dirt-dark: #b97a45;
  --sun: #ffd23f;
  --sun-dark: #f4a900;
  --ball: #ffffff;
  --stitch: #ee4b4b;
  --ink: #23303a;
  --ink-soft: #5a6a75;
  --cream: #fff8ec;
  --card: #ffffff;
  --shadow: 0 8px 0 rgba(0,0,0,.10), 0 14px 26px rgba(35,48,58,.16);
  --shadow-sm: 0 4px 0 rgba(0,0,0,.08), 0 8px 16px rgba(35,48,58,.12);

  --r-lg: 28px;
  --r-md: 20px;
  --r-sm: 14px;

  --font: "Baloo 2", "Comic Sans MS", "PingFang SC", "Microsoft YaHei",
          -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --touch: 64px; /* 最小触控目标 */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--sky-light) 0%, var(--sky) 45%, var(--grass-light) 46%, var(--grass) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* 云朵装饰 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(closest-side, #fff 92%, transparent) ,
    radial-gradient(closest-side, #fff 92%, transparent);
  background-repeat: no-repeat;
  background-size: 160px 70px, 120px 55px;
  background-position: 8% 12%, 78% 8%;
  opacity: .55;
  z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: 1000px; margin: 0 auto; padding: 16px 16px 120px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid rgba(0,0,0,.06);
}
.topbar .home-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 20px; color: var(--ink);
  text-decoration: none;
  background: var(--sun); border: 3px solid var(--sun-dark);
  padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow-sm);
  min-height: 52px;
}
.topbar .spacer { flex: 1; }
.topbar .coin {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 20px; color: var(--ink);
  background: #fff; border: 3px solid var(--sun-dark);
  padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow-sm);
}

/* ---------- 通用文字 ---------- */
h1 { font-size: clamp(30px, 7vw, 52px); margin: 12px 0 4px; text-shadow: 0 3px 0 rgba(0,0,0,.12); }
h2 { font-size: clamp(24px, 5vw, 34px); margin: 8px 0; }
p.lead { font-size: clamp(18px, 3.4vw, 22px); color: var(--ink); line-height: 1.5; }
.center { text-align: center; }
.white { color: #fff; }

/* 术语气泡（中英对照，可点发音） */
.term {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--cream); border: 2px dashed var(--sun-dark);
  border-radius: 999px; padding: 2px 12px; margin: 2px;
  font-weight: 800; cursor: pointer;
}
.term .en { color: var(--sky-dark); font-size: .85em; }
.term::after { content: "🔊"; font-size: .8em; opacity: .6; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--touch); padding: 0 26px;
  font-family: var(--font); font-weight: 800; font-size: 22px;
  color: var(--ink); background: var(--sun);
  border: 4px solid var(--sun-dark); border-radius: 999px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(6px); box-shadow: 0 2px 0 rgba(0,0,0,.1); }
.btn.green { background: var(--grass-light); border-color: var(--grass-dark); color: #10331a; }
.btn.blue  { background: var(--sky-light); border-color: var(--sky-dark); color: #063a52; }
.btn.big   { font-size: 26px; min-height: 76px; padding: 0 40px; }
.btn.ghost { background: #fff; border-color: rgba(0,0,0,.15); }
.btn:disabled { filter: grayscale(.6) opacity(.6); pointer-events: none; }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px){ .grid.cols3, .grid.cols2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border-radius: var(--r-lg);
  box-shadow: var(--shadow); border: 4px solid #fff;
  padding: 22px; position: relative; overflow: hidden;
}
.hub-card {
  text-align: center; cursor: pointer; text-decoration: none; color: var(--ink);
  transition: transform .1s ease;
}
.hub-card:active { transform: scale(.97); }
.hub-card .emoji { font-size: 74px; line-height: 1; display: block; margin-bottom: 6px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.12)); }
.hub-card h2 { margin: 6px 0 2px; }
.hub-card p { color: var(--ink-soft); font-size: 17px; margin: 0; font-weight: 600; }
.hub-card .ribbon {
  position: absolute; top: 14px; right: -34px; transform: rotate(38deg);
  background: var(--stitch); color: #fff; font-weight: 800; font-size: 13px;
  padding: 4px 40px;
}

/* 进度条 */
.bar { background: #eef1f0; border-radius: 999px; height: 18px; overflow: hidden; border: 2px solid rgba(0,0,0,.06); }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--grass-light), var(--grass)); border-radius: 999px; transition: width .5s ease; }

/* 星星 */
.stars { font-size: 26px; letter-spacing: 2px; }
.stars .on { color: var(--sun-dark); }
.stars .off { color: #d8ddda; }

/* 徽章 */
.badge {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  width: 108px; text-align: center;
}
.badge .disc {
  width: 88px; height: 88px; border-radius: 50%;
  display: grid; place-items: center; font-size: 44px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--sun) 70%, var(--sun-dark));
  border: 4px solid #fff; box-shadow: var(--shadow-sm);
}
.badge.locked .disc { background: #e7ebe9; color: #b7c0bb; filter: none; }
.badge small { font-weight: 800; font-size: 13px; }

/* ---------- 弹层 ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,30,20,.55); display: none;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-back.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--r-lg); max-width: 460px; width: 100%;
  padding: 28px; text-align: center; box-shadow: var(--shadow);
  animation: pop .3s cubic-bezier(.2,1.4,.5,1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff; font-weight: 800; font-size: 18px;
  padding: 14px 24px; border-radius: 999px; z-index: 200; opacity: 0;
  transition: all .3s ease; box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* 五彩纸屑 */
.confetti { position: fixed; top: -20px; z-index: 300; font-size: 22px; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .2; } }

/* 返回按钮通用 */
.backline { display: flex; align-items: center; gap: 12px; margin: 10px 0 18px; }

/* 章节标题带棒球线 */
.sect-title {
  display: inline-block; background: #fff; padding: 10px 26px; border-radius: 999px;
  border: 4px dashed var(--stitch); font-weight: 800; box-shadow: var(--shadow-sm);
}

/* 摇一摇动画 */
@keyframes wiggle { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-4deg)} 75%{transform:rotate(4deg)} }
.wiggle { animation: wiggle .5s ease infinite; }

@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-14px)} }
.bounce { animation: bounce 1.2s ease infinite; }

.hide { display: none !important; }

/* ---------- 吉祥物「棒仔」 ---------- */
.mascot {
  position: fixed; right: 14px; bottom: 16px; z-index: 90;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.mascot-body {
  position: relative; width: 78px; height: 78px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--sun) 75%, var(--sun-dark));
  border: 4px solid #fff; box-shadow: var(--shadow-sm);
  display: grid; place-items: center; pointer-events: auto; cursor: pointer;
}
.mascot-face { font-size: 40px; line-height: 1; }
.mascot-cap { position: absolute; top: -14px; font-size: 30px; transform: rotate(-8deg); }
.mascot-body.hop { animation: mhop .5s ease; }
@keyframes mhop { 0%,100%{transform:translateY(0) scale(1)} 40%{transform:translateY(-16px) scale(1.08)} }
.mascot-bubble {
  max-width: 220px; background: #fff; color: var(--ink);
  border: 3px solid var(--sky-dark); border-radius: 18px 18px 4px 18px;
  padding: 10px 14px; font-weight: 800; font-size: 16px; box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(10px) scale(.8); transform-origin: bottom right;
  transition: all .25s cubic-bezier(.2,1.4,.5,1);
}
.mascot-bubble.show { opacity: 1; transform: translateY(0) scale(1); }
@media (max-width: 720px){ .mascot-body{ width:62px;height:62px } .mascot-face{font-size:32px} .mascot-bubble{max-width:170px;font-size:14px} }

/* 屏幕震动 */
@keyframes shakeAnim { 0%,100%{transform:translate(0,0)} 15%{transform:translate(-8px,3px)} 30%{transform:translate(7px,-4px)} 45%{transform:translate(-6px,4px)} 60%{transform:translate(5px,-3px)} 75%{transform:translate(-3px,2px)} }
body.shake { animation: shakeAnim .5s ease; }

/* 金币跳动 */
@keyframes pumpAnim { 0%,100%{transform:scale(1)} 40%{transform:scale(1.25)} }
.coin.pump { animation: pumpAnim .4s ease; }

/* 大按钮呼吸提示 */
@keyframes breathe { 0%,100%{transform:scale(1)} 50%{transform:scale(1.05)} }
.btn.big.pulse { animation: breathe 1.4s ease infinite; }

/* 连击数字 */
.combo { font-weight: 800; color: var(--sun-dark); font-size: 22px; }
