/* ============================================================
   视觉基调：柔和渐变 + 大圆角 + 低对比 + 衬线标题
   目标人群偏好「温暖、精致、无压力」，避免高饱和撞色与硬阴影
   ============================================================ */
:root {
  --accent: #D98098;
  --deep: #8C4E63;
  --bg0: #FDF1F3;
  --bg1: #F7DDE4;
  --ink: #4A3A40;
  --card: rgba(255, 255, 255, 0.72);
  --shadow: 0 6px 22px rgba(140, 78, 99, 0.16);
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Avenir Next", "Helvetica Neue", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

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

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg0), var(--bg1));
  -webkit-user-select: none; user-select: none;
}

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------------- HUD ---------------- */
#hud { padding: 8px 14px 4px; flex: 0 0 auto; }

.hud-row { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px;
  border: none; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow);
  color: var(--deep); font-size: 17px; line-height: 1;
}

.chapter { flex: 1 1 auto; text-align: center; min-width: 0; }
.chapter-name {
  font-family: var(--serif); font-size: 19px; font-weight: 600;
  color: var(--deep); letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chapter-sub {
  font-size: 11px; opacity: .6; margin-top: 1px; letter-spacing: .8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.coins {
  display: flex; align-items: center; gap: 5px;
  height: 38px; padding: 0 13px;
  border-radius: 19px; background: var(--card); box-shadow: var(--shadow);
  font-weight: 700; font-size: 14px; color: var(--deep);
}
.coin-ico { font-size: 14px; }

.meters { margin-top: 8px; align-items: flex-end; gap: 12px; }
.meter { flex: 1 1 0; min-width: 0; }
.meter-label {
  display: flex; justify-content: space-between;
  font-size: 10.5px; opacity: .66; margin-bottom: 4px; letter-spacing: .4px;
}
.meter-label b { font-weight: 800; }

.bar {
  height: 7px; border-radius: 4px;
  background: rgba(255, 255, 255, .6);
  overflow: hidden; box-shadow: inset 0 1px 2px rgba(140, 78, 99, .10);
}
.bar > i {
  display: block; height: 100%; width: 0%;
  border-radius: 4px; background: var(--accent);
  transition: width .35s cubic-bezier(.22, .9, .28, 1);
}
.bar.xp > i { background: linear-gradient(90deg, #E3C07A, #D4AA57); }

.score-box { flex: 0 0 auto; text-align: center; padding: 0 4px; }
.score-label { font-size: 9.5px; opacity: .55; letter-spacing: 1.2px; text-transform: uppercase; }
.score-num {
  font-family: var(--serif); font-size: 23px; font-weight: 700;
  color: var(--deep); line-height: 1.05;
}

/* ---------------- Canvas ---------------- */
#stage { flex: 1 1 auto; width: 100%; display: block; }

/* ---------------- 底部工具条 ---------------- */
#dock {
  flex: 0 0 auto;
  display: flex; justify-content: center; gap: 12px;
  padding: 4px 16px 10px;
}

.tool {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  width: 84px; height: 54px;
  border: none; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow);
  color: var(--deep);
  transition: transform .12s ease, opacity .2s;
}
.tool:active { transform: scale(.94); }
.tool:disabled { opacity: .42; }
.tool-ico { font-size: 17px; line-height: 1; }
.tool-txt { font-size: 10px; letter-spacing: .5px; opacity: .75; }
.tool-cost {
  position: absolute; top: -6px; right: -4px;
  min-width: 24px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(140, 78, 99, .28);
}
.tool.bonus .tool-cost { background: #D4AA57; }

/* ---------------- 弹层 ---------------- */
#overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(74, 58, 64, .38);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 24px;
  animation: fade .22s ease;
}
#overlay.hidden { display: none; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  width: 100%; max-width: 380px;
  max-height: 84vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #fff; border-radius: 28px;
  padding: 26px 22px 22px;
  box-shadow: 0 20px 60px rgba(74, 58, 64, .28);
  text-align: center;
  animation: pop .3s cubic-bezier(.2, 1.1, .3, 1);
}
@keyframes pop { from { transform: scale(.9) translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }

.sheet h2 {
  font-family: var(--serif); font-size: 25px; font-weight: 600;
  color: var(--deep); margin: 0 0 4px;
}
.sheet .lead { font-size: 13px; opacity: .6; margin: 0 0 18px; }

.stars { font-size: 34px; letter-spacing: 6px; margin: 6px 0 14px; color: #E0CFA0; }
.stars .on { color: #E8B93C; text-shadow: 0 3px 10px rgba(232, 185, 60, .4); }

.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin: 4px 0 18px;
}
.stat {
  background: var(--bg0); border-radius: 16px; padding: 11px 4px;
}
.stat .v { font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--deep); }
.stat .k { font-size: 9.5px; opacity: .6; letter-spacing: .8px; text-transform: uppercase; margin-top: 2px; }

.chiplist { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 4px; }
.chip {
  padding: 5px 11px; border-radius: 12px;
  background: var(--bg1); color: var(--deep);
  font-size: 12px; font-weight: 700; letter-spacing: .8px;
}
.chip.dim { background: #F2EEF0; color: #B3A6AB; }

.btn {
  width: 100%; height: 52px; margin-top: 10px;
  border: none; border-radius: 20px;
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 800; letter-spacing: .6px;
  box-shadow: 0 8px 22px rgba(217, 128, 152, .38);
  transition: transform .12s ease;
}
.btn:active { transform: scale(.97); }
.btn.ghost {
  background: transparent; color: var(--deep);
  box-shadow: none; font-weight: 600; height: 44px; font-size: 14px; opacity: .75;
}

.reward-big {
  font-family: var(--serif); font-size: 40px; font-weight: 700;
  color: #D4AA57; margin: 8px 0 2px;
}
.note { font-size: 12px; opacity: .62; line-height: 1.6; margin-top: 8px; }

.decor-card {
  margin: 12px 0; padding: 16px;
  background: linear-gradient(160deg, var(--bg0), var(--bg1));
  border-radius: 20px;
}
.decor-card .ico { font-size: 36px; }
.decor-card .nm { font-family: var(--serif); font-size: 17px; color: var(--deep); margin-top: 4px; }

.menu-list { text-align: left; margin: 8px 0 4px; }
.menu-list .row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 4px; border-bottom: 1px solid #F1EAED;
  font-size: 14px;
}
.menu-list .row:last-child { border-bottom: none; }
.menu-list .row b { font-weight: 800; color: var(--deep); }

/* ============================================================
   广告位（全站三处，均为页面内的固定静态位置）
   ============================================================ */

/* 1) 游戏页底部：10 留白 + 50 高度 */
.ad-down {
  position: relative;
  flex: 0 0 auto;
  height: 50px;
  margin-top: 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: rgba(255, 255, 255, .38);
}

/* 2)(3) 结算页中部 / 目录页顶部：响应式单元，宽度撑满、高度由广告决定
   只给 min-height 占位防止布局跳动，不设 height 以免裁切广告 */
.ad-slot {
  position: relative;
  width: 100%;
  min-height: 280px;
  margin: 0 auto;
  border-radius: 14px; overflow: hidden;
  background: rgba(74, 58, 64, .04);
}

/* 未填充时的占位标识，被实际广告盖住 */
.ad-down::before, .ad-slot::before {
  content: 'Advertisement';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; letter-spacing: 2.2px; text-transform: uppercase;
  color: rgba(74, 58, 64, .2);
  pointer-events: none;
}
.ad-down > ins, .ad-slot > ins { position: relative; z-index: 1; display: block; }

/* ============================================================
   结算页
   ============================================================ */
body.page-result, body.page-catalog {
  overflow-y: auto;
  height: auto;
  min-height: 100%;
}

.rp {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 10px) 16px
           calc(env(safe-area-inset-bottom) + 28px);
}

.rp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.rp-head-mid { flex: 1 1 auto; text-align: center; min-width: 0; }
.rp-head-mid h1 {
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  color: var(--deep); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rp-sub { font-size: 11px; opacity: .6; letter-spacing: .8px; margin-top: 2px; }

.rp-score { text-align: center; padding: 6px 0 4px; }

.rp-stars { font-size: 40px; letter-spacing: 8px; color: #E4D8C0; }
.rp-stars span { display: inline-block; transition: color .25s; }
.rp-stars span.on { color: #E8B93C; text-shadow: 0 4px 14px rgba(232, 185, 60, .45); }
.rp-stars span.pop { animation: starPop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes starPop {
  0% { transform: scale(.3) rotate(-25deg); opacity: 0 }
  60% { transform: scale(1.25) rotate(6deg); opacity: 1 }
  100% { transform: none }
}

.rp-score-num {
  font-family: var(--serif); font-size: 54px; font-weight: 700;
  color: var(--deep); line-height: 1.05; margin-top: 6px;
}
.rp-score-label {
  font-size: 10px; letter-spacing: 2px; text-transform: uppercase;
  opacity: .5; margin-bottom: 16px;
}

.rp-gains { display: flex; gap: 8px; }
.rp-gain {
  flex: 1 1 0;
  background: var(--bg0); border-radius: 16px; padding: 11px 4px;
  display: flex; flex-direction: column; gap: 3px;
}
.rp-gain .v {
  font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--deep);
}
.rp-gain .k { font-size: 9px; opacity: .58; letter-spacing: .8px; text-transform: uppercase; }

.rp-empty { text-align: center; padding: 20px 10px 6px; }
.rp-empty-ico { font-size: 44px; }
.rp-empty p { font-size: 13.5px; line-height: 1.65; opacity: .7; margin: 10px 0 18px; }

/* 广告与下方内容、按钮保持足够距离，避免误点 */
.rp-ad-wrap { margin: 26px 0; }

.rp-tip {
  padding: 14px 16px;
  background: linear-gradient(160deg, var(--bg0), var(--bg1));
  border-radius: 18px;
}
.rp-tip-label {
  font-size: 9.5px; font-weight: 800; letter-spacing: 1.4px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 5px;
}
.rp-tip p { margin: 0; font-size: 12.5px; line-height: 1.65; }

.rp-words { margin-top: 22px; }
.rp-words h2 {
  font-family: var(--serif); font-size: 15px; font-weight: 600;
  color: var(--deep); margin: 0 0 8px;
}
.rp-bonus { margin-top: 18px; }
.rp-words .note { text-align: center; margin-top: 14px; }

/* 按钮区与广告拉开 150px 以上的安全距离 */
.rp-nav { margin-top: 34px; }
.rp-nav .btn { display: block; text-align: center; line-height: 52px; text-decoration: none; }
.rp-nav .btn.ghost { line-height: 44px; }

/* ============================================================
   关卡目录页
   ============================================================ */
.cat {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 22px) 16px
           calc(env(safe-area-inset-bottom) + 32px);
}

.cat-head { text-align: center; margin-bottom: 22px; }
.cat-head h1 {
  font-family: var(--serif); font-size: 34px; font-weight: 600;
  color: var(--deep); margin: 0;
}
.cat-tagline { font-size: 12.5px; opacity: .62; line-height: 1.6; margin: 8px 0 0; }

.cat-ad-wrap { margin: 22px 0 26px; }

.cat-stats { display: flex; gap: 6px; margin-bottom: 16px; }
.cat-stat {
  flex: 1 1 0; min-width: 0;
  background: rgba(255, 255, 255, .7); border-radius: 14px;
  padding: 10px 2px; text-align: center;
  box-shadow: var(--shadow);
}
.cat-stat .v {
  display: block;
  font-family: var(--serif); font-size: 17px; font-weight: 700; color: var(--deep);
}
.cat-stat .k {
  display: block;
  font-size: 8.5px; opacity: .55; letter-spacing: .5px; text-transform: uppercase; margin-top: 2px;
}

.cat-resume { margin-bottom: 28px; }
.cat-resume .btn { display: block; text-align: center; line-height: 52px; text-decoration: none; }

.cat-chapter {
  margin-bottom: 26px;
  padding: 16px 14px 18px;
  border-radius: 22px;
  background: linear-gradient(160deg, var(--c-bg0), var(--c-bg1));
}
.cat-chapter-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cat-chapter-head .cc-ico { font-size: 22px; }
.cat-chapter-head h2 {
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  color: var(--c-deep); margin: 0;
}
.cat-chapter-head p { font-size: 11px; opacity: .6; margin: 2px 0 0; }
.cat-chapter-progress {
  margin-left: auto; flex: 0 0 auto;
  font-size: 11px; font-weight: 700; color: var(--c-deep); opacity: .75;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cat-cell {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  background: rgba(255, 255, 255, .72);
  color: var(--c-deep);
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(74, 58, 64, .07);
  transition: transform .12s ease;
}
.cat-cell:active { transform: scale(.94); }
.cat-cell.done { background: #fff; box-shadow: 0 4px 14px rgba(74, 58, 64, .12); }
.cat-cell.next { outline: 2px solid var(--c-accent); outline-offset: 1px; }

.cc-num { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.cc-stars { font-size: 9px; letter-spacing: 1px; color: #E8B93C; }
.cat-cell:not(.done) .cc-stars { color: rgba(74, 58, 64, .18); }
.cc-word {
  font-size: 7.5px; letter-spacing: 1px; opacity: .4; margin-top: 1px;
}
.cc-bonus {
  position: absolute; top: 4px; right: 5px;
  font-size: 8px; font-weight: 800; color: var(--c-accent);
}

.cat-foot {
  margin-top: 10px; text-align: center;
}
.cat-foot p { font-size: 11.5px; line-height: 1.7; opacity: .55; margin: 0; }

@media (max-width: 359px) {
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .cat-stat .k { font-size: 8px; }
}

