/* ==========================================================
   星消达人 · 消灭星星
   竖屏 H5，原生 HTML / CSS / JS
   ========================================================== */

:root {
  --gold: #ffc42e;
  --gold-deep: #b45f00;
  --ink: #141a66;
  --violet: #4a2a9c;
  --panel: rgba(25, 22, 82, 0.88);
  --radius-lg: 24px;
  --pad-x: 16px;
  --tile-yellow: #ffc633;
  --tile-blue: #36a6f5;
  --tile-green: #67ce43;
  --tile-red: #fa4c5f;
  --tile-purple: #b265f3;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #080d33;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background: #141a66;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.65);
}

/* ---------------- 天空背景 ---------------- */

.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(92, 128, 255, 0.5), transparent 65%),
    radial-gradient(ellipse 55% 38% at 12% 30%, rgba(48, 78, 220, 0.42), transparent 70%),
    linear-gradient(
      180deg,
      #080d3a 0%,
      #10165a 22%,
      #211e80 42%,
      #3a258f 60%,
      #66369f 76%,
      #a952a8 89%,
      #e88ab9 100%
    );
}

.sky-glow {
  position: absolute;
  left: -18%;
  right: -18%;
  bottom: -18%;
  height: 58%;
  background:
    radial-gradient(ellipse 44% 58% at 22% 100%, rgba(255, 168, 216, 0.6), transparent 72%),
    radial-gradient(ellipse 52% 64% at 74% 102%, rgba(147, 128, 255, 0.55), transparent 72%),
    radial-gradient(ellipse 38% 40% at 50% 108%, rgba(255, 214, 178, 0.3), transparent 76%);
  filter: blur(14px);
  pointer-events: none;
}

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

.star-dot {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px rgba(205, 226, 255, 0.95);
  animation: twinkle var(--dur, 3.2s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: var(--op, 0.75);
}

.star-cross {
  position: absolute;
  width: var(--s, 14px);
  height: var(--s, 14px);
  background: radial-gradient(circle, #fff 0 18%, rgba(205, 232, 255, 0.85) 30%, transparent 68%);
  clip-path: polygon(50% 0, 58% 40%, 100% 50%, 58% 60%, 50% 100%, 42% 60%, 0 50%, 42% 40%);
  filter: drop-shadow(0 0 5px rgba(180, 220, 255, 0.9));
  animation: twinkle var(--dur, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  opacity: var(--op, 0.8);
}

.shooting-star {
  position: absolute;
  width: 130px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 65%, #cfe6ff);
  box-shadow: 0 0 10px rgba(190, 225, 255, 0.9);
  transform: rotate(-34deg);
  opacity: 0;
  animation: shoot 9.5s ease-in infinite;
}

.ss1 { top: 12%; left: -22%; animation-delay: 1.8s; }
.ss2 { top: 33%; right: 4%; width: 90px; transform: rotate(-34deg); animation-delay: 6.4s; }

@keyframes shoot {
  0%, 86% { opacity: 0; transform: rotate(-34deg) translateX(0); }
  88% { opacity: 1; }
  100% { opacity: 0; transform: rotate(-34deg) translateX(360px); }
}

.clouds {
  position: absolute;
  left: -22%;
  right: -22%;
  pointer-events: none;
}

.clouds-back {
  bottom: 7%;
  height: 38%;
  opacity: 0.5;
  filter: blur(16px);
  background:
    radial-gradient(ellipse 24% 58% at 10% 92%, rgba(184, 190, 255, 0.8), transparent 72%),
    radial-gradient(ellipse 28% 62% at 36% 100%, rgba(210, 184, 255, 0.72), transparent 72%),
    radial-gradient(ellipse 26% 60% at 62% 96%, rgba(255, 188, 231, 0.68), transparent 72%),
    radial-gradient(ellipse 30% 64% at 90% 100%, rgba(160, 166, 255, 0.8), transparent 72%);
}

.clouds-mid {
  bottom: -4%;
  height: 32%;
  opacity: 0.62;
  filter: blur(9px);
  background:
    radial-gradient(ellipse 22% 72% at 6% 100%, rgba(204, 196, 255, 0.8), transparent 70%),
    radial-gradient(ellipse 20% 62% at 30% 106%, rgba(244, 192, 242, 0.82), transparent 72%),
    radial-gradient(ellipse 24% 76% at 52% 106%, rgba(255, 211, 238, 0.7), transparent 72%),
    radial-gradient(ellipse 22% 66% at 76% 104%, rgba(195, 184, 255, 0.8), transparent 72%),
    radial-gradient(ellipse 26% 78% at 100% 106%, rgba(224, 190, 255, 0.8), transparent 72%);
}

.clouds-front {
  bottom: -12%;
  height: 23%;
  opacity: 0.72;
  filter: blur(7px);
  background:
    radial-gradient(ellipse 18% 90% at 2% 112%, rgba(255, 229, 251, 0.85), transparent 70%),
    radial-gradient(ellipse 22% 90% at 24% 112%, rgba(247, 203, 255, 0.7), transparent 70%),
    radial-gradient(ellipse 20% 92% at 50% 114%, rgba(255, 230, 247, 0.68), transparent 70%),
    radial-gradient(ellipse 24% 88% at 76% 110%, rgba(232, 202, 255, 0.7), transparent 70%),
    radial-gradient(ellipse 18% 92% at 98% 112%, rgba(255, 218, 243, 0.8), transparent 70%);
}

@keyframes twinkle {
  0%, 100% { opacity: 0.28; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ---------------- 屏幕切换 ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.975);
  transition: opacity 0.32s ease, transform 0.36s cubic-bezier(0.2, 0.8, 0.3, 1),
    visibility 0.32s;
  pointer-events: none;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}

/* ==========================================================
   首页
   ========================================================== */

.home {
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px
    calc(env(safe-area-inset-bottom, 0px) + 14px);
  overflow: hidden;
}

.home-top {
  position: relative;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  height: 44px;
  flex: 0 0 auto;
}

.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(180deg, rgba(96, 110, 230, 0.5), rgba(40, 36, 118, 0.62));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 16px rgba(0, 0, 0, 0.28);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.14s ease, opacity 0.14s ease;
}

.glass-btn:active { transform: scale(0.92); }
.glass-btn .mp-icon { width: 23px; height: 23px; }

.home-main {
  position: relative;
  z-index: 4;
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  padding: 0 0 172px;
}

.logo-wrap {
  width: min(92vw, 420px);
  flex: 0 0 auto;
  margin-top: -1vh;
  filter: drop-shadow(0 18px 28px rgba(4, 6, 40, 0.5));
  animation: logoFloat 5.4s ease-in-out infinite;
  pointer-events: none;
  /* 让生成图的深蓝底色与星空背景柔和过渡，去掉硬卡片边 */
  -webkit-mask-image:
    linear-gradient(90deg, transparent 0, #000 4.5%, #000 95.5%, transparent 100%),
    linear-gradient(180deg, transparent 0, #000 4%, #000 96%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(90deg, transparent 0, #000 4.5%, #000 95.5%, transparent 100%),
    linear-gradient(180deg, transparent 0, #000 4%, #000 96%, transparent 100%);
  mask-composite: intersect;
}

.logo {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.best-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(13, 15, 62, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 5px 14px rgba(0, 0, 0, 0.2);
  color: rgba(226, 230, 255, 0.78);
  font-size: 12px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.best-chip .mp-icon {
  width: 15px;
  height: 15px;
  color: #ffd45f;
  filter: drop-shadow(0 0 6px rgba(255, 197, 54, 0.7));
}

.best-chip b {
  color: #ffe18d;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* 开始按钮 */
.btn-start {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  width: min(76vw, 318px);
  height: 78px;
  margin-top: auto;
  padding: 0 20px;
  border-radius: 999px;
  border: 3px solid #ffc33a;
  background: linear-gradient(180deg, #fff47d 0%, #ffd938 32%, #ffbc10 64%, #ff9800 100%);
  box-shadow:
    inset 0 5px 0 rgba(255, 255, 255, 0.58),
    inset 0 -10px 0 rgba(187, 93, 0, 0.26),
    0 9px 0 #ab5900,
    0 18px 32px rgba(0, 0, 0, 0.42),
    0 0 46px rgba(255, 175, 30, 0.52);
  color: #fff;
  font-size: 31px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 0 3px 0 #a85a00, 0 5px 0 rgba(110, 52, 0, 0.5);
  -webkit-text-stroke: 1.5px #a85a00;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.1s ease;
  overflow: visible;
}

.btn-start::after {
  content: "";
  position: absolute;
  inset: 5px 8px auto;
  height: 33%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.btn-start:active {
  transform: translateY(5px) scale(0.985);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.45),
    inset 0 -6px 0 rgba(187, 93, 0, 0.28),
    0 4px 0 #ab5900,
    0 8px 20px rgba(0, 0, 0, 0.4),
    0 0 28px rgba(255, 175, 30, 0.4);
  filter: brightness(1.04);
}

.btn-start-text {
  display: inline-block;
  position: relative;
  z-index: 2;
  transform: translateY(-1px);
}

.play-tri {
  position: relative;
  z-index: 2;
  width: 0;
  height: 0;
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
  border-left: 26px solid #fff;
  filter: drop-shadow(0 3px 0 #a85a00) drop-shadow(0 0 4px rgba(255, 255, 255, 0.35));
  flex: 0 0 auto;
}

.home-tip {
  position: relative;
  z-index: 4;
  margin: 16px 0 0;
  color: rgba(231, 234, 255, 0.66);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}

/* 首页边缘的星星方块 */
.home-deco {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.deco-tile {
  position: absolute;
  width: var(--w, 56px);
  height: var(--w, 56px);
  border-radius: 24%;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transform: rotate(var(--rot, 0deg));
  filter: drop-shadow(0 7px 12px rgba(3, 5, 34, 0.42));
  animation: decoFloat var(--dur, 4.6s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
  opacity: var(--op, 1);
}

@keyframes decoFloat {
  from { transform: rotate(var(--rot, 0deg)) translateY(0); }
  to { transform: rotate(var(--rot, 0deg)) translateY(-7px); }
}

/* ==========================================================
   游戏界面
   ========================================================== */

.game {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px
    calc(env(safe-area-inset-bottom, 0px) + 10px);
  overflow: hidden;
}

.game-wrap {
  position: relative;
  z-index: 3;
  display: flex;
  width: 100%;
  max-width: 436px;
  flex-direction: column;
  gap: 11px;
}

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

.hud-btn {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(198, 205, 255, 0.38);
  background: linear-gradient(180deg, rgba(102, 108, 214, 0.62), rgba(44, 38, 124, 0.72));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34), 0 6px 16px rgba(0, 0, 0, 0.26);
  color: #f1f3ff;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.13s ease, filter 0.13s ease;
}

.hud-btn:active { transform: scale(0.9); filter: brightness(1.2); }
.hud-btn .mp-icon { width: 22px; height: 22px; }

.hud-panel {
  flex: 1;
  min-width: 0;
  padding: 7px 14px 9px;
  border-radius: 22px;
  border: 1px solid rgba(161, 172, 255, 0.3);
  background: linear-gradient(180deg, rgba(74, 63, 166, 0.86), rgba(31, 24, 92, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 22px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 17px;
  color: rgba(211, 216, 255, 0.82);
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.hud-level b {
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  margin-left: 2px;
}

.hud-divider {
  width: 1px;
  height: 15px;
  background: rgba(200, 208, 255, 0.24);
}

.hud-target {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: rgba(211, 216, 255, 0.82);
}

.hud-target .mp-icon {
  width: 14px;
  height: 14px;
  color: #ffd45f;
  filter: drop-shadow(0 0 5px rgba(255, 202, 55, 0.55));
}

.hud-target b {
  color: #ffd76b;
  font-size: 15px;
  font-weight: 900;
  margin-left: 1px;
  font-variant-numeric: tabular-nums;
}

.hud-score-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 34px;
}

.hud-score {
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.hud-goal-tag {
  display: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 200, 60, 0.18);
  border: 1px solid rgba(255, 210, 90, 0.45);
  color: #ffe08a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  transform: translateY(-2px);
}

.hud-goal-tag.is-show { display: inline-block; }

.hud-progress {
  height: 3px;
  margin-top: 3px;
  border-radius: 99px;
  background: rgba(5, 6, 30, 0.5);
  overflow: hidden;
}

.hud-progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffd23e, #ff9f1a);
  box-shadow: 0 0 8px rgba(255, 193, 46, 0.8);
  transition: width 0.45s ease;
}

/* 棋盘 */
.board-shell {
  position: relative;
  padding: 8px;
  border-radius: 26px;
  border: 1px solid rgba(156, 167, 255, 0.38);
  background: linear-gradient(180deg, rgba(47, 44, 126, 0.9), rgba(16, 15, 56, 0.96));
  box-shadow:
    inset 0 0 28px rgba(82, 94, 220, 0.22),
    0 0 0 3px rgba(8, 8, 36, 0.32),
    0 16px 34px rgba(0, 0, 0, 0.42);
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 4px;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 19px;
  background:
    radial-gradient(ellipse 80% 70% at 50% 5%, rgba(61, 62, 156, 0.5), transparent 72%),
    rgba(9, 9, 38, 0.78);
  overflow: hidden;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: 23%;
}

.cell.is-empty {
  background: rgba(255, 255, 255, 0.016);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.tile {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 23%;
  background-color: transparent;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  will-change: transform;
  transition: transform 0.13s ease, filter 0.13s ease, opacity 0.17s ease;
}

.tile:active { transform: scale(0.9); }

.tile.t-yellow { background-image: url("images/tiles/yellow.png"); }
.tile.t-blue { background-image: url("images/tiles/blue.png"); }
.tile.t-green { background-image: url("images/tiles/green.png"); }
.tile.t-red { background-image: url("images/tiles/red.png"); }
.tile.t-purple { background-image: url("images/tiles/purple.png"); }

.tile.is-sel {
  z-index: 3;
  animation: selPulse 0.72s ease-in-out infinite alternate;
  filter: brightness(1.2) saturate(1.16) drop-shadow(0 0 8px rgba(255, 246, 158, 0.95));
}

.tile.is-sel::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 27%;
  border: 2px solid rgba(255, 248, 168, 0.92);
  box-shadow: 0 0 12px rgba(255, 231, 100, 0.85), inset 0 0 12px rgba(255, 241, 150, 0.55);
}

@keyframes selPulse {
  from { transform: scale(1.045); }
  to { transform: scale(1.1); }
}

.tile.is-popping {
  transform: scale(1.38);
  opacity: 0;
  filter: brightness(1.65) saturate(1.35);
  pointer-events: none;
  transition: transform 0.2s ease-out, opacity 0.2s ease-out, filter 0.2s ease-out;
}

.tile.is-wrong { animation: tileShake 0.3s ease; }

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  55% { transform: translateX(3px); }
  80% { transform: translateX(-2px); }
}

.board-shell.is-shaking { animation: shellShake 0.42s ease; }

@keyframes shellShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-3px); }
}

.board-glow {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 50px rgba(255, 206, 70, 0.55), inset 0 0 40px rgba(255, 220, 120, 0.3);
  transition: opacity 0.5s ease;
}

.board-glow.is-on { opacity: 1; }

.combo-toast {
  position: absolute;
  left: 50%;
  top: 12px;
  z-index: 8;
  padding: 8px 17px;
  border-radius: 999px;
  border: 1px solid rgba(255, 215, 110, 0.48);
  background: rgba(20, 14, 62, 0.85);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3), 0 0 22px rgba(255, 190, 50, 0.22);
  color: #ffe28a;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -10px) scale(0.92);
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

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

.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 3px;
}

.foot-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(19, 17, 64, 0.55);
  color: rgba(220, 224, 255, 0.72);
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.foot-chip .mp-icon {
  width: 12px;
  height: 12px;
  color: #ffd45f;
}

.foot-chip b {
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.foot-hint {
  flex: 1;
  color: rgba(217, 222, 255, 0.55);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================
   弹窗
   ========================================================== */

.modal-mask {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 20px;
  background: rgba(6, 5, 28, 0.68);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s;
}

.modal-mask.is-show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 336px;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 22px 20px 20px;
  border-radius: 28px;
  border: 1px solid rgba(255, 211, 118, 0.4);
  background:
    radial-gradient(ellipse 90% 50% at 50% 0%, rgba(110, 88, 210, 0.5), transparent 70%),
    linear-gradient(180deg, #30276f 0%, #1f1956 55%, #171244 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 0 5px rgba(8, 7, 34, 0.25);
  text-align: center;
  transform: translateY(14px) scale(0.92);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.18, 1.1, 0.3, 1), opacity 0.24s ease;
}

.modal-mask.is-show .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-emblem {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin: -4px auto 11px;
  border-radius: 50%;
  border: 2px solid rgba(255, 220, 130, 0.7);
  background: radial-gradient(circle at 35% 25%, #ffe786, #ffb21c 70%, #f28a00);
  box-shadow: 0 0 26px rgba(255, 190, 50, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.65);
  color: #8b4700;
}

.modal-emblem .mp-icon {
  width: 33px;
  height: 33px;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.35));
}

.modal-emblem.is-blue {
  border-color: rgba(150, 210, 255, 0.7);
  background: radial-gradient(circle at 35% 25%, #9edcff, #3b9cf5 70%, #1e6bd0);
  box-shadow: 0 0 26px rgba(70, 160, 255, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  color: #0a3d78;
}

.modal-emblem.is-pink {
  border-color: rgba(255, 180, 220, 0.7);
  background: radial-gradient(circle at 35% 25%, #ffc2e5, #f46bb4 70%, #cf3b8e);
  box-shadow: 0 0 26px rgba(255, 100, 190, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  color: #8b1c58;
}

.modal-kicker {
  color: rgba(220, 224, 255, 0.62);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.modal-title {
  margin: 4px 0 4px;
  color: #ffe7a8;
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28), 0 0 22px rgba(255, 200, 70, 0.3);
}

.modal-sub {
  margin: 0 0 14px;
  color: rgba(218, 222, 255, 0.68);
  font-size: 12px;
  line-height: 1.6;
}

.modal-score-box {
  padding: 12px 10px 11px;
  margin-bottom: 13px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 7, 34, 0.32);
  box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.24);
}

.modal-score-label {
  display: block;
  color: rgba(214, 219, 255, 0.62);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.modal-score {
  display: block;
  margin-top: 1px;
  color: #fff;
  font-size: 43px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 214, 110, 0.4), 0 3px 0 rgba(0, 0, 0, 0.28);
}

.modal-score.gold { color: #ffe08a; }

.modal-stats {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0 0 17px;
  padding: 0 2px;
}

.modal-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: rgba(216, 220, 255, 0.68);
  font-size: 12px;
}

.modal-stat b {
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.modal-stat b.gold { color: #ffd76b; }
.modal-stat b.red { color: #ff8b9a; }

.modal-bonus {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 0 13px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 208, 90, 0.26);
  background: rgba(255, 186, 40, 0.1);
  color: #ffe08a;
  font-size: 12px;
  font-weight: 700;
}

.modal-bonus .mp-icon { width: 14px; height: 14px; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.btn-gold,
.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 11px 18px;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.btn-gold {
  border: 2px solid #ffd15a;
  background: linear-gradient(180deg, #fff07a 0%, #ffd238 38%, #ffb00f 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.55), 0 5px 0 #a75b00,
    0 10px 22px rgba(0, 0, 0, 0.32);
  color: #fff;
  text-shadow: 0 2px 0 #a75b00;
  -webkit-text-stroke: 0.6px #a75b00;
}

.btn-gold .mp-icon {
  width: 19px;
  height: 19px;
  color: #fff;
  filter: drop-shadow(0 1px 0 #a75b00);
}

.btn-ghost {
  border: 1px solid rgba(190, 198, 255, 0.28);
  background: rgba(255, 255, 255, 0.07);
  color: rgba(230, 233, 255, 0.86);
}

.btn-ghost .mp-icon { width: 18px; height: 18px; }

.btn-gold:active,
.btn-ghost:active {
  transform: translateY(3px) scale(0.99);
  filter: brightness(1.05);
}

.btn-gold:active { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 2px 0 #a75b00; }

.modal-sound {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 10px 13px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(8, 7, 34, 0.26);
  color: rgba(220, 224, 255, 0.76);
  font-size: 13px;
}

.modal-sound span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.modal-sound .mp-icon {
  width: 18px;
  height: 18px;
  color: #ffd45f;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.switch.is-on {
  background: linear-gradient(180deg, #ffd23e, #ffa919);
  border-color: rgba(255, 220, 120, 0.7);
}

.switch.is-on::after { transform: translateX(20px); }

/* ---------------- 粒子与飘分 ---------------- */

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  pointer-events: none;
}

.spark {
  position: absolute;
  width: var(--s, 6px);
  height: var(--s, 6px);
  border-radius: 50%;
  background: var(--c, #ffe28a);
  box-shadow: 0 0 9px var(--c, #ffe28a);
  animation: sparkFly 0.62s ease-out forwards;
}

@keyframes sparkFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx, 0), var(--dy, -30px)) scale(0.15); opacity: 0; }
}

.score-float {
  position: absolute;
  z-index: 82;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 2px 0 #a85a00, 0 0 14px rgba(255, 210, 80, 0.95);
  transform: translate(-50%, -50%);
  animation: scoreFloat 0.9s ease-out forwards;
  pointer-events: none;
}

@keyframes scoreFloat {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, -55%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.96); }
}

/* ---------------- 响应式高度 ---------------- */

@media (max-height: 720px) {
  .home-main { padding-bottom: 154px; }
  .logo-wrap { width: min(80vw, 340px); margin-top: -2vh; }
  .best-chip { margin-top: -2px; padding: 5px 13px; }
  .btn-start { height: 68px; font-size: 27px; width: min(72vw, 286px); }
  .play-tri { border-top-width: 14px; border-bottom-width: 14px; border-left-width: 22px; }
  .home-tip { margin-top: 12px; font-size: 11px; }
  .hud-panel { padding: 5px 12px 7px; }
  .hud-score { font-size: 27px; }
  .hud-btn { width: 42px; height: 42px; flex-basis: 42px; }
  .game-wrap { gap: 9px; }
  .modal { padding: 18px 17px 16px; }
  .modal-emblem { width: 52px; height: 52px; margin-bottom: 8px; }
  .modal-score { font-size: 37px; }
}

@media (max-height: 620px) {
  .home-main { padding-bottom: 72px; }
  .logo-wrap { width: min(66vw, 280px); }
  .btn-start { height: 60px; font-size: 24px; }
  .home-tip { display: none; }
  .best-chip { font-size: 11px; }
  .deco-tile.side,
  .deco-tile.extra,
  .deco-tile.floaty { display: none; }
  .hud-score { font-size: 24px; }
  .board { gap: 3px; }
  .board-shell { padding: 6px; border-radius: 22px; }
  .game-foot { display: none; }
}

@media (min-width: 620px) {
  .app { border-radius: 28px; height: calc(100dvh - 32px); margin-top: 16px; }
  .home-main { padding-bottom: 184px; }
}

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