/* ==========================================================================
   消消乐 · 卡通糖果屋
   移动端优先，竖屏铺满，无顶部标题栏
   ========================================================================== */
:root {
  --orange: #FF8A3D;
  --orange-deep: #EF640D;
  --orange-dark: #C94F08;
  --cream: #FFF8E9;
  --ink: #4A2B13;
  --ink-soft: #8D6039;
  --brown: #8B4F22;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  background: #FFB761;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-weight: 600;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   背景
   -------------------------------------------------------------------------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 4%, rgba(255, 249, 209, 0.95) 0, rgba(255, 244, 190, 0.42) 22%, rgba(255, 244, 190, 0) 48%),
    linear-gradient(180deg, #FFE7BC 0%, #FFC57B 30%, #FF9E52 64%, #FFC347 100%);
}

.sun {
  position: absolute;
  top: -16vw;
  right: -18vw;
  width: 78vw;
  height: 78vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 253, 213, 0.92) 0, rgba(255, 229, 139, 0.5) 38%, rgba(255, 220, 120, 0) 70%);
  filter: blur(2px);
}

.cloud {
  position: absolute;
  background: #FFFDF4;
  border-radius: 999px;
  opacity: 0.48;
  filter: blur(0.3px);
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud-a {
  width: 148px;
  height: 38px;
  top: 12%;
  left: -46px;
  animation: drift 19s ease-in-out infinite alternate;
}
.cloud-a::before { width: 56px; height: 56px; left: 26px; top: -26px; }
.cloud-a::after { width: 40px; height: 40px; right: 20px; top: -18px; }
.cloud-b {
  width: 112px;
  height: 30px;
  top: 27%;
  right: -30px;
  opacity: 0.38;
  animation: drift 23s 1s ease-in-out infinite alternate-reverse;
}
.cloud-b::before { width: 44px; height: 44px; left: 20px; top: -22px; }
.cloud-b::after { width: 32px; height: 32px; right: 16px; top: -14px; }
.cloud-c {
  width: 90px;
  height: 24px;
  top: 44%;
  left: -28px;
  opacity: 0.3;
  animation: drift 26s 2s ease-in-out infinite alternate;
}
.cloud-c::before { width: 36px; height: 36px; left: 14px; top: -18px; }
.cloud-c::after { width: 26px; height: 26px; right: 12px; top: -11px; }

.hill {
  position: absolute;
  bottom: -8%;
  width: 82%;
  height: 26%;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, #A6E06F 0%, #70BE45 55%, #4F9F35 100%);
  opacity: 0.72;
}
.hill-left { left: -28%; transform: rotate(-5deg); }
.hill-right { right: -30%; transform: rotate(5deg); opacity: 0.62; }

.bush {
  position: absolute;
  bottom: -18px;
  width: 150px;
  height: 88px;
  background: radial-gradient(circle at 32% 35%, #A8E677 0 24%, transparent 25%),
    radial-gradient(circle at 65% 28%, #8FD862 0 28%, transparent 29%),
    radial-gradient(circle at 85% 52%, #79C64D 0 26%, transparent 27%),
    radial-gradient(circle at 45% 68%, #6AB93F 0 30%, transparent 31%);
  filter: blur(0.2px);
  opacity: 0.8;
}
.bush-left { left: -44px; }
.bush-right { right: -52px; transform: scaleX(-1) scale(1.15); }

.bg-spark {
  position: absolute;
  width: 15px;
  height: 15px;
  background: #FFF9CB;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  opacity: 0.65;
  animation: twinkle 3.4s ease-in-out infinite;
}
.sp1 { top: 18%; left: 12%; animation-delay: 0s; }
.sp2 { top: 33%; right: 14%; width: 21px; height: 21px; animation-delay: 0.8s; }
.sp3 { top: 56%; left: 8%; width: 11px; height: 11px; animation-delay: 1.6s; }
.sp4 { top: 66%; right: 9%; width: 13px; height: 13px; animation-delay: 2.2s; }
.sp5 { top: 8%; right: 32%; width: 10px; height: 10px; animation-delay: 1.1s; }

/* --------------------------------------------------------------------------
   屏幕与通用控件
   -------------------------------------------------------------------------- */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.is-active {
  display: flex;
}

.round-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #C75F16;
  background: linear-gradient(180deg, rgba(255, 253, 242, 0.96), rgba(255, 235, 198, 0.96));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 10px rgba(150, 75, 20, 0.22), inset 0 2px 0 #FFFFFF;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.round-btn:active {
  transform: scale(0.9);
  box-shadow: 0 2px 5px rgba(150, 75, 20, 0.22), inset 0 2px 0 #FFFFFF;
}
.round-btn.small { width: 38px; height: 38px; }
.round-btn .mp-icon { width: 22px; height: 22px; }
.round-btn.small .mp-icon { width: 19px; height: 19px; }

.sound-toggle .ico-off { display: none; }
body.sound-off .sound-toggle .ico-off { display: inline-block; }
body.sound-off .sound-toggle .ico-on { display: none; }

.big-btn {
  position: relative;
  width: 100%;
  height: 62px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #FFFFFF;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 0 rgba(168, 62, 0, 0.38);
  background: linear-gradient(180deg, #FFBD58 0%, #FF8A2C 48%, #F36A11 100%);
  box-shadow: 0 7px 0 var(--orange-dark), 0 13px 24px rgba(177, 68, 7, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
}
.big-btn::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 5px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.big-btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--orange-dark), 0 5px 10px rgba(177, 68, 7, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.big-btn .mp-icon {
  width: 29px;
  height: 29px;
  filter: drop-shadow(0 2px 0 rgba(150, 55, 0, 0.25));
}
.big-btn > span { position: relative; z-index: 1; }

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 12px auto 0;
  padding: 10px 16px;
  color: #A2714B;
  font-size: 14px;
  font-weight: 700;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.text-btn:active { background: rgba(190, 130, 74, 0.14); }
.text-btn .mp-icon { width: 18px; height: 18px; }

/* --------------------------------------------------------------------------
   开始页
   -------------------------------------------------------------------------- */
.start-screen {
  z-index: 5;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(var(--safe-top) + 12px) 20px calc(var(--safe-bottom) + 14px);
  justify-content: space-between;
}

.start-top {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.start-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  color: #A45516;
  font-size: 12.5px;
  font-weight: 800;
  background: rgba(255, 250, 234, 0.66);
  border: 1.5px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 3px 8px rgba(160, 85, 25, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}
.start-badge .mp-icon { width: 15px; height: 15px; color: #E77A1C; }

.start-main {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 4px 0 8px;
  flex: 1 1 auto;
}

.hero {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4px;
}

.bear-wrap {
  position: relative;
  width: 196px;
  height: 172px;
  animation: bearBob 3.4s ease-in-out infinite;
  z-index: 2;
}
.bear-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 10px 12px rgba(126, 56, 9, 0.24));
}
.bear-shadow {
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 2px;
  height: 14px;
  border-radius: 50%;
  background: rgba(126, 56, 9, 0.18);
  filter: blur(5px);
  z-index: -1;
  animation: shadowBob 3.4s ease-in-out infinite;
}

.hero-candy {
  position: absolute;
  z-index: 1;
  filter: drop-shadow(0 5px 6px rgba(120, 55, 10, 0.22));
  animation: candyFloat 4.6s ease-in-out infinite;
}
.hero-candy svg { width: 100%; height: 100%; display: block; }
.hc1 { width: 52px; height: 52px; left: 3%; top: 26%; transform: rotate(-16deg); animation-delay: 0.2s; }
.hc2 { width: 46px; height: 46px; right: 2%; top: 16%; transform: rotate(12deg); animation-delay: 1.1s; }
.hc3 { width: 39px; height: 39px; left: 6%; top: 61%; transform: rotate(-8deg); animation-delay: 0.7s; }
.hc4 { width: 42px; height: 42px; right: 5%; top: 55%; transform: rotate(18deg); animation-delay: 1.6s; }

.logo {
  position: relative;
  z-index: 3;
  margin: -6px 0 0;
  font-size: clamp(44px, 13.6vw, 58px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: 4px;
  color: #FFFFFF;
  text-shadow:
    0 3px 0 #F9B23E,
    0 6px 0 #E36B12,
    0 10px 16px rgba(150, 55, 0, 0.26);
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.5);
  animation: logoPop 0.65s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.logo::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -13px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  filter: blur(4px);
}

.tagline {
  position: relative;
  z-index: 3;
  margin: 13px 0 0;
  color: #8B4A15;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.start-card {
  position: relative;
  width: 100%;
  margin-top: 2px;
  padding: 15px 17px 13px;
  border-radius: 27px;
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.95), rgba(255, 240, 214, 0.95));
  border: 2px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 32px rgba(140, 66, 12, 0.23), 0 2px 0 rgba(255, 255, 255, 0.8) inset,
    0 -3px 0 rgba(208, 137, 64, 0.12) inset;
  backdrop-filter: blur(6px);
}

.best-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}
.best-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.best-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #9D704B;
  font-size: 11.5px;
  font-weight: 700;
}
.best-label .mp-icon { width: 14px; height: 14px; color: #E8962C; }
.best-item strong {
  color: #C85C10;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.best-divider {
  width: 1px;
  height: 30px;
  background: linear-gradient(180deg, transparent, rgba(190, 135, 80, 0.36), transparent);
}

.how-to {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 10px 0 0;
  color: #A87A53;
  font-size: 12px;
  font-weight: 700;
}
.how-to .mp-icon { width: 15px; height: 15px; color: #E79032; }

.start-foot {
  flex: 0 0 auto;
  margin: 6px auto 0;
  color: rgba(119, 61, 19, 0.66);
  font-size: 11.5px;
  text-align: center;
  letter-spacing: 0.3px;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   游戏页 HUD
   -------------------------------------------------------------------------- */
.game-screen {
  z-index: 4;
  padding: calc(var(--safe-top) + 10px) 0 calc(var(--safe-bottom) + 8px);
}

.hud {
  flex: 0 0 auto;
  width: min(92vw, 452px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.level-chip {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 18px;
  border-radius: 999px;
  color: #A95A18;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, rgba(255, 253, 242, 0.9), rgba(255, 235, 198, 0.9));
  border: 2px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 3px 8px rgba(150, 75, 20, 0.15), inset 0 2px 0 #FFFFFF;
}
.level-chip b {
  color: #EF680C;
  font-size: 18px;
  font-weight: 900;
  margin: 0 2px;
}

.hud-main {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.score-panel {
  flex: 1;
  min-width: 0;
  padding: 7px 12px 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 252, 242, 0.9), rgba(255, 238, 210, 0.9));
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 5px 14px rgba(150, 75, 20, 0.16), inset 0 2px 0 rgba(255, 255, 255, 0.85);
}
.score-line {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.hud-label {
  color: #A0734C;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding-bottom: 2px;
}
#scoreNum {
  color: #F05E0B;
  font-size: 27px;
  line-height: 0.95;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #FFD9B5;
  transition: transform 0.12s ease;
}
#scoreNum.bump { animation: scoreBump 0.24s ease; }

.progress-track {
  position: relative;
  height: 10px;
  margin-top: 6px;
  border-radius: 6px;
  background: #F0D2AC;
  box-shadow: inset 0 2px 3px rgba(140, 80, 30, 0.24);
  overflow: hidden;
}
.progress-fill {
  position: relative;
  width: 0%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #FFD23F 0%, #FF9F35 52%, #FF6A1F 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}
.progress-fill::after {
  content: "";
  position: absolute;
  inset: 1px 3px auto;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.55);
}
.progress-track.done .progress-fill {
  background: linear-gradient(90deg, #FFD84D, #FFB01F);
  animation: goalGlow 1.4s ease-in-out infinite;
}
.goal-line {
  margin-top: 4px;
  color: #A77B56;
  font-size: 10.5px;
  font-weight: 700;
  text-align: right;
  letter-spacing: 0.2px;
}
.goal-line b { color: #D9670F; font-weight: 800; }
.goal-line.done { color: #E07612; }

.moves-panel {
  flex: 0 0 74px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF8E8 0%, #FFE3B8 100%);
  border: 2px solid #EBAC66;
  box-shadow: 0 5px 14px rgba(150, 75, 20, 0.17), inset 0 2px 0 #FFFFFF,
    inset 0 -3px 0 rgba(205, 133, 62, 0.16);
  line-height: 1;
}
.moves-panel strong {
  color: #E8640C;
  font-size: 27px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transition: transform 0.12s ease;
}
.moves-panel span {
  margin-top: 2px;
  color: #9C6B44;
  font-size: 10.5px;
  font-weight: 800;
}
.moves-panel.low {
  border-color: #F07551;
  background: linear-gradient(180deg, #FFF1E8 0%, #FFD3C0 100%);
  animation: lowPulse 1.1s ease-in-out infinite;
}
.moves-panel.low strong { color: #E3391C; }

/* --------------------------------------------------------------------------
   棋盘
   -------------------------------------------------------------------------- */
.board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 0 7px;
}

.board-frame {
  position: relative;
  width: min(92vw, 452px, 52vh);
  width: min(92vw, 452px, 52dvh);
  aspect-ratio: 1 / 1;
  padding: 9px;
  border-radius: 30px;
  background: linear-gradient(155deg, #EDB77A 0%, #C98547 44%, #A45F2B 100%);
  border: 2px solid rgba(132, 70, 24, 0.55);
  box-shadow:
    0 16px 28px rgba(109, 52, 13, 0.34),
    inset 0 3px 0 rgba(255, 231, 190, 0.62),
    inset 0 -4px 0 rgba(88, 42, 8, 0.3);
}
.board-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 26px;
  border: 1px solid rgba(255, 228, 182, 0.4);
  pointer-events: none;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, #FFF8E9 0%, #F8E2BE 100%);
  box-shadow: inset 0 3px 10px rgba(143, 84, 32, 0.28), inset 0 -2px 0 rgba(255, 255, 255, 0.65);
  touch-action: none;
}

.cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}
.cell { position: relative; }
.cell::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 251, 237, 0.92), rgba(242, 218, 179, 0.9));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.88),
    inset 0 -2px 3px rgba(162, 105, 49, 0.14);
}
.cell.alt::after {
  background: linear-gradient(180deg, rgba(255, 249, 230, 0.92), rgba(238, 211, 170, 0.9));
}

.tiles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tile {
  position: absolute;
  left: 0;
  top: 0;
  width: 12.5%;
  height: 12.5%;
  z-index: 2;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.3, 1);
  will-change: transform;
}
.tile.moving { z-index: 6; }
.tile-inner {
  position: absolute;
  inset: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease, filter 0.14s ease;
}
.candy {
  display: block;
  width: 94%;
  height: 94%;
  filter: drop-shadow(0 2px 1.5px rgba(98, 46, 8, 0.3));
  pointer-events: none;
}

.tile.pressed .tile-inner { transform: scale(0.9); }

.tile.sel { z-index: 7; }
.tile.sel .tile-inner { transform: scale(1.1); }
.tile.sel .tile-inner::before {
  content: "";
  position: absolute;
  inset: 2%;
  border-radius: 50%;
  border: 2.5px solid #FFF9C7;
  box-shadow: 0 0 0 2px rgba(255, 145, 45, 0.45), 0 0 16px #FFE178;
  animation: selPulse 0.9s ease-in-out infinite;
}

.tile.hint .tile-inner { animation: hintBounce 0.68s ease-in-out infinite; }
.tile.hint .tile-inner::before {
  content: "";
  position: absolute;
  inset: 1%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 12px rgba(255, 222, 100, 0.9);
}

.tile.clearing { z-index: 10; pointer-events: none; }
.tile.clearing .tile-inner {
  animation: candyPop 0.28s ease-in forwards;
}
.tile.made .tile-inner { animation: madeSpecial 0.46s cubic-bezier(0.2, 1.4, 0.4, 1); }

.tile.t-rainbow .candy {
  filter: drop-shadow(0 0 7px rgba(255, 240, 140, 0.95)) drop-shadow(0 2px 2px rgba(98, 46, 8, 0.3));
  animation: rainbowSpin 3.4s linear infinite;
}

.sp {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
}
.sp-row {
  background: linear-gradient(180deg,
    transparent 16%, rgba(255, 255, 255, 0.9) 16%, rgba(255, 255, 255, 0.9) 28%,
    transparent 28%, transparent 39%, rgba(255, 255, 255, 0.9) 39%, rgba(255, 255, 255, 0.9) 51%,
    transparent 51%, transparent 62%, rgba(255, 255, 255, 0.9) 62%, rgba(255, 255, 255, 0.9) 74%,
    transparent 74%);
  opacity: 0.82;
}
.sp-col {
  background: linear-gradient(90deg,
    transparent 16%, rgba(255, 255, 255, 0.9) 16%, rgba(255, 255, 255, 0.9) 28%,
    transparent 28%, transparent 39%, rgba(255, 255, 255, 0.9) 39%, rgba(255, 255, 255, 0.9) 51%,
    transparent 51%, transparent 62%, rgba(255, 255, 255, 0.9) 62%, rgba(255, 255, 255, 0.9) 74%,
    transparent 74%);
  opacity: 0.82;
}
.sp-bomb {
  left: 26%;
  top: 26%;
  width: 48%;
  height: 48%;
  background: radial-gradient(circle, #FFFFFF 0 20%, rgba(255, 236, 142, 0.95) 34%, rgba(255, 190, 60, 0.35) 58%, transparent 70%);
  box-shadow: 0 0 12px #FFE36E;
  animation: bombPulse 1.2s ease-in-out infinite;
}

/* 消除特效 */
.fx {
  position: absolute;
  z-index: 9;
  pointer-events: none;
}
.fx-line-h {
  left: 0;
  width: 100%;
  height: 12.5%;
  border-radius: 50%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95) 32%, #FFF8C9 50%, rgba(255, 255, 255, 0.95) 68%, transparent);
  filter: blur(1px);
  animation: fxLine 0.4s ease-out forwards;
}
.fx-line-v {
  top: 0;
  height: 100%;
  width: 12.5%;
  border-radius: 50%;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.95) 32%, #FFF8C9 50%, rgba(255, 255, 255, 0.95) 68%, transparent);
  filter: blur(1px);
  animation: fxLine 0.4s ease-out forwards;
}
.fx-bomb {
  width: 37.5%;
  height: 37.5%;
  border-radius: 50%;
  background: radial-gradient(circle, #FFFDF0 0 18%, rgba(255, 210, 82, 0.92) 34%, rgba(255, 140, 40, 0.3) 60%, transparent 72%);
  animation: fxBomb 0.44s ease-out forwards;
}
.spark-p {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FFF8BE;
  box-shadow: 0 0 7px #FFD84D;
  z-index: 11;
  pointer-events: none;
  animation: sparkFly 0.58s ease-out forwards;
}
.float-score {
  position: absolute;
  z-index: 12;
  transform: translate(-50%, -50%);
  color: #FFFFFF;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 0 #E2610D, 0 0 10px rgba(255, 180, 60, 0.85);
  animation: floatUp 0.9s ease-out forwards;
}

.combo-pop {
  position: absolute;
  left: 50%;
  top: 49%;
  z-index: 15;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  color: #FFFFFF;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 1px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 3px 0 #E66009, 0 0 14px rgba(255, 180, 60, 0.9);
}
.combo-pop.show { animation: comboBurst 0.92s ease-out; }

.board-toast {
  position: absolute;
  left: 50%;
  bottom: 3.2%;
  z-index: 16;
  transform: translateX(-50%) translateY(8px);
  opacity: 0;
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(92, 48, 14, 0.88);
  color: #FFF4D9;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  box-shadow: 0 4px 12px rgba(70, 35, 8, 0.25);
}
.board-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.game-foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 2px 16px 0;
}
.game-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 999px;
  color: #8E5A31;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 248, 226, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 6px rgba(140, 70, 15, 0.1);
  white-space: nowrap;
}
.game-foot .mp-icon { width: 14px; height: 14px; color: #E4771E; }

/* --------------------------------------------------------------------------
   结束页
   -------------------------------------------------------------------------- */
.end-screen {
  z-index: 9;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 40px) 22px calc(var(--safe-bottom) + 22px);
  background: radial-gradient(circle at 50% 32%, rgba(255, 242, 199, 0.4), rgba(105, 47, 8, 0.48));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.result-card {
  position: relative;
  width: 100%;
  max-width: 348px;
  padding: 6px 22px 18px;
  border-radius: 30px;
  text-align: center;
  background: linear-gradient(180deg, #FFFDF6 0%, #FFF2DA 60%, #FFE8C4 100%);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 26px 60px rgba(88, 38, 6, 0.42), inset 0 2px 0 #FFFFFF,
    inset 0 -4px 0 rgba(205, 133, 62, 0.16);
  animation: cardIn 0.42s cubic-bezier(0.2, 1.25, 0.4, 1) both;
}
.result-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 23px;
  border: 1px solid rgba(236, 191, 130, 0.35);
  pointer-events: none;
}

.result-bear {
  position: relative;
  z-index: 1;
  width: 158px;
  height: 132px;
  margin: -66px auto 0;
  filter: drop-shadow(0 12px 12px rgba(110, 48, 8, 0.22));
  animation: resultBearIn 0.55s 0.08s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.result-bear .bear-svg { width: 100%; height: 100%; }

.result-card h2 {
  position: relative;
  z-index: 1;
  margin: 2px 0 0;
  color: #E9630D;
  font-size: 29px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 #FFDFC0;
}
.result-sub {
  position: relative;
  z-index: 1;
  margin: 6px 0 2px;
  color: #A37651;
  font-size: 13px;
  font-weight: 700;
}

.stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 8px 0 4px;
}
.star-i {
  width: 41px;
  height: 41px;
  color: #E8D5BD;
  filter: drop-shadow(0 2px 0 rgba(160, 105, 50, 0.15));
  transition: color 0.2s ease, transform 0.2s ease;
}
.star-i.on {
  color: #FFC229;
  filter: drop-shadow(0 3px 0 #DD8A05) drop-shadow(0 0 8px rgba(255, 205, 70, 0.6));
  animation: starIn 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.star-i.on:nth-child(2) { animation-delay: 0.12s; }
.star-i.on:nth-child(3) { animation-delay: 0.24s; }

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 0;
  color: #A37651;
  font-size: 12.5px;
  font-weight: 700;
}
.result-score strong {
  color: #F05E0B;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #FFD9B5;
}
.result-best {
  margin: 7px 0 14px;
  color: #AE8561;
  font-size: 12px;
  font-weight: 700;
}
.result-best b { color: #D2782C; font-size: 14px; }
.result-card .big-btn { height: 58px; font-size: 21px; }
.result-card .text-btn { margin-top: 11px; }

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.confetti-piece {
  position: absolute;
  top: -12vh;
  width: 9px;
  height: 15px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall 2.6s linear forwards;
}

/* --------------------------------------------------------------------------
   暂停弹窗
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(80, 36, 8, 0.46);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.overlay.show { display: flex; }

.modal {
  width: 100%;
  max-width: 330px;
  padding: 24px 22px 20px;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(180deg, #FFFDF7 0%, #FFF0D5 100%);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 24px 56px rgba(85, 36, 5, 0.4), inset 0 2px 0 #FFFFFF;
  animation: cardIn 0.32s cubic-bezier(0.2, 1.25, 0.4, 1) both;
}
.modal-icon {
  width: 62px;
  height: 62px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #E76A12;
  background: linear-gradient(180deg, #FFE9C8, #FFD69B);
  border: 2px solid #FFFFFF;
  box-shadow: 0 5px 12px rgba(166, 84, 22, 0.18), inset 0 2px 0 #FFFFFF;
}
.modal-icon .mp-icon { width: 30px; height: 30px; }
.modal h2 {
  margin: 0;
  color: #D95A0C;
  font-size: 24px;
  font-weight: 900;
}
.modal p {
  margin: 6px 0 16px;
  color: #A37651;
  font-size: 12.5px;
  font-weight: 700;
}
.modal-row {
  display: flex;
  gap: 9px;
  margin-top: 12px;
}
.soft-btn {
  flex: 1;
  min-height: 46px;
  padding: 8px 6px;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #9A5D2B;
  font-size: 13px;
  font-weight: 800;
  background: linear-gradient(180deg, #FFF9EE, #FFE7C4);
  border: 1.5px solid #F0C38D;
  box-shadow: 0 3px 0 #E2B27A, inset 0 1px 0 #FFFFFF;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.soft-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #E2B27A, inset 0 1px 0 #FFFFFF;
}
.soft-btn .mp-icon { width: 18px; height: 18px; }

.result-card.lose h2 {
  color: #9A6A3D;
  text-shadow: 0 2px 0 #F3E4D2;
}

/* --------------------------------------------------------------------------
   动画
   -------------------------------------------------------------------------- */
@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(38px); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.2; transform: scale(0.75) rotate(0deg); }
  50% { opacity: 0.8; transform: scale(1) rotate(18deg); }
}
@keyframes bearBob {
  0%, 100% { transform: translateY(0) rotate(-0.6deg); }
  50% { transform: translateY(-8px) rotate(0.8deg); }
}
@keyframes shadowBob {
  0%, 100% { transform: scaleX(1); opacity: 0.22; }
  50% { transform: scaleX(0.86); opacity: 0.14; }
}
@keyframes candyFloat {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}
@keyframes logoPop {
  0% { transform: scale(0.7) rotate(-3deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes resultBearIn {
  0% { transform: translateY(16px) scale(0.8); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes cardIn {
  0% { transform: translateY(18px) scale(0.94); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes starIn {
  0% { transform: scale(0.4) rotate(-25deg); opacity: 0; }
  70% { transform: scale(1.14) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes scoreBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.16); }
  100% { transform: scale(1); }
}
@keyframes lowPulse {
  0%, 100% { box-shadow: 0 5px 14px rgba(150, 75, 20, 0.17), inset 0 2px 0 #FFFFFF; }
  50% { box-shadow: 0 5px 18px rgba(227, 57, 28, 0.35), inset 0 2px 0 #FFFFFF; }
}
@keyframes goalGlow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.16); }
}
@keyframes selPulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
@keyframes hintBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.06); }
}
@keyframes candyPop {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.24); filter: brightness(1.5); }
  100% { transform: scale(0.1); opacity: 0; filter: brightness(1.7); }
}
@keyframes madeSpecial {
  0% { transform: scale(0.55); filter: brightness(1.8); }
  55% { transform: scale(1.2); filter: brightness(1.35); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes rainbowSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes bombPulse {
  0%, 100% { transform: scale(0.9); opacity: 0.75; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes fxLine {
  0% { opacity: 0; transform: scaleY(0.3); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scaleY(1.3); }
}
@keyframes fxBomb {
  0% { transform: scale(0.4); opacity: 0; }
  35% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 12px), var(--dy, -18px)) scale(0); opacity: 0; }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
@keyframes comboBurst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(-4deg); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  65% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(0.94); }
}
@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(0) rotate(0deg); }
  8% { opacity: 1; }
  100% { opacity: 0.9; transform: translateY(122vh) rotate(720deg); }
}

/* --------------------------------------------------------------------------
   小屏适配
   -------------------------------------------------------------------------- */
@media (max-height: 720px) {
  .start-screen { padding-top: calc(var(--safe-top) + 8px); padding-bottom: calc(var(--safe-bottom) + 8px); }
  .start-main { gap: 10px; }
  .bear-wrap { width: 160px; height: 140px; }
  .logo { font-size: clamp(38px, 11.5vw, 48px); }
  .tagline { margin-top: 9px; font-size: 12.5px; }
  .start-card { padding: 12px 15px 10px; }
  .best-row { margin-bottom: 10px; }
  .big-btn { height: 54px; font-size: 20px; border-radius: 19px; }
  .how-to { margin-top: 8px; }
  .start-foot { display: none; }
  .bear-wrap { margin-top: -4px; }
}

@media (max-height: 600px) {
  .bear-wrap { width: 136px; height: 118px; }
  .logo { font-size: 36px; letter-spacing: 3px; }
  .tagline { font-size: 11.5px; margin-top: 7px; }
  .start-main { justify-content: flex-start; padding-top: 8px; }
  .hero-candy { display: none; }
  .board-frame { width: min(92vw, 420px, 49vh); width: min(92vw, 420px, 49dvh); }
  .game-foot { display: none; }
}

@media (min-width: 700px) {
  .board-frame { border-radius: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
