:root {
  --green: #3f9e4f;
  --green-dark: #2e7d3b;
  --red: #e8494f;
  --ink: #4a2b1d;
  --ink-soft: #8a6a58;
  --cream: #fff7ec;
  --card: #fffdf8;
  --shadow: 0 8px 24px rgba(90, 50, 20, .12);
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fff3df 0%, #ffe8d2 60%, #ffdcc8 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}
.page {
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  gap: 10px;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; gap: 10px; }
.logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-shadow: 0 1px 0 #fff;
}
.logo .wm { font-size: 24px; }
.topbar .spacer { flex: 1; }
.icon-btn {
  border: none;
  background: var(--card);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--ink);
  line-height: 1;
}
.icon-btn:active { transform: scale(.93); }

/* ---------- 计分板 ---------- */
.hud { display: flex; gap: 10px; align-items: stretch; }
.hud .cell {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 86px;
}
.hud .label { font-size: 11px; color: var(--ink-soft); letter-spacing: 2px; }
.hud .value { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.hud .next-cell { flex-direction: row; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }
#next-canvas { width: 44px; height: 44px; }

/* ---------- 游戏区 ---------- */
.stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage { position: relative; display: inline-block; line-height: 0; }
#game {
  display: block;
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(90, 40, 10, .18), inset 0 0 0 2px rgba(255, 255, 255, .6);
  background: #fff7ea;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 244, 226, .72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 20px;
  z-index: 5;
  padding: 20px;
  line-height: 1.4;
}
.overlay.hidden { display: none; }
.card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(120, 60, 20, .25);
  padding: 26px 24px;
  width: 100%;
  max-width: 320px;
  max-height: 94%;
  overflow: auto;
  text-align: center;
}
.card h1 { margin: 4px 0 10px; font-size: 26px; }
.card p { color: var(--ink-soft); font-size: 14px; line-height: 1.8; margin: 6px 0; }
.card .hint { font-size: 13px; color: #c98a3d; }
.big-emoji { font-size: 54px; line-height: 1.1; }
.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  color: #fff;
  font-family: inherit;
  background: linear-gradient(180deg, #58b86a, var(--green-dark));
  box-shadow: 0 6px 16px rgba(46, 125, 59, .35);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn.secondary {
  background: linear-gradient(180deg, #ff7a6e, var(--red));
  box-shadow: 0 6px 16px rgba(232, 73, 79, .3);
}
.score-big { font-size: 46px; font-weight: 900; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.badge-new {
  display: inline-block;
  background: linear-gradient(180deg, #ffd76e, #f7b733);
  color: #7a4a00;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 12px;
  margin-top: 6px;
  box-shadow: 0 4px 10px rgba(247, 183, 51, .4);
}

/* ---------- 广告位 ---------- */
.ad-slot {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-placeholder {
  display: none;
  width: 100%;
  height: 58px;
  border: 2px dashed rgba(138, 106, 88, .35);
  border-radius: 12px;
  color: rgba(138, 106, 88, .65);
  font-size: 12px;
  letter-spacing: 1px;
  align-items: center;
  justify-content: center;
}
.ad-slot--empty .ad-placeholder { display: flex; }
.ad-slot--modal .ad-placeholder { height: 100px; }

/* ---------- 其他 ---------- */
footer { text-align: center; font-size: 12px; color: var(--ink-soft); padding-top: 2px; }
footer a { color: var(--ink-soft); }
#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(60, 30, 10, .85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 50;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 380px) {
  .hud .value { font-size: 18px; }
  .hud .cell { min-width: 70px; padding: 6px 10px; }
  .logo { font-size: 17px; }
}
