/* 解压爱消消 · 竖屏卡通合成游戏 */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E96B17;
  --orange-soft: #FFB06A;
  --ink: #3D2A1D;
  --ink-soft: #8E6A50;
  --cream: #FFF8EC;
  --line: rgba(196, 120, 62, .16);
  --shadow: 0 12px 26px rgba(160, 84, 24, .14);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: #FFE4C2;
  background-image: radial-gradient(120% 80% at 50% 0%, #FFF2DE 0%, #FFE0B7 58%, #FFD2A0 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

.game {
  position: relative;
  z-index: 1;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: calc(9px + env(safe-area-inset-top)) 14px calc(9px + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 255, 255, .9) 0%, rgba(255, 255, 255, 0) 60%),
    radial-gradient(90% 55% at 8% 8%, #FFDCB0 0%, rgba(255, 220, 176, 0) 70%),
    radial-gradient(90% 50% at 100% 18%, #FFE9CA 0%, rgba(255, 233, 202, 0) 70%),
    linear-gradient(180deg, #FFF1DC 0%, #FFE0B7 48%, #FFD2A0 100%);
}

.game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .65) 1.1px, transparent 1.1px);
  background-size: 23px 23px;
  opacity: .5;
  mask-image: linear-gradient(180deg, #000 0%, transparent 62%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 62%);
}

.bg-art { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .55;
}

.blob-a {
  width: 220px; height: 220px; left: -90px; top: 16%;
  background: radial-gradient(circle at 35% 35%, #FFC98D, #FFAE62 70%);
}

.blob-b {
  width: 180px; height: 180px; right: -80px; top: 5%;
  background: radial-gradient(circle at 35% 35%, #FFF3D8, #FFD699 70%);
  opacity: .7;
}

.blob-c {
  width: 260px; height: 260px; left: 20%; bottom: -150px;
  background: radial-gradient(circle at 40% 40%, #FFC07A, #FFA453 70%);
  opacity: .35;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .5);
}

.ring-a { width: 86px; height: 86px; left: -26px; bottom: 22%; }
.ring-b { width: 46px; height: 46px; right: 10px; bottom: 36%; border-width: 1.5px; }

/* ===== 顶部 HUD ===== */
.hud {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

.level-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 7px 16px 8px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(160deg, #FFB064 0%, #FF8A3D 55%, #F77725 100%);
  box-shadow: 0 5px 0 #D85F12, 0 10px 20px rgba(216, 95, 18, .26), inset 0 2px 0 rgba(255, 255, 255, .4);
  text-shadow: 0 1px 2px rgba(153, 63, 0, .25);
}

.level-cap { font-size: 11px; font-weight: 700; opacity: .92; letter-spacing: .08em; }
.level-num { font-size: 21px; line-height: 1; font-weight: 900; letter-spacing: -.02em; }

.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  border: 1.5px solid rgba(255, 255, 255, .95);
  box-shadow: 0 4px 0 rgba(194, 112, 51, .13), 0 9px 18px rgba(170, 90, 30, .13);
  color: #B75A0D;
  min-height: 38px;
  transition: transform .1s ease, box-shadow .1s ease;
}

.coin-pill:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(194, 112, 51, .13), 0 5px 10px rgba(170, 90, 30, .11);
}

.coin-pill > .mp-icon { width: 20px; height: 20px; color: #F7B500; filter: drop-shadow(0 1px 0 #C98B00); }
.coin-num { display: inline-block; font-size: 16px; font-weight: 900; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

.coin-plus {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(150deg, #92E27D, #4FBB4C);
  box-shadow: 0 2px 0 #2F8B33, inset 0 1px 0 rgba(255, 255, 255, .55);
  margin-left: 1px;
}
.coin-plus .mp-icon { width: 15px; height: 15px; }

.coin-pill.bump .coin-num { animation: coinBump .42s cubic-bezier(.2, 1.4, .4, 1); }
.coin-pill.bump { animation: coinPillBump .42s cubic-bezier(.2, 1.4, .4, 1); }

@keyframes coinBump {
  0% { transform: scale(1); color: #B75A0D; }
  45% { transform: scale(1.25); color: #E79A13; }
  100% { transform: scale(1); color: #B75A0D; }
}

@keyframes coinPillBump {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.06); }
}

/* ===== 关卡目标 ===== */
.goal {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 10px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 252, 245, .9));
  border: 1.5px solid rgba(255, 255, 255, .95);
  box-shadow: 0 8px 20px rgba(168, 92, 32, .12), inset 0 -2px 0 rgba(255, 255, 255, .9);
}

.goal-orb {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(150deg, #FFC47A 0%, #FF8A3D 58%, #F2721F 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .48), 0 4px 10px rgba(255, 138, 61, .32);
}
.goal-orb .mp-icon { width: 23px; height: 23px; }

.goal-main { flex: 1; min-width: 0; }

.goal-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  line-height: 1.15;
}

.goal-label {
  font-size: 11px;
  font-weight: 700;
  color: #B08A6D;
  letter-spacing: .04em;
}

.goal-target {
  font-size: 12px;
  font-weight: 700;
  color: #9A6741;
}
.goal-target b {
  display: inline-block;
  font-size: 19px;
  line-height: 1;
  color: var(--orange-deep);
  font-weight: 900;
  letter-spacing: -.03em;
  padding: 0 1px;
}

.goal-pct {
  margin-left: auto;
  font-size: 11px;
  font-weight: 900;
  color: #C46A1F;
  background: #FFF0DC;
  border-radius: 999px;
  padding: 3px 8px;
  font-variant-numeric: tabular-nums;
}

.bar {
  position: relative;
  height: 12px;
  margin-top: 7px;
  border-radius: 999px;
  background: #F4E4D0;
  box-shadow: inset 0 2px 4px rgba(143, 84, 35, .14), inset 0 -1px 0 rgba(255, 255, 255, .8);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFCB57 0%, #FF9E3D 45%, #FF7A26 100%);
  box-shadow: 0 0 12px rgba(255, 138, 61, .55), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: width .45s cubic-bezier(.22, .9, .28, 1);
  overflow: hidden;
}

.bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 55%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-18deg);
  animation: barShine 2.2s linear infinite;
}

@keyframes barShine {
  0% { left: -60%; }
  100% { left: 120%; }
}

.goal-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 10px;
  color: #A98163;
  font-weight: 600;
  white-space: nowrap;
}

.goal-gap { color: #C96B22; font-weight: 800; }

/* ===== 棋盘 ===== */
.board {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  padding: 9px 9px 5px;
  border-radius: 25px;
  background:
    radial-gradient(120% 55% at 50% 0%, rgba(255, 255, 255, .92), rgba(255, 255, 255, 0) 55%),
    linear-gradient(180deg, #FFFDF7 0%, #FFF4E3 100%);
  border: 1.5px solid #fff;
  box-shadow: 0 14px 30px rgba(164, 88, 27, .15), inset 0 -3px 0 rgba(255, 255, 255, .9), inset 0 1px 0 #fff;
}

.board-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 3px 7px;
  color: #B28A6B;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.board-top .mp-icon { width: 14px; height: 14px; color: #C99A74; }

.board-hint {
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #FFEFD9;
  color: #B8733A;
  font-size: 9px;
  font-weight: 800;
}

.slots {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.slot {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  touch-action: none;
}

.slot-well {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(186, 113, 52, .07) 0%, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0) 82%, rgba(186, 113, 52, .07) 100%),
    linear-gradient(180deg, #FFEDD8 0%, #FFF8EC 30%, #FFF3E1 100%);
  box-shadow:
    inset 0 8px 14px rgba(178, 105, 45, .13),
    inset 4px 0 8px rgba(178, 105, 45, .06),
    inset -4px 0 8px rgba(178, 105, 45, .06),
    inset 0 -4px 0 rgba(255, 255, 255, .75),
    0 2px 4px rgba(178, 105, 45, .07);
  border: 1.5px solid rgba(255, 255, 255, .9);
  transition: box-shadow .18s ease, transform .18s ease;
}

.slot-well::before {
  content: "";
  position: absolute;
  z-index: 30;
  top: 4px;
  left: 12%;
  right: 12%;
  height: 8px;
  border-radius: 50%;
  background: rgba(164, 97, 42, .13);
  box-shadow: inset 0 -2px 3px rgba(255, 255, 255, .8);
  pointer-events: none;
}

.slot-scale {
  position: absolute;
  z-index: 1;
  top: 10px;
  bottom: 10px;
  left: 5px;
  right: 5px;
  border-radius: 12px;
  pointer-events: none;
  opacity: .55;
  background-image: repeating-linear-gradient(
    to top,
    rgba(171, 103, 49, .16) 0 1px,
    rgba(171, 103, 49, 0) 1px 20%
  );
}

.slot-count {
  flex: none;
  height: 18px;
  line-height: 18px;
  margin-top: 2px;
  text-align: center;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  color: #B08A6C;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
}

.slot-count.full {
  color: #fff;
  background: linear-gradient(160deg, #FFB13F, #FF7A26);
  box-shadow: 0 2px 5px rgba(216, 95, 18, .22);
  font-size: 8px;
  letter-spacing: -.02em;
}

.slot.sel .slot-well {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 3px rgba(255, 138, 61, .85),
    0 0 0 6px rgba(255, 138, 61, .16),
    0 9px 18px rgba(222, 108, 28, .24),
    inset 0 6px 12px rgba(178, 105, 45, .12);
}

.slot.full .slot-well {
  box-shadow:
    0 0 0 3px rgba(255, 185, 43, .95),
    0 0 18px rgba(255, 176, 40, .7),
    0 0 0 6px rgba(255, 185, 43, .17),
    inset 0 6px 12px rgba(178, 105, 45, .12);
}

.slot.full .slot-well::after {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 25;
  border-radius: 17px;
  border: 2px dashed rgba(255, 138, 61, .62);
  animation: fullRing 1.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes fullRing {
  0%, 100% { opacity: .5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.02); }
}

.full-badge {
  position: absolute;
  z-index: 40;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 7px 3px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(160deg, #FFB13F, #FF7A26);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  box-shadow: 0 3px 7px rgba(216, 95, 18, .32), inset 0 1px 0 rgba(255, 255, 255, .45);
  pointer-events: none;
  animation: badgeBob 1.1s ease-in-out infinite;
}

@keyframes badgeBob {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -3px); }
}

/* 筹码 */
.chip {
  position: absolute;
  left: 50%;
  z-index: 1;
  width: 84%;
  max-width: 47px;
  aspect-ratio: 1 / 1;
  transform: translateX(-50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .5);
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, .72) 0%, rgba(255, 255, 255, .18) 28%, rgba(255, 255, 255, 0) 48%),
    linear-gradient(160deg, var(--c1) 0%, var(--c2) 54%, var(--c3) 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, .38),
    inset 0 -4px 0 rgba(90, 34, 0, .18),
    0 3px 6px rgba(88, 42, 8, .2);
  will-change: transform;
}

.chip::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 255, 255, .46);
  pointer-events: none;
}

.chip span {
  position: relative;
  z-index: 2;
  color: #fff;
  font-size: clamp(11px, 3.5vw, 15px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1;
  text-shadow: 0 1.5px 0 rgba(91, 38, 0, .28), 0 0 6px rgba(91, 38, 0, .12);
  font-variant-numeric: tabular-nums;
  transform: translateY(-1px);
}

.chip[data-d="3"] span { font-size: clamp(9px, 2.9vw, 12px); letter-spacing: -.06em; }
.chip[data-d="4"] span { font-size: clamp(8px, 2.5vw, 10.5px); letter-spacing: -.08em; }

.chip.pop { animation: chipPop .34s cubic-bezier(.2, 1.5, .4, 1) both; }

@keyframes chipPop {
  0% { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.35); }
  70% { opacity: 1; transform: translateX(-50%) translateY(-2px) scale(1.08); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.slot.merge-bounce .slot-well { animation: mergeBounce .45s cubic-bezier(.2, 1.4, .4, 1); }

@keyframes mergeBounce {
  0% { transform: scale(1); }
  35% { transform: scale(1.08) translateY(-4px); }
  70% { transform: scale(.97); }
  100% { transform: scale(1); }
}

.merge-gain {
  position: absolute;
  z-index: 60;
  left: 50%;
  top: 44%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(150deg, #67D77A, #2FAE4A);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 5px 12px rgba(35, 146, 61, .34), inset 0 1px 0 rgba(255, 255, 255, .5);
  pointer-events: none;
  animation: gainFloat 1s cubic-bezier(.15, .9, .3, 1) both;
}

.merge-gain b { font-size: 13px; }

@keyframes gainFloat {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  75% { opacity: 1; transform: translate(-50%, -16px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(.94); }
}

.merge-ring {
  position: absolute;
  z-index: 50;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 184, 58, .9);
  pointer-events: none;
  animation: ringBurst .68s ease-out both;
}

@keyframes ringBurst {
  0% { opacity: 1; transform: scale(.4); }
  100% { opacity: 0; transform: scale(3.4); }
}

/* 锁定槽 / 广告槽 */
.slot.locked .slot-well {
  background:
    repeating-linear-gradient(135deg, rgba(210, 184, 155, .34) 0 7px, rgba(243, 229, 210, .7) 7px 14px),
    #F6EBDB;
  border: 2px dashed #DCC3A5;
  box-shadow: inset 0 4px 10px rgba(150, 100, 54, .08);
}

.slot.locked .slot-count { color: #AE8F72; }

.lock-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #A98767;
}

.lock-box .mp-icon {
  width: 24px;
  height: 24px;
  color: #B89372;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .7));
}

.lock-box span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 10px;
  line-height: 1.15;
  letter-spacing: 1px;
  font-weight: 800;
  color: #9E7A58;
}

.slot.ad .slot-well {
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 52%),
    linear-gradient(180deg, #FFF4E4 0%, #FFE6C8 100%);
  border: 2px dashed rgba(255, 138, 61, .55);
}

.ad-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #D26E22;
}

.ad-play {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(150deg, #FFB05E, #FF7A26);
  box-shadow: 0 3px 0 #D45E10, 0 6px 12px rgba(212, 94, 16, .25), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.ad-play .mp-icon { width: 20px; height: 20px; }

.ad-box > span:not(.ad-play) {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.15;
}

.ad-box small {
  writing-mode: vertical-rl;
  font-size: 8px;
  color: #C99B76;
  font-weight: 700;
}

.slot.temp .slot-well {
  box-shadow:
    inset 0 8px 14px rgba(178, 105, 45, .12),
    inset 0 -4px 0 rgba(255, 255, 255, .75),
    0 0 0 2px rgba(255, 154, 73, .28);
}

.slot-tag {
  position: absolute;
  z-index: 40;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 5px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 138, 61, .92);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .06em;
  pointer-events: none;
}

.slot.dragging .slot-well { opacity: .34; }

.slot.drop-ok .slot-well {
  box-shadow:
    0 0 0 3px rgba(63, 190, 106, .92),
    0 0 0 6px rgba(63, 190, 106, .18),
    0 8px 16px rgba(40, 150, 75, .2),
    inset 0 6px 12px rgba(178, 105, 45, .1);
  transform: translateY(-2px);
}

.slot.drop-no .slot-well {
  box-shadow:
    0 0 0 3px rgba(229, 83, 75, .82),
    0 0 0 6px rgba(229, 83, 75, .14),
    inset 0 6px 12px rgba(178, 105, 45, .1);
}

/* 拖拽幽灵 */
.drag-ghost {
  position: fixed;
  z-index: 90;
  width: 58px;
  height: 58px;
  margin: -50px 0 0 -29px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  background:
    radial-gradient(circle at 34% 26%, rgba(255, 255, 255, .75) 0%, rgba(255, 255, 255, .18) 28%, rgba(255, 255, 255, 0) 48%),
    linear-gradient(160deg, var(--c1) 0%, var(--c2) 54%, var(--c3) 100%);
  box-shadow: 0 12px 24px rgba(88, 42, 8, .28), inset 0 3px 0 rgba(255, 255, 255, .4), inset 0 -4px 0 rgba(90, 34, 0, .18);
  border: 2.5px solid rgba(255, 255, 255, .55);
  transform: rotate(-8deg) scale(1.04);
}

.drag-ghost em {
  position: absolute;
  right: -9px;
  top: -8px;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #3D2A1D;
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(40, 20, 4, .32);
}

/* ===== 提示行 & 操作区 ===== */
.tip-line {
  position: relative;
  z-index: 2;
  flex: none;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: #A97853;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .01em;
  padding: 0 4px;
}

.controls {
  position: relative;
  z-index: 2;
  flex: none;
  display: grid;
  grid-template-columns: 1.1fr 1.1fr .94fr;
  gap: 8px;
}

.action {
  position: relative;
  min-height: 64px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 5px;
  transition: transform .1s ease, box-shadow .1s ease, filter .1s ease;
  overflow: visible;
}

.action::after {
  content: "";
  position: absolute;
  inset: 2px 2px auto;
  height: 45%;
  border-radius: 18px 18px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, .19), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.action:active:not(:disabled) { transform: translateY(3px); filter: brightness(.98); }

.action-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(255, 255, 255, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28);
}
.action-icon .mp-icon { width: 20px; height: 20px; }

.action-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.08;
  min-width: 0;
}
.action-text b { font-size: 16px; font-weight: 900; letter-spacing: .02em; white-space: nowrap; }
.action-text small {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 9px;
  font-weight: 700;
  opacity: .84;
  white-space: nowrap;
}
.action-text small .mp-icon { width: 10px; height: 10px; }

.action.deal {
  color: #fff;
  background: linear-gradient(160deg, #FFB061 0%, #FF8A3D 58%, #F67722 100%);
  box-shadow: 0 5px 0 #D45E10, 0 11px 20px rgba(212, 94, 16, .3), inset 0 2px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 1px 1px rgba(140, 56, 0, .22);
}

.action.merge {
  color: #fff;
  background: linear-gradient(160deg, #8BE092 0%, #49C062 55%, #2FA84C 100%);
  box-shadow: 0 5px 0 #24853B, 0 11px 20px rgba(40, 139, 66, .28), inset 0 2px 0 rgba(255, 255, 255, .38);
  text-shadow: 0 1px 1px rgba(18, 100, 40, .22);
}

.action.merge:disabled {
  color: rgba(255, 255, 255, .86);
  background: linear-gradient(160deg, #D9D0C5 0%, #C7B9AA 100%);
  box-shadow: 0 5px 0 #A99A8A, 0 8px 14px rgba(120, 95, 70, .14);
  text-shadow: none;
  cursor: default;
}

.action.merge:disabled .action-icon { opacity: .7; }

.action.shuffle {
  color: #A45F27;
  background: linear-gradient(180deg, #FFFFFF 0%, #FFF7EA 100%);
  border: 1.5px solid #FFE1C1;
  box-shadow: 0 5px 0 #EBC9A8, 0 10px 16px rgba(160, 90, 30, .12), inset 0 1px 0 #fff;
}
.action.shuffle .action-icon { background: #FFF0DD; box-shadow: none; color: #D98640; }
.action.shuffle .action-text small { color: #C0844F; opacity: 1; }
.action.shuffle .action-text small .mp-icon { color: #F2AE00; }

.badge {
  position: absolute;
  z-index: 4;
  top: -6px;
  right: -4px;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #FF7360, #F23F34);
  font-size: 10px;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(200, 46, 36, .38), inset 0 1px 0 rgba(255, 255, 255, .4);
  animation: badgePulse 1.2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  z-index: 95;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom));
  max-width: 82vw;
  padding: 9px 17px;
  border-radius: 999px;
  background: rgba(61, 42, 29, .93);
  color: #FFF8EC;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  box-shadow: 0 8px 18px rgba(54, 28, 8, .24);
  backdrop-filter: blur(6px);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 弹窗 ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(82, 44, 15, .4);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity .22s ease;
}

.overlay[hidden] { display: none; }
.overlay.open { opacity: 1; }

.modal {
  position: relative;
  width: 100%;
  max-width: 336px;
  max-height: calc(100dvh - 44px);
  overflow: auto;
  padding: 22px 20px 20px;
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(90% 45% at 50% 0%, #FFE8C7 0%, rgba(255, 232, 199, 0) 65%),
    linear-gradient(180deg, #FFFEFA 0%, #FFF4E3 100%);
  border: 2px solid #fff;
  box-shadow: 0 26px 60px rgba(80, 40, 10, .34), inset 0 -4px 0 #fff;
  transform: scale(.9) translateY(8px);
  transition: transform .26s cubic-bezier(.2, 1.35, .4, 1);
}

.overlay.open .modal { transform: scale(1) translateY(0); }

.modal::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 28px;
  background-image: radial-gradient(rgba(255, 180, 100, .22) 1.4px, transparent 1.4px);
  background-size: 17px 17px;
  opacity: .55;
  pointer-events: none;
  mask-image: linear-gradient(180deg, #000, transparent 50%);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 50%);
}

.modal > * { position: relative; z-index: 1; }

.modal-icon {
  width: 66px;
  height: 66px;
  margin: 0 auto 12px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(150deg, #FFC36E 0%, #FF8A3D 58%, #F0701F 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 8px 18px rgba(232, 108, 26, .32);
}
.modal-icon .mp-icon { width: 38px; height: 38px; }
.modal-icon.win {
  background: linear-gradient(150deg, #FFE174 0%, #FFB01F 52%, #F28A00 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), 0 8px 20px rgba(232, 152, 20, .4);
}
.modal-icon.ad {
  background: linear-gradient(150deg, #91E58C 0%, #42BC5C 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .4), 0 8px 18px rgba(40, 152, 72, .3);
}

.modal h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: #3D2A1D;
}

.modal p {
  margin: 8px 0 15px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #93735A;
  font-weight: 500;
}
.modal p b { color: #D96A16; font-weight: 900; }

.target-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 13px 0 15px;
}

.target-preview .chip {
  position: relative;
  left: auto;
  width: 58px;
  height: 58px;
  max-width: none;
  transform: none;
  display: grid;
  place-items: center;
  font-size: 0;
  border-width: 3px;
  box-shadow: 0 7px 14px rgba(88, 42, 8, .22), inset 0 3px 0 rgba(255, 255, 255, .4), inset 0 -4px 0 rgba(90, 34, 0, .18);
}

.target-preview .chip span { font-size: 19px; }
.target-preview .chip[data-d="3"] span { font-size: 16px; }
.target-preview .chip[data-d="4"] span { font-size: 13px; }

.target-preview .arrow { color: #C9A385; font-size: 16px; font-weight: 900; }
.target-preview .plus {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: #FFF0DC; color: #CC7A32; font-size: 16px; font-weight: 900;
}

.reward-row { display: flex; justify-content: center; margin: 0 0 16px; }

.coin-reward {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: #FFF1D8;
  color: #B75A0D;
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 #fff, 0 2px 5px rgba(180, 110, 40, .1);
}
.coin-reward .mp-icon { width: 20px; height: 20px; color: #F7B500; }

.modal-btn {
  width: 100%;
  min-height: 50px;
  border-radius: 17px;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(160deg, #FFAE5C 0%, #FF8A3D 55%, #F3741F 100%);
  box-shadow: 0 5px 0 #D45E10, 0 10px 18px rgba(212, 94, 16, .28), inset 0 2px 0 rgba(255, 255, 255, .38);
  transition: transform .1s ease, box-shadow .1s ease;
  text-shadow: 0 1px 1px rgba(140, 56, 0, .2);
}

.modal-btn .mp-icon { width: 18px; height: 18px; color: #F7B500; }

.modal-btn:disabled {
  opacity: .62;
  cursor: default;
  box-shadow: 0 3px 0 #D8A16A, inset 0 1px 0 rgba(255, 255, 255, .3);
  transform: none;
  text-shadow: none;
}

.modal-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #D45E10, 0 5px 10px rgba(212, 94, 16, .2); }

.modal-btn.secondary {
  margin-top: 9px;
  color: #9C6434;
  background: #FFF3E2;
  box-shadow: 0 4px 0 #E8CFB6, inset 0 1px 0 #fff;
  text-shadow: none;
}
.modal-btn.secondary:active { box-shadow: 0 1px 0 #E8CFB6; }

.ad-progress {
  height: 9px;
  margin: 4px 0 16px;
  border-radius: 999px;
  background: #F2E3D1;
  overflow: hidden;
  box-shadow: inset 0 2px 3px rgba(140, 90, 40, .12);
}
.ad-progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8BE092, #42BC5C);
  transition: width .9s linear;
}

.ad-note { font-size: 11px; color: #B1947C; margin-top: 10px; }

.confetti {
  position: absolute;
  z-index: 2;
  top: 40%;
  left: 50%;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  pointer-events: none;
  animation: confettiFall 1.5s ease-out forwards;
}

@keyframes confettiFall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.7); }
}

/* ===== 小屏适配 ===== */
@media (max-height: 700px) {
  .game { gap: 7px; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .goal { padding: 8px 10px; }
  .goal-orb { width: 38px; height: 38px; border-radius: 12px; }
  .goal-orb .mp-icon { width: 21px; height: 21px; }
  .board { min-height: 250px; padding-top: 7px; }
  .board-top { padding-bottom: 5px; }
  .action { min-height: 58px; }
  .tip-line { font-size: 9px; }
}

@media (max-height: 620px) {
  .goal-line { gap: 5px; }
  .goal-target b { font-size: 17px; }
  .goal-sub { margin-top: 3px; }
  .bar { margin-top: 5px; height: 10px; }
  .board { min-height: 220px; }
  .action { min-height: 54px; }
  .action-icon { width: 26px; height: 26px; }
  .action-text b { font-size: 14px; }
  .action-text small { font-size: 8px; }
  .chip { width: 72%; }
  .chip span { font-size: 10px; }
  .chip[data-d="3"] span { font-size: 8px; }
  .chip[data-d="4"] span { font-size: 7px; }
  .slot-count { font-size: 8px; height: 15px; line-height: 15px; }
}

@media (max-width: 350px) {
  .game { padding-left: 10px; padding-right: 10px; }
  .slots { gap: 4px; }
  .controls { gap: 6px; }
  .action-text small { display: none; }
  .action.shuffle .action-text small { display: inline-flex; }
  .action-icon { width: 26px; height: 26px; }
  .action-text b { font-size: 15px; }
  .goal-label { display: none; }
  .board-top > span:first-of-type { overflow: hidden; text-overflow: ellipsis; }
}

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