        :root {
            --bg-main: #0a0a0a;
            --bg-panel: #141414;
            --border-color: #262626;
            --text-main: #d8d8d8;
            --text-muted: #5d5d5d;
            --color-gold: #f1c40f;
            --color-accent: #e74c3c;
            --color-success: #2ecc71;
            --color-blue: #3498db;
            --color-purple: #9b59b6;
            --color-orange: #e67e22;
            --color-honghuang: #ff3366;
        }

        /* —— 客户端化：禁止选中文字 / iOS 长按复制·放大镜浮层 / 图片拖拽 / 点按灰色高亮。输入框豁免，保证起名可编辑粘贴 —— */
        html, body { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
        input, textarea, [contenteditable] { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; -webkit-touch-callout: default; }
        img, svg, .sprite-vector { -webkit-user-drag: none; user-select: none; }

        body { background-color: var(--bg-main); color: var(--text-main); font-family: "PingFang SC", "Microsoft YaHei", sans-serif; margin: 0; padding: 15px; display: flex; justify-content: center; }
        #game-window { width: 100%; max-width: 1200px; box-sizing: border-box; background: var(--bg-panel); border: 2px solid #222; box-shadow: 0 20px 50px rgba(0,0,0,0.9); border-radius: 8px; overflow: hidden; position: relative; }
        
        #create-role-overlay { position: absolute; top:0; left:0; width:100%; height:100%; background: rgba(10,10,10,0.98); z-index: 999; display: flex; flex-direction: column; justify-content: center; align-items: center; }
        .create-box { background: #1a1a1a; padding: 40px; border: 2px solid var(--color-gold); border-radius: 8px; text-align: center; box-shadow: 0 0 20px rgba(241,196,15,0.2); }
        .create-input { background: #000; border: 1px solid var(--border-color); color: #fff; padding: 10px 15px; font-size: 16px; border-radius: 4px; width: 220px; text-align: center; margin-bottom: 20px; }
        .create-input:focus { border-color: var(--color-gold); outline: none; }

        #story-overlay { display: none; position: absolute; top:0; left:0; width:100%; height:100%; background: rgba(5,5,5,0.98); z-index: 998; flex-direction: column; justify-content: center; align-items: center; padding: 40px; box-sizing: border-box; }
        #story-text { color: var(--color-gold); font-size: 20px; line-height: 2.2; letter-spacing: 3px; max-width: 800px; text-align: center; margin-bottom: 40px; text-shadow: 0 0 15px rgba(241,196,15,0.4); min-height: 250px; font-family: "KaiTi", "楷体", serif; }

        .game-header { background: #0b0b0b; padding: 15px 20px; border-bottom: 2px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; position: relative; }
        .header-title { font-size: 26px; color: var(--color-gold); font-weight: bold; letter-spacing: 3px; text-shadow: 0 0 5px rgba(241,196,15,0.3); }
        .currency-bar { display: flex; gap: 25px; font-size: 14px; }

        /* —— 左侧分组菜单（桌面常驻；移动端见 ≤768 媒体查询改为汉堡抽屉）—— */
        #game-body { display: flex; align-items: stretch; }
        .menu-toggle { display: none; background: none; border: none; color: var(--color-gold); font-size: 24px; line-height: 1; cursor: pointer; padding: 0; }

        .nav-sidebar { flex-shrink: 0; width: 190px; background: #080808; border-right: 1px solid var(--border-color); padding: 14px 0; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
        .menu-group { padding: 2px 0; }
        .menu-group + .menu-group { border-top: 1px solid #141414; }
        .menu-group-title { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; color: var(--text-muted); font-size: 12px; font-weight: bold; letter-spacing: 1px; cursor: pointer; user-select: none; transition: color 0.15s; }
        .menu-group-title::after { content: '▾'; font-size: 10px; opacity: 0.55; }
        .menu-group.collapsed .menu-group-title::after { content: '▸'; }
        .menu-group-title:hover { color: var(--text-main); }
        .menu-group.collapsed .menu-items { display: none; }
        .menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 16px; background: none; border: none; border-left: 3px solid transparent; color: var(--text-muted); font-size: 14px; font-weight: bold; cursor: pointer; text-align: left; transition: all 0.15s; }
        .menu-item:hover { color: var(--text-main); background: #111; }
        .menu-item.active { color: var(--color-gold); background: rgba(241,196,15,0.08); border-left-color: var(--color-gold); }
        .menu-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }

        #menu-overlay { display: none; }

        .game-content { padding: 20px; min-height: 600px; flex: 1; min-width: 0; }
        .page { display: none; grid-template-columns: 1fr 1fr; gap: 20px; }
        .page.active { display: grid; }

        .sub-panel { background: #181818; border: 1px solid var(--border-color); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; }
        .panel-title { font-size: 16px; color: var(--color-gold); border-bottom: 1px solid var(--border-color); padding-bottom: 8px; margin-top: 0; margin-bottom: 15px; font-weight: bold; display: flex; justify-content: space-between; align-items: center; }

        .btn { background: #2c1a0c; color: #fff; border: 1px solid #4a2e16; padding: 8px 16px; cursor: pointer; border-radius: 4px; font-size: 13px; transition: all 0.1s; font-weight: bold; }
        .btn:hover { background: #4a2e16; border-color: var(--color-gold); }
        .btn:disabled { background: #1b1b1b !important; border-color: #2c2c2c !important; color: #444 !important; cursor: not-allowed; text-shadow: none; }
        .btn-danger { background: #5c1d1d; border-color: #7c2b2b; }
        .btn-danger:hover { background: #7c2b2b; }
        .btn-success { background: #1e4620; border-color: #2d6630; }
        .btn-success:hover { background: #2d6630; }

        .smelt-console { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; background: #101010; padding: 12px; border-radius: 5px; border: 1px solid #1a1a1a; }
        .btn-smelt { padding: 6px 12px; font-size: 12px; border: 1px solid #333; border-radius: 4px; cursor: pointer; font-weight: bold; color: #fff; transition: all 0.15s; }
        .smelt-low { background: #2c3e50; border-color: #34495e; }
        .smelt-low:hover { background: #34495e; border-color: #3498db; }
        .smelt-q2 { background: #1b3a4b; border-color: #2874a6; color: #3498db; }
        .smelt-q2:hover { background: #2874a6; color: #fff; }
        .smelt-q3 { background: #2e1a47; border-color: #6c3483; color: #9b59b6; }
        .smelt-q3:hover { background: #6c3483; color: #fff; }
        .smelt-q4 { background: #4a2711; border-color: #b9770e; color: #e67e22; }
        .smelt-q4:hover { background: #b9770e; color: #fff; }
        .smelt-all { background: #7b241c; border-color: #b03a2e; color: #f5b041; text-shadow: 0 1px 2px #000; }
        .smelt-all:hover { background: #b03a2e; border-color: var(--color-accent); }

        .scroll-box { flex: 1; max-height: 460px; overflow-y: auto; padding-right: 5px; }
        
        .grid-container { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
        .item-slot { aspect-ratio: 1; background: #0f0f0f; border: 1px solid #222; border-radius: 4px; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 11px; cursor: pointer; position: relative; padding: 4px; text-align: center; overflow: hidden; transition: border-color 0.15s; }
        .item-slot:hover { border-color: var(--color-gold); background: #161616; }
        
        .q-0 { color: #7f8c8d; } 
        .q-1 { color: #2ecc71; } 
        .q-2 { color: #3498db; font-weight: 500; } 
        .q-3 { color: #9b59b6; font-weight: bold; } 
        .q-4 { color: #e67e22; font-weight: bold; text-shadow: 0 0 3px rgba(230,126,34,0.4); } 
        .q-5 { color: #e74c3c; font-weight: bold; text-shadow: 0 0 6px rgba(231,76,60,0.7); } 
        .q-hh { color: var(--color-honghuang); font-weight: bold; text-shadow: 0 0 8px rgba(255,51,102,0.6); }
        .forge-glow { box-shadow: 0 0 15px rgba(230,126,34,0.5); border-color: var(--color-orange) !important; }

        /* —— 拖拽融合 —— */
        .drag-ghost { position: fixed; left: 0; top: 0; width: 54px; height: 54px; transform: translate(-50%, -50%); pointer-events: none; z-index: 10000; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; font-size: 11px; padding: 4px; box-sizing: border-box; overflow: hidden; background: #161616; border: 2px solid var(--color-gold); border-radius: 4px; box-shadow: 0 10px 24px rgba(0,0,0,0.7); opacity: 0.95; }
        .item-slot.drag-source { opacity: 0.3; }
        .drop-target { border-color: var(--color-success) !important; box-shadow: 0 0 16px rgba(46,204,113,0.75) !important; background: #14211a !important; }
        #bag-grid.drop-target { background: none !important; box-shadow: none !important; outline: 2px dashed var(--color-success); outline-offset: 3px; border-radius: 4px; }
        body.dragging-active, body.dragging-active * { cursor: grabbing !important; }

        .list-card { background: #111; border: 1px solid #222; padding: 12px; margin-bottom: 10px; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; }
        .skill-btns { display: flex; gap: 6px; flex-shrink: 0; }
        .prop-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; background: #111; padding: 6px 10px; border-radius: 4px; border: 1px solid #1a1a1a; position: relative; }

        /* —— 生产技能页（采矿 / 锻造）：经验条 + 动作卡 + 读条动画 + 物料仓库 —— */
        .prof-bar-wrap { height: 8px; background: #0a0a0a; border: 1px solid #222; border-radius: 4px; overflow: hidden; margin: 4px 0; }
        .prof-bar-inner { height: 100%; width: 0; background: linear-gradient(90deg, #1e4620, #2ecc71); transition: width 0.3s ease; }
        .prof-exp-text { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
        .act-card { background: #111; border: 1px solid #222; border-radius: 5px; padding: 10px 12px; margin-bottom: 8px; transition: border-color 0.15s; }
        .act-card.locked { opacity: 0.45; }
        .act-card.running { border-color: var(--color-success); box-shadow: 0 0 10px rgba(46,204,113,0.25); }
        .act-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
        .act-title { font-weight: bold; color: var(--text-main); font-size: 14px; }
        .act-meta { font-size: 11px; color: var(--text-muted); margin-top: 5px; line-height: 1.5; }
        .act-progress { height: 5px; background: #0a0a0a; border-radius: 3px; overflow: hidden; margin-top: 8px; display: none; }
        .act-card.running .act-progress { display: block; }
        .act-progress > i { display: block; height: 100%; width: 0; background: var(--color-success); animation-name: idleFill; animation-timing-function: linear; animation-iteration-count: infinite; }
        @keyframes idleFill { from { width: 0; } to { width: 100%; } }
        .wh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
        .wh-item { background: #0f0f0f; border: 1px solid #222; border-radius: 4px; padding: 8px 4px; text-align: center; font-size: 12px; color: var(--text-main); }
        .wh-item .wh-ico { font-size: 22px; line-height: 1.3; }
        .wh-item .wh-qty { color: var(--color-gold); font-weight: bold; }
        .wh-item .wh-sell { display: block; margin-top: 6px; padding: 3px 4px; font-size: 10px; width: 100%; box-sizing: border-box; }
        .wh-empty { color: var(--text-muted); text-align: center; padding: 24px 10px; font-size: 13px; }

        /* 打造图谱：档位标签页（卡片复用 .act-card） */
        .craft-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
        .craft-tab { padding: 6px 12px; background: #111; border: 1px solid #2c2c2c; border-radius: 4px; color: var(--text-muted); font-size: 13px; font-weight: bold; cursor: pointer; transition: all 0.15s; }
        .craft-tab:hover:not(:disabled) { border-color: var(--color-gold); color: var(--text-main); }
        .craft-tab.active { background: rgba(241,196,15,0.12); border-color: var(--color-gold); color: var(--color-gold); }
        .craft-tab:disabled { opacity: 0.4; cursor: not-allowed; }

        #battle-view-container { display: flex; flex-direction: column; gap: 10px; height: 500px; }
        #battle-canvas-wrapper { width: 100%; height: 200px; background: linear-gradient(180deg, #090c10 0%, #11161d 100%); border: 1px solid #2c3e50; border-radius: 6px; position: relative; overflow: hidden; box-shadow: inset 0 0 30px rgba(0,0,0,0.9); }
        
        .actor-sprite { position: absolute; bottom: 10px; width: 110px; height: 140px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; transition: all 0.15s ease-out; }
        #sprite-player { left: 60px; }
        #sprite-enemy { right: 60px; }
        
        .sprite-vector { width: 100px; height: 120px; position: relative; z-index: 2; }
        .sprite-name-plate { font-size: 11px; color: #fff; background: rgba(15,15,15,0.9); padding: 2px 8px; border-radius: 10px; border: 1px solid #444; text-align: center; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.5); z-index: 5; margin-top: 5px; width: 80px; }
        #sprite-player .sprite-name-plate { border-color: var(--color-blue); }
        #sprite-enemy .sprite-name-plate { border-color: var(--color-accent); }
        
        .actor-hp-bar-wrapper { width: 100%; height: 4px; background: #222; border-radius: 2px; margin-top: 3px; overflow: hidden; }
        .actor-hp-bar-inner { width: 100%; height: 100%; background: var(--color-accent); transition: width 0.1s ease; }
        #sprite-player .actor-hp-bar-inner { background: var(--color-success); }

        .battle-ground { position: absolute; bottom: 0; left: 0; width: 100%; height: 15px; background: linear-gradient(180deg, #1c2833, #0f171e); border-top: 1px solid #2c3e50; }
        .combat-effect-text { position: absolute; font-weight: bold; font-family: 'Impact', 'Arial Black', sans-serif; font-size: 22px; pointer-events: none; animation: effectFloatUp 0.6s forwards ease-out; z-index: 10; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
        @keyframes effectFloatUp { 0% { transform: translateY(0) scale(0.5); opacity: 0; } 20% { transform: translateY(-20px) scale(1.3); opacity: 1; } 100% { transform: translateY(-60px) scale(0.9); opacity: 0; } }

        .idle-breath { animation: breathe 1.8s infinite ease-in-out; }
        @keyframes breathe { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px) scaleY(1.02); } }
        
        .strike-dash-right { transform: translateX(260px) scale(1.1) !important; z-index: 8; }
        .strike-dash-left { transform: translateX(-260px) scale(1.1) !important; z-index: 8; }
        
        .hurt-shake { animation: shake 0.2s linear; }
        @keyframes shake { 0%, 100% { margin-left: 0; filter: brightness(2) sepia(0.5); } 25% { margin-left: -10px; } 50% { margin-left: 10px; } 75% { margin-left: -5px; } }

        #battle-log { flex: 1; background: #0a0a0a; border: 1px solid #222; border-radius: 4px; padding: 12px; overflow-y: auto; font-family: 'Consolas', monospace; font-size: 12px; line-height: 1.8; }
        .log-item { margin-bottom: 5px; border-bottom: 1px dashed #151515; padding-bottom: 3px; }

        #global-tooltip { position: fixed; z-index: 9999; display: none; background: rgba(12, 12, 12, 0.98); border: 1px solid var(--color-gold); border-radius: 6px; padding: 14px; box-shadow: 0 15px 35px rgba(0,0,0,0.9); pointer-events: none; font-size: 12px; line-height: 1.5; }
        .tooltip-container { display: flex; gap: 20px; }
        .tooltip-column { width: 220px; position: relative; }
        .equipped-badge { position: absolute; top: -5px; right: 0; background: #2c3e50; color: #3498db; border: 1px solid #3498db; padding: 1px 6px; font-size: 10px; border-radius: 3px; font-weight: bold; letter-spacing: 1px; box-shadow: 0 2px 4px rgba(0,0,0,0.5); }
        .tooltip-title { font-size: 14px; font-weight: bold; border-bottom: 1px dashed #333; padding-bottom: 6px; margin-bottom: 6px; }
        .tooltip-attr { display: flex; justify-content: space-between; color: #aaa; margin-bottom: 4px; }
        .tooltip-desc { color: #888; border-top: 1px dashed #333; padding-top: 6px; margin-top: 6px; font-style: italic; }
        .compare-tag { font-size: 11px; padding: 1px 4px; border-radius: 3px; font-weight: bold; }
        .comp-up { color: #2ecc71; }
        .comp-down { color: #e74c3c; }
        .comp-equal { color: #888; }

        /* —— 江湖秘典（游戏全机制说明，只读静态页）—— */
        .guide-content { font-size: 13px; line-height: 1.75; }
        .guide-content h3 { color: var(--color-gold); font-size: 17px; margin: 26px 0 10px; padding: 6px 0 6px 12px; border-left: 4px solid var(--color-gold); border-bottom: 1px solid var(--border-color); letter-spacing: 1px; scroll-margin-top: 64px; }
        .guide-content h3:first-of-type { margin-top: 4px; }
        .guide-content h4 { color: var(--color-blue); font-size: 14px; margin: 16px 0 6px; }
        .guide-content p { margin: 7px 0; color: #b8b8b8; }
        .guide-content ul { margin: 7px 0; padding-left: 22px; }
        .guide-content li { margin: 5px 0; color: #b8b8b8; }
        .guide-content b, .guide-content strong { color: var(--text-main); }

        .guide-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; position: sticky; top: 0; background: #181818; padding: 10px 4px; z-index: 2; border-bottom: 1px solid var(--border-color); }
        .guide-toc a { background: #111; border: 1px solid #2c2c2c; color: var(--color-gold); padding: 5px 12px; border-radius: 14px; font-size: 12px; cursor: pointer; font-weight: bold; transition: all 0.15s; }
        .guide-toc a:hover { border-color: var(--color-gold); background: #2c1a0c; }

        .guide-formula { background: #0a0a0a; border: 1px solid #222; border-left: 3px solid var(--color-orange); border-radius: 4px; padding: 10px 14px; margin: 10px 0; font-family: 'Consolas', monospace; font-size: 12px; color: #cfd6dd; line-height: 1.7; white-space: pre-wrap; overflow-x: auto; }

        .guide-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 12px; }
        .guide-table th, .guide-table td { border: 1px solid #222; padding: 7px 9px; text-align: left; vertical-align: top; }
        .guide-table th { background: #1c1c1c; color: var(--color-gold); font-weight: bold; white-space: nowrap; }
        .guide-table tr:nth-child(even) td { background: #0e0e0e; }

        .guide-note { background: rgba(241,196,15,0.06); border: 1px solid rgba(241,196,15,0.22); border-radius: 5px; padding: 9px 13px; margin: 12px 0; font-size: 12px; color: #d4c178; line-height: 1.7; }
        .guide-tip { background: rgba(46,204,113,0.06); border: 1px solid rgba(46,204,113,0.22); border-radius: 5px; padding: 9px 13px; margin: 12px 0; font-size: 12px; color: #8fd9ab; line-height: 1.7; }
        .guide-tip b, .guide-note b { color: #fff; }

        /* ============================================================
           响应式适配（移动端 / 平板）。桌面端 (>1024px) 布局完全不变。
           断点：平板 ≤1024，手机 ≤768，小屏手机 ≤400。
           ============================================================ */

        /* —— 平板：略收紧间距、背包格减为 6 列 —— */
        @media (max-width: 1024px) {
            body { padding: 10px; }
            .header-title { font-size: 22px; letter-spacing: 2px; }
            .currency-bar { gap: 16px; }
            .game-content { padding: 14px; min-height: 0; }
            .grid-container { grid-template-columns: repeat(6, 1fr); }
            .page { gap: 14px; }
        }

        /* —— 手机：单列布局、可滑动标签栏、堆叠顶栏、触摸友好尺寸 —— */
        @media (max-width: 768px) {
            body { padding: 0; }
            /* 手机端：窗口固定为一屏高(100dvh，动态视口高自适应地址栏；100vh 回退)，配合 overflow:hidden(基础样式)。
               header/标签栏固定在窗口顶部，滚动交给内部 game-content/scroll-box —— 而非整页(body)滚动。 */
            #game-window { border-radius: 0; border-width: 0; box-shadow: none; height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

            /* 顶栏：标题与货币纵向堆叠，货币可换行。
               min-height + 整条不折行，避免数值变长时顶栏高度跳变带动下方抖动 */
            .game-header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 48px 12px 14px; min-height: 56px; box-sizing: border-box; }
            .header-title { font-size: 19px; letter-spacing: 1px; }
            .currency-bar { gap: 8px 16px; font-size: 12px; flex-wrap: wrap; }
            .currency-bar span { white-space: nowrap; }

            /* 左侧菜单：移动端收为左滑抽屉(off-canvas)，汉堡按钮在顶栏右上角唤出；点项/点遮罩/再点汉堡均收起 */
            .menu-toggle { display: block; position: absolute; top: 12px; right: 14px; z-index: 2; }
            #game-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
            .nav-sidebar { position: fixed; top: 0; left: -100%; width: min(264px, 82vw); height: 100vh; height: 100dvh; z-index: 1000; box-shadow: 2px 0 16px rgba(0,0,0,0.85); transition: left 0.28s ease; }
            .nav-sidebar.open { left: 0; }
            #menu-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 999; }
            #menu-overlay.visible { display: block; }

            /* game-content 吃满窗口剩余高度并成为可滚动容器：
               列表页由内层 scroll-box 滚动(本身不溢出)；命格/征途等内容超高的页则由 game-content 自身滚动。 */
            .game-content { padding: 10px; min-height: 0; flex: 1; display: flex; flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }

            /* 所有分页改单列；抵消 index.html 内联的 grid-column: span 2。
               作者样式表里的 !important 优先级高于普通内联样式，可正常覆盖。 */
            .page.active { grid-template-columns: 1fr; gap: 12px; }
            .page > .sub-panel { grid-column: auto !important; }

            /* 列表页(行囊/秘籍/黑市)：内容区吃满整屏，列表滚动区延伸到屏幕底部，消除窗口底部空白。
               flex 链每级 min-height:0，保证内层 scroll-box 仍能正常滚动（否则 flex item 默认 min-height:auto 会撑破不滚动）。
               命格/征途结构不同(无列表/列表在首面板)，不套此链——其底部留白与现状同色(#141414)，不变差。 */
            #page-bag.active, #page-kungfu.active, #page-shop.active { flex: 1; min-height: 0; display: flex; flex-direction: column; }
            #page-bag.active > .sub-panel:last-child,
            #page-kungfu.active > .sub-panel,
            #page-shop.active > .sub-panel { flex: 1; min-height: 0; }
            #page-bag.active > .sub-panel:last-child .scroll-box,
            #page-kungfu.active .scroll-box,
            #page-shop.active .scroll-box { flex: 1; max-height: none; min-height: 0; }

            .sub-panel { padding: 14px; }
            .panel-title { font-size: 15px; }

            /* 背包格子：每行 5 个，触摸尺寸。格子略压扁(高=宽*0.85)，让滚动区能多显示一整行(目标 4 行)，避免露出半行。
               洪炉槽下方有显式 width/height，不受 aspect-ratio 影响。 */
            .grid-container { grid-template-columns: repeat(5, 1fr); gap: 6px; }
            .grid-container .item-slot { aspect-ratio: 1 / 0.85; }
            .item-slot { font-size: 10px; padding: 2px; }

            /* 洪炉槽与融合按钮：index.html 内联写死 70px，这里覆盖为与背包格/浮影相称的尺寸，避免小屏整行溢出 */
            #forge-slot-0, #forge-slot-1 { width: 58px !important; height: 58px !important; font-size: 11px !important; }
            button[data-act="forge"] { height: 58px !important; padding: 0 16px !important; margin-left: 10px !important; font-size: 14px !important; }

            /* 列表卡片：按钮换行铺满，便于点按 */
            .list-card { flex-wrap: wrap; gap: 8px; padding: 12px 10px; }
            .list-card > button { width: 100%; padding: 10px; }
            .list-card > .skill-btns { width: 100%; }
            .list-card > .skill-btns > .btn { flex: 1; padding: 10px; }

            .scroll-box { max-height: 52vh; }

            /* 熔炼按钮区 */
            .smelt-console { gap: 6px; padding: 10px; }
            .btn-smelt { font-size: 11px; padding: 7px 9px; }
            .btn { padding: 9px 14px; }

            /* 战斗区：缩小画布与立绘，避免双方重叠或冲出屏幕 */
            #battle-view-container { height: auto; gap: 10px; }
            #battle-canvas-wrapper { height: 160px; }
            .actor-sprite { width: 80px; height: 100px; bottom: 8px; }
            .sprite-vector { width: 70px; height: 84px; }
            .sprite-name-plate { width: 70px; font-size: 10px; }
            #sprite-player { left: 16px; }
            #sprite-enemy { right: 16px; }
            .strike-dash-right { transform: translateX(40vw) scale(1.05) !important; }
            .strike-dash-left { transform: translateX(-40vw) scale(1.05) !important; }
            #battle-log { font-size: 11px; max-height: 32vh; }

            /* 江湖秘典：缩排表格/公式，避免窄屏溢出；TOC 收紧 */
            .guide-content { font-size: 12px; }
            .guide-content h3 { font-size: 15px; margin-top: 20px; scroll-margin-top: 56px; }
            .guide-table { font-size: 11px; }
            .guide-table th, .guide-table td { padding: 5px 6px; }
            .guide-formula { font-size: 11px; padding: 9px 10px; }
            .guide-toc { gap: 6px; padding: 8px 2px; }
            .guide-toc a { padding: 4px 9px; font-size: 11px; }

            /* 开场剧情 / 创角弹窗 */
            #story-overlay { padding: 24px; }
            #story-text { font-size: 16px; line-height: 1.9; letter-spacing: 1px; min-height: 0; }
            #btn-enter-game { font-size: 16px !important; padding: 12px 32px !important; }
            .create-box { padding: 26px 20px; width: 88%; box-sizing: border-box; }
            .create-input { width: 100%; box-sizing: border-box; }
        }

        /* —— 小屏手机：进一步压缩 —— */
        @media (max-width: 400px) {
            .header-title { font-size: 17px; }
            .currency-bar { font-size: 11px; gap: 8px 10px; }
            .grid-container { grid-template-columns: repeat(4, 1fr); }
            .menu-item { font-size: 13px; padding: 11px 14px; }
            #sprite-player { left: 8px; }
            #sprite-enemy { right: 8px; }
        }

        /* 对比列宽度收归 class（桌面端保持原 140px），便于窄屏覆盖换行 */
        .tooltip-column.diff-column { width: 140px; border-left: 1px dashed #333; padding-left: 15px; }

        /* —— 触摸设备（无 hover）：浮动提示改为底部信息卡 ——
           按 (hover: none) 触发，与 render.js 的 matchMedia('(hover: none)') 判定一致，
           故平板/横屏(宽>768px)的触摸设备也能正确显示，不受像素断点影响。 */
        @media (hover: none) {
            #global-tooltip {
                left: 0 !important; right: 0; top: auto !important; bottom: 0;
                width: 100%; box-sizing: border-box; max-height: 70vh; overflow-y: auto;
                border-radius: 12px 12px 0 0; border-left: 0; border-right: 0; border-bottom: 0;
                pointer-events: auto; padding: 16px 16px 22px;
            }
            #global-tooltip .tooltip-container { flex-wrap: wrap; gap: 14px; }
            #global-tooltip .tooltip-column { width: auto !important; flex: 1 1 130px; min-width: 118px; padding-left: 0 !important; border-left: 0 !important; }
        }
