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

:root {
  --orange: #FF8A3D;
  --orange-2: #FFA45A;
  --orange-deep: #F06A18;
  --orange-dark: #C95412;
  --jade: #2C8C72;
  --jade-2: #1F705C;
  --jade-deep: #135044;
  --jade-ink: #0E3F35;
  --gold: #FFD25A;
  --gold-soft: #FFE9A8;
  --gold-deep: #D98A12;
  --ink: #42250F;
  --ink-2: #6B4327;
  --muted: #9C7A5C;
  --paper: #FFFDF8;
  --cream: #FFF7E9;
  --line: rgba(150, 91, 44, .16);
  --shadow-warm: rgba(120, 66, 24, .16);
  --shadow-jade: rgba(15, 70, 56, .28);
}

html {
  min-height: 100%;
  background: #E8F6EE;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: #E8F6EE;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.app {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(80% 48% at 50% -8%, rgba(255, 255, 255, .72), transparent 72%),
    linear-gradient(180deg, #D6F2E7 0%, #EEF9EC 30%, #FFF2DC 62%, #FFE2BC 100%);
}

/* ---------- 背景插画 ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-art {
  display: block;
  width: 100%;
  height: 100%;
}

.bg-cloud {
  transform-box: fill-box;
  transform-origin: center;
  animation: cloudFloat 9s ease-in-out infinite alternate;
}

.cloud-b {
  animation-delay: -4s;
  animation-duration: 11s;
}

.bg-fw {
  transform-box: fill-box;
  transform-origin: center;
  animation: fwTwinkle 3.6s ease-in-out infinite;
}

.fw-b {
  animation-delay: -1.8s;
  animation-duration: 4.4s;
}

.bg-float {
  transform-box: fill-box;
  transform-origin: center;
  animation: bgFloat 7s ease-in-out infinite alternate;
}

.float-b {
  animation-delay: -3s;
  animation-duration: 9s;
}

@keyframes cloudFloat {
  from { transform: translate3d(-6px, 0, 0); }
  to { transform: translate3d(8px, -4px, 0); }
}

@keyframes fwTwinkle {
  0%, 100% { opacity: .32; }
  50% { opacity: .62; }
}

@keyframes bgFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-16px); }
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(4px);
}

.glow-a {
  width: 280px;
  height: 280px;
  right: -130px;
  top: -110px;
  background: radial-gradient(circle, rgba(255, 182, 94, .42), rgba(255, 182, 94, 0) 68%);
}

.glow-b {
  width: 340px;
  height: 340px;
  left: -180px;
  top: 42%;
  background: radial-gradient(circle, rgba(140, 214, 184, .38), rgba(140, 214, 184, 0) 70%);
}

/* ---------- 主布局 ---------- */
.game {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px calc(env(safe-area-inset-bottom, 0px) + 10px);
}

/* ---------- 顶部数据 ---------- */
.hud {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex: none;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 8px 14px 9px;
  border-radius: 19px;
}

.stat-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .12em;
  opacity: .85;
}

.stat-label .mp-icon {
  width: 12px;
  height: 12px;
}

.stat.score {
  flex: 1.16;
  color: #fff;
  background:
    radial-gradient(92% 140% at 100% 0%, rgba(255, 255, 255, .3), transparent 55%),
    linear-gradient(135deg, #FFA45A 0%, #FF8A3D 42%, #F06A18 100%);
  border: 1px solid rgba(255, 255, 255, .34);
  box-shadow:
    0 9px 20px rgba(240, 106, 24, .27),
    inset 0 1px 0 rgba(255, 255, 255, .46),
    inset 0 -2px 0 rgba(160, 67, 8, .16);
}

.stat.score .stat-label {
  color: rgba(255, 255, 255, .92);
}

.stat.best {
  flex: .92;
  color: #6B4227;
  background: rgba(255, 253, 248, .88);
  border: 1px solid rgba(255, 255, 255, .95);
  box-shadow:
    0 8px 18px rgba(93, 61, 31, .1),
    inset 0 1px 0 #fff,
    inset 0 0 0 1px rgba(201, 148, 94, .07);
}

.stat.best .stat-label {
  color: var(--muted);
}

.stat-value {
  margin-top: 5px;
  font-size: clamp(22px, 6vw, 28px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.stat.best .stat-value {
  color: #6B4227;
}

.restart {
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  min-height: 54px;
  padding: 0;
  color: #A96834;
  background: rgba(255, 253, 248, .88);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 19px;
  box-shadow:
    0 8px 18px rgba(93, 61, 31, .1),
    inset 0 1px 0 #fff,
    inset 0 0 0 1px rgba(201, 148, 94, .07);
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, color .14s ease;
}

.restart .mp-icon {
  width: 22px;
  height: 22px;
}

.restart:active {
  transform: translateY(2px) scale(.97);
  color: var(--orange-deep);
  box-shadow: 0 3px 8px rgba(93, 61, 31, .12);
}

.restart.spin .mp-icon {
  animation: spin .45s ease;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 目标进度 ---------- */
.goal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 6px 11px;
  background: rgba(255, 253, 248, .74);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(93, 61, 31, .07);
}

.goal-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  font-size: 11.5px;
  font-weight: 900;
  color: #7A4A22;
  white-space: nowrap;
  letter-spacing: .01em;
}

.goal-label .mp-icon {
  width: 14px;
  height: 14px;
  color: var(--orange-deep);
}

.bar {
  position: relative;
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(111, 65, 30, .14);
  box-shadow: inset 0 1px 2px rgba(100, 55, 20, .13);
}

.bar i {
  position: relative;
  z-index: 1;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFC46B, #FF8A3D 58%, #F06A18);
  box-shadow: 0 0 8px rgba(255, 138, 61, .5);
  transition: width .4s cubic-bezier(.3, .8, .3, 1);
}

.bar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1.5px), rgba(255, 252, 243, .82) calc(12.5% - 1.5px) 12.5%);
  pointer-events: none;
}

.goal-count {
  flex: none;
  min-width: 28px;
  font-size: 10.5px;
  font-weight: 900;
  color: #A5724A;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- 本次落子 ---------- */
.launcher {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

.current-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px 6px 6px;
  background: rgba(255, 253, 248, .92);
  border: 1px solid rgba(255, 255, 255, .96);
  border-radius: 18px;
  box-shadow:
    0 8px 17px rgba(93, 61, 31, .11),
    inset 0 1px 0 #fff;
}

.mini-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  box-shadow:
    0 3px 0 rgba(122, 63, 28, .16),
    0 6px 10px rgba(131, 72, 32, .15),
    inset 0 1px 0 rgba(255, 255, 255, .84);
  overflow: hidden;
}

.mini-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .56), rgba(255, 255, 255, 0) 48%);
  pointer-events: none;
}

.mini-tile svg {
  position: relative;
  z-index: 1;
  width: 84%;
  height: 84%;
  filter: drop-shadow(0 2px 1px rgba(96, 42, 14, .18));
}

.mini-tile .rank {
  top: 3px;
  left: 3px;
  min-width: 14px;
  height: 14px;
  line-height: 14px;
  font-size: 8px;
}

.mini-tile.swap {
  animation: miniPop .28s cubic-bezier(.2, .9, .3, 1.2);
}

@keyframes miniPop {
  0% { transform: scale(.82); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.current-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 54px;
}

.current-meta span {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #B08A6A;
}

.current-meta strong {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.15;
  color: #5E361D;
  white-space: nowrap;
}

.current-lv {
  flex: none;
  padding: 4px 7px;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  color: #C55A16;
  background: rgba(255, 138, 61, .12);
  border: 1px solid rgba(255, 138, 61, .16);
  border-radius: 999px;
  white-space: nowrap;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 9px 12px;
  font-size: 11.5px;
  font-weight: 800;
  color: #6E4A2D;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(255, 255, 255, .85);
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(93, 61, 31, .06);
}

.hint .mp-icon {
  width: 16px;
  height: 16px;
  color: var(--orange-deep);
}

/* ---------- 棋盘 ---------- */
.board-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 0;
}

.board {
  position: relative;
  width: min(100%, calc((100vh - 268px) * 0.8333));
  aspect-ratio: 5 / 6;
  border-radius: 26px;
  background:
    radial-gradient(118% 88% at 50% 0%, rgba(255, 255, 255, .18), transparent 56%),
    linear-gradient(158deg, #32967B 0%, #20735E 46%, #145545 100%);
  border: 1px solid rgba(255, 231, 170, .58);
  box-shadow:
    0 0 0 4px rgba(255, 252, 241, .72),
    0 0 0 5px rgba(201, 141, 60, .18),
    0 24px 42px rgba(15, 70, 56, .28),
    0 6px 12px rgba(15, 70, 56, .16),
    inset 0 2px 0 rgba(255, 255, 255, .18),
    inset 0 -8px 18px rgba(0, 42, 34, .26);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@supports (height: 100dvh) {
  .board {
    width: min(100%, calc((100dvh - 268px) * 0.8333));
  }
}

.board::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 0;
  border: 1px solid rgba(255, 225, 160, .28);
  border-radius: 21px;
  pointer-events: none;
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background:
    radial-gradient(90% 60% at 50% 110%, rgba(255, 190, 95, .12), transparent 65%),
    radial-gradient(70% 40% at 50% -10%, rgba(255, 255, 255, .12), transparent 60%);
  pointer-events: none;
}

.slots {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  pointer-events: none;
}

.slot {
  position: relative;
  border-radius: 13px;
  background: rgba(7, 48, 40, .23);
  border: 1px solid rgba(255, 245, 215, .08);
  box-shadow: inset 0 2px 4px rgba(0, 30, 24, .22);
  transition: background .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.slot.aim {
  background: rgba(255, 190, 90, .2);
  border-color: rgba(255, 215, 130, .52);
  box-shadow:
    inset 0 0 0 1px rgba(255, 215, 130, .3),
    0 0 12px rgba(255, 180, 80, .2);
}

.slot.shake {
  animation: slotShake .28s ease;
}

@keyframes slotShake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
}

.pieces {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.piece {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  transition: transform .2s cubic-bezier(.3, .85, .4, 1);
  will-change: transform;
}

.pieces.no-anim .piece {
  transition: none !important;
}

.piece.dropping {
  z-index: 6;
}

.face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 13px;
  overflow: hidden;
  box-shadow:
    0 4px 0 rgba(88, 47, 20, .2),
    0 7px 12px rgba(24, 60, 45, .18),
    inset 0 1px 0 rgba(255, 255, 255, .84);
  transform-origin: 50% 58%;
}

.face::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, .58), rgba(255, 255, 255, 0) 46%);
  opacity: .82;
  pointer-events: none;
}

.face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .44),
    inset 0 -2px 4px rgba(126, 65, 28, .08);
  pointer-events: none;
}

.face svg {
  position: relative;
  z-index: 1;
  width: 84%;
  height: 84%;
  filter: drop-shadow(0 2px 1px rgba(96, 42, 14, .2));
}

.rank {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 3;
  display: inline-grid;
  place-items: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  color: #8A4A1D;
  background: rgba(255, 253, 248, .9);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(80, 40, 10, .16);
  pointer-events: none;
}

/* 等级底色 */
.t1 { background: linear-gradient(155deg, #FFEBDD 0%, #FFD0B2 100%); }
.t2 { background: linear-gradient(155deg, #FFE0D3 0%, #FFB79F 100%); }
.t3 { background: linear-gradient(155deg, #FFE8C2 0%, #FFC476 100%); }
.t4 { background: linear-gradient(155deg, #FFF1BE 0%, #FFCA4F 100%); }
.t5 { background: linear-gradient(155deg, #DDF6E9 0%, #A6DEC7 100%); }
.t6 { background: linear-gradient(155deg, #E0F2FB 0%, #A8D4EB 100%); }
.t7 { background: linear-gradient(155deg, #F1E5FB 0%, #CFB4EF 100%); }
.t8 {
  background: linear-gradient(150deg, #FFF9D0 0%, #FFDD79 45%, #FFBE35 100%);
  box-shadow:
    0 0 0 2px rgba(255, 214, 94, .62),
    0 0 20px rgba(255, 166, 36, .6),
    0 5px 0 rgba(181, 104, 8, .24),
    inset 0 1px 0 rgba(255, 255, 255, .9);
}

.piece.merge .face {
  animation: mergePop .32s cubic-bezier(.2, .9, .3, 1.25);
}

@keyframes mergePop {
  0% { transform: scale(.72); filter: brightness(1.5); }
  55% { transform: scale(1.13); }
  100% { transform: scale(1); }
}

.piece.merge .face::before {
  animation: mergeFlash .34s ease-out;
}

@keyframes mergeFlash {
  0% { opacity: 1; background: radial-gradient(circle, #fff, rgba(255, 255, 255, .1) 70%); }
  100% { opacity: .82; }
}

.piece.gone .face {
  animation: vanish .17s ease-in forwards;
}

@keyframes vanish {
  to { transform: scale(.1); opacity: 0; }
}

.piece.t8 .face::before {
  animation: goldSweep 2.6s ease-in-out infinite;
}

@keyframes goldSweep {
  0%, 100% { transform: translateX(-30%); opacity: .35; }
  50% { transform: translateX(30%); opacity: .7; }
}

/* ---------- 落点预览 ---------- */
.ghost {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  border-radius: 13px;
  border: 2px dashed rgba(255, 235, 180, .64);
  background: rgba(255, 235, 180, .1);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .08s linear;
  will-change: transform;
}

.ghost.show {
  opacity: .55;
}

.ghost svg {
  width: 74%;
  height: 74%;
  opacity: .9;
  filter: drop-shadow(0 2px 2px rgba(0, 30, 24, .25));
}

/* ---------- 新手手势 ---------- */
.coach {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 24%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .32s ease, visibility .32s ease;
}

.coach.show {
  opacity: 1;
  visibility: visible;
}

.coach-tip {
  padding: 7px 13px;
  font-size: 11.5px;
  font-weight: 900;
  color: #6A4226;
  background: rgba(255, 253, 248, .94);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(8, 54, 44, .18);
  white-space: nowrap;
}

.coach-hand {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--orange-deep);
  background: rgba(255, 253, 248, .94);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(8, 54, 44, .2), inset 0 1px 0 #fff;
  animation: tapHint 1.7s ease-in-out infinite;
}

.coach-hand .mp-icon {
  width: 25px;
  height: 25px;
}

@keyframes tapHint {
  0%, 100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-8px) scale(1.04); }
  60% { transform: translateY(-8px) scale(.96); }
  72% { transform: translateY(0) scale(1.02); }
}

/* ---------- 飘分 / 粒子 ---------- */
.pop {
  position: absolute;
  z-index: 9;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.1;
  color: #F05A12;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 2px 0 #fff, 0 0 10px rgba(255, 255, 255, .95);
  animation: popRise .85s cubic-bezier(.2, .7, .3, 1) forwards;
}

.pop small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 800;
  color: #B46218;
  letter-spacing: .04em;
}

@keyframes popRise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); }
  22% { opacity: 1; transform: translate(-50%, -70%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -185%) scale(1); }
}

.spark-fx {
  position: absolute;
  z-index: 7;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px rgba(255, 210, 90, .8);
  pointer-events: none;
  animation: sparkFly .62s ease-out forwards;
}

@keyframes sparkFly {
  from {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(.2);
    opacity: 0;
  }
}

/* ---------- 合成链 ---------- */
.chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  flex: none;
  padding: 4px 5px;
  background: rgba(255, 253, 248, .68);
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 15px;
  box-shadow: 0 4px 10px rgba(93, 61, 31, .06);
}

.chain .node {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, .38);
  box-shadow: inset 0 0 0 1px rgba(150, 91, 44, .08);
  opacity: .36;
  filter: saturate(.45);
  transition: opacity .25s ease, filter .25s ease, transform .25s ease, box-shadow .25s ease;
}

.chain .node svg {
  width: 86%;
  height: 86%;
  filter: drop-shadow(0 1px 1px rgba(96, 42, 14, .14));
}

.chain .node.on {
  opacity: 1;
  filter: none;
  background: rgba(255, 255, 255, .76);
}

.chain .node.now {
  transform: translateY(-1px) scale(1.1);
  box-shadow:
    0 0 0 2px var(--orange),
    0 3px 7px rgba(240, 106, 24, .26);
}

.chain .arrow {
  width: 4px;
  height: 4px;
  flex: none;
  margin: 0 2px;
  border-top: 1.5px solid rgba(150, 91, 44, .4);
  border-right: 1.5px solid rgba(150, 91, 44, .4);
  transform: rotate(45deg);
}

/* ---------- 底部说明 ---------- */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: none;
  padding: 0 3px;
  font-size: 10.5px;
  color: #957052;
}

.foot-hint {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.max-chip {
  flex: none;
  padding: 5px 9px;
  font-size: 9.5px;
  font-weight: 900;
  color: #A3652F;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(255, 255, 255, .82);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 结算弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 48, 40, .48);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 330px;
  padding: 24px 22px 20px;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 225, 168, .55), transparent 55%),
    linear-gradient(180deg, #FFFDF8 0%, #FFF3E2 100%);
  border: 1px solid rgba(255, 255, 255, .95);
  border-radius: 28px;
  box-shadow:
    0 28px 64px rgba(7, 45, 37, .4),
    inset 0 1px 0 #fff;
  transform: translateY(12px) scale(.96);
  transition: transform .3s cubic-bezier(.2, .9, .3, 1.15);
}

.modal::before {
  content: "2026";
  position: absolute;
  right: -12px;
  bottom: -18px;
  font-size: 92px;
  font-weight: 900;
  line-height: 1;
  color: #F08A2E;
  opacity: .06;
  pointer-events: none;
  letter-spacing: -2px;
}

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

.modal-badge {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  color: #fff;
  background: radial-gradient(circle at 35% 28%, #FFC174, #FF8A3D 52%, #ED6314 100%);
  border-radius: 50%;
  box-shadow:
    0 10px 20px rgba(240, 106, 24, .32),
    inset 0 2px 0 rgba(255, 255, 255, .5);
}

.modal-badge .mp-icon {
  width: 32px;
  height: 32px;
}

.modal-badge.over {
  background: radial-gradient(circle at 35% 28%, #C8B6A8, #9B7A62 55%, #7A5841 100%);
  box-shadow:
    0 10px 20px rgba(104, 69, 40, .28),
    inset 0 2px 0 rgba(255, 255, 255, .35);
}

.modal h2 {
  position: relative;
  margin: 0;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: -.01em;
  color: #4E2B15;
}

.modal p {
  position: relative;
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: #9B7256;
}

.modal-score {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

.modal-score span {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  color: #F26B1D;
  text-shadow: 0 2px 0 #fff;
}

.modal-score small {
  font-size: 12px;
  font-weight: 800;
  color: #A17D5D;
}

.modal-best {
  font-size: 11px !important;
  color: #A17D5D !important;
}

.modal-best strong {
  color: #7A4A22;
  font-weight: 900;
}

.modal-actions {
  position: relative;
  display: flex;
  gap: 9px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 900;
  border-radius: 16px;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
}

.btn.primary {
  flex: 1;
  color: #fff;
  background: linear-gradient(180deg, #FFA45A 0%, #FF8A3D 45%, #F06A18 100%);
  border: 1px solid rgba(255, 255, 255, .4);
  box-shadow: 0 5px 0 #C95412, 0 11px 18px rgba(240, 106, 24, .28);
}

.btn.primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #C95412, 0 5px 10px rgba(240, 106, 24, .25);
}

.btn.ghost {
  flex: .82;
  color: #8B5B35;
  background: rgba(255, 255, 255, .8);
  border: 1px solid rgba(180, 122, 76, .18);
  box-shadow: 0 4px 0 rgba(180, 122, 76, .14);
}

.btn.ghost:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(180, 122, 76, .14);
}

.btn[hidden] {
  display: none;
}

/* ---------- 撒花 ---------- */
.confetti {
  position: fixed;
  top: -18px;
  z-index: 60;
  width: 8px;
  height: 14px;
  border-radius: 3px;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(112vh) rotate(620deg); opacity: 0; }
}

/* ---------- 屏幕适配 ---------- */
@media (min-height: 760px) {
  .game {
    justify-content: space-between;
  }

  .board-shell {
    flex: 0 0 auto;
  }
}

@media (max-height: 700px) {
  .game {
    gap: 7px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 7px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 7px);
  }

  .stat {
    padding: 7px 13px 8px;
    border-radius: 17px;
  }

  .stat-value {
    font-size: 22px;
  }

  .restart {
    width: 50px;
    min-height: 50px;
    border-radius: 17px;
  }

  .hint {
    padding: 7px 10px;
    font-size: 11px;
  }

  .current-card {
    padding: 5px 10px 5px 5px;
  }

  .mini-tile {
    width: 42px;
    height: 42px;
  }

  .chain .node {
    width: 22px;
    height: 22px;
  }

  .board {
    width: min(100%, calc((100vh - 252px) * 0.8333));
  }

  @supports (height: 100dvh) {
    .board {
      width: min(100%, calc((100dvh - 252px) * 0.8333));
    }
  }
}

@media (max-height: 610px) {
  .chain {
    display: none;
  }

  .foot-hint {
    display: none;
  }

  .foot {
    justify-content: flex-end;
  }

  .board {
    width: min(100%, calc((100vh - 214px) * 0.8333));
  }

  @supports (height: 100dvh) {
    .board {
      width: min(100%, calc((100dvh - 214px) * 0.8333));
    }
  }
}

@media (max-width: 355px) {
  .game {
    padding-left: 10px;
    padding-right: 10px;
  }

  .stat {
    padding-left: 11px;
    padding-right: 11px;
  }

  .current-meta {
    min-width: 44px;
  }

  .current-lv {
    display: none;
  }

  .hint span {
    display: none;
  }

  .hint {
    padding: 10px;
  }

  .hint .mp-icon {
    width: 19px;
    height: 19px;
  }

  .chain .node {
    width: 21px;
    height: 21px;
  }

  .chain .arrow {
    margin: 0 1px;
  }

  .slots {
    gap: 5px;
    padding: 7px;
  }

  .board::before {
    inset: 4px;
  }
}

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