/* ----- 全局 ----- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: #2b2b2b;
  background: #f5efe6;
  overscroll-behavior: none;
}
body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.layout {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f1e6 0%, #f3eada 60%, #e6dccb 100%);
  position: relative;
}

/* ----- 顶部信息条 ----- */
.hud {
  position: relative;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 18px 22px 8px;
}
.hud-left { display: flex; flex-direction: column; gap: 2px; }
.score-wrap { display: flex; align-items: baseline; gap: 8px; }
.label { font-size: 12px; color: #9a8b73; letter-spacing: 1px; }
.score {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  color: #3a2e22;
  font-variant-numeric: tabular-nums;
}
.best { font-size: 12px; color: #9a8b73; }
.best span { color: #6b5b46; font-weight: 600; }

.combo {
  min-width: 64px;
  text-align: right;
  font-size: 20px;
  font-weight: 700;
  color: #ff6b6b;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .25s, transform .25s;
}
.combo.show { opacity: 1; transform: translateY(0); }

/* ----- 画布舞台 ----- */
.stage {
  position: relative;
  flex: 1 1 auto;
  margin: 0 0 6px;
  min-height: 60vh;
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ----- 遮罩 ----- */
.overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(247,241,230,.0) 0%, rgba(247,241,230,.85) 35%, rgba(243,234,218,.96) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 5;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  transition: opacity .25s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-inner {
  width: 84%;
  max-width: 340px;
  padding: 28px 24px;
}
.brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 14px; }
.brand-dot {
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f9f4ea 0%, #b29c80 65%, #6f5b3f 100%);
  box-shadow: 0 6px 14px rgba(111,91,63,.35);
}
.brand h1 {
  font-size: 30px; font-weight: 800; margin: 0;
  color: #3a2e22; letter-spacing: 4px;
}
.tip { font-size: 14px; line-height: 1.7; color: #5a4a36; margin: 8px 0 22px; }
.tip b { color: #3a2e22; }
.hint { margin-top: 12px; font-size: 12px; color: #9a8b73; }

.primary {
  appearance: none;
  border: none;
  font-size: 16px; font-weight: 600;
  padding: 12px 36px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, #c9a06a 0%, #a4814b 100%);
  box-shadow: 0 8px 18px rgba(111,91,63,.35);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.primary:active { transform: translateY(1px); box-shadow: 0 4px 10px rgba(111,91,63,.3); }

#overlay-over .overlay-inner { padding-top: 36px; }
#overlay-over h2 { font-size: 22px; margin: 0 0 18px; color: #3a2e22; }
.final-score {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin: 14px 0 24px;
}
.final-score > div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.final-score span:not(.label) { font-size: 28px; font-weight: 700; color: #3a2e22; }

/* ----- 小程序入口卡片 ----- */
.mp-card {
  margin: 14px 16px 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .65);
  border: 1px solid rgba(184,162,128,.25);
  box-shadow: 0 4px 14px rgba(111,91,63,.08);
}
.mp-card-text { flex: 1; min-width: 0; }
.mp-card-text h3 { margin: 0 0 4px; font-size: 15px; color: #3a2e22; }
.mp-card-text p { margin: 0; font-size: 12.5px; line-height: 1.5; color: #6b5b46; }
.mp-card-qr {
  width: 84px;
  height: 84px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(184,162,128,.3);
}
.mp-card-qr img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fdfaf3 0%, #ece1c9 100%);
}
.mp-fallback-inner {
  font-size: 10px;
  line-height: 1.4;
  color: #8a7553;
  text-align: center;
  padding: 6px;
}
.mp-fallback-icon { font-size: 20px; margin-bottom: 2px; }

/* ----- 页脚 ----- */
.footer {
  text-align: center;
  font-size: 11px;
  color: #b3a187;
  padding: 8px 0 14px;
}

/* ----- 自适应 ----- */
@media (min-width: 540px) {
  .stage { min-height: 70vh; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .hud { padding-top: 8px; }
  .score { font-size: 32px; }
  .stage { min-height: 55vh; }
}
