/* 三消 · 专属样式（选择器统一 .g-match3 前缀；宝石用 CSS clip-path + 渐变绘制） */

/* ---------------- 视图容器 ---------------- */
.g-match3 .m3-setup-view,
.g-match3 .m3-play,
.g-match3 .m3-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.g-match3 .m3-play { flex: 1; }
.g-match3 .m3-result { flex: 1; }

/* ---------------- 设置 ---------------- */
.g-match3 .m3-setup-view .panel { padding: 12px 13px; }
.g-match3 .m3-setup-view .panel-h { margin-bottom: 8px; }
.g-match3 .m3-setup-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.g-match3 .m3-setup-meta .hint { flex: 1; min-width: 0; }
.g-match3 .m3-rules { padding: 12px 13px; }
.g-match3 .m3-rule-line {
  font-size: 12px;
  line-height: 1.78;
  color: var(--dim);
}
.g-match3 .m3-rule-line b { color: var(--text); font-weight: 600; }
.g-match3 .m3-setup-view .stats { margin-top: 2px; }
.g-match3 .m3-setup-view .stat-v { font-size: 17px; }

/* ---------------- HUD ---------------- */
.g-match3 .m3-hud { display: flex; gap: 8px; flex: none; }
.g-match3 .m3-hud-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 6px 7px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.g-match3 .m3-hud-k { font-size: 10px; letter-spacing: 0.05em; color: var(--faint); }
.g-match3 .m3-hud-item .num { font-size: 17px; font-weight: 700; line-height: 1.2; color: var(--text); }
.g-match3 .m3-combo { color: var(--dim); transition: color 0.15s; }
.g-match3 .m3-combo.hot { color: var(--accent); text-shadow: 0 0 12px rgba(242, 209, 107, 0.55); }

.g-match3 .m3-progress-row { display: flex; flex-direction: column; gap: 5px; flex: none; }
.g-match3 .m3-target-label {
  font-size: 10.5px;
  color: var(--faint);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.g-match3 .m3-target-bar { height: 6px; }
.g-match3 .m3-target-bar > i { transition: width 0.3s ease; }
.g-match3 .m3-target-bar.done > i { background: linear-gradient(90deg, var(--ok), #b7ffd9); }

/* ---------------- 棋盘 ---------------- */
.g-match3 .m3-board-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.g-match3 .m3-board {
  position: relative;
  z-index: 1;
  display: block;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(242, 209, 107, 0.1), transparent 62%),
    rgba(255, 255, 255, 0.022);
  box-shadow: 0 18px 44px -22px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.g-match3 .m3-cells {
  position: absolute;
  inset: 4px;
  display: grid;
  gap: var(--gap, 4px);
  pointer-events: none;
}
.g-match3 .m3-cell {
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.032);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.g-match3 .m3-cell.alt { background: rgba(255, 255, 255, 0.052); }
.g-match3 .m3-layer { position: absolute; inset: 4px; pointer-events: none; }

.g-match3 .m3-gem {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell);
  height: var(--cell);
  pointer-events: auto;
  cursor: pointer;
  touch-action: manipulation;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.g-match3 .m3-gem-inner {
  position: absolute;
  inset: 8%;
  background: linear-gradient(148deg, var(--c1), var(--c2));
  clip-path: var(--shape);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.32));
  transition: transform 0.16s ease, opacity 0.18s ease, filter 0.16s ease;
  will-change: transform;
}
.g-match3 .m3-gem-inner::after {
  content: "";
  position: absolute;
  left: 22%;
  top: 14%;
  width: 25%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 72%);
}
.g-match3 .m3-gem.sel .m3-gem-inner {
  transform: scale(1.13);
  filter: drop-shadow(0 0 9px rgba(255, 255, 255, 0.9)) brightness(1.14);
}
.g-match3 .m3-gem.pop .m3-gem-inner {
  transform: scale(0.12) rotate(70deg);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.5, 0, 0.8, 0.2), opacity 0.2s ease;
}
.g-match3 .m3-gem.boom .m3-gem-inner { animation: m3Boom 0.22s ease; }

/* 六种宝石：颜色 + 形状 */
.g-match3 .m3-gem-inner.t0 {
  --c1: #ff9aa6; --c2: #c92f49;
  --shape: polygon(50% 2%, 98% 50%, 50% 98%, 2% 50%);
}
.g-match3 .m3-gem-inner.t1 {
  --c1: #8fd0ff; --c2: #2f6fd0;
  --shape: polygon(25% 2%, 75% 2%, 98% 50%, 75% 98%, 25% 98%, 2% 50%);
}
.g-match3 .m3-gem-inner.t2 {
  --c1: #8af5b8; --c2: #1f9e6a;
  --shape: circle(47% at 50% 50%);
}
.g-match3 .m3-gem-inner.t3 {
  --c1: #ffe49a; --c2: #d9a21f;
  --shape: inset(4% round 27%);
}
.g-match3 .m3-gem-inner.t4 {
  --c1: #d3b0ff; --c2: #7c4ddb;
  --shape: polygon(50% 2%, 61% 35%, 96% 36%, 68% 57%, 78% 93%, 50% 71%, 22% 93%, 32% 57%, 4% 36%, 39% 35%);
}
.g-match3 .m3-gem-inner.t5 {
  --c1: #9af3e9; --c2: #1f9e8a;
  --shape: polygon(30% 2%, 70% 2%, 98% 30%, 98% 70%, 70% 98%, 30% 98%, 2% 70%, 2% 30%);
}
.g-match3 .m3-bomb-mark {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: calc(var(--cell) * 0.36);
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.9), 0 0 18px rgba(255, 255, 255, 0.65);
  animation: m3BombSpin 2.2s linear infinite;
  pointer-events: none;
}
.g-match3 .m3-gem.bomb .m3-bomb-mark { display: flex; }
.g-match3 .m3-gem.bomb .m3-gem-inner { filter: drop-shadow(0 0 8px var(--c1)) brightness(1.12); }

/* ---------------- 连锁特效字 ---------------- */
.g-match3 .m3-combo-float {
  position: absolute;
  z-index: 6;
  transform: translate(-50%, -50%);
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  white-space: nowrap;
  animation: m3Float 0.7s ease-out forwards;
}
.g-match3 .m3-combo-float.chain {
  font-size: 16.5px;
  color: #ffe9a8;
  text-shadow: 0 0 12px rgba(255, 233, 168, 0.8), 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* ---------------- 工具 ---------------- */
.g-match3 .m3-tools { display: flex; gap: 8px; flex: none; }
.g-match3 .m3-tools .btn { flex: 1; min-height: 44px; }

/* ---------------- 结算 ---------------- */
.g-match3 .m3-res-head { text-align: center; padding: 4px 0 0; }
.g-match3 .m3-res-big {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.01em;
  background: linear-gradient(120deg, var(--accent), #fff2c2 55%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.g-match3 .m3-res-big.lose {
  background: linear-gradient(120deg, #ff8b96, #ffc1c7);
  -webkit-background-clip: text;
  background-clip: text;
}
.g-match3 .m3-res-big.practice {
  background: linear-gradient(120deg, #8fd0ff, #c9a6ff);
  -webkit-background-clip: text;
  background-clip: text;
}
.g-match3 .m3-res-sub { margin-top: 3px; font-size: 11.5px; color: var(--faint); }
.g-match3 .m3-res-best {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--dim);
  text-align: center;
}
.g-match3 .m3-res-best .badge { font-size: 10.5px; }

/* ---------------- 动画 ---------------- */
@keyframes m3Boom {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}
@keyframes m3BombSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes m3Float {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  22% { opacity: 1; transform: translate(-50%, -82%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

/* ---------------- 小屏 ---------------- */
@media (max-width: 359px) {
  .g-match3 .m3-hud-item .num { font-size: 16px; }
  .g-match3 .m3-res-big { font-size: 27px; }
}
