/* =========================================================================
   靈承錄 · 驚蟄堂 - 移动端专属适配 (layout_mobile.css) v0.54H_DeployReady
   ========================================================================= */

/* 彻底清除 iOS 点击时的半透明/红色高亮与长按选中底色 */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* 强行锁死小人图片与法坛容器背景为透明 */
.game-stage-frame,
.villain-wrapper,
#villain-img,
#face-overlay {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-touch-callout: none !important;
    background-color: transparent !important;
}

@media screen and (max-width: 768px) {
    /* 0. 移动端强行拦截字体，全盘退回手机原生繁体黑体 */
    :root {
        --font-lisu: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Segoe UI", Roboto, sans-serif !important;
        --font-kaiti: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Heiti TC", "Kaiti SC", serif !important;
        --font-sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", "Heiti TC", sans-serif !important;
        --font-tc-sans: var(--font-lisu) !important;
    }

    /* ================= 商城專屬手機端適配 ================= */
    .product-grid { 
        grid-template-columns: 1fr !important;
        gap: 25px !important;
        padding: 0 5px !important;
    }
    
    .mall-nav { 
        justify-content: center !important; 
        flex-wrap: wrap !important; 
        gap: 10px !important;
        padding: 12px 10px !important;
    }

    .mall-nav-btn {
        width: 48% !important;
        text-align: center !important;
        padding: 10px 0 !important;
    }

    /* ================= 强制重置法坛布局与小人/鞋子尺寸 ================= */
    .game-stage-frame {
        position: relative !important;
        justify-content: center !important;
        align-items: center !important;
        min-height: 400px !important;
        width: 100% !important;
    }
    
    .villain-wrapper {
        position: relative !important;
        width: 210px !important;
        height: 275px !important;
        margin: 0 auto !important;
        transform: rotateX(12deg) rotateZ(-2deg) translateY(-20px);
    }
    
    .weapon-wrapper {
        position: absolute !important;
        bottom: 5%;
        right: -10px; 
        width: 180px !important;
    }
    
    /* 1. 全局与页头缩放 */
    .container { padding: 0 0.8rem; }
    header { padding: 1rem 0 0.5rem; margin-bottom: 1rem; }
    .brand-intro-box { padding: 12px; font-size: 0.85rem; line-height: 1.5; }
    .ritual-section { margin-bottom: 2.5rem; }
    .section-header { 
        font-size: 1.3rem !important; 
        margin-bottom: 12px !important; 
        gap: 8px !important;
    }
    .section-header::before, .section-header::after { width: 30px !important; }

    .version-tag { 
        top: 38px !important; 
        right: 10px !important; 
        font-size: 0.75rem !important; 
        padding: 2px 8px !important; 
    }
    .bgm-toggle-btn { top: 10px; right: 10px; padding: 3px 10px; font-size: 0.8rem; }

    /* 2. 文化卡片 */
    .culture-grid { grid-template-columns: 1fr; gap: 15px; margin-bottom: 2.5rem; }
    .card-image-container { height: 200px; }
    .services-section { grid-template-columns: 1fr; gap: 20px; }

    /* 3. 游戏主舞台与第一步/第四步弹窗适配 */
    .ritual-interface { 
        height: min(640px, 76vh) !important; 
        border-width: 2px !important;
        position: relative !important;
    }
    .wizard-overlay {
        z-index: 100 !important;
        pointer-events: auto !important;
    }
    
    .wizard-card { 
        padding: 15px 12px 25px !important; 
        width: 96% !important; 
    }
    
    #wizard-step-4 {
        max-height: 85vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .wizard-card .wizard-title { 
        font-size: 1.3rem !important; 
        margin-top: 50px !important;
    }

    .wizard-options { gap: 6px; }
    .wizard-btn { 
        padding: 10px 4px; 
        font-size: 0.85rem; 
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }
    .gender-icon-wrapper { width: 68px; height: 68px; }
    .transparent-input { width: 95%; font-size: 1rem; }
    .striker-options-grid { grid-template-columns: 1fr; gap: 10px; }
    .striker-card-btn { padding: 12px 10px; }
    .striker-name { font-size: 1.2rem; }

    .wizard-action-btn { 
        margin-top: 10px !important;
        margin-bottom: 20px !important; 
        position: relative !important;
        top: 0px !important; 
    }

    #wizard-step-4 .wizard-action-btn {
        top: -15px !important; 
    }

    /* 4. 祭白虎版面修正 */
    .tiger-hint-title { 
        font-size: 1.5rem !important; 
        margin-top: 40px !important; 
    }
    .tiger-hint-sub {
        font-size: 0.9rem !important;
        padding: 0 20px !important;
        text-align: center !important;
    }
    .tiger-container { width: 250px !important; height: 250px !important; }
    .pork-item { width: 130px !important; height: 130px !important; margin-bottom: 20px !important; }

    .active-tiger-bg .hud-text-right,
    .active-tiger-bg .combo-num,
    .active-tiger-bg .combo-label {
        display: none !important;
    }

    /* 5. 化寶環節 */
    .huabao-stage-overlay {
        display: none; 
        position: absolute !important;
        top: 0 !important; left: 0 !important;
        width: 100% !important; height: 100% !important;
        z-index: 80 !important;
        padding: 10px !important;
        box-sizing: border-box !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    .game-column.active-huabao-bg {
        background-position: center bottom !important;
        background-size: contain !important;
    }

    .huabao-stage-overlay .tiger-hint-title {
        font-size: 1.3rem !important;
        margin-top: 25px !important;
        margin-bottom: 2px !important;
        text-align: center !important;
    }
    .huabao-stage-overlay .tiger-hint-sub {
        font-size: 0.8rem !important;
        margin-bottom: 10px !important;
        text-align: center !important;
    }

    .huabao-side-dock.dock-left,
    .huabao-side-dock.dock-right {
        display: flex !important; 
        position: relative !important;
        top: auto !important; left: auto !important; right: auto !important; bottom: auto !important;
        transform: none !important;
        flex-direction: row !important;
        width: 95% !important;
        justify-content: space-around !important;
        padding: 6px 8px !important;
        background: rgba(20, 10, 30, 0.88) !important;
        border: 1px solid var(--ancient-copper) !important;
        border-radius: 12px !important;
        z-index: 90 !important;
        margin-bottom: 6px !important;
    }

    .huabao-paper-btn { width: 42px !important; height: 42px !important; }
    .huabao-paper-btn.btn-tiger { width: 50px !important; height: 50px !important; }
    .huabao-item-label { font-size: 0.8rem !important; margin-top: 4px !important; }

    .huabao-incense-pot-area {
        position: absolute !important;
        bottom: 48px !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        height: 60px !important;
        width: 140px !important;
    }

    .active-huabao-bg .hud-text-right {
        display: none !important;
    }

    /* 6. 擲杯舞台 */
    .poe-drop-zone { 
        gap: 30px !important; 
        margin-top: 130px !important;
    }
    .poe-block-wrapper { width: 100px; height: 130px; }
    .poe-giant-banner { font-size: 1.6rem; padding: 12px 20px; width: 90vw; white-space: normal; line-height: 1.4; }
    .poe-status-title { font-size: 1.4rem; }

    /* 7. HUD 与弹幕 */
    .hud-text-left { font-size: 1rem; top: 10px; left: 10px; }
    .hud-text-right { font-size: 1rem; top: 10px; right: 10px; }
    .combo-num { font-size: 1.3rem; }
    .danmu-item { font-size: 1.5rem; }
    .crit-text {
        font-size: 2.8rem !important;
        white-space: nowrap !important;
        letter-spacing: 2px !important;
    }
    .center-pop-hint {
        font-size: 1rem !important;
        padding: 10px 18px !important;
        width: 85% !important;
        border-radius: 20px !important;
        line-height: 1.4 !important;
    }
    
    /* 8. 结算弹窗 */
    .victory-overlay { 
        padding: 15px; 
        z-index: 100000 !important;
        pointer-events: auto !important;
    }
    
    .victory-title { 
        font-size: 1.8rem !important; 
        margin-bottom: 10px !important; 
        white-space: nowrap !important; 
    }

    .victory-dialog { width: 95%; padding: 20px 15px; font-size: 1.1rem; }
    .restart-btn, .wizard-action-btn {
        position: relative !important;
        z-index: 100001 !important;
        pointer-events: auto !important;
        touch-action: manipulation !important;
    }

    /* 9. 商業生態矩陣 */
    .business-matrix-section {
        width: 100% !important;
        margin-bottom: 3rem !important;
    }
    .matrix-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    .matrix-card {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    .matrix-media {
        width: 100% !important;
        aspect-ratio: 16 / 9 !important;
        height: auto !important;
    }

    /* 10. 移動端五色米粒子渲染與層級強化 */
    .rice-particle {
        position: absolute !important;
        display: block !important;
        z-index: 999999 !important;
        pointer-events: none !important;
        will-change: transform, opacity;
        animation: riceBurstMobile 0.5s cubic-bezier(0.15, 0.85, 0.35, 1.2) forwards;
    }

    @keyframes riceBurstMobile {
        0% {
            opacity: 1;
            transform: translate(0, 0) scale(1);
        }
        100% {
            opacity: 0;
            transform: translate(var(--dx, 0px), var(--dy, 50px)) rotate(360deg) scale(0.4);
        }
    }

    /* ================= 修复 iOS 下小人白底/红线露底问题 ================= */
   /* 老旧 iOS 物理绝杀白块：完全禁用不稳定的 multiply 混合模式 */
.ios-device #villain-img {
    mix-blend-mode: normal !important;
    -webkit-filter: none !important;
    filter: none !important;
    background: transparent !important;
}

    /* 严禁给小人加 translateZ(0)，防止 iOS 混合模式失效变成白色实心块 */
    .ios-device .villain-wrapper,
    .ios-device #villain-img {
        -webkit-transform: none !important;
        transform: none !important;
        will-change: auto !important;
    }
}