/* ===== 基础样式：重置 / 画布 / HUD / 提示 ===== */

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            user-select: none;
        }
        body {
            background: #0a0a0a;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            overflow: hidden;
            font-family: Arial, sans-serif;
        }
        canvas {
            display: block;
            background: #1a1a2e;
            cursor: crosshair;
            border: 2px solid #2a2a4a;
            box-shadow: 0 0 40px rgba(0, 100, 255, 0.15);
            width: 100vw;
            height: 100vh;
            outline: none;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 0;
            pointer-events: none;
        }
        canvas.canvas-active {
            pointer-events: auto !important;
        }
        #ui {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 10;
        }
        #hud {
            position: absolute;
            top: 16px;
            left: 16px;
            right: 16px;
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            pointer-events: none;
            color: #fff;
            font-size: 14px;
            text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
        }
        /* ===== Kenney 面板底座：与弹窗统一（panel_blue 9-slice 边框） ===== */
        #hud-left,
        #hud-right {
            border: 10px solid transparent;
            border-image: url('../assets/ui/panel_blue.png') 12 stretch;
            border-radius: 0;
            background: linear-gradient(168deg, rgba(14, 18, 40, 0.86), rgba(7, 9, 24, 0.90));
            box-shadow: 0 4px 0 rgba(4, 6, 14, 0.55), 0 12px 30px rgba(0, 0, 0, 0.42);
            pointer-events: auto;
        }
        #hud-left {
            width: 252px;
            padding: 10px 12px 12px;
            max-height: calc(100vh - 48px);
            overflow-y: auto;
            overflow-x: hidden;
        }
        #hud-right {
            padding: 10px 14px 12px;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 8px;
            min-width: 190px;
        }
        /* ===== 头部玩家名 ===== */
        .hud-head {
            display: flex;
            align-items: center;
            gap: 7px;
            padding-bottom: 7px;
            margin-bottom: 8px;
            border-bottom: 1px solid rgba(150, 175, 240, 0.18);
        }
        .hud-userdot {
            width: 9px;
            height: 9px;
            border-radius: 50%;
            background: #6ee87a;
            box-shadow: 0 0 6px rgba(110, 232, 122, 0.8);
            flex: none;
        }
        .hud-name {
            font-weight: bold;
            font-size: 14px;
            color: #cfe0ff;
            letter-spacing: 0.5px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        /* ===== 状态条行：图标 + 条 + 数值 ===== */
        .bar-row {
            display: flex;
            align-items: center;
            gap: 7px;
            margin-bottom: 7px;
        }
        .bar-ico {
            flex: none;
            width: 18px;
            font-size: 13px;
            text-align: center;
            filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6));
        }
        .bar-frame {
            position: relative;
            flex: 1;
            height: 15px;
            border-radius: 7px;
            background: rgba(0, 0, 0, 0.55);
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.65), 0 0 0 1.5px rgba(170, 195, 255, 0.22), 0 1px 0 rgba(255, 255, 255, 0.06);
            overflow: hidden;
        }
        .bar-frame > div {
            height: 100%;
            width: 100%;
            border-radius: 7px;
            transition: width .18s ease;
        }
        /* 顶部高光线（贴在填充层上方的玻璃质感） */
        .bar-frame::before {
            content: '';
            position: absolute;
            inset: 0 0 auto 0;
            height: 45%;
            border-radius: 7px 7px 0 0;
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02));
            pointer-events: none;
            z-index: 2;
        }
        /* 分段刻度 */
        .bar-ticks {
            position: absolute;
            inset: 0;
            z-index: 3;
            pointer-events: none;
            background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 1px), rgba(5, 8, 18, 0.55) calc(20% - 1px) 20%);
        }
        .hp-fill {
            background: linear-gradient(90deg, #44dd44, #88ff44);
            box-shadow: 0 0 8px rgba(110, 255, 110, 0.4);
        }
        .shield-fill {
            width: 0%;
            background: linear-gradient(90deg, #22bbee, #77eeff);
            box-shadow: 0 0 8px rgba(68, 221, 255, 0.45);
        }
        .stealth-fill {
            width: 0%;
            background: linear-gradient(90deg, #8844ff, #bb88ff);
            box-shadow: 0 0 8px rgba(170, 136, 255, 0.45);
        }
        .exp-fill {
            width: 0%;
            background: linear-gradient(90deg, #48c848, #a2f0a2);
            box-shadow: 0 0 6px rgba(120, 240, 120, 0.35);
        }
        .bar-val {
            flex: none;
            min-width: 38px;
            text-align: right;
            font-size: 12px;
            font-weight: bold;
            font-variant-numeric: tabular-nums;
        }
        .hp-num { color: #ff7a8c; }
        .shield-num { color: #7fe4ff; }
        .stealth-num { color: #c3a6ff; }
        .exp-num { color: #9fe89f; font-weight: normal; font-size: 11px; }
        /* ===== 徽章 chips ===== */
        .chip-row {
            display: flex;
            flex-wrap: wrap;
            gap: 5px;
            margin-bottom: 7px;
        }
        .chip {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 2.5px 9px;
            font-size: 12px;
            border-radius: 20px;
            background: rgba(10, 14, 32, 0.72);
            border: 1.5px solid rgba(140, 165, 235, 0.28);
            box-shadow: 0 2px 0 rgba(4, 6, 14, 0.6);
            white-space: nowrap;
        }
        .chip b {
            font-variant-numeric: tabular-nums;
            font-size: 13px;
        }
        .chip-lvl { border-color: rgba(255, 200, 80, 0.5); color: #ffd98a; }
        .chip-lvl b { color: #ffcc44; }
        .chip-enemy { border-color: rgba(255, 120, 100, 0.45); }
        .chip-enemy b { color: #ff8866; }
        .chip-diff b { color: #ff6644; }
        .chip-crit b { color: #ff9999; }
        .chip-coin { border-color: rgba(255, 215, 90, 0.5); }
        .chip-coin b { color: #ffdd44; }
        .chip-soul { border-color: rgba(180, 140, 255, 0.5); }
        .chip-soul b { color: #bfa2ff; }
        .chip-wave { border-color: rgba(120, 200, 255, 0.5); color: #a8d8ff; }
        .chip-wave b { color: #7fd0ff; font-size: 15px; }
        .chip-weapon { border-color: rgba(255, 180, 90, 0.5); color: #ffcf9a; }
        /* ===== 右侧面板 ===== */
        .score-big {
            font-size: 26px;
            font-weight: 900;
            color: #ffcc44;
            text-align: center;
            text-shadow: 0 2px 0 rgba(80, 40, 0, 0.75), 0 0 22px rgba(255, 200, 60, 0.3);
            font-variant-numeric: tabular-nums;
            letter-spacing: 1px;
        }
        .right-chip-row {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }
        .right-chip-row .chip {
            justify-content: space-between;
            padding: 4px 12px;
        }
        .right-btns {
            display: flex;
            flex-direction: column;
            gap: 5px;
            margin-top: 2px;
        }
        /* ===== 次要信息行 ===== */
        .hud-minor {
            font-size: 11.5px;
            line-height: 1.55;
            border-top: 1px solid rgba(150, 175, 240, 0.14);
            padding-top: 6px;
        }
        .minor-line {
            color: #9fb2d8;
            min-height: 15px;
        }
        .stealth-line {
            color: #b599ff;
            font-weight: bold;
            animation: stealthPulse 0.6s ease-in-out infinite alternate;
        }
        .event-text {
            font-size: 13px;
            color: #ff4444;
            font-weight: bold;
            animation: eventPulse 0.8s ease-in-out infinite alternate;
        }
        @keyframes eventPulse {
            0% { text-shadow: 0 0 6px rgba(255,40,40,0.35); }
            100% { text-shadow: 0 0 16px rgba(255,40,40,0.9); }
        }
        @keyframes stealthPulse {
            0% { opacity: 0.6; text-shadow: 0 0 8px rgba(170, 136, 255, 0.3); }
            100% { opacity: 1; text-shadow: 0 0 25px rgba(170, 136, 255, 0.7); }
        }
        .controls-hint {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            color: rgba(255, 255, 255, 0.25);
            font-size: 13px;
            background: rgba(0, 0, 0, 0.4);
            padding: 8px 20px;
            border-radius: 20px;
            backdrop-filter: blur(4px);
            border: 1px solid rgba(255, 255, 255, 0.05);
            white-space: nowrap;
            pointer-events: auto;
        }
        .controls-hint kbd {
            background: rgba(255, 255, 255, 0.1);
            padding: 2px 10px;
            border-radius: 4px;
            margin: 0 3px;
            font-size: 12px;
            border: 1px solid rgba(255, 255, 255, 0.08);
        }
        .pause-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: clamp(48px, 8vw, 100px);
            color: #ffdd44;
            text-shadow: 0 0 60px rgba(255, 200, 0, 0.3);
            z-index: 30;
            pointer-events: none;
            display: none;
        }
        .settings-btn {
            pointer-events: auto;
            /* Kenney UI Pack（CC0）灰色按钮贴图 */
            background: url('../assets/ui/btn_grey.png') center / 100% 100% no-repeat;
            border: none;
            color: #3a4258;
            font-weight: bold;
            padding: 7px 14px;
            font-size: 13px;
            cursor: pointer;
            transition: filter .15s ease, transform .15s ease;
            text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
        }
        .settings-btn:hover {
            filter: brightness(1.12);
            transform: translateY(-1px);
        }
        .settings-btn:active {
            transform: translateY(1px);
            filter: brightness(0.92);
        }
        /* 退出按钮：红调提示 */
        .settings-btn.exit-btn {
            color: #7a2430;
            filter: drop-shadow(0 0 4px rgba(255, 80, 80, 0.25));
        }
        /* ===== 隐藏界面模式（H 键 / 🙈 按钮）：藏 HUD 与按键提示，保留右上微型恢复钮 ===== */
        body.ui-hidden #hud,
        body.ui-hidden .controls-hint {
            display: none !important;
        }
        #uiMiniBtn {
            display: none;
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 40;
            width: 34px;
            height: 34px;
            font-size: 15px;
            line-height: 1;
            cursor: pointer;
            pointer-events: auto;
            opacity: 0.28;
            border: 1px solid rgba(255, 255, 255, 0.14);
            border-radius: 8px;
            background: rgba(10, 14, 30, 0.45);
            color: rgba(255, 255, 255, 0.75);
            transition: opacity .18s ease;
        }
        #uiMiniBtn:hover {
            opacity: 0.85;
        }
        body.ui-hidden #uiMiniBtn {
            display: block;
        }

        /* 深色主题滚动条（HUD/排行/弹窗内滚动区） */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        ::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.04);
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.18);
            border-radius: 4px;
        }
        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }

        /* ===== 装备栏 / 技能栏图标槽（v6：Tiny Dungeon 像素图标） ===== */
        .icon-row {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 6px;
            min-height: 36px;
        }
        .icon-slot {
            position: relative;
            width: 36px;
            height: 36px;
            flex: none;
            border-radius: 9px;
            background: linear-gradient(180deg, rgba(44,58,110,0.92), rgba(18,24,48,0.95));
            border: 1px solid rgba(120,160,255,0.38);
            box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 2px 6px rgba(0,0,0,0.45);
        }
        .icon-slot .ico {
            position: absolute;
            inset: 3px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            image-rendering: pixelated;
        }
        .icon-slot.empty {
            border-style: dashed;
            border-color: rgba(120,140,190,0.28);
            background: rgba(20,26,48,0.5);
            box-shadow: none;
        }
        .icon-slot.ready { border-color: rgba(120,255,190,0.55); }
        .icon-slot.active {
            border-color: #ffd76a;
            box-shadow: 0 0 10px rgba(255,200,80,0.6), inset 0 1px 0 rgba(255,255,255,0.15);
        }
        .icon-slot .lv {
            position: absolute;
            right: -4px;
            bottom: -4px;
            z-index: 3;
            font-size: 9px;
            font-weight: 700;
            line-height: 13px;
            padding: 0 4px;
            color: #ffe27a;
            background: #3a2a08;
            border: 1px solid #a67c1a;
            border-radius: 7px;
        }
        .icon-slot .cd {
            position: absolute;
            left: 0; right: 0; bottom: 0;
            z-index: 1;
            height: 0%;
            background: rgba(5,8,18,0.78);
            border-radius: 0 0 8px 8px;
        }
        .icon-slot .cdt {
            position: absolute;
            inset: 0;
            z-index: 2;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            font-weight: 700;
            color: #9fdcff;
            text-shadow: 0 1px 2px #000;
        }
        .icon-hint {
            font-size: 11px;
            color: rgba(160,180,220,0.55);
        }
        /* 升级面板技能选项小图标 */
        .opt-ico {
            display: inline-block;
            width: 26px;
            height: 26px;
            margin-right: 8px;
            vertical-align: -7px;
            border-radius: 7px;
            border: 1px solid rgba(120,160,255,0.4);
            background-color: rgba(24,30,58,0.9);
            background-size: 72% !important;
            background-repeat: no-repeat !important;
            background-position: center !important;
            image-rendering: pixelated;
        }

        /* ===== 玩法扩展 HUD：连击显示 + 大招按钮 ===== */
        .combo-display {
            margin-top: 8px;
            font-size: 16px;
            font-weight: 900;
            color: #ffb347;
            text-shadow: 0 2px 0 rgba(60,20,0,0.8), 0 0 14px rgba(255,150,40,0.35);
            letter-spacing: 1px;
            user-select: none;
        }
        .combo-display b { color: #ffe066; font-size: 20px; }
        .combo-display .combo-mult { color: #ff8844; font-size: 13px; font-weight: 700; }

        #superBtn {
            position: relative;
            display: block;
            margin-top: 10px;
            width: 150px;
            height: 36px;
            border-radius: 10px;
            border: 2px solid rgba(150,170,230,0.35);
            background: rgba(14,18,40,0.85);
            color: #aab4d8;
            font-size: 13px;
            font-weight: 800;
            letter-spacing: 1px;
            cursor: pointer;
            overflow: hidden;
            transition: border-color .15s ease, box-shadow .15s ease, color .15s ease;
            user-select: none;
        }
        #superBtn .super-fill {
            position: absolute;
            left: 0; top: 0; bottom: 0;
            width: 0%;
            background: linear-gradient(90deg, rgba(90,80,255,0.35), rgba(255,200,40,0.45));
            transition: width .18s ease;
            pointer-events: none;
        }
        #superBtn .super-label {
            position: relative;
            z-index: 1;
        }
        #superBtn.ready {
            border-color: rgba(255,215,60,0.9);
            color: #ffe9a0;
            box-shadow: 0 0 16px rgba(255,200,40,0.4);
            animation: superReady 1.1s ease-in-out infinite;
        }
        @keyframes superReady {
            0%, 100% { box-shadow: 0 0 10px rgba(255,200,40,0.28); }
            50% { box-shadow: 0 0 22px rgba(255,210,60,0.55); }
        }
        #superBtn:hover { filter: brightness(1.15); }

        /* ===== 嵌入场景：失焦提示（点击外部页面后键盘让位时显示） ===== */
        #focusHint {
            position: fixed;
            top: 14px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 12000;
            padding: 10px 26px;
            border-radius: 999px;
            background: linear-gradient(160deg, rgba(24,30,58,0.94), rgba(12,16,36,0.94));
            border: 1px solid rgba(150,180,255,0.45);
            box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 0 18px rgba(120,170,255,0.25);
            color: #dce6ff;
            font-size: 14px;
            font-weight: 700;
            letter-spacing: 1px;
            pointer-events: none;
            user-select: none;
            animation: focusHintFloat 1.6s ease-in-out infinite;
        }
        @keyframes focusHintFloat {
            0%, 100% { transform: translateX(-50%) translateY(0); }
            50% { transform: translateX(-50%) translateY(-4px); }
        }
