* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #FFE9D2;
  color: #3A2418;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: radial-gradient(120% 70% at 50% -10%, #FFD9B0 0%, #FFE9D2 45%, #FFF3E4 100%);
  overflow: hidden;
}

/* 背景装饰 */
.bg-deco { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; }
.b1 { width: 190px; height: 190px; left: -70px; top: 8%; background: radial-gradient(circle at 35% 30%, #FFC48A, #FF9A4D); opacity: .35; }
.b2 { width: 150px; height: 150px; right: -60px; top: 34%; background: radial-gradient(circle at 35% 30%, #FFD3A8, #FFB070); opacity: .32; }
.b3 { width: 220px; height: 220px; left: 50%; bottom: -120px; transform: translateX(-50%); background: radial-gradient(circle at 50% 30%, #FFE0BE, #FFC48A); opacity: .4; }

/* 顶部 HUD */
.hud {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
}
.hud-left { display: flex; gap: 8px; align-items: center; }
.hud-right { display: flex; gap: 8px; align-items: center; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px 0 10px;
  border-radius: 999px;
  background: #FFFFFF;
  border: 2px solid #FFD2AE;
  box-shadow: 0 4px 0 #FFD2AE, 0 8px 16px rgba(255, 138, 61, .18);
  font-weight: 800; font-size: 17px;
  color: #E86A1E;
  font-variant-numeric: tabular-nums;
}
.pill .mp-icon { font-size: 20px; width: 20px; height: 20px; color: #FF8A3D; }
.score-pill { background: linear-gradient(180deg, #FFFFFF, #FFF6EC); }
.best-pill { color: #9A6A3C; border-color: #FFE0C4; box-shadow: 0 4px 0 #FFE0C4, 0 8px 16px rgba(255, 138, 61, .12); }
.best-pill .mp-icon { color: #FFB347; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 14px;
  border: 2px solid #FFD2AE;
  background: #FFFFFF;
  color: #FF8A3D;
  display: grid; place-items: center;
  box-shadow: 0 4px 0 #FFD2AE;
  transition: transform .08s ease, box-shadow .08s ease;
  cursor: pointer;
  padding: 0;
}
.icon-btn .mp-icon { font-size: 22px; width: 22px; height: 22px; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #FFD2AE; }
.icon-btn.off { color: #C9B7A6; }

/* 连击 */
.combo-wrap { position: relative; z-index: 3; height: 26px; flex: 0 0 auto; display: flex; justify-content: center; }
.combo {
  opacity: 0; transform: translateY(6px) scale(.9);
  transition: opacity .18s ease, transform .18s ease;
  font-weight: 900; font-size: 15px; letter-spacing: .04em;
  color: #FFFFFF;
  background: linear-gradient(180deg, #FFA95C, #FF7A2E);
  padding: 3px 14px; border-radius: 999px;
  box-shadow: 0 4px 12px rgba(255, 122, 46, .4);
}
.combo.show { opacity: 1; transform: translateY(0) scale(1); }

/* 棋盘 */
.board-wrap {
  position: relative; z-index: 2;
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  padding: 6px 0;
}
.board {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 100%;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFFDF9 0%, #FFF4E6 100%);
  border: 3px solid #FFD2AE;
  box-shadow: 0 10px 0 rgba(255, 178, 122, .35), 0 18px 34px rgba(214, 122, 52, .18), inset 0 2px 0 #FFFFFF;
  overflow: hidden;
  touch-action: manipulation;
}
.board-inner { position: absolute; inset: 0; }
.drop-line {
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: repeating-linear-gradient(90deg, #FFB98A 0 10px, transparent 10px 20px);
  opacity: .8;
  pointer-events: none;
}

/* 宠物块 */
.pet {
  position: absolute;
  display: grid; place-items: center;
  border-radius: 50%;
  will-change: transform, left, top;
  transition: left .09s linear, top .09s linear;
}
.pet-face {
  width: 100%; height: 100%;
  border-radius: 50%;
  display: grid; place-items: center;
  position: relative;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .10), inset 0 4px 0 rgba(255, 255, 255, .55), 0 3px 6px rgba(120, 60, 20, .16);
}
.pet-face .mp-icon { color: #FFFFFF; font-size: 58%; width: 58%; height: 58%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); }
.pet-face::after {
  content: ""; position: absolute; top: 14%; left: 20%;
  width: 26%; height: 18%; border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  transform: rotate(-18deg);
}
.pet.pop { animation: pop .28s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.pet.merge-out { animation: mergeOut .22s ease forwards; }
@keyframes mergeOut {
  to { transform: scale(.2); opacity: 0; }
}

/* 下一个 */
.next-wrap {
  position: relative; z-index: 3;
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding-top: 8px;
}
.next-card {
  display: flex; align-items: center; gap: 10px;
  background: #FFFFFF;
  border: 2px solid #FFD2AE;
  border-radius: 18px;
  padding: 6px 14px 6px 10px;
  box-shadow: 0 4px 0 #FFD2AE, 0 10px 18px rgba(255, 138, 61, .14);
}
.next-label { font-size: 12px; font-weight: 800; color: #B98A63; letter-spacing: .06em; }
.next-pet { width: 34px; height: 34px; display: grid; place-items: center; }
.next-pet .pet-face { box-shadow: inset 0 -4px 0 rgba(0,0,0,.1), inset 0 3px 0 rgba(255,255,255,.5); }
.next-pet .pet-face .mp-icon { font-size: 18px; width: 18px; height: 18px; }
.tip {
  flex: 1 1 auto;
  font-size: 12.5px; line-height: 1.35; color: #A97C58; font-weight: 600;
  text-align: right;
}

/* 弹层 */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(58, 36, 24, .38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity .22s ease;
}
.overlay.hide { opacity: 0; pointer-events: none; }
.panel {
  width: 100%; max-width: 330px;
  background: linear-gradient(180deg, #FFFFFF 0%, #FFF7EE 100%);
  border: 3px solid #FFD2AE;
  border-radius: 28px;
  padding: 22px 20px 20px;
  text-align: center;
  box-shadow: 0 14px 0 rgba(255, 178, 122, .3), 0 26px 50px rgba(120, 60, 20, .28);
  animation: panelIn .3s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes panelIn {
  from { transform: translateY(16px) scale(.94); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.panel-pets { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.panel-pets .pet-face { width: 44px; height: 44px; }
.panel-pets .pet-face .mp-icon { font-size: 24px; width: 24px; height: 24px; }
.panel h2 { margin: 0 0 8px; font-size: 22px; font-weight: 900; color: #E86A1E; letter-spacing: -.01em; }
.panel p { margin: 0 0 18px; font-size: 14px; line-height: 1.6; color: #8A6A50; font-weight: 600; }
.cta {
  width: 100%; height: 54px;
  border: none; border-radius: 18px;
  background: linear-gradient(180deg, #FFA95C 0%, #FF7A2E 100%);
  color: #FFFFFF; font-size: 17px; font-weight: 900; letter-spacing: .04em;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 6px 0 #E0601A, 0 12px 22px rgba(255, 122, 46, .38);
  transition: transform .08s ease, box-shadow .08s ease;
  cursor: pointer;
}
.cta .mp-icon { font-size: 24px; width: 24px; height: 24px; }
.cta:active { transform: translateY(4px); box-shadow: 0 2px 0 #E0601A, 0 6px 12px rgba(255, 122, 46, .3); }

/* 提示条 */
.toast {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%) scale(.9);
  z-index: 12;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(58, 36, 24, .86);
  color: #FFF3E4; font-size: 14px; font-weight: 800;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
