/* =========================================================
 * 24点 · 极智卡牌
 * 午夜赌场霓虹风 (Midnight Casino Arcade)
 * ========================================================= */

/* ---------- 设计令牌 ---------- */
:root {
  /* 背景 */
  --bg-0: #06091a;
  --bg-1: #0b1133;
  --bg-2: #141b4d;

  /* 桌面 (牌桌) */
  --felt-0: #0d4331;
  --felt-1: #07271c;
  --felt-edge: #0f5c41;
  --felt-line: rgba(120, 255, 190, 0.08);

  /* 强调色 */
  --gold: #f6c453;
  --gold-hi: #ffe08a;
  --gold-deep: #d99a2b;
  --cyan: #3ee6ff;
  --magenta: #ff5fa2;
  --green: #7dffb2;

  /* 牌面 */
  --ivory: #fbf3e2;
  --ivory-dim: #e7d9b8;
  --ink: #232a4d;
  --red: #e0433a;
  --dark: #262b4a;

  /* 界面 */
  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.09);
  --ring: rgba(255, 255, 255, 0.14);
  --radius: 18px;
  --radius-sm: 12px;

  --font-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Georgia, "Songti SC", "STSong", "Times New Roman", serif;

  /* 安全区 (刘海/圆角屏 + 底部手势条) — 兼容 iOS 11+ */
  --sat: constant(safe-area-inset-top, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sab: constant(safe-area-inset-bottom, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: constant(safe-area-inset-left, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: constant(safe-area-inset-right, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html {
  /* 与 body 渐变主色一致: PWA 启动/滚动回弹/加载前不闪白 */
  background-color: var(--bg-0);
}
body {
  font-family: var(--font-ui);
  color: #eef1fb;
  background: radial-gradient(120% 90% at 50% -10%, var(--bg-1) 0%, var(--bg-0) 55%, #030409 100%);
  min-height: 100vh;   /* 旧版 iOS 回退 */
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; touch-action: manipulation; }
.card, .pchip, .op, .btn, .seg-btn, .icon-btn, .step { touch-action: manipulation; }

/* 游戏界面元素禁选中/长按弹出菜单, 避免误触 */
.pool, .ops, .controls, .top, .steps, .overlay {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 6px; }

::selection { background: rgba(246, 196, 83, 0.4); }

/* =========================================================
 * 背景场景
 * ========================================================= */
.bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.5; mix-blend-mode: screen; animation: drift 18s ease-in-out infinite alternate; }
.orb-a { width: 46vmax; height: 46vmax; left: -12vmax; top: -16vmax; background: radial-gradient(circle, rgba(62, 230, 255, 0.5), transparent 65%); }
.orb-b { width: 40vmax; height: 40vmax; right: -14vmax; top: 18vmax; background: radial-gradient(circle, rgba(255, 95, 162, 0.42), transparent 65%); animation-delay: -6s; }
.orb-c { width: 36vmax; height: 36vmax; left: 24vmax; bottom: -18vmax; background: radial-gradient(circle, rgba(246, 196, 83, 0.34), transparent 65%); animation-delay: -12s; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(4vmax, -3vmax) scale(1.15); }
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, black, transparent 78%);
}
.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse 120% 100% at 50% 45%, transparent 55%, rgba(2, 3, 10, 0.85) 100%); }

#fx-canvas { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.flash {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  opacity: 0; transition: opacity 0.3s ease;
  background: var(--gold);
}
.flash.on { opacity: 0.22; }

/* =========================================================
 * 布局容器
 * ========================================================= */
.app {
  width: min(1040px, 100% - 2rem);
  margin: 0 auto;
  padding: 0.7rem 0 0.8rem;
  padding-top: calc(0.7rem + var(--sat, 0px));
  padding-bottom: calc(0.8rem + var(--sab, 0px));
  padding-left: var(--sal, 0px);
  padding-right: var(--sar, 0px);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  flex: 1;
}

/* =========================================================
 * 顶部: 两行布局
 * row1: 计时/挑战模式 (左) | 声音按钮 (右)
 * row2: HUD统计 (居中)
 * ========================================================= */
.top { display: flex; flex-direction: column; gap: 0.6rem; }

.top-row1 { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.top-row2 { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; }
.top-row2 .hud { justify-content: center; }

.hud { display: flex; gap: 0.55rem; }
.stat {
  background: var(--glass);
  border: 1px solid var(--ring);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  min-width: 88px;
  text-align: center;
  backdrop-filter: blur(8px);
}
.stat-label { display: block; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: #8b95c0; }
.stat-value {
  display: block; margin-top: 0.12rem; font-size: 1.35rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.stat-time { transition: color 0.25s; }
.stat-time.urgent { color: var(--magenta); animation: urgentPulse 0.55s ease-in-out infinite; }
.stat-time.win { color: var(--green); text-shadow: 0 0 12px rgba(125, 255, 178, 0.8); }
@keyframes urgentPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }

/* 顶部第一行用的: 模式切换 + 声音按钮 */
.seg { display: flex; background: var(--glass); border: 1px solid var(--ring); border-radius: 999px; padding: 0.2rem; backdrop-filter: blur(8px); }
.seg-btn {
  padding: 0.32rem 0.85rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; color: #aab3d8;
  transition: all 0.2s ease;
  display: inline-flex; align-items: center; gap: 0.25rem;
}
.seg-btn svg { width: 12px; height: 12px; display: block; }
.seg-btn.is-on {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-deep));
  color: #241d08;
  box-shadow: 0 4px 14px rgba(246, 196, 83, 0.4);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--ring);
  font-size: 0.9rem; display: grid; place-items: center;
  transition: all 0.2s;
}
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn:hover { background: var(--glass-strong); transform: translateY(-2px); }

/* =========================================================
 * 牌桌
 * ========================================================= */
.table { display: flex; flex-direction: column; gap: 0.4rem; }
.table-meta { display: flex; align-items: center; justify-content: center; gap: 0.7rem; font-size: 0.78rem; color: #b9c0e3; }
.chip {
  font-size: 0.72rem; font-weight: 700; padding: 0.18rem 0.6rem; border-radius: 999px; letter-spacing: 0.05em;
}
.chip-cyan { color: var(--cyan); border: 1px solid rgba(62, 230, 255, 0.5); background: rgba(62, 230, 255, 0.1); }
.chip-magenta { color: var(--magenta); border: 1px solid rgba(255, 95, 162, 0.5); background: rgba(255, 95, 162, 0.1); }

.felt {
  position: relative;
  border-radius: 26px;
  padding: clamp(1.4rem, 4vw, 2.6rem) clamp(0.8rem, 3vw, 2rem);
  background:
    radial-gradient(120% 130% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 45%),
    linear-gradient(160deg, var(--felt-0) 0%, var(--felt-1) 100%);
  border: 1px solid rgba(125, 255, 178, 0.18);
  box-shadow:
    inset 0 2px 18px rgba(255, 255, 255, 0.06),
    0 18px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.felt::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(ellipse 90% 70% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.4) 100%),
    repeating-linear-gradient(115deg, var(--felt-line) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(25deg, var(--felt-line) 0 1px, transparent 1px 26px);
  pointer-events: none;
}
.felt::after {
  content: ""; position: absolute; inset: 10px; border-radius: 20px;
  border: 1.5px dashed rgba(246, 196, 83, 0.28);
  pointer-events: none;
}
.felt-spot { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(246, 196, 83, 0.08), transparent 60%); pointer-events: none; }

/* =========================================================
 * 数字池 (当前可用的数字, 含原始卡牌与每步结果)
 * ========================================================= */
.pool {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(0.6rem, 2.6vw, 1.5rem);
  min-height: clamp(140px, 22vw, 190px);
  perspective: 1200px;
  flex-wrap: wrap;
}
.pool.won .pchip { animation: cardWin 0.6s cubic-bezier(0.22, 1.2, 0.36, 1) both; animation-delay: calc(var(--i, 0s) * 0.2); }
.pool.answered .pchip { animation: cardAnswer 1s ease-in-out infinite; animation-delay: calc(var(--i, 0s)); }
@keyframes cardWin {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-16px) scale(1.06); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes cardAnswer {
  0%, 100% { box-shadow: 0 0 12px rgba(62, 230, 255, 0.25), 0 10px 24px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 30px rgba(62, 230, 255, 0.7), 0 10px 30px rgba(0, 0, 0, 0.45); }
}

/* ---------- 数字池筹码 ---------- */
.pchip {
  position: relative;
  width: clamp(76px, 15vw, 108px);
  aspect-ratio: 3 / 4.2;
  border-radius: clamp(8px, 1.2vw, 14px);
  cursor: pointer;
  user-select: none;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.3, 1), box-shadow 0.22s ease, filter 0.22s ease, opacity 0.35s ease;
}
.pchip:hover { transform: translateY(-6px) scale(1.04); }
.pchip:active { transform: scale(0.96); }

/* 原始扑克牌 */
.pchip.card-chip {
  background:
    linear-gradient(180deg, #fffdf6 0%, var(--ivory) 55%, var(--ivory-dim) 100%);
  border: 1px solid rgba(0, 0, 0, 0.14);
  color: var(--dark);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  padding: clamp(0.4rem, 1.6vw, 0.75rem);
}
.pchip.card-chip.red { color: var(--red); }
.pchip.card-chip.dark { color: var(--dark); }

/* 计算得出的结果 */
.pchip.result-chip {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(160deg, #3a3166 0%, #1c1640 100%);
  border: 2px solid rgba(246, 196, 83, 0.75);
  box-shadow:
    0 0 24px rgba(246, 196, 83, 0.28),
    0 10px 26px rgba(0, 0, 0, 0.5),
    inset 0 0 18px rgba(246, 196, 83, 0.18);
}
.result-val {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 3.6vw, 2.3rem);
  color: var(--gold-hi);
  text-shadow: 0 0 16px rgba(246, 196, 83, 0.7);
  line-height: 1;
  padding: 0.15rem;
  text-align: center;
}
.result-val.chip-sm { font-size: clamp(1.15rem, 2.8vw, 1.7rem); }
.result-val.chip-xs { font-size: clamp(0.9rem, 2.2vw, 1.3rem); }

/* 选中态: 第1个=青色, 第2个=品红 */
.pchip.sel1 {
  transform: translateY(-10px) scale(1.06);
  box-shadow: 0 0 0 3px var(--cyan), 0 0 26px rgba(62, 230, 255, 0.55), 0 12px 30px rgba(0, 0, 0, 0.5);
  filter: brightness(1.08);
}
.pchip.sel2 {
  transform: translateY(-10px) scale(1.06);
  box-shadow: 0 0 0 3px var(--magenta), 0 0 26px rgba(255, 95, 162, 0.55), 0 12px 30px rgba(0, 0, 0, 0.5);
  filter: brightness(1.08);
}
.pchip.result-chip.sel1 { border-color: var(--cyan); }
.pchip.result-chip.sel2 { border-color: var(--magenta); }

/* 离场 / 入场动画 */
.pchip.leaving {
  transform: scale(0.25) translateY(-30px);
  opacity: 0;
  filter: blur(3px);
  pointer-events: none;
}
.pchip.entering { animation: chipPop 0.5s cubic-bezier(0.2, 1.4, 0.3, 1) both; }
@keyframes chipPop {
  0% { transform: scale(0.2) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.14) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* 发牌动画: 从空中飞入 */
.pchip.dealt { animation: dealFly 0.55s cubic-bezier(0.22, 1.25, 0.36, 1) var(--i, 0s) both; }
@keyframes dealFly {
  0% { transform: translateY(-42vh) translateX(calc(var(--dx, 0) * -1px)) rotate(var(--spin, 0deg)) scale(0.55); opacity: 0; }
  55% { opacity: 1; }
  82% { transform: translateY(2.5vh) translateX(calc(var(--dx, 0) * -0.2px)) rotate(calc(var(--spin, 0deg) * 0.2)) scale(1.03); }
  100% { transform: translateY(0) translateX(0) rotate(0deg) scale(1); opacity: 1; }
}

/* 池内提示文字 */
.pool-hint {
  margin-top: 0.7rem;
  text-align: center;
  font-size: 0.82rem;
  color: #93a0c8;
  letter-spacing: 0.02em;
}

/* ---------- 牌面细节 (卡牌筹码) ---------- */
.corner { position: absolute; display: flex; flex-direction: column; align-items: center; line-height: 1; user-select: none; }
.corner b { font-family: var(--font-display); font-size: clamp(0.7rem, 1.6vw, 1.05rem); }
.corner i { font-style: normal; font-size: clamp(0.62rem, 1.4vw, 0.9rem); }
.corner.tl { top: 5.5%; left: 8%; }
.corner.br { bottom: 5.5%; right: 8%; transform: rotate(180deg); }

.pips {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2%;
  pointer-events: none;
}
.big-rank { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.2rem, 3vw, 2.1rem); line-height: 1; }
.big-suit { font-size: clamp(1.5rem, 4vw, 2.7rem); line-height: 1; opacity: 0.92; text-shadow: 0 1px 0 rgba(255,255,255,0.6); }

/* =========================================================
 * 消息 & 答案横幅
 * ========================================================= */
.message, .answer {
  min-height: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.88rem; font-weight: 600;
  opacity: 0; transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  text-align: center; padding: 0.08rem 0.6rem;
}
.message.show, .answer.show { opacity: 1; transform: translateY(0); }
.message.info { color: var(--cyan); }
.message.warn { color: var(--gold); }
.message.error { color: var(--magenta); }

.answer { font-size: 1rem; }
.answer.gold { color: var(--gold); text-shadow: 0 0 14px rgba(246, 196, 83, 0.55); }
.answer.red { color: var(--magenta); }
.answer .ans-expr {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; letter-spacing: 0.04em;
  margin-left: 0.3rem;
}
.answer.gold .ans-expr {
  background: linear-gradient(180deg, var(--gold-hi), var(--gold-deep));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none;
  animation: answerShimmer 1.6s linear infinite;
}
.answer b { font-size: 1.3rem; }
.answer i { font-style: normal; color: var(--gold); }
@keyframes answerShimmer {
  from { filter: brightness(1); }
  50% { filter: brightness(1.35); }
  to { filter: brightness(1); }
}

/* =========================================================
 * 步骤历史
 * ========================================================= */
.steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  min-height: 1.8rem;
}
.step {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  background: var(--glass);
  border: 1px solid var(--ring);
  padding: 0.22rem 0.6rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #dfe4f7;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.step:hover { transform: translateY(-2px); border-color: rgba(62, 230, 255, 0.6); box-shadow: 0 0 14px rgba(62, 230, 255, 0.25); }
.step .st-a, .step .st-b { font-family: var(--font-display); font-weight: 800; }
.step .st-op { color: var(--gold); font-weight: 800; }
.step .st-eq { color: #7c86b2; }
.step .st-res { font-family: var(--font-display); font-weight: 800; color: var(--gold-hi); text-shadow: 0 0 10px rgba(246, 196, 83, 0.5); }
.step.entering { animation: stepPop 0.35s cubic-bezier(0.2, 1.4, 0.3, 1) both; }
@keyframes stepPop {
  0% { transform: scale(0.5) translateY(8px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* =========================================================
 * 运算符
 * ========================================================= */
.ops {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.45rem, 1.2vw, 0.65rem);
  width: min(460px, 100%);
  margin: 0 auto;
}
.op {
  position: relative;
  height: clamp(44px, 7vw, 54px);
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--ring);
  color: #dfe4f7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.06rem;
  transition: transform 0.13s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s, color 0.2s;
}
.op span { font-size: clamp(1.1rem, 2.5vw, 1.45rem); font-weight: 800; line-height: 1; }
.op small { font-size: 0.56rem; opacity: 0.7; letter-spacing: 0.1em; }
.op:hover { background: var(--glass-strong); border-color: rgba(246, 196, 83, 0.5); transform: translateY(-2px); }
.op:active { transform: scale(0.95); }
.op-add span { color: var(--cyan); }
.op-sub span { color: var(--magenta); }
.op-mul span { color: var(--gold); }
.op-div span { color: var(--green); }

/* 选中两个数字后 → 运算符激活 */
.op.ready {
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--gold-deep) 100%);
  border-color: transparent;
  color: #241d08;
  box-shadow: 0 8px 24px rgba(246, 196, 83, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: opReadyPulse 1.4s ease-in-out infinite;
}
.op.ready span { color: #241d08; }
.op.ready small { color: #241d08; opacity: 0.75; }
@keyframes opReadyPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.ops.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* =========================================================
 * 操作按钮
 * ========================================================= */
.controls { display: flex; flex-direction: column; gap: 0.5rem; align-items: stretch; }
.ctrl-row { display: flex; gap: 0.5rem; }
.ctrl-row .btn { flex: 1 1 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  font-size: 0.88rem; font-weight: 800; letter-spacing: 0.04em;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s;
  min-width: 0;
  flex: 1 1 auto;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(0.96); }
.btn .btn-glyph { font-size: 0.95rem; }
.btn .btn-glyph svg { width: 1.1em; height: 1.1em; display: block; }
.btn em { font-style: normal; font-size: 0.7rem; opacity: 0.85; background: rgba(0,0,0,0.25); padding: 0.1rem 0.4rem; border-radius: 999px; }

.btn-gold {
  color: #241d08;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--gold-deep) 100%);
  box-shadow: 0 8px 22px rgba(246, 196, 83, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-gold:hover { box-shadow: 0 10px 30px rgba(246, 196, 83, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5); }

.btn-ghost {
  color: #dfe4f7;
  background: var(--glass);
  border: 1px solid var(--ring);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: var(--glass-strong); border-color: rgba(246, 196, 83, 0.5); color: var(--gold); }

.btn-lg { padding: 0.9rem 2.2rem; font-size: 1.1rem; }

/* =========================================================
 * 页脚提示
 * ========================================================= */
.footnote {
  text-align: center; font-size: 0.66rem; color: #6f79a6; margin-top: 0.1rem;
}

/* =========================================================
 * 结算浮层
 * ========================================================= */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: var(--sat, 0px) var(--sar, 0px) var(--sab, 0px) var(--sal, 0px);
  background: rgba(3, 5, 14, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0; transition: opacity 0.3s ease;
}
.overlay[hidden] { display: none; }
.overlay.show { opacity: 1; }
.overlay-card {
  width: min(360px, 92vw);
  background: linear-gradient(180deg, #161c40, #0d1130);
  border: 1px solid rgba(246, 196, 83, 0.35);
  border-radius: 24px;
  padding: 2rem 1.6rem 1.7rem;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 40px rgba(246, 196, 83, 0.18);
  transform: scale(0.85) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.2, 1.2, 0.3, 1);
}
.overlay.show .overlay-card { transform: scale(1) translateY(0); }
.overlay-badge { font-size: 3.2rem; animation: badgePop 0.6s cubic-bezier(0.2, 1.4, 0.3, 1) 0.15s both; color: var(--gold); display: flex; justify-content: center; }
.overlay-badge svg { width: 48px; height: 48px; filter: drop-shadow(0 0 12px rgba(246,196,83,0.6)); }
@keyframes badgePop { 0% { transform: scale(0) rotate(-20deg); } 100% { transform: scale(1) rotate(0); } }
.overlay-title { font-size: 1.6rem; font-weight: 800; margin: 0.5rem 0 1rem; color: var(--gold); }
.overlay-rows { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.4rem; }
.overlay-rows .row {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px; padding: 0.55rem 0.9rem;
  font-size: 0.9rem; color: #b9c0e3;
}
.overlay-rows .row b { color: #fff; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* =========================================================
 * 响应式
 * ========================================================= */
@media (max-width: 640px) {
  .app {
    width: min(100% - 1rem, 1040px);
    padding: 0.5rem 0 0.5rem;
    padding-top: calc(0.5rem + var(--sat, 0px));
    padding-bottom: calc(0.5rem + var(--sab, 0px));
    padding-left: var(--sal, 0px);
    padding-right: var(--sar, 0px);
    gap: 0.45rem;
  }
  .top { gap: 0.4rem; }
  /* 顶部两行: row1 模式+声音 | row2 HUD 居中 */
  .top-row2 {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
  }
  .hud { gap: 0.4rem; }
  .stat { min-width: 0; padding: 0.4rem 0.6rem; }
  .stat-label { font-size: 0.62rem; }
  .stat-value { font-size: 1.1rem; }
  .seg-btn { padding: 0.3rem 0.65rem; min-height: 32px; font-size: 0.72rem; }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 15px; height: 15px; }
  .felt { padding: 0.8rem 0.4rem; border-radius: 18px; }
  .pool { min-height: 120px; gap: 0.35rem; }
  .pchip { width: clamp(60px, 16vw, 82px); }
  .btn { padding: 0.5rem 0.5rem; min-height: 44px; font-size: 0.82rem; }
  .ctrl-row { gap: 0.35rem; }
  .op { height: 46px; }
  .op small { display: none; }
  /* 符号按钮与底部操作按钮隔开, 防误触 */
  .ops { margin-bottom: 0.9rem; }
  .footnote { font-size: 0.6rem; line-height: 1.5; padding: 0 0.5rem; }
  /* 牌区占满剩余高度并垂直居中, 操作区贴底(拇指可及) */
  .table { flex: 1 1 auto; justify-content: center; }
}

/* 小屏/矮屏 (如 320x568): 进一步压缩, 保证一屏放下不滚动 */
@media (max-height: 620px) and (max-width: 640px) {
  .app { gap: 0.3rem; }
  .top { gap: 0.25rem; }
  .hud { gap: 0.3rem; }
  .stat { padding: 0.3rem 0.5rem; }
  .stat-value { font-size: 0.95rem; }
  .pool { min-height: 96px; }
  .felt { padding: 0.5rem 0.4rem; }
  .pchip { width: clamp(52px, 15vw, 74px); }
  .message, .answer { min-height: 1.2rem; font-size: 0.82rem; }
  .steps { min-height: 1.4rem; }
  .footnote { margin-top: 0; line-height: 1.4; }
  .table { justify-content: flex-start; }
}

/* =========================================================
 * 无障碍: 减弱动效
 * ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  .pchip.dealt { animation: none; opacity: 1; }
}

/* =========================================================
 * 移动端省电: 收窄模糊半径、停止背景球漂移动画
 * ========================================================= */
@media (max-width: 640px) {
  .orb { filter: blur(56px); animation: none; }
}
/* 超窄屏: 进一步关闭混合模式, 用更省的光晕 */
@media (max-width: 380px) {
  .orb { mix-blend-mode: normal; opacity: 0.32; filter: blur(48px); }
}
