/* =========================================================
   碎核消消乐 CRUSH CORE - 主样式（全机型兼容·沉浸式满屏）
   风格：深色霓虹 / 硬核工业 / 成年男性向
   单位：rem （基准：1rem = 屏幕宽度 / 10，设计稿 750 时约 75px）
   动态变量：--app-height / --app-width（由 index.html 首屏 JS 写入）
   ========================================================= */

/* ---------- 全局根级：防误操作 + 满屏约束 ---------- */
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* 禁止 iOS/小米 橡皮筋滚动后退 / 下拉刷新干扰游戏 */
    overscroll-behavior: none;
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
    background: #0a0014;
    /* 所有交互元素：禁止长按文字选中/弹出放大镜/复制菜单
       — 300ms 点击延迟取消 / 捏合手势不触发浏览器默认缩放
       — 避免用户在棋盘滑动时被当成手势导航后退 */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
       -moz-user-select: none;
        -ms-user-select: none;
            user-select: none;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    color: #fff;
    font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei",
                 "Helvetica Neue", Arial, sans-serif;
}

/* 如果设备不支持 dvh（老安卓），用 JS 变量 --app-height；否则 dvh 也可以 */
@supports (height: 100dvh) {
    html, body { height: 100dvh; }
}

/* 允许极少数文本选中（难度描述/结算数字），但游戏内控件一律不选 */
.allow-select, .final-stats {
    -webkit-user-select: text;
       -moz-user-select: text;
        -ms-user-select: text;
            user-select: text;
}

/* 全局 touch 反馈基线：所有可点击元素按下时略微下沉 */
button, .btn-primary, .btn-ghost, .diff-btn, .powerup-btn, .tile, .hud-exit {
    -webkit-user-drag: none;
     -khtml-user-drag: none;
         user-drag: none;
}
button:active,
.btn-primary:active,
.btn-ghost:active,
.diff-btn:active,
.powerup-btn:active,
.hud-exit:active {
    transform: scale(0.96);
    filter: brightness(1.15);
}

/* ---------- 全局布局 ---------- */
.game-root {
    position: relative;
    width: 100%;
    width: 100vw;
    /* 优先 JS 精确值，回退 dvh → vh */
    height: var(--app-height, 100vh);
    height: var(--app-height, 100dvh);
    min-height: 100vh;
    /* 刘海屏/底部 Home 指示条安全区 padding */
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
    background:
        radial-gradient(ellipse at top, #1a0033 0%, #000 55%),
        linear-gradient(180deg, #0a0014 0%, #000 100%);
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 背景扫描线 + 粒子噪点 */
.game-root::before {
    content: "";
    position: absolute;
    /* 不用 inset 简写（Chrome < 87 不支持），手写四边兼容老 WebView */
    top: 0; right: 0; bottom: 0; left: 0;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 0, 128, 0.03) 0px,
        rgba(255, 0, 128, 0.03) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 1;
}

/* ---------- HUD 顶栏（★ 修复「数值块全部消失」★） ---------- */
.hud-bar {
    position: relative;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: stretch;      /* 改成 stretch，每一行所有块高度一样，不会被压扁 */
    align-content: flex-start;
    gap: 0.06rem 0.08rem;
    padding: 0.10rem 0.12rem 0.08rem;
    padding-left:  calc(0.12rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.12rem + env(safe-area-inset-right, 0px));
    padding-top:   calc(0.10rem + env(safe-area-inset-top, 0px));
    border-bottom: 1px solid rgba(255, 0, 128, 0.15);
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(255, 0, 128, 0.10) 70%, transparent 100%);
    flex-shrink: 0;
    flex-grow: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* ★ 溢出必须是 visible：否则 flex-wrap 到第二行会被切掉！*/
    overflow: visible;
    backdrop-filter: blur(0.06rem);
    -webkit-backdrop-filter: blur(0.06rem);
    flex-direction: row;
    top: auto; left: auto; right: auto; bottom: auto;
    order: 0;
    writing-mode: horizontal-tb;
}

.hud-exit {
    /* 退出按钮是高优先级控件，给它肥一点的触控热区
       — 44px 是 iOS HIG "最小触控目标"推荐值（≈0.65rem @750）*/
    flex: 0 0 auto;
    min-height: 0.52rem;
    min-width: 0.96rem;
    padding: 0.10rem 0.16rem;
    font-size: 0.16rem;
    font-weight: 800;
    letter-spacing: 0.02rem;
    line-height: 1.1;
    color: #ffe0ec;
    background: linear-gradient(135deg, rgba(255, 40, 90, 0.95) 0%, rgba(140, 0, 60, 0.95) 100%);
    border: 1px solid rgba(255, 220, 230, 0.28);
    border-radius: 0.10rem;
    box-shadow:
        0 0 0.14rem rgba(255, 40, 90, 0.45),
        0 0 0.04rem rgba(255, 255, 255, 0.1) inset,
        0 0 0.10rem rgba(0,0,0,0.6) ;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    /* 退出按钮视觉上"独立浮着"：z-index 最高、永远在最上层 */
    position: relative;
    z-index: 5;
}
.hud-exit::before {
    content: "";
    position: absolute;
    /* 触控热区外扩 0.08rem（不用 inset 简写，Chrome<87 不支持）*/
    top: -0.08rem; right: -0.08rem; bottom: -0.08rem; left: -0.08rem;
    z-index: -1;
}
.hud-exit:active {
    transform: scale(0.93);
    filter: brightness(1.2);
    box-shadow:
        0 0 0.22rem rgba(255, 60, 100, 0.7),
        0 0 0.06rem rgba(255, 255, 255, 0.18) inset;
}
.hud-sound-toggle {
    min-width: 0.52rem;
    min-height: 0.52rem;
    padding: 0.08rem 0.12rem;
    font-size: 0.22rem;
    font-weight: 700;
    letter-spacing: 0;
    background: linear-gradient(135deg, rgba(70, 160, 255, 0.95) 0%, rgba(20, 80, 180, 0.95) 100%);
    border: 1px solid rgba(220, 240, 255, 0.28);
    box-shadow:
        0 0 0.14rem rgba(70, 160, 255, 0.45),
        0 0 0.04rem rgba(255, 255, 255, 0.1) inset,
        0 0 0.10rem rgba(0, 0, 0, 0.6);
}

.hud-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.03rem;
    min-width: 0;
    /* 行高兜底：最少 0.52rem，不会被 flex stretch 挤扁 */
    min-height: 0.52rem;
    padding: 0.05rem 0.06rem;
    margin: 0;
    /* ★ 核心：flex-basis 改成 30%（原来是 0 一压缩就没宽度）
       让 3 个 hud-block（生命/得分/最高）各占 30% 宽度，
       340px 窄屏每个还有 1.02rem（38px）宽，4 颗桃心完全放得下 */
    flex: 1 1 30%;
    box-sizing: border-box;
    overflow: visible;
    writing-mode: horizontal-tb;
    border: none !important;
}

/* 得分/最高：略肥一点 32%（不影响换行） */
.hud-block.score,
.hud-block.best {
    flex: 1 1 32%;
    min-width: 0.92rem;
}

/* 生命块：最少 28%，保证 4 颗桃心不缩 */
.hud-block.lives {
    flex: 1 1 28%;
    min-width: 0.88rem;
}

.hud-label {
    font-size: 0.11rem;
    color: #b0b0c6;
    letter-spacing: 0.03rem;
    white-space: nowrap;
    padding: 0 !important;
    border: none !important;
    margin: 0 !important;
    line-height: 1.1;
    text-shadow: 0 0 0.04rem rgba(0,0,0,0.7);
}

.hud-value {
    /* 字号用 JS 动态变量，fallback 从 0.24 提升到 0.28rem：
       如果变量没写入（比如极端情况 load 顺序错），依旧一眼可见 */
    font-size: var(--hud-value-size, 0.28rem);
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.005rem;
    line-height: 1.1;       /* 1.05 → 1.1，桃心不被上下切到 */
    min-height: 1.1em;      /* 最低高度锁死：不让 narrow 屏给我缩成点 */
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    max-width: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* HUD 生命图标（❤）再肥一点：4 颗生命塞下不难看
   — 注意：.hud-block.lives 的 flex-basis 和 min-width 已在上方统一定义 */
.hud-block.lives .hud-value {
    letter-spacing: 0.01rem;   /* 桃心之间留一点点缝，不挤成一团黑 */
    font-size: var(--hud-lives-size, 0.22rem);
    color: #ff8fa8;
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    text-shadow:
        0 0 0.10rem rgba(255, 0, 80, 0.65),
        0 0 0.02rem rgba(0,0,0,0.7);
}
.hud-block.score .hud-value {
    color: #ffd87a;
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    text-shadow:
        0 0 0.10rem rgba(255, 170, 0, 0.65),
        0 0 0.02rem rgba(0,0,0,0.7);
}
.hud-block.best .hud-value {
    color: #9bd8ff;
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    text-shadow:
        0 0 0.10rem rgba(0, 170, 255, 0.65),
        0 0 0.02rem rgba(0,0,0,0.7);
}

/* ---------- 关卡/连击条（★ 本次也同步精修：和 HUD 同色背景条，视觉一体 ★） ---------- */
.combo-bar {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.06rem calc(0.20rem + env(safe-area-inset-left, 0px)) 0.06rem calc(0.20rem + env(safe-area-inset-right, 0px));
    left: auto;
    top: auto;
    transform: none;
    flex-shrink: 0;
    flex-grow: 0;
    order: 0;
    gap: 0.06rem;
    background: linear-gradient(180deg, transparent 0%, rgba(255, 0, 128, 0.06) 100%);
    border-bottom: 1px solid rgba(0, 180, 255, 0.12);
    transform: translateZ(0);
}

/* 思考倒计时条 */
.idle-bar-wrap {
    position: relative;
    z-index: 10;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
    flex-shrink: 0;
}
.idle-bar {
    height: 100%;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: linear-gradient(90deg, #00ff88 0%, #aaff00 60%, #ffaa00 85%, #ff3333 100%);
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.4);
    will-change: transform;
    transition: none;
}
.idle-bar.danger {
    box-shadow: 0 0 6px rgba(255, 51, 51, 0.7);
    animation: idlePulse 0.5s ease-in-out infinite alternate;
}
@keyframes idlePulse {
    from { opacity: 0.7; }
    to   { opacity: 1; }
}

.level-tag {
    display: inline-block;
    padding: 0.06rem 0.18rem;
    background: linear-gradient(135deg, #00d4ff 0%, #0066ff 100%);
    color: #fff;
    font-size: 0.22rem;
    font-weight: 900;
    border-radius: 0.08rem;
    letter-spacing: 0.03rem;
    box-shadow: 0 0 0.2rem rgba(0, 180, 255, 0.5);
}

.diff-tag {
    padding: 0.06rem 0.2rem;
    border-radius: 0.08rem;
    font-size: 0.22rem;
    font-weight: 900;
    letter-spacing: 0.03rem;
    color: #fff;
}
.diff-tag.easy   { background: linear-gradient(135deg, #00e676 0%, #008f39 100%); box-shadow: 0 0 0.2rem rgba(0, 230, 120, 0.55); }
.diff-tag.normal { background: linear-gradient(135deg, #ff9900 0%, #cc3300 100%); box-shadow: 0 0 0.2rem rgba(255, 120, 0, 0.6); }
.diff-tag.hard   { background: linear-gradient(135deg, #ff1744 0%, #550000 100%); box-shadow: 0 0 0.25rem rgba(255, 30, 70, 0.75); }

.combo-tag {
    padding: 0.06rem 0.18rem;
    background: linear-gradient(135deg, #ff0077 0%, #ff7b00 100%);
    color: #fff;
    font-size: 0.24rem;
    font-weight: 900;
    border-radius: 0.08rem;
    letter-spacing: 0.02rem;
    box-shadow:
        0 0 0.25rem rgba(255, 60, 140, 0.8),
        inset 0 0 0.1rem rgba(255, 255, 255, 0.25);
    animation: comboPulse 0.35s ease-out;
}

@keyframes comboPulse {
    0%   { transform: scale(1.6); opacity: 0; }
    40%  { transform: scale(0.92); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* ---------- 棋盘区域 ---------- */
.board-wrap {
    position: relative;
    z-index: 5;
    flex: 1 1 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.08rem 0.08rem;
    min-height: 0;
    overflow: hidden;
}

.board {
    position: relative;
    width: 100%;
    max-width: 7.4rem;
    height: 7.4rem;
    max-height: calc(100vh - 3.2rem);
    max-height: calc(100dvh - 3.2rem);
    background:
        linear-gradient(135deg, rgba(40, 0, 80, 0.85) 0%, rgba(0, 0, 30, 0.9) 100%);
    border: 2px solid rgba(255, 0, 128, 0.35);
    border-radius: 0.2rem;
    box-shadow:
        0 0 0.35rem rgba(255, 0, 128, 0.45),
        inset 0 0 0.4rem rgba(0, 180, 255, 0.2);
    padding: 0.08rem;
    box-sizing: border-box;
    overflow: hidden;
}

/* 8x8 网格用 CSS 变量做视觉参考（JS 实际 absolute 定位） */
.board[data-size="8"]::after {
    content: "";
    position: absolute;
    /* 不用 inset 简写，Chrome<87 不支持 */
    top: 0.08rem; right: 0.08rem; bottom: 0.08rem; left: 0.08rem;
    background-image:
        linear-gradient(to right, rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: calc(100% / 8) calc(100% / 8);
    pointer-events: none;
    z-index: 0;
}

/* ---------- 方块 ---------- */
.tile {
    position: absolute;
    box-sizing: border-box;
    padding: 8%;
    border-radius: 0.12rem;
    cursor: pointer;
    transition:
        transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.18s ease,
        box-shadow 0.2s ease;
    transform-origin: center center;
    will-change: transform, opacity;
    z-index: 1;
    /* 拖动动画（消消乐最常用的"按下去凹下去"效果）：
       Android 触摸 + iOS 触摸都能识别的 active 状态，
       做触觉+视觉反馈，比单纯"选中边框"更有爽感 */
    transition-property: transform, opacity, box-shadow, filter;
}
.tile:active {
    transform: scale(0.90);
    filter: brightness(1.3);
}

.tile::before {
    /* 内圈光（不用 inset 简写，Chrome<87 不支持）*/
    content: "";
    position: absolute;
    top: 10%; right: 10%; bottom: 10%; left: 10%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
}

.tile::after {
    /* 中心符号（硬核元素）
       — 不用 inset:0，老 WebView(Chrome<87) 不支持
       — 符号不在左上角的根因就是这个！
       — 必须手写 top/right/bottom/left:0 让符号铺满整个 tile 再居中 */
    content: attr(data-sym);
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.38rem;
    font-size: var(--tile-font-size, 0.38rem);
    line-height: 1;
    filter: drop-shadow(0 0.03rem 0.05rem rgba(0,0,0,0.6));
    pointer-events: none;
    /* ★ 强制 emoji 使用彩色表情字体，小米/老 Android fallback 成「小黑方块」就靠这个救 */
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
                 "Segoe UI Symbol", "Android Emoji",
                 -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 方块主题色 - 霓虹工业感 */
.tile.t-0 { /* 🔩 螺丝 - 青 */
    background: linear-gradient(145deg, #00ffd5 0%, #0094ff 100%);
    box-shadow: 0 0 0.12rem rgba(0, 255, 213, 0.7), inset 0 0 0.06rem rgba(255,255,255,0.3);
}
.tile.t-1 { /* ⚙️ 齿轮 - 橙 */
    background: linear-gradient(145deg, #ffcc00 0%, #ff4400 100%);
    box-shadow: 0 0 0.12rem rgba(255, 140, 0, 0.7), inset 0 0 0.06rem rgba(255,255,255,0.3);
}
.tile.t-2 { /* 🔫 枪 - 红 */
    background: linear-gradient(145deg, #ff4d6d 0%, #c3002f 100%);
    box-shadow: 0 0 0.12rem rgba(255, 40, 80, 0.75), inset 0 0 0.06rem rgba(255,255,255,0.3);
}
.tile.t-3 { /* 🧨 炸药 - 黄 */
    background: linear-gradient(145deg, #fff176 0%, #f5a623 100%);
    box-shadow: 0 0 0.12rem rgba(255, 220, 0, 0.7), inset 0 0 0.06rem rgba(255,255,255,0.3);
}
.tile.t-4 { /* 💣 炸弹 - 紫 */
    background: linear-gradient(145deg, #cc66ff 0%, #5500aa 100%);
    box-shadow: 0 0 0.12rem rgba(180, 60, 255, 0.75), inset 0 0 0.06rem rgba(255,255,255,0.3);
}
.tile.t-5 { /* 🔩 深绿 */
    background: linear-gradient(145deg, #9cff4d 0%, #008f39 100%);
    box-shadow: 0 0 0.12rem rgba(80, 220, 40, 0.7), inset 0 0 0.06rem rgba(255,255,255,0.3);
}
.tile.t-6 { /* 蓝钢 */
    background: linear-gradient(145deg, #82b1ff 0%, #1a237e 100%);
    box-shadow: 0 0 0.12rem rgba(80, 140, 255, 0.7), inset 0 0 0.06rem rgba(255,255,255,0.3);
}

/* 被选中态 */
.tile.selected {
    transform: scale(1.12);
    z-index: 2;
    animation: selectedGlow 0.8s ease-in-out infinite alternate;
}

@keyframes selectedGlow {
    from {
        box-shadow:
            0 0 0.18rem rgba(255, 255, 255, 0.95),
            0 0 0.35rem rgba(255, 255, 255, 0.7);
    }
    to {
        box-shadow:
            0 0 0.25rem rgba(255, 255, 255, 1),
            0 0 0.5rem rgba(0, 200, 255, 0.9);
    }
}

/* 消除动画 - 更夸张的爆裂 */
.tile.removing {
    animation: tileExplode 0.46s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
    z-index: 4;
}

@keyframes tileExplode {
    0% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
    18% {
        transform: scale(1.15) rotate(-2deg);
    }
    40% {
        transform: scale(2.1) rotate(6deg);
        filter: brightness(4) saturate(1.6);
    }
    65% {
        transform: scale(1.3) rotate(-3deg);
        filter: brightness(7);
    }
    100% {
        transform: scale(0.02) rotate(15deg);
        opacity: 0;
        filter: brightness(10);
    }
}

/* 下落动画（由 JS 加 translateY） */
.tile.dropping {
    transition: transform 0.32s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

/* 交换失败抖动 */
.tile.swap-fail {
    animation: shakeBack 0.35s ease-in-out;
}

@keyframes shakeBack {
    0%, 100% { transform: translate(0, 0); }
    25%      { transform: translate(-8%, 0) rotate(-4deg); }
    75%      { transform: translate(8%, 0) rotate(4deg); }
}

/* ---------- 粒子层 ---------- */
.particle-layer {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;   /* 不用 inset:0 兼容 Chrome<87 */
    pointer-events: none;
    overflow: visible;
    z-index: 20;
}

.particle {
    position: absolute;
    width: 0.32rem;
    height: 0.32rem;
    border-radius: 50%;
    will-change: transform, opacity;
    animation: none;
    color: #fff;
    box-shadow: 0 0 0.2rem currentColor, 0 0 0.5rem currentColor;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}
.particle.fx-active {
    visibility: visible;
    animation: particleFly 1.1s cubic-bezier(0.12, 0.85, 0.28, 1) forwards;
}

@keyframes particleFly {
    0% {
        transform: translate(-50%, -50%) scale(0.4);
        opacity: 0;
    }
    8% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 1;
    }
    35% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0.05) rotate(720deg);
        opacity: 0;
    }
}

/* 冲击波环（每次爆炸中心再放一个） */
.shockwave {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    border: 0.08rem solid #fff;
    will-change: transform, opacity;
    animation: none;
    z-index: 22;
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
    visibility: hidden;
}
.shockwave.fx-active {
    visibility: visible;
    animation: shockwaveGrow 0.72s cubic-bezier(0.18, 0.88, 0.3, 1) forwards;
}

@keyframes shockwaveGrow {
    0% {
        transform: translate(-50%, -50%) scale(0.15);
        opacity: 1;
    }
    55% {
        opacity: 0.75;
    }
    100% {
        transform: translate(-50%, -50%) scale(5.2);
        opacity: 0;
    }
}

/* 得分蹦字 - 更夸张 */
.score-pop {
    position: absolute;
    pointer-events: none;
    font-size: 0.65rem;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 0 0.2rem #ff0077,
        0 0 0.35rem #ffaa00,
        0 0.02rem 0.05rem #000;
    animation: none;
    z-index: 30;
    font-family: "Impact", "Segoe UI Black", sans-serif;
    white-space: nowrap;
    letter-spacing: 0.02em;
    -webkit-text-stroke: 0.015rem #000;
    opacity: 0;
    visibility: hidden;
}
.score-pop.fx-active {
    visibility: visible;
    animation: scorePop 1s cubic-bezier(0.2, 0.7, 0.25, 1) forwards;
}

@keyframes scorePop {
    0%   { transform: translate(-50%, 0.1rem) scale(0.3); opacity: 0; }
    20%  { transform: translate(-50%, -0.05rem) scale(1.5); opacity: 1; }
    45%  { transform: translate(-50%, -0.35rem) scale(1.1); }
    100% { transform: translate(-50%, -1.5rem) scale(0.95); opacity: 0; }
}

/* 全屏白光闪一下 - 更猛 */
.board-wrap.flash::after {
    content: "";
    position: absolute;
    /* 不用 inset 简写，Chrome<87 不支持 */
    top: -0.3rem; right: -0.3rem; bottom: -0.3rem; left: -0.3rem;
    background: radial-gradient(circle at center, #ffffff 0%, #ffe7f1 45%, transparent 100%);
    border-radius: 0.32rem;
    pointer-events: none;
    animation: flashOut 0.6s ease-out forwards;
    z-index: 25;
}

.board-wrap.flash-hype::after {
    content: "";
    position: absolute;
    top: -0.4rem; right: -0.4rem; bottom: -0.4rem; left: -0.4rem;
    background:
        radial-gradient(circle at 50% 50%, #ffffff 0%, #ffef5e 22%, #ff2e86 48%, #3dc9ff 75%, transparent 100%);
    border-radius: 0.36rem;
    pointer-events: none;
    animation: flashHype 0.72s ease-out forwards;
    z-index: 25;
}

@keyframes flashOut {
    0%   { opacity: 0; }
    10%  { opacity: 0.95; }
    100% { opacity: 0; }
}

@keyframes flashHype {
    0%   { opacity: 0; transform: scale(1); }
    12%  { opacity: 1; }
    55%  { opacity: 0.7; }
    100% { opacity: 0; transform: scale(1.04); }
}

/* ---------- 屏幕震动 - 加大力度 ---------- */
.game-root.shake-1 { animation: shake1 0.22s linear; }
.game-root.shake-2 { animation: shake2 0.32s linear; }
.game-root.shake-3 { animation: shake3 0.52s linear; }

@keyframes shake1 {
    0%,100% { transform: translate(0,0); }
    25%     { transform: translate(-0.14rem, 0.1rem); }
    75%     { transform: translate(0.14rem, -0.1rem); }
}
@keyframes shake2 {
    0%,100% { transform: translate(0,0) rotate(0); }
    18%     { transform: translate(-0.26rem, 0.16rem) rotate(-1.2deg); }
    36%     { transform: translate(0.3rem, -0.14rem) rotate(1.2deg); }
    54%     { transform: translate(-0.22rem, 0.2rem) rotate(-0.8deg); }
    72%     { transform: translate(0.22rem, -0.18rem) rotate(0.8deg); }
    90%     { transform: translate(-0.1rem, 0.08rem); }
}
@keyframes shake3 {
    0%,100% { transform: translate(0,0) scale(1); }
    12%     { transform: translate(-0.4rem, 0.26rem) rotate(-2deg) scale(1.01); }
    25%     { transform: translate(0.45rem, -0.3rem) rotate(2.2deg); }
    38%     { transform: translate(-0.4rem, 0.35rem) rotate(-1.8deg); }
    50%     { transform: translate(0.4rem, -0.3rem) rotate(1.6deg); }
    62%     { transform: translate(-0.3rem, 0.24rem) rotate(-1.2deg); }
    75%     { transform: translate(0.28rem, -0.2rem) rotate(1deg); }
    88%     { transform: translate(-0.14rem, 0.12rem) scale(1.005); }
}

/* ---------- 道具栏（★ 修复「按钮又瘦又长」爆炸高度 ★） ---------- */
.powerup-bar {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;   /* 原 space-around → center：3 个按钮并排居中，不乱飘 */
    align-items: stretch;        /* 所有按钮一样高 */
    padding: 0.14rem 0.22rem calc(0.26rem + env(safe-area-inset-bottom, 0px));
    padding-left:  calc(0.22rem + env(safe-area-inset-left, 0px));
    padding-right: calc(0.22rem + env(safe-area-inset-right, 0px));
    border-top: 1px solid rgba(0, 180, 255, 0.12);
    background: linear-gradient(0deg, rgba(0, 60, 120, 0.30) 0%, transparent 100%);
    /* 道具间距从 0.22 → 0.18rem（三个按钮并排，太紧误触 / 太松显少，0.18 折中） */
    gap: 0.18rem;
    flex-shrink: 0;
}

/* ★ 根因修复：彻底抛弃「padding-top 90.9% 伪比例」手法！
   那方法的百分比基准是父容器宽度，不是按钮自身宽度，
   在 flex: 1 1 0 配合下直接把按钮高度撑成 "道具栏宽 × 90%"，
   就是截图里那种又瘦又长 2 倍高的灾难。
   — 改用显式 rem 固定尺寸（最稳定的老办法）*/
.powerup-btn {
    position: relative;
    display: block;
    flex: 1 1 0;
    min-width:  1.50rem;
    max-width:  2.40rem;
    min-height: 1.60rem;
    height: 1.78rem;
    max-height: 2.00rem;
    padding: 0;
    background: linear-gradient(160deg, rgba(60, 0, 100, 0.92) 0%, rgba(0, 20, 60, 0.92) 100%);
    border: 1.5px solid rgba(0, 200, 255, 0.4);
    border-radius: 0.18rem;
    box-shadow:
        0 0 0.22rem rgba(0, 180, 255, 0.28),
        0 0.06rem 0.12rem rgba(0,0,0,0.55),
        inset 0 0 0.16rem rgba(0, 150, 255, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}
.powerup-btn::before {
    content: "";
    position: absolute;
    /* 触控热区外扩（不用 inset 简写，Chrome<87 不支持）*/
    top: -0.08rem; right: -0.08rem; bottom: -0.08rem; left: -0.08rem;
    z-index: -1;
}

.powerup-btn:active {
    transform: scale(0.94);
}

.powerup-btn.active {
    border-color: #ff0077;
    box-shadow:
        0 0 0.3rem rgba(255, 0, 120, 0.8),
        inset 0 0 0.2rem rgba(255, 0, 120, 0.4);
    animation: toolPulse 1s ease-in-out infinite alternate;
}

@keyframes toolPulse {
    from { box-shadow: 0 0 0.25rem rgba(255, 0, 120, 0.6), inset 0 0 0.15rem rgba(255, 0, 120, 0.3); }
    to   { box-shadow: 0 0 0.5rem rgba(255, 0, 120, 1), inset 0 0 0.25rem rgba(255, 0, 120, 0.55); }
}

.powerup-btn.disabled {
    opacity: 0.4;
    filter: grayscale(0.7);
    pointer-events: none;
}

/* 现在 .powerup-btn 用 padding-top 撑开高宽比 1.1:1，
   子元素（icon/label）绝对定位铺在内部 — 不再依赖 flex + aspect-ratio */
.powerup-icon {
    position: absolute;
    left: 50%;
    top: 44%;      /* 43% → 44%：按钮高度变矮了，图标再沉一点到视觉中心 */
    transform: translate(-50%, -50%);
    font-size: 0.50rem;
    line-height: 1;
    filter:
        drop-shadow(0 0 0.14rem rgba(255, 255, 255, 0.45))
        drop-shadow(0 0.04rem 0.05rem rgba(0,0,0,0.55));
    pointer-events: none;
}

.powerup-count {
    position: absolute;
    top: 0.06rem;
    right: 0.08rem;
    min-width: 0.36rem;     /* 0.34 → 0.36，胖一圈好读 */
    height: 0.36rem;
    padding: 0 0.08rem;
    background: linear-gradient(135deg, #ff0077 0%, #ff5500 100%);
    color: #fff;
    font-size: 0.20rem;
    font-weight: 900;
    border-radius: 0.18rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow:
        0 0 0.12rem rgba(255, 0, 120, 0.8),
        0 0.04rem 0.08rem rgba(0,0,0,0.5);
    z-index: 2;
}

.powerup-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.08rem;   /* 0.06 → 0.08，离底多一点缝不挤 */
    text-align: center;
    font-size: 0.20rem; /* 0.18 → 0.20，字大好读 */
    letter-spacing: 0.02rem;
    color: #dce8f5;
    font-weight: 700;
    text-shadow: 0 0.02rem 0.06rem rgba(0,0,0,0.7);
}

/* ---------- 通用浮层 ---------- */
.overlay {
    position: fixed;
    left: 0; top: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    z-index: 99999;
    background:
        radial-gradient(circle at center, rgba(120, 0, 60, 0.75) 0%, rgba(0, 0, 0, 0.98) 72%);
    display: none;
    justify-content: center;
    align-items: center;
    padding: 0.24rem;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* 强制独立合成层，防止被棋盘/粒子穿透 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform, opacity;
}
.overlay.active {
    display: flex;
}

/* 游戏内容隐藏类：overlay 显示时给 #app 加这个
   仅用 opacity + pointer-events：visibility 是离散属性会跳过过渡动画 */
.app-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.15s ease !important;
}
.app-hidden * {
    pointer-events: none !important;
}

.overlay-panel {
    position: relative;
    width: 100%;
    max-width: 6.2rem;
    max-height: 92%;
    max-height: calc(100dvh - 0.48rem);
    padding: 0.48rem 0.38rem;
    background: linear-gradient(160deg, #1a0030 0%, #000014 100%);
    border: 2px solid rgba(255, 0, 128, 0.45);
    border-radius: 0.2rem;
    box-shadow:
        0 0 0.5rem rgba(255, 0, 128, 0.5),
        0 0 1rem rgba(0, 180, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.26rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 关键：所有 stage 默认 none，JS 加类 active-stage 才显示 — 防止小米 webview 把 style.display:none 忽略 */
.overlay-stage {
    display: none !important;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    animation: panelIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.overlay-stage.active-stage {
    display: flex !important;
}

@keyframes panelIn {
    from { transform: scale(0.85) translateY(0.2rem); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* ---- 开始页品牌区（新标题 + 图标） ---- */
.brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.24rem;
    padding: 0.08rem 0 0.04rem;
}
.brand-icon {
    width: 1.0rem;
    height: 1.0rem;
    flex: 0 0 1.0rem;
    filter: drop-shadow(0 0 0.22rem rgba(255, 46, 134, 0.55));
}
.brand-text { display: flex; flex-direction: column; align-items: flex-start; gap: 0.06rem; }
.brand-text .title-main {
    text-align: left;
    letter-spacing: 0.03rem;
    font-size: 0.54rem;
}
.brand-text .title-sub {
    margin: 0;
    font-size: 0.18rem;
    letter-spacing: 0.18rem;
    color: #ff9ac5;
    text-shadow: 0 0 0.1rem rgba(255, 0, 120, 0.4);
}

/* ---- 工作室签名：难度选择之下、开始按钮之上 ---- */
.studio-line {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    margin: -0.04rem 0 0.02rem;
    padding: 0.02rem 0 0.08rem;
}
.studio-line-bar {
    flex: 0 0 0.4rem;
    height: 0.02rem;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 0, 120, 0.6) 100%);
    border-radius: 0.02rem;
}
.studio-line-bar + .studio-name ~ .studio-line-bar {
    background: linear-gradient(90deg, rgba(61, 201, 255, 0.6) 0%, transparent 100%);
}
.studio-name {
    font-size: 0.2rem;
    letter-spacing: 0.12rem;
    color: #c8c8d8;
    font-weight: 700;
    text-shadow: 0 0 0.08rem rgba(255, 255, 255, 0.15);
}

.version-tag {
    font-size: 0.18rem;
    color: #666;
    letter-spacing: 0.04rem;
    margin: 0;
    padding: 0;
}

.title-main {
    font-size: 0.9rem;
    font-weight: 900;
    line-height: 1;
    font-family: "Impact", "Arial Black", sans-serif;
    letter-spacing: 0.06rem;
    background: linear-gradient(180deg, #ffffff 0%, #ff0077 55%, #ff6600 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 0.25rem rgba(255, 0, 120, 0.9));
    text-align: center;
}

.gameover-stage .title-main {
    font-size: 0.7rem;
    background: linear-gradient(180deg, #ffffff 0%, #ff3030 45%, #550000 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.title-sub {
    font-size: 0.26rem;
    color: #a0a0b0;
    letter-spacing: 0.18rem;
    margin-top: -0.1rem;
    text-align: center;
}

/* ---- 难度选择器 ---- */
.diff-picker {
    width: 100%;
    display: flex;
    gap: 0.12rem;
    margin: 0.1rem 0 0.15rem;
}

.diff-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.06rem;
    padding: 0.18rem 0.08rem;
    background: rgba(20, 0, 40, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.14rem;
    transition: all 0.18s ease;
}
.diff-btn:active { transform: scale(0.96); }

.diff-btn .diff-title {
    font-size: 0.26rem;
    font-weight: 900;
    color: #e0e0ee;
    letter-spacing: 0.02rem;
}
.diff-btn .diff-desc {
    font-size: 0.17rem;
    color: #8080a0;
    letter-spacing: 0.01rem;
    text-align: center;
}

.diff-btn[data-diff="easy"].active {
    border-color: #00e676;
    background: rgba(0, 100, 50, 0.5);
    box-shadow: 0 0 0.25rem rgba(0, 230, 120, 0.6), inset 0 0 0.12rem rgba(0, 230, 120, 0.25);
}
.diff-btn[data-diff="easy"].active .diff-title { color: #a5ffd0; text-shadow: 0 0 0.15rem rgba(0, 230, 120, 0.7); }

.diff-btn[data-diff="normal"].active {
    border-color: #ff9900;
    background: rgba(120, 60, 0, 0.5);
    box-shadow: 0 0 0.25rem rgba(255, 150, 0, 0.6), inset 0 0 0.12rem rgba(255, 150, 0, 0.25);
}
.diff-btn[data-diff="normal"].active .diff-title { color: #ffd080; text-shadow: 0 0 0.15rem rgba(255, 150, 0, 0.7); }

.diff-btn[data-diff="hard"].active {
    border-color: #ff1744;
    background: rgba(120, 0, 20, 0.5);
    box-shadow: 0 0 0.3rem rgba(255, 30, 70, 0.75), inset 0 0 0.12rem rgba(255, 30, 70, 0.3);
}
.diff-btn[data-diff="hard"].active .diff-title { color: #ff8599; text-shadow: 0 0 0.15rem rgba(255, 30, 70, 0.8); }


/* =============================================================
   横屏自适应（宽度 > 高度时）：三栏布局，左 HUD+combo / 中棋盘 / 右道具
   兼容 99% 机型：iPad mini / 折叠屏展开 / 普通手机横屏
   ============================================================= */
@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
    .game-root {
        flex-direction: row;
        padding:
            env(safe-area-inset-top, 0px)
            env(safe-area-inset-right, 0px)
            env(safe-area-inset-bottom, 0px)
            env(safe-area-inset-left, 0px);
        gap: 0.08rem;
    }

    /* 左栏：HUD + combo bar 变成竖排叠起来 */
    .hud-bar {
        position: static;
        top: auto;
        flex: 0 0 1.1rem;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        padding: 0.16rem 0.08rem;
        gap: 0.16rem;
        writing-mode: horizontal-tb;
        order: 1;
    }
    .hud-block {
        flex-direction: column-reverse;
        align-items: center;
        justify-content: center;
        min-width: 0;
        padding: 0.1rem 0.06rem;
        margin: 0;
    }
    .hud-block .hud-label {
        padding-left: 0;
        margin-top: 0.04rem;
        margin-bottom: 0;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.15);
        padding-top: 0.04rem;
        font-size: 0.13rem;
    }
    .hud-block .hud-value {
        font-size: 0.30rem;
        line-height: 1;
    }
    .hud-exit {
        width: 100%;
        text-align: center;
        padding: 0.12rem 0;
    }

    /* 棋盘占据中间，按高度限制 + 两侧留白 */
    .combo-bar {
        order: 1;
        position: absolute;
        left: 0.2rem;
        top: 50%;
        transform: translateY(-50%);
        flex-direction: column;
        gap: 0.16rem;
        padding: 0;
        pointer-events: none;
    }
    .combo-bar .level-tag, .combo-bar .diff-tag, .combo-bar .combo-tag {
        pointer-events: auto;
    }

    .board-wrap {
        order: 2;
        padding: 0.12rem 0.1rem;
        width: auto;
    }
    .board {
        /* 横屏 @media 中的 .board 也不要用 min()（Chrome<79 不支持），
           给个 max-width/max-height 上限，JS resizeBoard() 会写精确像素 */
        max-width: 80vh;
        max-width: 80vmin;
        max-width: calc(var(--app-width, 100vw) - 3.2rem);
        max-height: calc(var(--app-height, 100vh) - 0.36rem);
        height: auto;
        width: 100%;
    }

    /* 道具条：竖排靠右 */
    .powerup-bar {
        order: 3;
        position: static;
        flex: 0 0 1.3rem;
        bottom: auto;
        left: auto;
        right: 0;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0.18rem;
        padding: 0.12rem 0.06rem;
    }
    .powerup-btn {
        width: 100%;
        height: auto;
        padding: 0.14rem 0.06rem;
        flex-direction: column;
    }
    .powerup-btn .powerup-icon {
        font-size: 0.36rem;
        margin: 0 0 0.04rem;
    }
    .powerup-btn .powerup-label {
        font-size: 0.15rem;
    }
}

/* 短屏（如 4.7 寸 iPhone SE / 老安卓）：字号微调，不要溢出 */
@media (max-height: 620px) and (orientation: portrait) {
    .hud-block .hud-label { font-size: 0.12rem; }
    .hud-block .hud-value { font-size: 0.24rem; }
    .level-tag, .diff-tag { font-size: 0.20rem; padding: 0.05rem 0.16rem; }
    .combo-tag { font-size: 0.22rem; }
    .powerup-btn { height: 1.50rem; min-height: 1.40rem; }
    .powerup-icon { font-size: 0.42rem; }
    .board-wrap { padding: 0.04rem 0.06rem; }
}

/* 长屏（全面屏 / 19.5:9 / 20:9）：棋盘和道具栏利用多余垂直空间 */
@media (min-height: 780px) and (orientation: portrait) {
    .board { max-width: 7.6rem; }
    .powerup-btn { height: 2.00rem; max-height: 2.20rem; }
    .powerup-icon { font-size: 0.54rem; }
    .powerup-label { font-size: 0.22rem; }
}

/* 超窄屏（折叠屏折叠态）：HUD 取消 block 最小宽度，按比例压缩到底 */
@media (max-width: 340px) {
    .hud-block { padding: 0.06rem 0.06rem; }
    .hud-block .hud-value { font-size: 0.22rem; }
    .hud-block .hud-label { font-size: 0.12rem; margin-left: 0; border-left: none; padding-left: 0; margin-top: 0.02rem; }
    .hud-block { flex-direction: column-reverse; align-items: center; justify-content: center; }
}

/* 平板 / 大尺寸桌面端预览（> 800px）：给 .game-root 最大宽度，居中显示，不要变形拉满整个宽屏 */
@media (min-width: 820px) and (orientation: landscape) {
    .game-root {
        max-width: 1200px;
        margin: 0 auto;
    }
}
@media (min-width: 520px) and (orientation: portrait) {
    .game-root {
        max-width: 520px;
        margin: 0 auto;
        border-left: 1px solid rgba(255,0,128,0.2);
        border-right: 1px solid rgba(255,0,128,0.2);
    }
}


.final-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.12rem;
    font-size: 0.26rem;
    color: #c0c0d0;
    padding: 0.15rem 0.4rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0.12rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.final-stats span {
    font-weight: 900;
    color: #ffb300;
    margin-left: 0.1rem;
}

/* 主按钮 */
.btn-primary {
    width: 100%;
    padding: 0.22rem 0.3rem;
    background: linear-gradient(135deg, #ff0077 0%, #ff5500 100%);
    color: #fff;
    font-size: 0.3rem;
    font-weight: 900;
    letter-spacing: 0.08rem;
    border-radius: 0.12rem;
    box-shadow:
        0 0 0.28rem rgba(255, 0, 120, 0.75),
        inset 0 0 0.12rem rgba(255, 255, 255, 0.25);
    transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-primary:active {
    transform: scale(0.97);
    filter: brightness(1.1);
}

.btn-xl {
    padding: 0.28rem 0.4rem;
    font-size: 0.34rem;
}

/* 幽灵按钮（广告等） */
.btn-ghost {
    width: 100%;
    padding: 0.2rem 0.3rem;
    background: rgba(0, 0, 0, 0.4);
    color: #80d0ff;
    font-size: 0.26rem;
    font-weight: 700;
    border: 1.5px solid rgba(0, 180, 255, 0.45);
    border-radius: 0.12rem;
    transition: all 0.15s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.1rem;
}
.btn-ghost:active {
    background: rgba(0, 180, 255, 0.15);
    transform: scale(0.98);
}

.ad-icon {
    font-size: 0.3rem;
}

.tip-line {
    margin-top: 0.1rem;
    font-size: 0.2rem;
    color: #606070;
    letter-spacing: 0.05rem;
}
