        /* Local fonts - avoid network dependency */
        @font-face {
            font-family: 'Cinzel';
            font-style: normal;
            font-weight: 400;
            font-display: swap;
            src: url('fonts/Cinzel-Regular.ttf') format('truetype');
        }

        @font-face {
            font-family: 'Cinzel';
            font-style: normal;
            font-weight: 700;
            font-display: swap;
            src: url('fonts/Cinzel-Bold.ttf') format('truetype');
        }

        @font-face {
            font-family: 'Roboto';
            font-style: normal;
            font-weight: 400;
            font-display: swap;
            src: url('fonts/Roboto-Regular.ttf') format('truetype');
        }

        @font-face {
            font-family: 'Roboto';
            font-style: normal;
            font-weight: 500;
            font-display: swap;
            src: url('fonts/Roboto-Medium.ttf') format('truetype');
        }

        :root {
            --font-ui: 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
            --font-number: 'Roboto', 'Segoe UI', sans-serif;
            --bg-color: #050505;
            --ui-border: #5d4a37;
            --ui-header-bg: #2a2218;
            --ui-panel-bg: rgba(15, 15, 18, 0.98);
            --ui-metal-dark: #090909;
            --ui-metal-mid: #1d1a16;
            --ui-metal-edge: #6f5a37;
            --ui-metal-hi: #b99a55;
            --ui-ember: #8b2f18;
            --text-gold: #c7b377;
            --text-red: #c23b22;
            --text-blue: #4d69cd;
            --item-unique: #908858;
            --item-rare: #ffff00;
            --item-magic: #4850b8;
            --item-normal: #ffffff;
            --ui-glow: rgba(199, 179, 119, 0.3);
        }

        body {
            margin: 0;
            overflow: hidden;
            background-color: var(--bg-color);
            color: #ccc;
            font-family: var(--font-ui);
            user-select: none;
            -webkit-user-select: none;
        }

        #game-container {
            position: relative;
            width: 100vw;
            height: 100vh;
            background: #000;
        }

        canvas {
            display: block;
            image-rendering: auto;
        }

        /* In high quality mode, let the Canvas scale smoothly to reduce aliasing (for non-pixel-art styles or big screens) */
        .high-quality canvas {
            image-rendering: auto;
        }

        /* Floating combat text styles (DOM-driven for best smoothness) */
        .damage-number {
            position: absolute;
            pointer-events: none;
            font-family: var(--font-ui);
            font-weight: 900;
            text-shadow: 1px 1px 2px #000, 0 0 5px rgba(0, 0, 0, 0.5);
            z-index: 100;
            white-space: nowrap;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.1s linear, opacity 0.1s linear;
        }

        .dmg-crit {
            font-size: 32px;
            color: #ff3300;
            text-shadow: 0 0 10px rgba(255, 50, 0, 0.9), 2px 2px 0px #000;
            z-index: 110;
            animation: crit-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), crit-flash 0.5s infinite alternate;
        }

        @keyframes crit-pop {
            0% {
                transform: scale(0.5);
                opacity: 0;
            }

            50% {
                transform: scale(1.4);
                opacity: 1;
            }

            100% {
                transform: scale(1);
            }
        }

        @keyframes crit-flash {
            from {
                filter: brightness(1);
            }

            to {
                filter: brightness(1.8) drop-shadow(0 0 8px gold);
            }
        }

        .dmg-normal {
            font-size: 18px;
            color: #ffffff;
        }

        .dmg-gold {
            font-size: 20px;
            color: #ffd700;
            font-weight: bold;
        }

        /* Combo HUD (DOM-driven) */
        #combo-hud {
            position: absolute;
            top: 20%;
            left: 50%;
            transform: translateX(-50%);
            pointer-events: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            opacity: 0;
            transition: opacity 0.3s;
            z-index: 100;
            font-family: var(--font-ui);
        }

        #combo-hud.active {
            opacity: 1;
        }

        .combo-title {
            font-size: 18px;
            font-weight: 700;
            font-style: italic;
            color: #ffcc00;
            text-shadow: 0 0 10px rgba(255, 200, 0, 0.6);
            letter-spacing: 2px;
        }

        .combo-count {
            font-size: 64px;
            font-weight: 900;
            color: #fff;
            line-height: 1;
            filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.5));
        }

        .combo-timer-bar {
            width: 100px;
            height: 4px;
            background: rgba(0, 0, 0, 0.5);
            border: 1px solid rgba(255, 255, 255, 0.2);
            margin-top: 5px;
            position: relative;
            overflow: hidden;
        }

        .combo-timer-fill {
            height: 100%;
            background: #ffcc00;
            width: 100%;
            box-shadow: 0 0 5px #ffcc00;
        }

        /* Low-HP visual warning: red edge glow on the screen */
        #low-hp-vignette {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.3s ease;
            box-shadow: inset 0 0 150px 60px rgba(180, 0, 0, 0.7);
            z-index: 50;
        }

        /* Death filter - fullscreen grayscale effect */
        .dead-filter {
            filter: grayscale(80%) brightness(0.7) !important;
            transition: filter 0.3s ease;
        }

        #low-hp-vignette.active {
            opacity: 1;
            animation: lowHpPulse 1.2s ease-in-out infinite;
        }

        @keyframes lowHpPulse {

            0%,
            100% {
                box-shadow: inset 0 0 120px 40px rgba(180, 0, 0, 0.5);
            }

            50% {
                box-shadow: inset 0 0 180px 80px rgba(220, 0, 0, 0.8);
            }
        }

        .ui-layer {
            position: absolute;
            pointer-events: none;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
        }

        #minimap-container {
            position: absolute;
            top: 50px;
            right: 20px;
            width: 150px;
            height: 150px;
            border: 2px solid var(--ui-border);
            background: rgba(0, 0, 0, 0.8);
            border-radius: 4px;
            overflow: hidden;
            pointer-events: auto;
            z-index: 50;
            /* 3D light and shadow */
            box-shadow:
                0 0 15px rgba(0, 0, 0, 0.8),
                inset 0 0 20px rgba(0, 0, 0, 0.6),
                inset 0 1px 0 rgba(255, 255, 255, 0.03);
        }

        #minimap {
            width: 100%;
            height: 100%;
            display: block;
        }

        #bottom-hud {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 140px;
            background:
                radial-gradient(ellipse at center bottom, rgba(124, 82, 32, 0.22) 0%, rgba(8, 8, 8, 0.86) 44%, transparent 76%),
                linear-gradient(to top, rgba(5, 5, 6, 0.98) 0%, rgba(13, 12, 11, 0.78) 48%, transparent 100%);
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            padding: 0 20px 10px;
            box-sizing: border-box;
            pointer-events: auto;
        }

        .orb-container {
            width: 108px;
            height: 108px;
            flex: 0 0 108px;
            aspect-ratio: 1 / 1;
            position: relative;
            background: #000;
            border-radius: 50%;
            /* Dark bronze trim shared by panels and skill slots */
            box-shadow:
                0 0 0 2px #14110d,
                0 0 0 3px var(--ui-metal-edge),
                0 5px 12px #000,
                inset 0 0 18px #000;
            overflow: hidden;
            z-index: 10;
        }

        /* Glass reflection layer (highlight) */
        .orb-container::after {
            content: '';
            position: absolute;
            top: 10%;
            left: 15%;
            width: 30%;
            height: 20%;
            border-radius: 50%;
            background: radial-gradient(ellipse at center, rgba(255, 237, 207, 0.25) 0%, rgba(255, 255, 255, 0) 70%);
            transform: rotate(-45deg);
            pointer-events: none;
            z-index: 5;
        }

        /* Glass bottom reflection (Fresnel effect) */
        .orb-container::before {
            content: '';
            position: absolute;
            bottom: 5%;
            left: 20%;
            width: 60%;
            height: 20%;
            border-radius: 50%;
            background: radial-gradient(ellipse at center, rgba(255, 237, 207, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
            pointer-events: none;
            z-index: 5;
        }

        .orb-fill {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            z-index: 2;
        }

        .orb-ghost-fill {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            z-index: 1;
            background: rgba(255, 255, 255, 0.3);
            filter: blur(2px);
        }

        #health-orb .orb-ghost-fill {
            background: rgba(255, 100, 100, 0.4);
        }

        #mana-orb .orb-ghost-fill {
            background: rgba(100, 150, 255, 0.4);
        }

        #health-orb .orb-fill {
            /* Deeper, more dimensional red liquid */
            background: radial-gradient(ellipse at 40% 15%, #bc4940, #7b241f 55%, #310b0b);
            box-shadow: inset 0 0 18px #290b0b;
        }

        #health-orb {
            border: 3px solid var(--ui-metal-edge);
            transition: filter 0.3s ease;
        }

        #health-orb.poisoned .orb-fill {
            background: linear-gradient(to top, #003300 0%, #006600 50%, #33cc33 100%) !important;
            box-shadow: 0 0 30px #00ff00 inset !important;
        }

        #health-orb.poisoned .orb-ghost-fill {
            background: rgba(0, 200, 0, 0.4) !important;
        }

        #mana-orb .orb-fill {
            /* Deeper, more dimensional blue liquid */
            background: radial-gradient(ellipse at 40% 15%, #487eb5, #204b76 55%, #0a1c32);
            box-shadow: inset 0 0 18px #081c31;
        }

        #mana-orb {
            border: 3px solid var(--ui-metal-edge);
            transition: filter 0.3s ease, transform 0.1s ease;
        }

        /* Frozen state: life orb turns blue with a white edge */
        #health-orb.frozen,
        #health-orb.chilled {
            filter: hue-rotate(180deg) brightness(1.2) saturate(1.2) !important;
            box-shadow: 0 0 15px #00ccff !important;
        }

        /* Lightning overload: mana orb jitters and brightens */
        #mana-orb.overloaded {
            animation: lightningJitter 0.2s infinite;
            filter: brightness(1.5) saturate(1.5) !important;
        }

        @keyframes lightningJitter {
            0% {
                transform: translate(0, 0);
            }

            25% {
                transform: translate(-1px, 1px);
            }

            50% {
                transform: translate(1px, -1px);
            }

            75% {
                transform: translate(-1px, -1px);
            }

            100% {
                transform: translate(1px, 1px);
            }
        }

        .orb-text {
            font-family: var(--font-number);
            font-variant-numeric: tabular-nums;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-weight: bold;
            font-size: 18px;
            color: #fff;
            text-shadow: 0 0 5px #000, 0 0 10px #000;
            z-index: 6;
            pointer-events: none;
        }

        /* Shield fill layer (hidden; replaced by border glow) */
        .orb-shield-fill {
            display: none;
        }

        /* HP orb glow border while the shield is active */
        #health-orb.shielded {
            border-color: #ffd700 !important;
            box-shadow:
                0 0 10px rgba(255, 215, 0, 0.8),
                0 0 20px rgba(255, 215, 0, 0.6),
                0 0 35px rgba(255, 215, 0, 0.4),
                0 0 50px rgba(255, 215, 0, 0.2),
                inset 0 0 15px rgba(255, 215, 0, 0.3);
            animation: shieldGlow 1.5s ease-in-out infinite;
        }

        @keyframes shieldGlow {

            0%,
            100% {
                box-shadow:
                    0 0 10px rgba(255, 215, 0, 0.8),
                    0 0 20px rgba(255, 215, 0, 0.6),
                    0 0 35px rgba(255, 215, 0, 0.4),
                    0 0 50px rgba(255, 215, 0, 0.2),
                    inset 0 0 15px rgba(255, 215, 0, 0.3);
            }

            50% {
                box-shadow:
                    0 0 15px rgba(255, 215, 0, 1),
                    0 0 30px rgba(255, 215, 0, 0.8),
                    0 0 50px rgba(255, 215, 0, 0.5),
                    0 0 70px rgba(255, 215, 0, 0.3),
                    inset 0 0 20px rgba(255, 215, 0, 0.4);
            }
        }

        /* Shield value text */
        .shield-text {
            position: absolute;
            top: -22px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 12px;
            font-weight: bold;
            color: #ffd700;
            text-shadow: 0 0 3px #000, 0 0 6px #000, 0 0 12px rgba(255, 215, 0, 0.8);
            z-index: 7;
            pointer-events: none;
            white-space: nowrap;
        }

        /* Fast flicker when the shield is about to expire */
        #health-orb.shield-low {
            animation: shieldLowFlicker 0.3s ease-in-out infinite !important;
        }

        @keyframes shieldLowFlicker {

            0%,
            100% {
                box-shadow:
                    0 0 10px rgba(255, 215, 0, 0.8),
                    0 0 20px rgba(255, 215, 0, 0.6),
                    inset 0 0 15px rgba(255, 215, 0, 0.3);
                border-color: #ffd700;
            }

            50% {
                box-shadow:
                    0 0 5px rgba(255, 100, 0, 0.6),
                    0 0 10px rgba(255, 100, 0, 0.4),
                    inset 0 0 8px rgba(255, 100, 0, 0.2);
                border-color: #ff6400;
            }
        }

        #center-hud {
            display: flex;
            flex-direction: column;
            align-items: center;
            /* Nudged down to hug the screen bottom */
            padding: 8px 14px 7px;
            gap: 2px;
            flex: 1;
            max-width: 600px;
            margin: 0 10px;
            position: relative;
            z-index: 5;
            border-radius: 8px 8px 0 0;
        }

        /* Decorative texture */
        #center-hud::before {
            content: none;
        }

        .belt-bar {
            display: flex;
            gap: 5px;
            margin-bottom: 2px;
            background: #000;
            padding: 4px;
            border: 1px solid #333;
            border-radius: 4px;
            margin-top: 5px;
        }

        .belt-slot {
            width: 32px;
            height: 32px;
            background: #080808;
            border: 1px solid #444;
            display: flex;
            justify-content: center;
            align-items: center;
            position: relative;
            cursor: pointer;
            font-size: 18px;
            box-shadow: inset 0 0 5px #000;
        }

        .belt-slot:hover {
            border-color: var(--text-gold);
        }

        .belt-key {
            position: absolute;
            top: -8px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 10px;
            color: #888;
            background: #000;
            padding: 0 3px;
            z-index: 5;
        }

        .belt-count {
            position: absolute;
            bottom: 0;
            right: 2px;
            font-size: 10px;
            color: #fff;
            font-weight: bold;
            text-shadow: 1px 1px 0 #000;
            z-index: 5;
        }

        .xp-container {
            width: 95%;
            /* Slightly widened */
            display: flex;
            align-items: center;
            gap: 5px;
            margin: 2px auto;
        }

        .xp-bar {
            flex: 1;
            height: 8px;
            background: #222;
            border: 1px solid #444;
            border-radius: 4px;
            position: relative;
            overflow: hidden;
        }

        .xp-fill {
            height: 100%;
            background: linear-gradient(to bottom, #e2d19b 0%, #c7b377 50%, #8a7a4a 100%);
            width: 0%;
            position: relative;
            box-shadow: 0 0 10px rgba(199, 179, 119, 0.5);
        }

        .xp-shine {
            position: absolute;
            top: 0;
            left: 0;
            width: 30px;
            height: 100%;
            background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.4), transparent);
            transform: skewX(-20deg);
            animation: xp-glow 3s infinite linear;
        }

        @keyframes xp-glow {
            0% {
                left: -50px;
            }

            30% {
                left: 110%;
            }

            100% {
                left: 110%;
            }
        }

        .xp-percentage {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 9px;
            color: #fff;
            font-weight: bold;
            text-shadow:
                -1px -1px 0 #000,
                1px -1px 0 #000,
                -1px 1px 0 #000,
                1px 1px 0 #000,
                0 0 2px rgba(0, 0, 0, 0.8);
            pointer-events: none;
        }

        .level-display {
            color: var(--text-gold);
            font-weight: bold;
            font-size: 14px;
            white-space: nowrap;
        }

        .skill-bar {
            display: flex;
            gap: 7px;
            margin-top: 3px;
            margin-bottom: 4px;
            background:
                linear-gradient(180deg, rgba(50, 43, 32, 0.94), rgba(5, 5, 5, 0.96)),
                radial-gradient(ellipse at center, rgba(199, 179, 119, 0.12), transparent 70%);
            padding: 7px;
            border: 1px solid rgba(111, 90, 55, 0.78);
            border-radius: 6px;
            box-shadow:
                0 4px 14px rgba(0, 0, 0, 0.75),
                inset 0 1px 0 rgba(255, 232, 177, 0.12),
                inset 0 -8px 14px rgba(0, 0, 0, 0.55);
        }

        .skill-btn {
            width: 38px;
            height: 38px;
            background:
                linear-gradient(145deg, #2f2a21 0%, #141312 42%, #050505 100%);
            border: 1px solid rgba(141, 112, 62, 0.85);
            border-radius: 5px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 12px;
            color: #9e8d69;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            box-shadow:
                0 2px 0 #050505,
                0 0 0 1px rgba(0, 0, 0, 0.72),
                inset 0 1px 0 rgba(255, 230, 170, 0.16),
                inset 0 -10px 16px rgba(0, 0, 0, 0.62);
            transition: transform 0.12s ease, filter 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
        }

        .skill-btn::before {
            content: '';
            position: absolute;
            inset: 2px;
            border: 1px solid rgba(255, 222, 150, 0.08);
            border-radius: 3px;
            pointer-events: none;
            z-index: 1;
        }

        /* Skill button pressed effect */
        .skill-btn:active {
            transform: scale(0.95);
            box-shadow:
                0 1px 0 #030303,
                inset 0 0 18px #000,
                inset 0 5px 12px rgba(0, 0, 0, 0.86);
            border-color: #3a2d20;
        }

        .skill-btn.active {
            border-color: var(--ui-metal-hi);
            color: #f1ddb0;
            background:
                linear-gradient(145deg, #4b3722 0%, #1c1712 46%, #070707 100%);
            box-shadow:
                0 2px 0 #060606,
                0 0 12px rgba(199, 179, 119, 0.28),
                inset 0 1px 0 rgba(255, 238, 190, 0.2),
                inset 0 -10px 16px rgba(0, 0, 0, 0.6);
        }

        .skill-btn .lvl {
            position: absolute;
            bottom: 2px;
            right: 2px;
            font-size: 10px;
            color: #d1bd82;
            z-index: 3;
            text-shadow: 0 1px 2px #000;
        }

        /* Fan-shaped cooldown mask */
        .skill-btn .cd-sweep {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 4px;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.1s;
            z-index: 2;
        }

        .skill-btn .cd-sweep.active {
            opacity: 1;
            background:
                conic-gradient(rgba(0, 0, 0, 0.9) var(--cd-progress, 0%),
                    rgba(0, 0, 0, 0.18) var(--cd-progress, 0%)),
                radial-gradient(circle at center, rgba(199, 179, 119, 0.16), rgba(0, 0, 0, 0.58));
            box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.86);
        }

        .skill-btn .cd-time {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 14px;
            font-weight: bold;
            color: #fff;
            text-shadow: 0 0 4px #000, 0 0 8px #000;
            z-index: 4;
            opacity: 0;
            pointer-events: none;
        }

        .skill-btn .cd-time.active {
            opacity: 1;
        }

        /* Skill button click ripple effect */
        .skill-btn::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            background: radial-gradient(circle, rgba(255, 200, 100, 0.6) 0%, transparent 70%);
            border-radius: 50%;
            transform: translate(-50%, -50%);
            opacity: 0;
            transition: width 0.3s, height 0.3s, opacity 0.3s;
        }

        .skill-btn.clicked::after {
            width: 80px;
            height: 80px;
            opacity: 0;
        }

        /* Enhanced pressed effect */
        .skill-btn:active {
            transform: scale(0.9) translateY(2px);
            box-shadow:
                0 1px 0 #030303,
                inset 0 0 20px #000,
                inset 0 5px 10px rgba(0, 0, 0, 0.8);
            border-color: #3a2d20;
            filter: brightness(0.8);
        }

        /* Belt cell click effect */
        .belt-slot {
            transition: all 0.1s;
        }

        .belt-slot:active {
            transform: scale(0.92) translateY(2px);
            filter: brightness(0.7);
        }

        .panel {
            position: absolute;
            background:
                linear-gradient(180deg, rgba(30, 27, 22, 0.98) 0%, rgba(12, 12, 14, 0.98) 42%, rgba(6, 6, 7, 0.98) 100%);
            border: 1px solid rgba(111, 90, 55, 0.9);
            /* 3D lighting: increased contrast */
            box-shadow:
                0 18px 42px rgba(0, 0, 0, 0.78),
                0 0 0 1px rgba(0, 0, 0, 0.85),
                0 0 24px rgba(111, 71, 29, 0.18),
                inset 0 1px 0 rgba(255, 235, 190, 0.12),
                inset 0 0 24px rgba(0, 0, 0, 0.58);
            padding: 15px;
            color: var(--text-gold);
            pointer-events: auto;
            display: none;
            width: 320px;
            z-index: 60;
            border-radius: 6px;
        }

        .panel-header {
            font-family: var(--font-ui);
            font-weight: 600;
            text-align: center;
            font-size: 1.2em;
            margin-bottom: 15px;
            border-bottom: 1px solid rgba(185, 154, 85, 0.45);
            padding: 4px 34px 9px;
            cursor: move;
            user-select: none;
            color: #e0c884;
            text-shadow: 0 1px 0 #000;
            background:
                linear-gradient(90deg, transparent, rgba(111, 90, 55, 0.2), transparent);
        }

        .panel-close {
            position: absolute;
            top: 8px;
            right: 10px;
            cursor: pointer;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background: linear-gradient(180deg, #493c2c, #201a14);
            border: 2px solid var(--ui-metal-edge);
            box-shadow: 0 2px 4px #000, inset 0 1px 0 rgba(255, 235, 190, 0.15);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 10;
        }

        /* X mark centered */
        .panel-close::before,
        .panel-close::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 10px;
            height: 2px;
            background: #fff;
            border-radius: 1px;
            box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
        }

        .panel-close::before {
            transform: translate(-50%, -50%) rotate(45deg);
        }

        .panel-close::after {
            transform: translate(-50%, -50%) rotate(-45deg);
        }

        .panel-close:hover {
            transform: scale(1.1) rotate(90deg);
            filter: brightness(1.2);
            box-shadow: 0 0 10px rgba(255, 50, 50, 0.5);
        }

        .panel-close:active {
            transform: scale(0.95);
            box-shadow:
                0 0 3px rgba(0, 0, 0, 0.8),
                inset 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        #stats-panel {
            top: 10%;
            left: 20px;
        }

        .stat-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 8px;
            font-size: 0.9em;
        }

        .stat-btn {
            background: #333;
            border: 1px solid #666;
            width: 20px;
            height: 20px;
            line-height: 18px;
            text-align: center;
            cursor: pointer;
            color: #fff;
        }

        .stat-btn:hover {
            background: #555;
        }

        #inventory-panel {
            top: 10%;
            right: 20px;
            width: 320px;
            /* Reserve space for borders, padding and safe areas; long inventories scroll inside the panel. */
            max-height: calc(100dvh - 52px);
            overflow-y: auto;
        }

        .equipment-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            margin-bottom: 20px;
            justify-items: center;
        }

        .equip-slot {
            width: 60px;
            height: 60px;
            border: 1px solid #444;
            background: #151411;
            border-radius: 4px;
            box-shadow: inset 0 1px 3px #000;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            cursor: pointer;
        }

        .bag-grid {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 4px;
        }

        .stash-grid {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 4px;
        }

        .stash-expand-btn {
            margin-top: 10px;
            padding: 8px 12px;
            background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
            border: 1px solid #444;
            border-radius: 4px;
            color: #ddd;
            font-size: 12px;
            cursor: pointer;
            text-align: center;
            transition: all 0.2s;
        }

        .stash-expand-btn:hover {
            background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
            border-color: #666;
        }

        .stash-expand-btn.disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        .stash-expand-btn.disabled:hover {
            background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
            border-color: #444;
        }

        .bag-slot {
            width: 48px;
            height: 48px;
            border: 1px solid #333;
            background: #151411;
            border-radius: 4px;
            box-shadow: inset 0 1px 3px #000;
            position: relative;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .item-count {
            position: absolute;
            bottom: 2px;
            right: 2px;
            color: #fff;
            font-size: 10px;
            font-weight: bold;
            text-shadow: 1px 1px 0 #000;
        }

        .enhance-level {
            position: absolute;
            top: 1px;
            right: 2px;
            color: #0f0;
            font-size: 10px;
            font-weight: bold;
            text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
        }

        /* Inventory sell-confirm styles */
        .bag-slot.sell-pending {
            border-color: #ff4444 !important;
            box-shadow: inset 0 0 12px rgba(255, 68, 68, 0.6) !important;
        }

        .bag-slot .sell-confirm-btn {
            position: absolute;
            bottom: 3px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(180deg, #c22 0%, #811 100%);
            color: #fff;
            font-size: 10px;
            padding: 2px 8px;
            border-radius: 2px;
            cursor: pointer;
            z-index: 10;
            text-shadow: 0 1px 1px #000;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
            transition: all 0.1s;
        }

        .bag-slot .sell-confirm-btn:hover {
            background: linear-gradient(180deg, #e33 0%, #a22 100%);
            transform: translateX(-50%) scale(1.1);
        }

        /* ========== Skill tree panel ========== */
        #skills-panel.skill-tree-panel {
            top: 10%;
            left: 50%;
            transform: translateX(-50%);
            width: 320px;
            max-height: 80vh;
        }

        .skill-tree-points {
            text-align: center;
            color: var(--text-gold);
            font-size: 14px;
            padding: 8px;
            background: rgba(0, 0, 0, 0.4);
            border-bottom: 1px solid #333;
            position: sticky;
            top: 0;
            z-index: 1;
        }

        .skill-tree-scroll {
            max-height: calc(80vh - 140px);
            overflow-y: auto;
            padding: 10px;
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        .skill-tree-scroll::-webkit-scrollbar {
            width: 8px;
        }

        .skill-tree-scroll::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        .skill-tree-scroll::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 4px;
            border: 1px solid #333;
        }

        .skill-tree-scroll::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        /* Skill tree tab switching */
        .skill-tree-tabs {
            display: flex;
            gap: 6px;
            padding: 8px 10px;
            border-bottom: 1px solid rgba(111, 90, 55, 0.55);
            background:
                linear-gradient(180deg, rgba(30, 25, 18, 0.72), rgba(0, 0, 0, 0.35));
        }

        .skill-tree-tab {
            flex: 1;
            padding: 8px 6px;
            text-align: center;
            font-size: 12px;
            color: #a89569;
            background:
                linear-gradient(180deg, rgba(35, 31, 25, 0.92), rgba(8, 8, 9, 0.92));
            border: 1px solid rgba(111, 90, 55, 0.62);
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.15s;
            white-space: nowrap;
            text-shadow: 0 1px 2px #000;
        }

        .skill-tree-tab:hover {
            background:
                linear-gradient(180deg, rgba(58, 47, 31, 0.95), rgba(13, 13, 13, 0.95));
            border-color: rgba(185, 154, 85, 0.78);
            color: #d8c28b;
        }

        .skill-tree-tab.active {
            background:
                linear-gradient(180deg, rgba(85, 60, 30, 0.9), rgba(24, 18, 13, 0.95));
            border-color: var(--ui-metal-hi);
            color: #f0dca8;
            box-shadow: inset 0 1px 0 rgba(255, 235, 190, 0.16), 0 0 10px rgba(199, 179, 119, 0.16);
        }

        /* Skill school divider */
        .skill-tree-branch {
            margin-bottom: 20px;
            position: relative;
        }

        .skill-branch-header {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 6px;
            background: linear-gradient(90deg, transparent, rgba(100, 80, 50, 0.4), transparent);
            margin-bottom: 12px;
            font-size: 13px;
            color: var(--text-gold);
        }

        .skill-branch-header::before,
        .skill-branch-header::after {
            content: '';
            flex: 1;
            height: 1px;
            background: linear-gradient(90deg, transparent, #665533, transparent);
        }

        /* Skill node container */
        .skill-tree-stage {
            position: relative;
            margin-bottom: 8px;
        }

        /* Stage 1: single centered node */
        .skill-tree-stage.stage-1 {
            display: flex;
            justify-content: center;
        }

        /* Stage 2/3: forked dual nodes */
        .skill-tree-stage.stage-fork {
            display: flex;
            justify-content: center;
            gap: 20px;
        }

        /* Connector container */
        .skill-tree-connector {
            display: flex;
            justify-content: center;
            height: 24px;
            position: relative;
        }

        /* Vertical connector */
        .skill-tree-connector .line-v {
            width: 2px;
            height: 100%;
            background: #444;
        }

        .skill-tree-connector.active .line-v {
            background: var(--text-gold);
            box-shadow: 0 0 4px var(--text-gold);
        }

        /* Fork connector */
        .skill-tree-connector.fork {
            height: 30px;
        }

        .skill-tree-connector.fork::before {
            content: '';
            position: absolute;
            top: 0;
            left: 50%;
            width: 2px;
            height: 12px;
            background: #444;
            transform: translateX(-50%);
        }

        .skill-tree-connector.fork::after {
            content: '';
            position: absolute;
            top: 12px;
            left: 25%;
            width: 50%;
            height: 2px;
            background: #444;
        }

        .skill-tree-connector.fork .line-left,
        .skill-tree-connector.fork .line-right {
            position: absolute;
            top: 14px;
            width: 2px;
            height: 16px;
            background: #444;
        }

        .skill-tree-connector.fork .line-left {
            left: 25%;
            transform: translateX(-50%);
        }

        .skill-tree-connector.fork .line-right {
            right: 25%;
            transform: translateX(50%);
        }

        .skill-tree-connector.fork.active::before,
        .skill-tree-connector.fork.active::after {
            background: var(--text-gold);
            box-shadow: 0 0 4px var(--text-gold);
        }

        .skill-tree-connector.fork.active .line-left,
        .skill-tree-connector.fork.active .line-right {
            background: var(--text-gold);
            box-shadow: 0 0 4px var(--text-gold);
        }

        .skill-tree-connector.fork.active-left .line-left {
            background: var(--text-gold);
            box-shadow: 0 0 4px var(--text-gold);
        }

        .skill-tree-connector.fork.active-right .line-right {
            background: var(--text-gold);
            box-shadow: 0 0 4px var(--text-gold);
        }

        /* Skill node */
        .skill-tree-node {
            width: 120px;
            background:
                linear-gradient(180deg, rgba(34, 31, 26, 0.94), rgba(9, 9, 10, 0.94));
            border: 1px solid rgba(111, 90, 55, 0.7);
            border-radius: 4px;
            padding: 8px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
        }

        .skill-tree-node:hover:not(.locked):not(.other-locked) {
            border-color: var(--ui-metal-hi);
            background:
                linear-gradient(180deg, rgba(53, 43, 29, 0.96), rgba(12, 12, 12, 0.96));
        }

        .skill-tree-node.active {
            border-color: var(--ui-metal-hi);
            box-shadow:
                0 0 12px rgba(199, 179, 119, 0.28),
                inset 0 1px 0 rgba(255, 235, 190, 0.12);
        }

        .skill-tree-node.maxed {
            border-color: #4a4;
            box-shadow: 0 0 8px rgba(80, 200, 80, 0.3);
        }

        .skill-tree-node.locked {
            opacity: 0.5;
            cursor: not-allowed;
            border-style: dashed;
        }

        .skill-tree-node.other-locked {
            opacity: 0.35;
            cursor: not-allowed;
            filter: grayscale(0.8);
        }

        .skill-tree-node.selectable {
            border-color: #668;
            border-style: dashed;
            animation: pulse-border 2s infinite;
        }

        @keyframes pulse-border {

            0%,
            100% {
                border-color: #446;
            }

            50% {
                border-color: #88a;
            }
        }

        /* Node icon */
        .skill-node-icon {
            width: 36px;
            height: 36px;
            margin: 0 auto 6px;
            background:
                radial-gradient(circle at 40% 28%, rgba(199, 179, 119, 0.18), transparent 52%),
                linear-gradient(145deg, #2b261d, #070707);
            border: 1px solid rgba(141, 112, 62, 0.82);
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow:
                inset 0 1px 0 rgba(255, 235, 190, 0.14),
                inset 0 -8px 12px rgba(0, 0, 0, 0.55);
        }

        .skill-tree-node.locked .skill-node-icon,
        .skill-tree-node.other-locked .skill-node-icon {
            filter: grayscale(1);
        }

        /* Node name */
        .skill-node-name {
            font-size: 11px;
            color: #ddd;
            margin-bottom: 4px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .skill-tree-node.active .skill-node-name,
        .skill-tree-node.maxed .skill-node-name {
            color: var(--text-gold);
        }

        /* Node level display */
        .skill-node-level {
            font-size: 10px;
            color: #888;
            margin-bottom: 4px;
        }

        .skill-tree-node.active .skill-node-level {
            color: #aaa;
        }

        /* Progress bar */
        .skill-node-progress {
            height: 4px;
            background: #222;
            border-radius: 2px;
            overflow: hidden;
            margin-bottom: 4px;
        }

        .skill-node-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #665533, var(--text-gold));
            transition: width 0.3s;
        }

        .skill-tree-node.maxed .skill-node-progress-fill {
            background: linear-gradient(90deg, #446644, #4a4);
        }

        /* Upgrade button */
        .skill-node-upgrade {
            display: inline-block;
            padding: 2px 10px;
            background: #333;
            border: 1px solid #555;
            border-radius: 3px;
            color: #aaa;
            font-size: 11px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .skill-node-upgrade:hover {
            background: #444;
            border-color: var(--text-gold);
            color: var(--text-gold);
        }

        .skill-node-upgrade.disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        /* Lock icon */
        .skill-node-lock {
            position: absolute;
            top: 4px;
            right: 4px;
            font-size: 10px;
            color: #666;
        }

        /* Maxed marker */
        .skill-node-check {
            position: absolute;
            top: 4px;
            right: 4px;
            font-size: 12px;
            color: #4a4;
        }

        /* Selection hint */
        .skill-node-hint {
            font-size: 9px;
            color: #668;
            margin-top: 2px;
        }

        /* Skill Sprites */
        .skill-sprite {
            width: 32px;
            height: 32px;
            background-image: url('skills-painted.webp?v=2026090801');
            background-size: 200% 200%;
            background-repeat: no-repeat;
            display: inline-block;
            vertical-align: middle;
            image-rendering: auto;
        }

        .skill-attack {
            background-position: 0% 0%;
        }

        .skill-fireball {
            background-position: 100% 0%;
        }

        .skill-thunder {
            background-position: 0% 100%;
        }

        .skill-multishot {
            background-position: 100% 100%;
        }

        /* Stage 2/3 nodes reuse the parent skill icon */
        .skill-tree-node[data-parent="fireball"] .skill-sprite {
            background-position: 100% 0%;
        }

        .skill-tree-node[data-parent="thunder"] .skill-sprite {
            background-position: 0% 100%;
        }

        .skill-tree-node[data-parent="multishot"] .skill-sprite {
            background-position: 100% 100%;
        }

        /* Legacy compatibility styles kept */
        .skill-row {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            background: rgba(0, 0, 0, 0.3);
            padding: 5px;
            border: 1px solid #333;
        }

        .skill-icon {
            width: 40px;
            height: 40px;
            background: #222;
            border: 1px solid #555;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 20px;
            margin-right: 10px;
        }

        .skill-info {
            flex: 1;
        }

        .skill-name {
            font-weight: bold;
            color: var(--text-gold);
            font-size: 0.9em;
        }

        .skill-desc {
            font-size: 0.7em;
            color: #888;
        }

        #shop-panel {
            top: 10%;
            left: 50%;
            transform: translateX(-50%);
            width: 400px;
        }

        .gamble-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 10px;
            margin-top: 10px;
        }

        .gamble-slot {
            background: #111;
            border: 1px solid #444;
            padding: 10px;
            text-align: center;
            cursor: pointer;
            transition: background 0.2s;
        }

        .gamble-slot:hover {
            background: #222;
            border-color: var(--text-gold);
        }

        .gamble-price {
            color: gold;
            font-size: 0.9em;
            margin-top: 5px;
        }

        .shop-item-icon {
            width: 32px;
            height: 32px;
            margin: 0 auto 5px auto;
            background-image: url('items-painted.webp?v=2026090801');
            background-size: 400% 400%;
            background-repeat: no-repeat;
            image-rendering: pixelated;
        }

        .shop-section-title {
            text-align: center;
            color: #888;
            font-size: 12px;
            margin-top: 10px;
            margin-bottom: 5px;
            border-bottom: 1px solid #333;
            padding-bottom: 2px;
        }

        #quest-panel {
            top: 15%;
            left: 20px;
            width: 300px;
            max-height: 85%;
            overflow-y: auto;
        }

        #achievements-panel {
            top: 10%;
            left: 20px;
            width: 320px;
            max-height: 85%;
            overflow-y: auto;
        }

        /* Custom scrollbar styles */
        #achievements-panel::-webkit-scrollbar {
            width: 8px;
        }

        #achievements-panel::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        #achievements-panel::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 4px;
            border: 1px solid #666;
        }

        #achievements-panel::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        /* Firefox support */
        #achievements-panel {
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        /* Quest panel custom scrollbar styles */
        #quest-panel::-webkit-scrollbar {
            width: 8px;
        }

        #quest-panel::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        #quest-panel::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 4px;
            border: 1px solid #666;
        }

        #quest-panel::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        /* Firefox support */
        #quest-panel {
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        .achievement-item {
            display: flex;
            padding: 10px 10px 10px 12px;
            margin-bottom: 8px;
            background: rgba(0, 0, 0, 0.4);
            border: 1px solid #333;
            border-left: 3px solid #666;
            border-radius: 4px;
            transition: all 0.2s;
        }

        .achievement-item:hover {
            background: rgba(40, 40, 40, 0.6);
            border-color: #555;
        }

        .achievement-item.completed {
            border-color: #4a4;
            border-left-color: #4a4;
            background: rgba(68, 170, 68, 0.08);
        }

        .achievement-item.completed::before {
            display: none;
        }

        .ach-content {
            flex: 1;
            min-width: 0;
        }

        .ach-name {
            color: #fff;
            font-size: 13px;
            font-weight: bold;
            margin-bottom: 2px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .ach-pts {
            font-size: 11px;
            color: #ffd700;
            font-weight: normal;
        }

        .ach-desc {
            color: #888;
            font-size: 11px;
            margin-bottom: 6px;
            line-height: 1.3;
        }

        .ach-bar-container {
            height: 4px;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 2px;
            overflow: hidden;
            margin-bottom: 3px;
        }

        .ach-bar {
            height: 100%;
            border-radius: 2px;
            transition: width 0.3s;
        }

        .ach-progress-text {
            color: #aaa;
            font-size: 10px;
            text-align: right;
        }

        .achievement-item.completed .ach-progress-text {
            color: #4a4;
        }

        /* Achievement panel header */
        .ach-header {
            margin-bottom: 12px;
            padding-bottom: 10px;
            border-bottom: 1px solid #333;
        }

        .ach-stats {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
        }

        .ach-completed {
            color: #aaa;
            font-size: 13px;
        }

        /* ========== Waypoint panel ========== */
        #waypoint-panel {
            top: 12%;
            left: 50%;
            transform: translateX(-50%);
            width: 380px;
            max-width: 92vw;
            max-height: 82vh;
            overflow-y: auto;
            border: 1.5px solid #38bdf8;
            box-shadow: 0 0 20px rgba(56, 189, 248, 0.28), 0 10px 30px rgba(0, 0, 0, 0.85);
            scrollbar-width: thin;
            scrollbar-color: #38bdf8 rgba(0, 0, 0, 0.4);
        }

        #waypoint-panel::-webkit-scrollbar {
            width: 6px;
        }
        #waypoint-panel::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 3px;
        }
        #waypoint-panel::-webkit-scrollbar-thumb {
            background: #0284c7;
            border-radius: 3px;
        }

        .waypoint-panel-body {
            padding: 4px 2px 10px;
        }

        .waypoint-subtitle {
            font-size: 12px;
            color: #94a3b8;
            text-align: center;
            margin-bottom: 12px;
            letter-spacing: 0.5px;
        }

        .waypoint-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .waypoint-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 14px;
            border-radius: 6px;
            background: linear-gradient(135deg, rgba(15, 23, 42, 0.88) 0%, rgba(30, 41, 59, 0.75) 100%);
            border: 1px solid rgba(56, 189, 248, 0.25);
            transition: all 0.2s ease;
            position: relative;
            overflow: hidden;
        }

        .waypoint-item:hover:not(.locked) {
            border-color: #38bdf8;
            background: linear-gradient(135deg, rgba(20, 32, 58, 0.95) 0%, rgba(38, 56, 82, 0.85) 100%);
            box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
        }

        .waypoint-item.current {
            border-color: #38bdf8;
            background: linear-gradient(135deg, rgba(12, 74, 110, 0.85) 0%, rgba(3, 105, 161, 0.65) 100%);
            box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
        }

        .waypoint-item.locked {
            opacity: 0.55;
            background: rgba(15, 23, 42, 0.4);
            border-color: rgba(71, 85, 105, 0.3);
            filter: grayscale(0.5);
        }

        .waypoint-item-left {
            display: flex;
            align-items: center;
            gap: 12px;
            min-width: 0;
            flex: 1;
        }

        .waypoint-icon-box {
            width: 38px;
            height: 38px;
            flex-shrink: 0;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            background: radial-gradient(circle, rgba(14, 116, 144, 0.65) 0%, rgba(15, 23, 42, 0.9) 100%);
            border: 1.5px solid #38bdf8;
            box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
        }

        .waypoint-item.locked .waypoint-icon-box {
            background: rgba(30, 41, 59, 0.5);
            border-color: #64748b;
            box-shadow: none;
            color: #64748b;
        }

        .waypoint-item-details {
            display: flex;
            flex-direction: column;
            gap: 2px;
            min-width: 0;
        }

        .waypoint-item-title {
            font-size: 14px;
            font-weight: bold;
            color: #f8fafc;
            display: flex;
            align-items: center;
            gap: 6px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .waypoint-floor-tag {
            font-size: 11px;
            padding: 1px 5px;
            border-radius: 3px;
            background: rgba(56, 189, 248, 0.2);
            color: #7dd3fc;
            border: 1px solid rgba(56, 189, 248, 0.4);
            font-weight: normal;
        }

        .waypoint-item.locked .waypoint-floor-tag {
            background: rgba(100, 116, 139, 0.2);
            color: #94a3b8;
            border-color: rgba(100, 116, 139, 0.4);
        }

        .waypoint-item-desc {
            font-size: 11px;
            color: #94a3b8;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .waypoint-btn {
            flex-shrink: 0;
            padding: 6px 14px;
            font-size: 12px;
            font-weight: bold;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
            border: 1px solid transparent;
        }

        .waypoint-btn.travel-btn {
            background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
            color: #ffffff;
            border-color: #38bdf8;
            box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
        }

        .waypoint-btn.travel-btn:hover {
            background: linear-gradient(180deg, #0369a1 0%, #075985 100%);
            box-shadow: 0 0 15px rgba(56, 189, 248, 0.6);
            transform: scale(1.03);
        }

        .waypoint-btn.current-btn {
            background: rgba(56, 189, 248, 0.15);
            color: #38bdf8;
            border-color: rgba(56, 189, 248, 0.4);
            cursor: default;
        }

        .waypoint-btn.locked-btn {
            background: rgba(30, 41, 59, 0.5);
            color: #64748b;
            border-color: rgba(71, 85, 105, 0.3);
            cursor: not-allowed;
        }

        .ach-points {
            color: #ffd700;
            font-size: 13px;
        }

        .ach-tabs {
            display: flex;
            gap: 4px;
            flex-wrap: nowrap;
        }

        .ach-tab {
            padding: 4px 7px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid #444;
            border-radius: 4px;
            font-size: 12px;
            color: #888;
            cursor: pointer;
            transition: all 0.15s;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
        }

        .ach-tab:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: #666;
        }

        .ach-tab.active {
            background: rgba(199, 179, 119, 0.2);
            border-color: var(--text-gold);
            color: var(--text-gold);
        }

        .ach-list-container {
            max-height: calc(100% - 80px);
            overflow-y: auto;
        }

        /* ========== Set codex panel ========== */
        #set-collection-panel {
            top: 10%;
            left: 20px;
            width: 340px;
            max-height: 85%;
            overflow-y: auto;
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        #set-collection-panel::-webkit-scrollbar {
            width: 8px;
        }

        #set-collection-panel::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        #set-collection-panel::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 4px;
            border: 1px solid #666;
        }

        .set-collection-header {
            padding: 10px 12px;
            border-bottom: 1px solid #333;
            margin-bottom: 10px;
        }

        .set-collection-stats {
            display: flex;
            justify-content: space-between;
            color: #888;
            font-size: 12px;
        }

        .set-collection-stats span:first-child {
            color: var(--text-gold);
        }

        /* Single set card */
        .set-card {
            background: rgba(0, 0, 0, 0.4);
            border: 1px solid #333;
            border-radius: 6px;
            margin: 0 10px 10px;
            overflow: hidden;
            transition: all 0.2s;
        }

        .set-card:hover {
            border-color: #555;
            background: rgba(30, 30, 30, 0.6);
        }

        .set-card.discovered {
            border-left: 3px solid #20ff20;
        }

        .set-card.locked {
            opacity: 0.5;
        }

        .set-card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 12px;
            background: rgba(0, 0, 0, 0.3);
            cursor: pointer;
        }

        .set-card-header:hover {
            background: rgba(40, 40, 40, 0.5);
        }

        .set-card-title {
            color: #20ff20;
            font-size: 14px;
            font-weight: bold;
        }

        .set-card.locked .set-card-title {
            color: #666;
        }

        .set-card-progress {
            font-size: 12px;
            color: #888;
        }

        .set-card-progress .collected {
            color: #20ff20;
        }

        /* Set pieces grid */
        .set-pieces-grid {
            display: none;
            padding: 10px 12px;
            border-top: 1px solid #222;
        }

        .set-card.expanded .set-pieces-grid {
            display: block;
        }

        .set-piece-row {
            display: flex;
            align-items: center;
            padding: 6px 8px;
            margin-bottom: 4px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
            border-left: 2px solid #333;
        }

        .set-piece-row.owned {
            border-left-color: #20ff20;
            background: rgba(32, 255, 32, 0.05);
        }

        .set-piece-icon {
            width: 24px;
            text-align: center;
            font-size: 16px;
            margin-right: 10px;
        }

        .set-piece-row.owned .set-piece-icon {
            filter: none;
        }

        .set-piece-row:not(.owned) .set-piece-icon {
            filter: grayscale(100%) opacity(0.4);
        }

        .set-piece-name {
            flex: 1;
            font-size: 12px;
            color: #ccc;
        }

        .set-piece-row:not(.owned) .set-piece-name {
            color: #555;
        }

        .set-piece-status {
            font-size: 11px;
            color: #20ff20;
        }

        .set-piece-row:not(.owned) .set-piece-status {
            color: #444;
        }

        /* Set bonus preview */
        .set-bonuses {
            padding: 8px 12px;
            background: rgba(0, 0, 0, 0.2);
            border-top: 1px solid #222;
        }

        .set-bonus-row {
            display: flex;
            align-items: flex-start;
            padding: 4px 0;
            font-size: 11px;
        }

        .set-bonus-count {
            min-width: 24px;
            color: #888;
            margin-right: 8px;
        }

        .set-bonus-desc {
            color: #666;
            flex: 1;
        }

        .set-bonus-row.active .set-bonus-count {
            color: #20ff20;
        }

        .set-bonus-row.active .set-bonus-desc {
            color: #20ff20;
        }

        /* Expand/collapse icon */
        .set-card-toggle {
            color: #666;
            font-size: 10px;
            transition: transform 0.2s;
        }

        .set-card.expanded .set-card-toggle {
            transform: rotate(180deg);
        }

        /* ========== Codex tab system ========== */
        .codex-tabs {
            display: flex;
            gap: 5px;
            padding: 8px 10px;
            border-bottom: 1px solid #333;
            background: rgba(0, 0, 0, 0.3);
        }

        .codex-tab {
            flex: 1;
            padding: 8px 12px;
            text-align: center;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid #444;
            border-radius: 4px;
            font-size: 13px;
            color: #888;
            cursor: pointer;
            transition: all 0.15s;
        }

        .codex-tab:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: #666;
        }

        .codex-tab.active {
            background: rgba(199, 179, 119, 0.2);
            border-color: var(--text-gold);
            color: var(--text-gold);
        }

        .codex-content {
            display: none;
        }

        .codex-content.active {
            display: block;
        }

        /* ========== Monster codex ========== */
        .monster-codex-header {
            padding: 10px 12px;
            border-bottom: 1px solid #333;
            margin-bottom: 10px;
        }

        .monster-codex-stats {
            color: var(--text-gold);
            font-size: 12px;
        }

        .monster-section-title {
            padding: 8px 12px;
            color: #888;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 1px;
            border-bottom: 1px solid #222;
            margin: 10px 0 5px;
        }

        .monster-section-title.boss {
            color: #ff6600;
        }

        /* Monster card */
        .monster-card {
            display: flex;
            align-items: center;
            padding: 10px 12px;
            margin: 0 10px 8px;
            background: rgba(0, 0, 0, 0.4);
            border: 1px solid #333;
            border-radius: 6px;
            transition: all 0.2s;
        }

        .monster-card:hover {
            border-color: #555;
            background: rgba(30, 30, 30, 0.6);
        }

        .monster-card.discovered {
            border-left: 3px solid #20ff20;
        }

        .monster-card.boss.discovered {
            border-left-color: #ff6600;
        }

        .monster-card.locked {
            opacity: 0.5;
        }

        /* Monster icon container */
        .monster-icon {
            width: 48px;
            height: 48px;
            margin-right: 12px;
            background-color: rgba(0, 0, 0, 0.5);
            border-radius: 4px;
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .monster-icon canvas {
            image-rendering: pixelated;
        }

        .monster-card.locked .monster-icon {
            filter: grayscale(100%) brightness(0.3);
        }

        .monster-icon .unknown-icon {
            font-size: 24px;
            color: #444;
        }

        /* Monster info */
        .monster-info {
            flex: 1;
            min-width: 0;
        }

        .monster-name {
            font-size: 13px;
            font-weight: bold;
            color: #ccc;
            margin-bottom: 3px;
        }

        .monster-card.boss .monster-name {
            color: #ff6600;
        }

        .monster-card.locked .monster-name {
            color: #555;
        }

        .monster-desc {
            font-size: 11px;
            color: #666;
        }

        .monster-card.locked .monster-desc {
            color: #444;
        }

        .monster-floor {
            font-size: 10px;
            color: #888;
            margin-top: 2px;
        }

        /* Monster kill stats */
        .monster-kills {
            text-align: right;
            font-size: 11px;
            color: #888;
        }

        .monster-kills .count {
            font-size: 14px;
            color: #20ff20;
            font-weight: bold;
        }

        .monster-card.boss .monster-kills .count {
            color: #ff6600;
        }

        #stash-panel {
            top: 15%;
            right: 20px;
            left: auto;
            width: 350px;
        }

        .quest-item {
            border: 1px solid #444;
            padding: 10px;
            margin-bottom: 10px;
            background: rgba(0, 0, 0, 0.5);
        }

        .quest-title {
            color: var(--text-gold);
            font-weight: bold;
            margin-bottom: 5px;
        }

        .quest-status {
            font-size: 0.8em;
            color: #888;
        }

        .quest-status.completed {
            color: #00ff00;
        }

        #dialog-box {
            position: absolute;
            bottom: 160px;
            left: 50%;
            transform: translateX(-50%);
            width: 500px;
            background: rgba(0, 0, 0, 0.9);
            border: 2px solid var(--ui-border);
            padding: 20px;
            color: #ccc;
            display: none;
            z-index: 100;
            pointer-events: auto;
            /* 3D light and shadow */
            box-shadow:
                0 0 25px rgba(0, 0, 0, 0.9),
                0 10px 40px rgba(0, 0, 0, 0.6),
                inset 0 1px 0 rgba(255, 255, 255, 0.05),
                inset 0 0 50px rgba(0, 0, 0, 0.4);
        }

        .dialog-name {
            color: var(--text-gold);
            font-weight: bold;
            margin-bottom: 10px;
            font-size: 1.2em;
        }

        .dialog-text {
            margin-bottom: 20px;
            line-height: 1.5;
        }

        .dialog-options {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            flex-wrap: wrap;
        }

        /* With a floor list present, switch to vertical layout */
        .dialog-options:has(.portal-floor-list) {
            flex-direction: column;
            align-items: stretch;
        }

        .dialog-options:has(.portal-floor-list)>.dialog-btn {
            align-self: flex-end;
        }

        .dialog-btn {
            background: #333;
            border: 1px solid #555;
            color: #fff;
            padding: 5px 15px;
            cursor: pointer;
            font-family: var(--font-ui);
        }

        .dialog-btn:hover {
            border-color: var(--text-gold);
            color: var(--text-gold);
        }

        /* Portal floor list */
        .portal-floor-list {
            max-height: 200px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 5px;
            margin-bottom: 10px;
            padding-right: 5px;
        }

        /* Widen the dialog when a floor list is present */
        #dialog-box:has(.portal-floor-list) {
            width: 300px;
        }

        .portal-floor-list::-webkit-scrollbar {
            width: 6px;
        }

        .portal-floor-list::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 3px;
        }

        .portal-floor-list::-webkit-scrollbar-thumb {
            background: #555;
            border-radius: 3px;
        }

        .portal-floor-btn {
            width: 100%;
            text-align: left;
            padding: 8px 12px;
        }

        .drop-label {
            position: absolute;
            background: rgba(4, 5, 8, 0.82);
            padding: 3px 7px;
            border: 1px solid rgba(255, 255, 255, 0.16);
            border-radius: 4px;
            font-size: 12px;
            line-height: 1.15;
            cursor: pointer;
            transform: translate(-50%, -50%);
            z-index: 10;
            pointer-events: auto;
            text-shadow: 0 1px 2px #000, 0 0 4px #000;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
            white-space: nowrap;
        }

        .drop-label:hover {
            background: rgba(50, 50, 50, 0.9);
            border-color: #666;
        }

        #tooltip {
            position: absolute;
            background: rgba(5, 5, 8, 0.95);
            border: 1px solid var(--text-gold);
            padding: 10px;
            pointer-events: auto;
            /* Allow mouse interaction (share button, hover kept) */
            z-index: 99999;
            display: none;
            max-width: 320px;
            font-size: 14px;
            /* 3D light and shadow */
            box-shadow:
                0 0 20px rgba(0, 0, 0, 0.9),
                0 5px 25px rgba(0, 0, 0, 0.7),
                inset 0 1px 0 rgba(255, 255, 255, 0.05),
                inset 0 0 30px rgba(0, 0, 0, 0.4);
        }

        .tooltip-title {
            font-weight: bold;
            margin-bottom: 5px;
        }

        .tooltip-type {
            color: #888;
            font-size: 12px;
            margin-bottom: 5px;
        }

        .tooltip-stat {
            color: #aaa;
            display: block;
        }

        /* Tooltip close button (mobile) */
        .tooltip-close {
            position: absolute;
            top: 5px;
            right: 8px;
            width: 20px;
            height: 20px;
            line-height: 18px;
            text-align: center;
            color: #888;
            font-size: 16px;
            cursor: pointer;
            border-radius: 50%;
            transition: all 0.2s;
        }

        .tooltip-close:hover {
            color: #fff;
            background: rgba(255, 255, 255, 0.1);
        }

        /* Tooltip share button */
        .tooltip-share-btn {
            margin-top: 10px;
            padding: 6px 10px;
            background: linear-gradient(180deg, #2a4a2a 0%, #1a3a1a 100%);
            border: 1px solid #3a5a3a;
            border-radius: 4px;
            color: #8f8;
            font-size: 11px;
            text-align: center;
            cursor: pointer;
            transition: all 0.15s;
        }

        .tooltip-share-btn:hover {
            background: linear-gradient(180deg, #3a6a3a 0%, #2a5a2a 100%);
            border-color: #4a7a4a;
            color: #afa;
        }

        .tooltip-share-btn:active {
            transform: scale(0.97);
        }

        /* Allow clicks when the tooltip is locked on mobile */
        #tooltip.locked {
            pointer-events: auto;
        }

        /* ========== Gear comparison view ========== */
        .tooltip-compare {
            display: flex;
            gap: 12px;
        }

        .tooltip-col {
            flex: 1;
            min-width: 110px;
        }

        .tooltip-col-header {
            font-size: 10px;
            color: #888;
            text-align: center;
            padding-bottom: 3px;
            margin-bottom: 5px;
            border-bottom: 1px solid #444;
        }

        .tooltip-col-left .tooltip-col-header {
            color: #c7b377;
        }

        .tooltip-col .tooltip-title {
            font-size: 12px;
            text-align: center;
            margin-bottom: 3px;
        }

        .tooltip-col .tooltip-stat {
            font-size: 11px;
            padding: 1px 0;
        }

        /* Stat comparison: better/worse/missing */
        .stat-better {
            color: #00ff00 !important;
        }

        .stat-worse {
            color: #ff4444 !important;
        }

        .stat-missing {
            color: #555 !important;
        }

        /* Delta display */
        .stat-diff {
            font-size: 0.85em;
            opacity: 0.8;
        }

        /* Requirements row in compare mode */
        .tooltip-req {
            margin-top: 8px;
            padding-top: 5px;
            border-top: 1px solid #444;
            font-size: 11px;
            color: #888;
            text-align: center;
        }

        #notification-area {
            position: absolute;
            top: 60px;
            left: 50%;
            transform: translateX(-50%);
            color: var(--text-gold);
            font-size: 16px;
            text-shadow: 0 0 5px #000;
            pointer-events: none;
            transition: opacity 0.5s;
            opacity: 1;
            text-align: center;
            z-index: 2000;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 8px;
            width: max-content;
            max-width: 92vw;
        }

        #standard-notify-slot {
            color: var(--text-gold);
            font-size: 16px;
            text-shadow: 0 0 5px #000;
            transition: opacity 0.5s;
            opacity: 0;
            text-align: center;
            pointer-events: none;
        }

        /* ========== Achievement unlock slide-in banner ========== */
        .achievement-notify-slot {
            display: flex;
            flex-direction: column;
            align-items: center;
            pointer-events: none;
            width: 100%;
        }

        .achievement-unlock-banner {
            position: relative;
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 10px 18px 10px 12px;
            min-width: 320px;
            max-width: 480px;
            background: linear-gradient(135deg, rgba(28, 20, 14, 0.97) 0%, rgba(16, 12, 10, 0.98) 50%, rgba(34, 23, 13, 0.97) 100%);
            border: 1.5px solid #d4af37;
            border-radius: 6px;
            box-shadow: 0 0 25px rgba(212, 175, 55, 0.4), 
                        inset 0 0 15px rgba(212, 175, 55, 0.18),
                        0 10px 30px rgba(0, 0, 0, 0.85);
            pointer-events: none;
            overflow: hidden;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            box-sizing: border-box;
            text-align: left;
            margin: 0 auto;
            will-change: transform, opacity, filter;
        }

        /* Enter slide-in animation */
        .achievement-unlock-banner.achievement-slide-in {
            animation: achievementSlideIn 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
        }

        /* Exit slide-out animation */
        .achievement-unlock-banner.achievement-slide-out {
            animation: achievementSlideOut 0.45s cubic-bezier(0.7, 0, 0.84, 0) forwards;
        }

        @keyframes achievementSlideIn {
            0% {
                transform: translateY(-55px) scale(0.85);
                opacity: 0;
                filter: brightness(2.2) drop-shadow(0 0 25px rgba(255, 215, 0, 0.9));
            }
            55% {
                transform: translateY(8px) scale(1.03);
                opacity: 1;
                filter: brightness(1.25) drop-shadow(0 8px 30px rgba(255, 215, 0, 0.75));
            }
            78% {
                transform: translateY(-2px) scale(0.99);
                filter: brightness(1.1) drop-shadow(0 6px 20px rgba(212, 175, 55, 0.6));
            }
            100% {
                transform: translateY(0) scale(1);
                opacity: 1;
                filter: brightness(1) drop-shadow(0 8px 24px rgba(0, 0, 0, 0.85));
            }
        }

        @keyframes achievementSlideOut {
            0% {
                transform: translateY(0) scale(1);
                opacity: 1;
                filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.85));
            }
            100% {
                transform: translateY(-35px) scale(0.9);
                opacity: 0;
                filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
            }
        }

        /* Golden shimmer sweep */
        .ach-banner-shimmer {
            position: absolute;
            top: 0;
            left: -150%;
            width: 70%;
            height: 100%;
            background: linear-gradient(
                105deg,
                transparent 20%,
                rgba(255, 235, 170, 0.05) 35%,
                rgba(255, 235, 170, 0.45) 50%,
                rgba(255, 235, 170, 0.05) 65%,
                transparent 80%
            );
            transform: skewX(-25deg);
            pointer-events: none;
            animation: achievementShimmerSweep 2.5s ease-in-out 0.35s infinite;
        }

        @keyframes achievementShimmerSweep {
            0% { left: -120%; }
            40%, 100% { left: 180%; }
        }

        /* Golden emblem icon frame */
        .ach-banner-icon-box {
            position: relative;
            width: 44px;
            height: 44px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            background: radial-gradient(circle, rgba(70, 50, 22, 0.95) 0%, rgba(20, 14, 8, 0.98) 100%);
            border: 1.5px solid #e5c158;
            border-radius: 50%;
            box-shadow: 0 0 14px rgba(255, 215, 0, 0.55), inset 0 0 10px rgba(255, 215, 0, 0.3);
        }

        .ach-banner-icon {
            font-size: 24px;
            line-height: 1;
            filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
            animation: achIconFloat 2s ease-in-out infinite alternate;
        }

        @keyframes achIconFloat {
            0% { transform: scale(1); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8)); }
            100% { transform: scale(1.12); filter: drop-shadow(0 0 10px rgba(255, 220, 100, 0.95)); }
        }

        .ach-banner-icon-ring {
            position: absolute;
            top: -4px;
            left: -4px;
            right: -4px;
            bottom: -4px;
            border: 1px dashed rgba(255, 215, 0, 0.45);
            border-radius: 50%;
            animation: achRingRotate 14s linear infinite;
        }

        @keyframes achRingRotate {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Banner text layout */
        .ach-banner-content {
            display: flex;
            flex-direction: column;
            gap: 3px;
            min-width: 0;
            flex: 1;
        }

        .ach-banner-kicker {
            display: flex;
            align-items: center;
            gap: 6px;
            font-size: 11px;
            letter-spacing: 1.8px;
            text-transform: uppercase;
            font-weight: 700;
            color: #f5d47a;
            text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
            line-height: 1.2;
        }

        .ach-kicker-star {
            font-size: 10px;
            color: #ffe082;
            animation: achStarTwinkle 1.6s ease-in-out infinite alternate;
        }

        @keyframes achStarTwinkle {
            0% { opacity: 0.6; transform: scale(0.9); }
            100% { opacity: 1; transform: scale(1.2); }
        }

        .ach-banner-title {
            font-size: 16px;
            font-weight: bold;
            color: #fffaf0;
            text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 2px 4px #000;
            letter-spacing: 0.5px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.3;
        }

        .ach-banner-desc {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            font-size: 12px;
            color: #c7b377;
            line-height: 1.2;
        }

        .ach-banner-desc-text {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: #bda773;
        }

        .ach-banner-reward {
            font-weight: 700;
            color: #ffd700;
            background: rgba(255, 215, 0, 0.12);
            border: 1px solid rgba(255, 215, 0, 0.4);
            border-radius: 3px;
            padding: 1px 6px;
            font-size: 11px;
            white-space: nowrap;
            flex-shrink: 0;
            text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
        }

        /* Corner gold ornaments */
        .ach-banner-corner {
            position: absolute;
            width: 6px;
            height: 6px;
            pointer-events: none;
        }
        .ach-banner-corner.top-left {
            top: 2px;
            left: 2px;
            border-top: 2px solid #ffd700;
            border-left: 2px solid #ffd700;
        }
        .ach-banner-corner.top-right {
            top: 2px;
            right: 2px;
            border-top: 2px solid #ffd700;
            border-right: 2px solid #ffd700;
        }
        .ach-banner-corner.bottom-left {
            bottom: 2px;
            left: 2px;
            border-bottom: 2px solid #ffd700;
            border-left: 2px solid #ffd700;
        }
        .ach-banner-corner.bottom-right {
            bottom: 2px;
            right: 2px;
            border-bottom: 2px solid #ffd700;
            border-right: 2px solid #ffd700;
        }

        /* Reduced motion and mobile fit */
        @media (prefers-reduced-motion: reduce) {
            .achievement-unlock-banner.achievement-slide-in {
                animation: achFadeIn 0.3s ease forwards;
            }
            .achievement-unlock-banner.achievement-slide-out {
                animation: achFadeOut 0.3s ease forwards;
            }
            .ach-banner-shimmer,
            .ach-banner-icon,
            .ach-banner-icon-ring,
            .ach-kicker-star {
                animation: none;
            }
        }
        @keyframes achFadeIn {
            0% { opacity: 0; }
            100% { opacity: 1; }
        }
        @keyframes achFadeOut {
            0% { opacity: 1; }
            100% { opacity: 0; }
        }

        @media (max-width: 768px) {
            .achievement-unlock-banner {
                min-width: 270px;
                max-width: 90vw;
                padding: 8px 14px 8px 10px;
                gap: 10px;
            }
            .ach-banner-icon-box {
                width: 36px;
                height: 36px;
            }
            .ach-banner-icon {
                font-size: 20px;
            }
            .ach-banner-title {
                font-size: 14px;
            }
            .ach-banner-desc {
                font-size: 11px;
            }
        }

        #interaction-msg {
            position: absolute;
            top: 70%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: #fff;
            font-size: 18px;
            font-weight: bold;
            text-shadow: 0 0 5px #000;
            pointer-events: none;
            display: none;
            z-index: 100;
            background: rgba(0, 0, 0, 0.7);
            padding: 8px 16px;
            border: 1px solid #c7b377;
            border-radius: 4px;
            font-family: var(--font-ui);
        }

        #floor-display {
            position: absolute;
            top: 50px;
            /* Was 20px; made room for the announcement bar */
            left: 20px;
            color: #bbb;
            font-size: 1.4em;
            font-weight: bold;
            text-shadow: 2px 2px 0 #000;
            pointer-events: none;
            z-index: 10;
        }

        /* Quest tracker sits at the lower left */
        #quest-tracker {
            position: absolute;
            top: 90px;
            /* Was 60px; made room for the announcement bar */
            left: 20px;
            text-align: left;
            pointer-events: none;
            z-index: 10;
            max-width: 300px;
        }

        .tracker-title {
            color: #c7b377;
            font-weight: bold;
            font-size: 14px;
            text-shadow: 1px 1px 0 #000;
        }

        .tracker-desc {
            color: #aaa;
            font-size: 12px;
            margin-top: 2px;
            text-shadow: 1px 1px 0 #000;
        }

        .menu-btns {
            position: absolute;
            bottom: 150px;
            right: 20px;
            display: flex;
            flex-direction: column;
            gap: 7px;
            pointer-events: auto;
        }

        .mobile-fab {
            display: none;
            position: absolute;
            width: 46px;
            height: 46px;
            border-radius: 50%;
            border: 1px solid rgba(199, 179, 119, 0.76);
            background:
                radial-gradient(circle at 32% 24%, rgba(255, 235, 178, 0.18), transparent 34%),
                linear-gradient(180deg, rgba(49, 42, 32, 0.96), rgba(9, 9, 10, 0.98));
            color: #ead7a9;
            font-family: var(--font-ui);
            font-size: 20px;
            font-weight: 700;
            align-items: center;
            justify-content: center;
            pointer-events: auto;
            z-index: 92;
            box-shadow:
                0 6px 18px rgba(0, 0, 0, 0.72),
                inset 0 1px 0 rgba(255, 235, 190, 0.16);
        }

        .mobile-fab:active {
            transform: translateY(1px) scale(0.96);
            filter: brightness(0.9);
        }

        #mobile-menu-toggle {
            right: 12px;
            bottom: 138px;
        }

        #mobile-chat-toggle {
            left: 12px;
            bottom: 138px;
        }

        .mobile-fab-dot {
            position: absolute;
            top: 6px;
            right: 6px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #ff3333;
            box-shadow: 0 0 8px rgba(255, 48, 48, 0.9);
            display: none;
        }

        .sys-btn {
            background:
                linear-gradient(180deg, rgba(49, 42, 32, 0.96), rgba(13, 13, 14, 0.98));
            border: 1px solid var(--ui-metal-edge);
            border-radius: 4px;
            color: #c9b88b;
            padding: 7px 12px;
            cursor: pointer;
            font-family: var(--font-ui);
            font-size: 13px;
            font-weight: 500;
            position: relative;
            min-width: 92px;
            text-align: left;
            text-shadow: 0 1px 2px #000;
            box-shadow:
                0 3px 10px rgba(0, 0, 0, 0.55),
                inset 0 1px 0 rgba(255, 235, 190, 0.12),
                inset 0 -8px 13px rgba(0, 0, 0, 0.48);
            transition: transform 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
        }

        .sys-btn:hover {
            border-color: var(--ui-metal-hi);
            color: #f0dca8;
            transform: translateX(-2px);
            box-shadow:
                0 4px 14px rgba(0, 0, 0, 0.65),
                0 0 12px rgba(199, 179, 119, 0.18),
                inset 0 1px 0 rgba(255, 235, 190, 0.18),
                inset 0 -8px 13px rgba(0, 0, 0, 0.48);
        }

        .sys-btn:active {
            transform: translateX(-1px) translateY(1px);
            filter: brightness(0.86);
        }

        .notification-badge {
            position: absolute;
            top: -3px;
            right: -3px;
            width: 10px;
            height: 10px;
            background-color: #ff3333;
            border-radius: 50%;
            box-shadow: 0 0 4px #ff0000;
            display: none;
        }

        #start-screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #000;
            z-index: 200;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            pointer-events: auto;
            overflow: hidden;
        }

        /* Login cover */
        #start-screen picture,
        #start-screen-bg {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
            object-fit: cover;
            object-position: center top;
        }



        /* Light overlay keeps login text readable */
        #start-screen::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(180deg, rgba(3, 12, 16, .12), rgba(3, 12, 16, .04) 60%, rgba(3, 12, 16, .25));
            z-index: 0;
        }

        #start-screen>*:not(img):not(picture) {
            position: relative;
            z-index: 1;
            transform: translateY(18px);
        }

        #start-screen > .login-brand {
            position: absolute;
            top: 12%;
            left: 0;
            width: 100%;
            text-align: center;
            transform: none;
            pointer-events: none;
        }

        .login-brand h1 {
            margin: 0;
            color: #f2d79b;
            font-family: var(--font-ui);
            font-size: clamp(42px, 7vw, 78px);
            font-weight: 900;
            letter-spacing: .12em;
            padding-left: .12em;
            text-shadow: 0 3px 0 #573919, 0 6px 24px #000;
        }

        .login-brand p {
            margin: 10px 0 0;
            color: #c2ad84;
            font: 600 13px Georgia, serif;
            letter-spacing: .48em;
            padding-left: .48em;
        }

        #start-screen .start-btn {
            border-color: #ac8248;
            border-radius: 6px;
            background: linear-gradient(#392d20, #1c1915);
            color: #f4dfb6;
            box-shadow: inset 0 0 0 2px #171411, 0 5px 22px #0008;
        }

        #start-screen .start-btn:hover:not(.disabled) {
            background: linear-gradient(#594126, #2d231a);
            border-color: #e3bd77;
        }

        @media (max-width: 768px) and (orientation: portrait) {
            #start-screen > .login-brand { top: 17%; }
            #start-screen #welcome-back { font-size: 16px; }
            #start-screen .start-btn { font-size: 21px; padding: 14px 30px; }
        }

        @media (max-height: 480px) {
            #start-screen > .login-brand { top: 4%; }
            .login-brand h1 { font-size: 38px; }
            .login-brand p { margin-top: 4px; font-size: 10px; }
            #start-screen .start-btn { margin-top: 10px; padding: 10px 28px; font-size: 20px; }
        }

        #floating-texts-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 10000;
            /* Ensure topmost layer */
        }

        .floating-text {
            position: absolute;
            font-weight: bold;
            font-size: 14px;
            text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
            pointer-events: none;
            transform: translate(-50%, -50%);
            transition: none;
        }

        h1 {
            color: #8a0e0e;
            font-size: 4em;
            margin-bottom: 0;
            text-shadow: 0 0 20px #ff0000;
            letter-spacing: 5px;
        }

        h2 {
            color: #555;
            margin-top: 0;
            font-size: 1.2em;
        }

        #welcome-back {
            color: #ffcc00;
            font-size: 1.2em;
            font-family: var(--font-ui);
            text-shadow: 0 0 10px #ff6600;
        }

        .start-btn {
            margin-top: 20px;
            padding: 15px 40px;
            background: #111;
            border: 2px solid #8a0e0e;
            color: #ccc;
            font-size: 1.5em;
            cursor: pointer;
            font-family: var(--font-ui);
            transition: all 0.3s;
        }

        .start-btn:hover {
            background: #8a0e0e;
            color: #000;
            box-shadow: 0 0 30px #8a0e0e;
        }

        /* Disabled state while the save system is not ready */
        .start-btn.disabled {
            opacity: 0.5;
            cursor: not-allowed;
            border-color: #444;
        }

        .start-btn.disabled:hover {
            background: #111;
            color: #ccc;
            box-shadow: none;
        }

        .reset-btn {
            margin-top: 20px;
            padding: 8px 15px;
            background: #220000;
            border: 1px solid #500;
            color: #888;
            font-size: 0.9em;
            cursor: pointer;
            font-family: var(--font-ui);
        }

        .reset-btn:hover {
            background: #400;
            color: #fff;
        }

        /* Settings */
        .settings-box {
            margin-top: 20px;
            display: flex;
            gap: 20px;
        }

        .setting-item {
            color: #fff;
            font-size: 14px;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        .setting-item:hover {
            color: #fff;
        }

        .setting-item input {
            cursor: pointer;
        }

        /* Sell toast fade-out animation */
        @keyframes fadeOut {
            0% {
                opacity: 1;
            }

            70% {
                opacity: 1;
            }

            100% {
                opacity: 0;
            }
        }

        /* Auto battle button container */
        .auto-battle-container {
            position: absolute;
            top: 210px;
            right: 20px;
            display: flex;
            align-items: center;
            gap: 4px;
            z-index: 50;
        }

        .auto-battle-btn {
            padding: 7px 12px;
            background: rgba(40, 40, 40, 0.9);
            border: 2px solid #555;
            border-radius: 5px 0 0 5px;
            color: #888;
            font-size: 12px;
            cursor: pointer;
            pointer-events: auto;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .auto-battle-btn:hover {
            background: rgba(60, 60, 60, 0.95);
            border-color: #777;
        }

        .auto-battle-btn.active {
            background: rgba(200, 80, 80, 0.9);
            border-color: #ff4444;
            color: #fff;
            box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
        }

        .auto-battle-btn.active:hover {
            background: rgba(220, 100, 100, 0.95);
        }

        .auto-battle-settings-btn {
            padding: 10px 12px;
            background: rgba(40, 40, 40, 0.9);
            border: 2px solid #555;
            border-radius: 0 5px 5px 0;
            color: #888;
            font-size: 14px;
            cursor: pointer;
            pointer-events: auto;
            transition: all 0.3s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .auto-battle-settings-btn:hover {
            background: rgba(60, 60, 60, 0.95);
            border-color: #777;
            color: #ffcc00;
        }

        #auto-battle-icon {
            font-size: 18px;
        }

        #auto-battle-text {
            font-weight: bold;
        }

        /* Auto battle hire cost HUD */
        .auto-battle-fee-hud {
            display: none;
            position: absolute;
            top: 100%;
            right: 0;
            margin-top: 5px;
            padding: 6px 10px;
            background: rgba(40, 40, 40, 0.9);
            border: 1px solid #555;
            border-radius: 4px;
            font-size: 12px;
            color: #ccc;
            white-space: nowrap;
        }

        .auto-battle-fee-hud.active {
            display: block;
        }

        .auto-battle-fee-hud span {
            color: #ffd700;
        }

        /* Custom checkbox styles */
        .checkbox-label {
            position: relative;
            display: inline-block;
            cursor: pointer;
        }

        .checkbox-label input[type="checkbox"] {
            position: absolute;
            opacity: 0;
            cursor: pointer;
            width: 0;
            height: 0;
        }



        /* Slider style polish */
        input[type="range"] {
            -webkit-appearance: none;
            appearance: none;
            width: 120px;
            height: 6px;
            background: #333;
            border-radius: 3px;
            outline: none;
            margin-right: 10px;
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 16px;
            height: 16px;
            background: #ff4444;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.2s;
        }

        input[type="range"]::-webkit-slider-thumb:hover {
            background: #ff6666;
            transform: scale(1.1);
        }

        input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            background: #ff4444;
            border-radius: 50%;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
        }

        input[type="range"]::-moz-range-thumb:hover {
            background: #ff6666;
            transform: scale(1.1);
        }

        /* Online system styles */
        #nickname-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.9);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 9999;
        }

        .nickname-dialog {
            background: rgba(20, 20, 25, 0.95);
            border: 2px solid #4a3b2a;
            padding: 30px 40px;
            text-align: center;
            border-radius: 8px;
        }

        .nickname-title {
            color: #c7b377;
            font-size: 20px;
            margin-bottom: 10px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .nickname-desc {
            color: #888;
            font-size: 14px;
            margin-bottom: 20px;
        }

        .nickname-error {
            color: #ff4444;
            font-size: 12px;
            margin-bottom: 15px;
            display: none;
        }

        /* ========== Cloud sync styles ========== */
        .cloud-sync-bar {
            margin-top: 15px;
            font-family: var(--font-ui);
            display: flex;
            align-items: center;
            gap: 15px;
            background: rgba(0, 0, 0, 0.6);
            padding: 8px 15px;
            border: 1px solid #444;
            border-radius: 4px;
            transition: all 0.3s;
        }

        .cloud-sync-bar.bound {
            border-color: #44aa44;
            background: rgba(0, 30, 0, 0.6);
        }

        .cloud-icon {
            font-size: 18px;
        }

        #cloud-sync-status {
            color: #ccc;
            font-size: 14px;
        }

        .cloud-btn {
            background: #222;
            border: 1px solid #555;
            color: #aaa;
            padding: 4px 10px;
            cursor: pointer;
            font-size: 12px;
            border-radius: 3px;
        }

        .cloud-btn:hover {
            border-color: #c7b377;
            color: #c7b377;
            background: #333;
        }

        .sync-code-value {
            color: #ffd700;
            font-family: monospace;
            font-size: 14px;
            letter-spacing: 1px;
            margin: 0 5px;
            user-select: text;
        }

        .copy-hint {
            color: #888;
            font-size: 10px;
            cursor: pointer;
            text-decoration: underline;
        }

        .copy-hint:hover {
            color: #fff;
        }

        /* Cloud sync dialog base */
        .cloud-dialog-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            z-index: 3000;
            display: none;
            justify-content: center;
            align-items: center;
        }

        .cloud-dialog-overlay.active {
            display: flex;
        }

        .cloud-dialog {
            background: #111;
            border: 1px solid #c7b377;
            width: 400px;
            max-width: 90%;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
            position: relative;
        }

        .cloud-dialog-header {
            background: #1a1a1a;
            padding: 10px 15px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid #333;
            color: #c7b377;
            font-weight: bold;
        }

        .cloud-dialog-close {
            cursor: pointer;
            font-size: 20px;
            color: #888;
        }

        .cloud-dialog-close:hover {
            color: #fff;
        }

        .cloud-dialog-body {
            padding: 20px;
            color: #ccc;
        }

        .cloud-error {
            background: rgba(255, 68, 68, 0.1);
            border: 1px solid #ff4444;
            color: #ff4444;
            padding: 8px;
            margin-bottom: 15px;
            font-size: 12px;
            text-align: center;
        }

        /* Unified cloud sync panel styles */
        .nickname-title {
            color: var(--text-gold);
            font-size: 18px;
            font-weight: bold;
            text-align: center;
            margin-bottom: 5px;
            font-family: var(--font-ui);
        }

        .nickname-desc {
            color: #888;
            font-size: 13px;
            text-align: center;
            margin-bottom: 20px;
        }

        .nickname-error {
            color: #ff4444;
            font-size: 12px;
            text-align: center;
            margin-bottom: 10px;
            min-height: 15px;
        }

        /* Shared styles for new user/admin options */
        .cloud-start-options {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .cloud-start-option {
            background: rgba(20, 20, 20, 0.8);
            border: 1px solid #444;
            padding: 15px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            border-radius: 4px;
        }

        .cloud-start-option:hover {
            background: rgba(40, 40, 40, 0.9);
            border-color: var(--text-gold);
            box-shadow: 0 0 10px rgba(199, 179, 119, 0.2);
        }

        .cloud-start-option.restore {
            cursor: default;
        }

        .cloud-start-option.restore:hover {
            border-color: #444;
            background: rgba(20, 20, 20, 0.8);
            box-shadow: none;
        }

        .cloud-start-title {
            color: #fff;
            font-weight: bold;
            margin-bottom: 5px;
            font-size: 15px;
        }

        .cloud-start-desc {
            color: #888;
            font-size: 12px;
        }

        .cloud-start-divider {
            text-align: center;
            color: #666;
            font-size: 12px;
            margin: 5px 0;
            position: relative;
        }

        .cloud-start-divider::before,
        .cloud-start-divider::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 40%;
            height: 1px;
            background: #333;
        }

        .cloud-start-divider::before {
            left: 0;
        }

        .cloud-start-divider::after {
            right: 0;
        }

        /* Unified polish for inner inputs and buttons */
        .cloud-start-option input {
            display: block;
            width: 100%;
            padding: 12px;
            margin-top: 15px;
            font-size: 16px;
            background: #000;
            border: 1px solid #444;
            color: var(--text-gold);
            text-align: center;
            text-transform: uppercase;
            letter-spacing: 2px;
            border-radius: 4px;
            box-sizing: border-box;
            font-family: monospace;
        }

        .cloud-start-option input:focus {
            outline: none;
            border-color: var(--text-gold);
            box-shadow: 0 0 5px rgba(199, 179, 119, 0.3);
        }

        .cloud-start-option button {
            display: block;
            width: 100%;
            margin-top: 10px;
            padding: 12px;
            background: #2a2a2a;
            border: 1px solid #555;
            color: var(--text-gold);
            font-size: 15px;
            cursor: pointer;
            font-family: var(--font-ui);
            border-radius: 4px;
            transition: all 0.2s;
        }

        .cloud-start-option button:hover {
            background: #3a3a3a;
            border-color: var(--text-gold);
        }

        /* Recovery dialog */
        .cloud-restore-form {
            text-align: center;
        }

        .cloud-restore-desc {
            margin-bottom: 15px;
            color: #aaa;
        }

        /* Conflict comparison panel */
        .conflict-dialog {
            width: 600px;
        }

        .conflict-content {
            padding: 20px;
            text-align: center;
        }

        .conflict-title {
            font-size: 18px;
            color: #ff4444;
            margin-bottom: 10px;
            font-weight: bold;
        }

        .conflict-desc {
            color: #aaa;
            margin-bottom: 20px;
        }

        .conflict-compare {
            display: flex;
            justify-content: space-between;
            align-items: stretch;
            margin-bottom: 25px;
            background: #1a1a1a;
            padding: 15px;
            border: 1px solid #333;
        }

        .conflict-side {
            flex: 1;
        }

        .conflict-vs {
            width: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            color: #666;
            font-size: 14px;
        }

        .conflict-side-title {
            color: #c7b377;
            margin-bottom: 10px;
            font-size: 14px;
            border-bottom: 1px solid #444;
            padding-bottom: 5px;
        }

        .conflict-slot {
            font-size: 12px;
            padding: 5px 0;
            border-bottom: 1px dashed #333;
            color: #ddd;
            text-align: left;
        }

        .conflict-slot.empty {
            color: #666;
        }

        .conflict-actions {
            display: flex;
            gap: 20px;
            justify-content: center;
            margin-bottom: 15px;
        }

        .conflict-btn {
            padding: 8px 20px;
            background: #333;
            border: 1px solid #555;
            color: #fff;
            cursor: pointer;
        }

        .conflict-btn:hover {
            border-color: #c7b377;
            color: #c7b377;
        }

        .conflict-btn.danger {
            border-color: #ff4444;
            color: #ff8888;
        }

        .conflict-btn.danger:hover {
            background: #300;
        }

        .conflict-cancel {
            background: none;
            border: none;
            color: #666;
            cursor: pointer;
            text-decoration: underline;
        }

        .conflict-cancel:hover {
            color: #888;
        }

        .conflict-warning {
            color: #ff4444;
            font-size: 12px;
            margin-bottom: 15px;
            background: rgba(255, 0, 0, 0.1);
            padding: 5px;
        }

        #nickname-input {
            padding: 10px 15px;
            font-size: 16px;
            background: #111;
            border: 1px solid #444;
            color: #fff;
            text-align: center;
            border-radius: 4px;
            font-family: var(--font-ui);
        }

        #nickname-input:focus {
            outline: none;
            border-color: #c7b377;
        }

        #nickname-confirm {
            display: block;
            width: 100%;
            margin-top: 15px;
            padding: 10px;
            background: #333;
            border: 1px solid #555;
            color: #c7b377;
            font-size: 16px;
            cursor: pointer;
            font-family: var(--font-ui);
            border-radius: 4px;
        }

        #nickname-confirm:hover {
            background: #444;
            border-color: #c7b377;
        }

        .nickname-back-btn {
            display: block;
            width: 100%;
            margin-top: 10px;
            padding: 8px;
            background: transparent;
            border: 1px solid #444;
            color: #888;
            font-size: 14px;
            cursor: pointer;
            font-family: var(--font-ui);
            border-radius: 4px;
        }

        .nickname-back-btn:hover {
            background: #222;
            border-color: #666;
            color: #aaa;
        }

        #online-count {
            position: absolute;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            color: #88ff88;
            font-size: 14px;
            background: rgba(0, 0, 0, 0.7);
            padding: 5px 15px;
            border-radius: 15px;
            pointer-events: none;
            z-index: 50;
        }

        /* ========== Leaderboard styles ========== */
        .leaderboard-tabs {
            display: flex;
            justify-content: center;
            gap: 5px;
            margin: 10px 0;
            padding: 0 10px;
        }

        .lb-tab {
            padding: 6px 13px;
            background: rgba(40, 35, 30, 0.8);
            border: 1px solid #3a3530;
            color: #888;
            cursor: pointer;
            font-size: 12px;
            border-radius: 3px;
            transition: all 0.2s;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
        }

        .lb-tab:hover {
            background: rgba(60, 55, 50, 0.9);
            color: #aaa;
        }

        .lb-tab.active {
            background: rgba(80, 70, 50, 0.9);
            border-color: #c7b377;
            color: #c7b377;
        }

        /* Weekly/all-time top toggle */
        .leaderboard-mode-tabs {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin: 8px 0;
            padding: 0 10px;
        }

        .lb-mode-tab {
            padding: 8px 24px;
            background: rgba(30, 28, 25, 0.9);
            border: 2px solid #3a3530;
            color: #888;
            cursor: pointer;
            font-size: 14px;
            font-weight: bold;
            border-radius: 5px;
            transition: all 0.2s;
        }

        .lb-mode-tab:hover {
            background: rgba(50, 45, 40, 0.9);
            color: #aaa;
            border-color: #555;
        }

        .lb-mode-tab.active {
            background: linear-gradient(135deg, rgba(100, 80, 50, 0.9), rgba(70, 55, 35, 0.9));
            border-color: #c7b377;
            color: #ffd700;
            text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
        }

        /* Weekly countdown */
        .week-countdown {
            text-align: center;
            font-size: 11px;
            color: #888;
            margin: -5px 0 5px 0;
            padding: 3px;
            background: rgba(20, 18, 15, 0.6);
            border-radius: 3px;
            margin-left: 10px;
            margin-right: 10px;
        }

        .personal-best {
            background: rgba(30, 28, 25, 0.9);
            border: 1px solid #3a3530;
            border-radius: 5px;
            margin: 10px;
            padding: 10px;
        }

        .pb-title {
            color: #c7b377;
            font-size: 13px;
            text-align: center;
            margin-bottom: 8px;
            border-bottom: 1px solid #3a3530;
            padding-bottom: 5px;
        }

        .pb-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

        .pb-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 5px;
            background: rgba(20, 18, 15, 0.6);
            border-radius: 3px;
        }

        .pb-label {
            font-size: 10px;
            color: #666;
        }

        .pb-value {
            font-size: 14px;
            color: #ddd;
            font-weight: bold;
        }

        /* ========== Rarity glow - Unique/Set item breathing halo (GPU optimized) ========== */
        /* Pseudo-element + opacity animation instead of box-shadow; GPU-composited for better performance */

        /* Base style: all rarity cells need position:relative for pseudo-element placement */
        .bag-slot.rarity-unique,
        .bag-slot.rarity-set,
        .bag-slot.rarity-rare,
        .equip-slot.rarity-unique,
        .equip-slot.rarity-set,
        .equip-slot.rarity-rare {
            position: relative;
        }

        /* Pseudo-element halo layer - opacity animation (GPU-accelerated) */
        .bag-slot.rarity-unique::before,
        .bag-slot.rarity-set::before,
        .bag-slot.rarity-rare::before,
        .equip-slot.rarity-unique::before,
        .equip-slot.rarity-set::before,
        .equip-slot.rarity-rare::before {
            content: '';
            position: absolute;
            inset: 0;
            pointer-events: none;
            z-index: 1;
            will-change: opacity;
        }

        /* Unique item glow (rarity 3/4) - gold breathing halo */
        .bag-slot.rarity-unique::before,
        .equip-slot.rarity-unique::before {
            box-shadow: inset 0 0 15px rgba(199, 179, 119, 0.5),
                0 0 12px rgba(199, 179, 119, 0.4);
            animation: glowPulse 2.5s ease-in-out infinite;
        }

        /* Set item glow (rarity 5) - green breathing halo */
        .bag-slot.rarity-set::before,
        .equip-slot.rarity-set::before {
            box-shadow: inset 0 0 15px rgba(0, 255, 0, 0.5),
                0 0 12px rgba(0, 255, 0, 0.4);
            animation: glowPulse 2.5s ease-in-out infinite;
        }

        /* Rare item glow (rarity 2) - faint blue halo */
        .bag-slot.rarity-rare::before,
        .equip-slot.rarity-rare::before {
            box-shadow: inset 0 0 10px rgba(77, 148, 255, 0.3);
            animation: glowPulse 3s ease-in-out infinite;
        }

        /* Unified opacity pulse animation - GPU accelerated */
        @keyframes glowPulse {

            0%,
            100% {
                opacity: 0.4;
            }

            50% {
                opacity: 1;
            }
        }

        /* ========== Keyword highlight enhancement ========== */
        .tooltip-stat.fire-stat {
            text-shadow: 0 0 8px rgba(255, 68, 0, 0.6);
        }

        .tooltip-stat.cold-stat {
            text-shadow: 0 0 8px rgba(68, 136, 255, 0.6);
        }

        .tooltip-stat.lightning-stat {
            text-shadow: 0 0 8px rgba(255, 255, 68, 0.6);
        }

        .tooltip-stat.poison-stat {
            text-shadow: 0 0 8px rgba(68, 255, 68, 0.6);
        }

        /* ========== Insufficient requirements overlay ========== */
        .bag-slot.requirement-not-met,
        .equip-slot.requirement-not-met {
            position: relative;
        }

        .bag-slot.requirement-not-met::after,
        .equip-slot.requirement-not-met::after {
            content: '';
            position: absolute;
            top: 1px;
            left: 1px;
            right: 1px;
            bottom: 1px;
            background: rgba(180, 0, 0, 0.35);
            pointer-events: none;
            z-index: 2;
        }

        /* Red border when requirements unmet - removed; rarity color kept */
        /* .bag-slot.requirement-not-met {
            border-color: #882222 !important;
        } */

        /* ========== Info hierarchy - sans-serif for numbers ========== */

        /* Tooltip numbers use Roboto */
        .tooltip-stat {
            font-family: 'Roboto', sans-serif;
            font-size: 13px;
            letter-spacing: 0.3px;
        }

        .tooltip-type {
            font-family: 'Roboto', sans-serif;
        }

        /* Character panel numbers */
        .stat-row {
            font-family: 'Roboto', sans-serif;
        }

        .stat-row span:first-child {
            font-family: var(--font-ui);
        }

        /* HP/mana orb numbers */
        .orb-text {
            font-family: 'Roboto', sans-serif;
        }

        /* Item quantity */
        .item-count {
            font-family: 'Roboto', sans-serif;
        }

        /* Belt quantity */
        .belt-count {
            font-family: 'Roboto', sans-serif;
        }

        /* XP percentage */
        .xp-percentage {
            font-family: 'Roboto', sans-serif;
        }

        /* Achievement progress */
        .ach-progress {
            font-family: 'Roboto', sans-serif;
        }

        /* Shop price */
        .gamble-price {
            font-family: 'Roboto', sans-serif;
        }

        /* Settings Panel Tabs */
        .settings-tabs {
            display: flex;
            justify-content: space-around;
            margin-bottom: 15px;
            border-bottom: 1px solid #333;
            padding-bottom: 10px;
            margin-top: 5px;
        }

        .tab-btn {
            background: transparent;
            border: none;
            color: #888;
            font-family: inherit;
            font-size: 14px;
            cursor: pointer;
            padding: 5px 10px;
            position: relative;
            transition: color 0.2s;
        }

        .tab-btn:hover {
            color: #aeaeae;
        }

        .tab-btn.active {
            color: var(--text-gold);
            font-weight: bold;
        }

        .tab-btn.active::after {
            content: '';
            position: absolute;
            bottom: -11px;
            left: 0;
            width: 100%;
            height: 2px;
            background: var(--text-gold);
            box-shadow: 0 0 5px var(--text-gold);
        }

        .tab-content {
            animation: fadeIn 0.3s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        /* ========== Talent shop styles ========== */
        #talent-shop-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            pointer-events: auto;
        }

        #talent-shop-overlay.active {
            display: flex;
            animation: fadeIn 0.3s ease;
        }

        #talent-shop {
            background: linear-gradient(135deg, rgba(20, 20, 25, 0.98) 0%, rgba(10, 10, 15, 0.98) 100%);
            border: 2px solid #4a3b2a;
            border-radius: 8px;
            padding: 15px 18px;
            min-width: 340px;
            max-width: 380px;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
        }

        .talent-shop-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
            padding-bottom: 6px;
            border-bottom: 1px solid #4a3b2a;
        }

        .talent-shop-title {
            font-size: 15px;
            color: #c7b377;
            font-weight: bold;
        }

        .talent-shop-floor {
            font-size: 11px;
            color: #888;
        }

        .talent-shop-gold {
            text-align: center;
            font-size: 13px;
            color: gold;
            margin-bottom: 10px;
        }

        .talent-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 8px;
            margin-bottom: 10px;
        }

        .talent-card {
            background: rgba(30, 30, 35, 0.9);
            border: 2px solid #444;
            border-radius: 5px;
            padding: 8px 6px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            min-height: 90px;
        }

        .talent-card:hover {
            transform: translateY(-3px);
            border-color: #c7b377;
            box-shadow: 0 5px 20px rgba(199, 179, 119, 0.2);
        }

        .talent-card.owned {
            opacity: 0.5;
            cursor: not-allowed;
            border-color: #333;
        }

        .talent-card.owned::after {
            content: 'Owned';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) rotate(-15deg);
            font-size: 14px;
            color: #888;
            background: rgba(0, 0, 0, 0.8);
            padding: 5px 15px;
            border-radius: 3px;
        }

        .talent-card.cant-afford {
            opacity: 0.6;
        }

        .talent-card.cant-afford .talent-price {
            color: #ff4444;
        }

        .talent-card-icon {
            font-size: 24px;
            margin-bottom: 4px;
        }

        .talent-card-name {
            font-size: 11px;
            font-weight: bold;
            margin-bottom: 3px;
        }

        .talent-card-desc {
            font-size: 9px;
            color: #aaa;
            margin-bottom: 6px;
            line-height: 1.3;
        }

        .talent-price {
            font-size: 11px;
            color: gold;
            font-weight: bold;
        }

        /* Talent rarity border */
        .talent-card.tier-normal {
            border-color: #555;
        }

        .talent-card.tier-rare {
            border-color: #4850b8;
        }

        .talent-card.tier-epic {
            border-color: #a335ee;
            box-shadow: inset 0 0 20px rgba(163, 53, 238, 0.1);
        }

        .talent-card.tier-legendary {
            border-color: #ff8000;
            box-shadow: inset 0 0 20px rgba(255, 128, 0, 0.15);
            animation: legendaryPulse 2s ease-in-out infinite;
        }

        @keyframes legendaryPulse {

            0%,
            100% {
                box-shadow: inset 0 0 20px rgba(255, 128, 0, 0.15);
            }

            50% {
                box-shadow: inset 0 0 30px rgba(255, 128, 0, 0.3);
            }
        }

        .talent-shop-actions {
            display: flex;
            justify-content: center;
            gap: 10px;
        }

        .talent-btn {
            padding: 5px 12px;
            font-family: var(--font-ui);
            font-size: 11px;
            border: 1px solid #555;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .talent-btn-refresh {
            background: #2a2a30;
            color: #aaa;
        }

        .talent-btn-refresh:hover {
            background: #3a3a40;
            border-color: #c7b377;
            color: #c7b377;
        }

        .talent-btn-skip {
            background: #1a1a20;
            color: #888;
        }

        .talent-btn-skip:hover {
            background: #2a2a30;
            color: #ccc;
        }

        .refresh-cost {
            font-size: 11px;
            color: gold;
            margin-left: 5px;
        }

        /* Talent HUD (shows owned talents) */
        #talent-hud {
            position: absolute;
            top: 50px;
            right: 180px;
            display: flex;
            flex-direction: column;
            flex-wrap: wrap-reverse;
            align-content: flex-end;
            max-height: 104px;
            gap: 4px;
            z-index: 50;
            pointer-events: auto;
        }

        .talent-hud-icon {
            box-sizing: border-box;
            width: 32px;
            height: 32px;
            background: rgba(20, 20, 25, 0.9);
            border: 2px solid #444;
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
            cursor: default;
            transition: all 0.2s;
        }

        .talent-hud-icon:hover {
            transform: scale(1.1);
            border-color: #c7b377;
        }

        .talent-hud-icon.tier-normal {
            border-color: #555;
        }

        .talent-hud-icon.tier-rare {
            border-color: #4850b8;
        }

        .talent-hud-icon.tier-epic {
            border-color: #a335ee;
        }

        .talent-hud-icon.tier-legendary {
            border-color: #ff8000;
            animation: legendaryPulse 2s ease-in-out infinite;
        }

        /* ========== Divine Blessing styles ========== */
        .sys-btn.db-btn {
            border-color: #ffd700;
            color: #ffd700;
            animation: blessingPulse 2s ease-in-out infinite;
        }

        .sys-btn.db-btn:hover {
            border-color: #ffec80;
            color: #ffec80;
        }

        .db-count-badge {
            margin-left: 5px;
            background: #ffd700;
            color: #000;
            padding: 1px 6px;
            border-radius: 10px;
            font-size: 11px;
            font-weight: bold;
        }

        @keyframes blessingPulse {

            0%,
            100% {
                box-shadow: 0 0 5px rgba(255, 215, 0, 0.4);
            }

            50% {
                box-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
            }
        }

        .db-card {
            width: 140px;
            padding: 15px 12px;
            background: rgba(20, 20, 25, 0.9);
            border: 2px solid #555;
            border-radius: 5px;
            cursor: pointer;
            transition: all 0.2s;
            text-align: center;
        }

        .db-card:hover {
            border-color: var(--text-gold);
            box-shadow: 0 0 10px rgba(199, 179, 119, 0.5);
        }

        .db-card.normal {
            border-color: #666;
        }

        .db-card.rare {
            border-color: var(--item-magic);
        }

        .db-card-icon {
            font-size: 28px;
            margin-bottom: 6px;
        }

        .db-card-name {
            font-size: 14px;
            font-weight: bold;
            margin-bottom: 8px;
        }

        .db-card.normal .db-card-name {
            color: #fff;
        }

        .db-card.rare .db-card-name {
            color: var(--item-magic);
        }

        .db-card-effect {
            color: #88ff88;
            font-size: 12px;
            line-height: 1.4;
        }

        /* Blessing button states */
        .sys-btn.db-btn {
            border-color: #666;
            color: #999;
            animation: none;
        }

        .sys-btn.db-btn.has-pending {
            border-color: #ffd700;
            color: #ffd700;
            animation: blessingPulse 2s ease-in-out infinite;
        }

        .sys-btn.db-btn:not(.has-pending) .db-count-badge {
            background: #666;
            color: #ccc;
        }

        /* Obtained blessing list styles */
        .db-list-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px;
            border-bottom: 1px solid #333;
        }

        .db-list-item:last-child {
            border-bottom: none;
        }

        .db-list-item.rare {
            background: rgba(106, 136, 255, 0.1);
        }

        .db-list-icon {
            font-size: 18px;
            width: 24px;
            text-align: center;
        }

        .db-list-name {
            font-size: 13px;
            font-weight: bold;
            min-width: 70px;
        }

        .db-list-item.normal .db-list-name {
            color: #fff;
        }

        .db-list-item.rare .db-list-name {
            color: var(--item-magic);
        }

        .db-list-effect {
            flex: 1;
            font-size: 11px;
            color: #88ff88;
        }

        .db-list-level {
            font-size: 10px;
            color: #888;
        }

        /* Blessing list scrollbar */
        #divine-blessing-list::-webkit-scrollbar {
            width: 6px;
        }

        #divine-blessing-list::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 3px;
        }

        #divine-blessing-list::-webkit-scrollbar-thumb {
            background: #555;
            border-radius: 3px;
        }

        #divine-blessing-list::-webkit-scrollbar-thumb:hover {
            background: #777;
        }

        #divine-blessing-list {
            scrollbar-width: thin;
            scrollbar-color: #555 rgba(0, 0, 0, 0.3);
        }

        /* ========== Daily login reward styles ========== */
        .daily-reward-card {
            width: 52px;
            padding: 8px 4px;
            background: rgba(30, 30, 35, 0.95);
            border: 2px solid #444;
            border-radius: 6px;
            text-align: center;
            position: relative;
            transition: all 0.2s;
        }

        .daily-reward-card.current {
            border-color: #ffd700;
            box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
            animation: dailyPulse 1.5s ease-in-out infinite;
        }

        .daily-reward-card.claimed {
            border-color: #555;
            opacity: 0.6;
        }

        .daily-reward-card.locked {
            border-color: #333;
            opacity: 0.4;
        }

        .daily-reward-card.day7 {
            border-color: #ff8c00;
            background: linear-gradient(135deg, rgba(50, 40, 20, 0.95), rgba(80, 60, 20, 0.95));
        }

        .daily-reward-card.day7:not(.claimed) {
            animation: day7Glow 2s ease-in-out infinite;
        }

        @keyframes day7Glow {

            0%,
            100% {
                box-shadow: 0 0 8px rgba(255, 140, 0, 0.4);
            }

            50% {
                box-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 140, 0, 0.4);
            }
        }

        .daily-reward-card.day7 .daily-reward-day {
            color: #ffd700;
        }

        .daily-reward-card.day7 .daily-reward-name {
            color: #ffd700;
        }

        @keyframes dailyPulse {

            0%,
            100% {
                box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
            }

            50% {
                box-shadow: 0 0 15px rgba(255, 215, 0, 0.7);
            }
        }

        .daily-reward-day {
            font-size: 10px;
            color: #888;
            margin-bottom: 4px;
        }

        .daily-reward-card.current .daily-reward-day {
            color: #ffd700;
        }

        .daily-reward-icon {
            font-size: 22px;
            margin-bottom: 4px;
        }

        .daily-reward-name {
            font-size: 9px;
            color: #aaa;
            line-height: 1.2;
        }

        .daily-reward-check {
            position: absolute;
            top: -5px;
            right: -5px;
            width: 18px;
            height: 18px;
            background: #4a4;
            border-radius: 50%;
            font-size: 12px;
            line-height: 18px;
            color: #fff;
        }

        #btn-claim-daily:disabled {
            background: #333;
            color: #666;
            cursor: not-allowed;
        }

        /* ========== Tutorial styles ========== */
        /* Top combat tutorial hint */
        #tutorial-tip {
            position: fixed;
            top: 60px;
            left: 50%;
            transform: translateX(-50%);
            display: none;
            align-items: center;
            gap: 12px;
            padding: 12px 24px;
            background: rgba(0, 0, 0, 0.85);
            border: 2px solid var(--text-gold);
            border-radius: 8px;
            box-shadow: 0 0 20px rgba(199, 179, 119, 0.3);
            z-index: 1000;
            opacity: 0;
            transition: opacity 0.3s ease;
            animation: tutorial-pulse 2s ease-in-out infinite;
        }

        @keyframes tutorial-pulse {

            0%,
            100% {
                box-shadow: 0 0 20px rgba(199, 179, 119, 0.3);
            }

            50% {
                box-shadow: 0 0 30px rgba(199, 179, 119, 0.6);
            }
        }

        .tutorial-text {
            color: #fff;
            font-size: 16px;
            font-family: 'Roboto', sans-serif;
        }

        .tutorial-key {
            display: inline-block;
            padding: 4px 10px;
            background: var(--text-gold);
            color: #000;
            font-size: 14px;
            font-weight: bold;
            border-radius: 4px;
            font-family: 'Roboto', sans-serif;
        }

        /* Town bubble tutorial */
        #tutorial-bubble {
            position: absolute;
            display: none;
            transform: translateX(-50%);
            padding: 10px 16px;
            background: rgba(0, 0, 0, 0.92);
            border: 2px solid var(--text-gold);
            border-radius: 8px;
            white-space: nowrap;
            z-index: 500;
            text-align: center;
            pointer-events: auto;
        }

        .bubble-text {
            display: block;
            color: #fff;
            font-size: 14px;
            font-family: 'Roboto', sans-serif;
            margin-bottom: 8px;
        }

        .bubble-btn {
            background: var(--text-gold);
            color: #000;
            border: none;
            padding: 4px 16px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: bold;
            cursor: pointer;
            font-family: 'Roboto', sans-serif;
        }

        .bubble-btn:hover {
            background: #e0c987;
        }

        .bubble-arrow {
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 8px solid transparent;
            border-right: 8px solid transparent;
            border-top: 10px solid var(--text-gold);
        }

        .bubble-arrow::after {
            content: '';
            position: absolute;
            top: -12px;
            left: -6px;
            width: 0;
            height: 0;
            border-left: 6px solid transparent;
            border-right: 6px solid transparent;
            border-top: 8px solid rgba(0, 0, 0, 0.92);
        }

        /* Arrow points right (toward the right-side UI buttons) */
        #tutorial-bubble.arrow-right {
            transform: translateX(-100%) translateY(-50%);
        }

        #tutorial-bubble.arrow-right .bubble-arrow {
            bottom: auto;
            top: 50%;
            left: 100%;
            transform: translateY(-50%);
            border-top: 8px solid transparent;
            border-bottom: 8px solid transparent;
            border-left: 10px solid var(--text-gold);
            border-right: none;
        }

        #tutorial-bubble.arrow-right .bubble-arrow::after {
            top: -6px;
            left: -12px;
            border-top: 6px solid transparent;
            border-bottom: 6px solid transparent;
            border-left: 8px solid rgba(0, 0, 0, 0.92);
            border-right: none;
        }

        /* Checkbox Styles (Global) */
        .checkbox-label {
            position: relative;
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
        }

        .checkbox-label input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .checkmark {
            position: absolute;
            top: 0;
            left: 0;
            height: 20px;
            width: 20px;
            background-color: #222;
            border: 1px solid #555;
            transition: all 0.2s;
        }

        .checkbox-label:hover input~.checkmark {
            background-color: #333;
        }

        .checkbox-label input:checked~.checkmark {
            background-color: #4850b8;
            border-color: #6a74e8;
            box-shadow: 0 0 5px #4850b8;
        }

        .checkmark:after {
            content: "";
            position: absolute;
            display: none;
        }

        .checkbox-label input:checked~.checkmark:after {
            display: block;
        }

        .checkbox-label .checkmark:after {
            left: 7px;
            top: 3px;
            width: 5px;
            height: 10px;
            border: solid white;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
        }

        /* Blacksmith Panel Styles */
        .forge-container {
            display: flex;
            flex-direction: column;
            gap: 15px;
            padding-top: 10px;
        }

        .forge-slots-area {
            position: relative;
            height: 180px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
            border: 1px solid #333;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        /* Triangle Layout Connection Lines */
        .forge-slots-area::before {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 120px;
            height: 60px;
            border-left: 2px dashed #444;
            border-right: 2px dashed #444;
            transform: translate(-50%, -10px);
            z-index: 0;
            opacity: 0.5;
            /* Create V shape lines */
            border-bottom: none;
            border-top: none;
            background: linear-gradient(to bottom, transparent 0%, transparent 100%);
        }

        .forge-slots-area::after {
            content: '';
            position: absolute;
            top: 60px;
            left: 50%;
            width: 140px;
            height: 2px;
            background: transparent;
            display: none;
            /* Removed complex line drawing for simplicity, using CSS borders on elements if needed */
        }

        .forge-main-slot-container {
            position: absolute;
            top: 15px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            z-index: 10;
        }

        .forge-sacrifices-container {
            position: absolute;
            bottom: 20px;
            width: 100%;
            display: flex;
            justify-content: center;
            gap: 80px;
            z-index: 10;
        }

        .sacrifice-wrapper {
            position: relative;
        }

        .forge-slot {
            width: 64px;
            height: 64px;
            background: #111;
            border: 2px solid #555;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            box-shadow: inset 0 0 10px #000;
            transition: all 0.2s;
            position: relative;
        }

        .forge-slot.main-slot {
            width: 80px;
            height: 80px;
            border-color: var(--text-gold);
            box-shadow: 0 0 15px rgba(199, 179, 119, 0.2), inset 0 0 10px #000;
        }

        .forge-slot:hover {
            border-color: #fff;
            filter: brightness(1.2);
        }

        .forge-slot.has-item {
            background-size: 80%;
            /* Smaller item icon */
        }

        .slot-placeholder {
            color: #444;
            font-size: 12px;
            pointer-events: none;
        }

        .slot-label {
            margin-top: 5px;
            font-size: 12px;
            color: #888;
        }

        .forge-info-area {
            text-align: center;
            min-height: 40px;
            background: rgba(0, 0, 0, 0.5);
            padding: 10px;
            border-radius: 4px;
            border: 1px solid #333;
        }

        .forge-preview {
            color: #aaa;
            font-size: 13px;
            line-height: 1.4;
        }

        .forge-cost {
            color: var(--text-gold);
            font-weight: bold;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
        }

        .forge-actions {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 15px;
            /* Add some space */
        }

        .forge-tools {
            margin-top: 8px;
            margin-bottom: 5px;
        }

        .sys-btn.small-btn {
            font-size: 11px;
            padding: 4px 10px;
            min-width: auto;
            width: auto;
            border-color: #666;
            background: linear-gradient(to bottom, #444, #222);
        }

        .sys-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            filter: grayscale(100%);
            border-color: #444;
            color: #888;
            background: #222;
            box-shadow: none;
        }

        .forge-rules {
            font-size: 11px;
            color: #666;
            background: rgba(0, 0, 0, 0.2);
            padding: 8px;
            border-radius: 4px;
        }

        .forge-rules p {
            margin: 2px 0;
            padding-left: 10px;
        }

        /* Animation for successful forge */
        @keyframes forgeSuccess {
            0% {
                box-shadow: 0 0 0 rgba(255, 215, 0, 0);
                border-color: var(--text-gold);
            }

            50% {
                box-shadow: 0 0 50px rgba(255, 215, 0, 0.8);
                border-color: #fff;
                background-color: rgba(255, 215, 0, 0.3);
            }

            100% {
                box-shadow: 0 0 0 rgba(255, 215, 0, 0);
                border-color: var(--text-gold);
            }
        }

        /* Animation for failed forge */
        @keyframes forgeFail {
            0% {
                box-shadow: 0 0 0 rgba(255, 0, 0, 0);
                border-color: #555;
            }

            50% {
                box-shadow: 0 0 50px rgba(255, 0, 0, 0.8);
                border-color: #ff0000;
                background-color: rgba(255, 0, 0, 0.3);
            }

            100% {
                box-shadow: 0 0 0 rgba(255, 0, 0, 0);
                border-color: #555;
            }
        }

        .forge-success-anim {
            animation: forgeSuccess 1s ease-out;
        }

        .forge-fail-anim {
            animation: forgeFail 1s ease-out;
        }

        /* ========== Update announcement panel styles ========== */
        .changelog-panel {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 420px;
            max-height: 70vh;
            background: rgba(10, 10, 12, 0.98);
            border: 2px solid var(--ui-border);
            border-radius: 8px;
            z-index: 250;
            pointer-events: auto;
            display: flex;
            flex-direction: column;
            box-shadow:
                0 0 30px rgba(0, 0, 0, 0.9),
                0 10px 50px rgba(0, 0, 0, 0.8),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
            animation: fadeIn 0.3s ease;
        }

        .changelog-header {
            padding: 15px 20px;
            text-align: center;
            font-size: 18px;
            color: var(--text-gold);
            border-bottom: 1px solid var(--ui-border);
            font-weight: bold;
        }

        .changelog-content {
            flex: 1;
            overflow-y: auto;
            padding: 15px 20px;
            max-height: 45vh;
        }

        /* Reuse scrollbar styles */
        .changelog-content::-webkit-scrollbar {
            width: 8px;
        }

        .changelog-content::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        .changelog-content::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 4px;
            border: 1px solid #666;
        }

        .changelog-content::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        .changelog-content {
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        .changelog-item {
            margin-bottom: 15px;
            padding-bottom: 15px;
            border-bottom: 1px solid #333;
        }

        .changelog-item:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }

        .changelog-version {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 8px;
        }

        .changelog-version-num {
            background: linear-gradient(135deg, #4a3b2a, #6a5b4a);
            color: var(--text-gold);
            padding: 3px 10px;
            border-radius: 4px;
            font-size: 13px;
            font-weight: bold;
        }

        .changelog-version-title {
            color: #fff;
            font-size: 14px;
            font-weight: bold;
        }

        .changelog-highlights {
            margin: 0;
            padding-left: 20px;
            color: #aaa;
            font-size: 12px;
            line-height: 1.6;
        }

        .changelog-highlights li {
            margin-bottom: 3px;
        }

        .changelog-footer {
            padding: 15px 20px;
            border-top: 1px solid var(--ui-border);
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .changelog-confirm-btn {
            background: linear-gradient(135deg, #4a3b2a, #6a5b4a);
            border: 1px solid var(--text-gold);
            color: var(--text-gold);
            padding: 8px 30px;
            font-family: var(--font-ui);
            font-size: 13px;
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.2s;
        }

        .changelog-confirm-btn:hover {
            background: linear-gradient(135deg, #5a4b3a, #7a6b5a);
            box-shadow: 0 0 10px rgba(199, 179, 119, 0.3);
        }

        /* ========== Daily reward claim flash animation ========== */
        @keyframes dailyFlash {
            0% {
                opacity: 1;
                transform: scale(1);
            }

            40% {
                opacity: 0.9;
            }

            100% {
                opacity: 0;
                transform: scale(1.2);
            }
        }

        /* ========== Save selection panel styles ========== */
        .slot-selection-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 300;
            pointer-events: auto;
        }

        .slot-selection-overlay.active {
            display: flex;
            animation: fadeIn 0.3s ease;
        }

        .slot-selection-panel {
            position: relative;
            background: rgba(10, 10, 12, 0.95);
            border: 2px solid var(--ui-border);
            box-shadow:
                0 0 20px rgba(0, 0, 0, 0.9),
                0 8px 32px rgba(0, 0, 0, 0.7),
                inset 0 1px 0 rgba(255, 255, 255, 0.05),
                inset 0 0 60px rgba(0, 0, 0, 0.5);
            padding: 15px 20px;
        }

        .slot-selection-header {
            text-align: center;
            font-size: 16px;
            color: var(--text-gold);
            padding-bottom: 12px;
            margin-bottom: 12px;
            border-bottom: 1px solid rgba(78, 66, 46, 0.5);
        }

        .slot-selection-grid {
            display: flex;
            gap: 12px;
            justify-content: center;
            margin-bottom: 12px;
        }

        .slot-card {
            width: 130px;
            min-height: 140px;
            background: rgba(20, 20, 25, 0.95);
            border: 1px solid #444;
            border-radius: 6px;
            padding: 10px 12px;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        #abyss-entrance-panel.active,
        #abyss-contract-panel.active {
            display: flex;
            flex-direction: column;
        }

        .slot-card:hover {
            border-color: var(--text-gold);
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(199, 179, 119, 0.15);
        }

        .slot-card.empty {
            justify-content: center;
            border-style: dashed;
            border-color: #555;
        }

        .slot-card.empty:hover {
            border-color: #88cc88;
            border-style: solid;
        }

        .slot-card-number {
            position: absolute;
            top: 6px;
            left: 8px;
            font-size: 11px;
            color: #555;
        }

        .slot-card-delete {
            position: absolute;
            top: 4px;
            right: 4px;
            width: 18px;
            height: 18px;
            background: rgba(180, 50, 50, 0.8);
            border: 1px solid #ff4444;
            border-radius: 50%;
            color: #fff;
            font-size: 10px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transition: all 0.2s;
        }

        .slot-card:hover .slot-card-delete {
            opacity: 1;
        }

        .slot-card-delete:hover {
            background: #ff4444;
            transform: scale(1.1);
        }

        .slot-empty-icon {
            font-size: 32px;
            color: #555;
            margin-bottom: 6px;
        }

        .slot-empty-text {
            color: #777;
            font-size: 12px;
        }

        .slot-card.empty:hover .slot-empty-icon {
            color: #88cc88;
        }

        .slot-card.empty:hover .slot-empty-text {
            color: #88cc88;
        }

        .slot-level {
            font-size: 18px;
            color: var(--text-gold);
            font-weight: bold;
            margin-top: 10px;
            margin-bottom: 8px;
        }

        .slot-info {
            font-size: 11px;
            color: #aaa;
            text-align: center;
            line-height: 1.5;
            width: 100%;
        }

        .slot-info-row {
            display: flex;
            justify-content: space-between;
            width: 100%;
            padding: 1px 0;
        }

        .slot-info-label {
            color: #666;
        }

        .slot-info-value {
            color: #bbb;
        }

        .slot-last-played {
            font-size: 10px;
            color: #555;
            margin-top: 6px;
        }

        /* Delete-save confirm dialog */
        .delete-slot-confirm-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 400;
        }

        .delete-slot-confirm-overlay.active {
            display: flex;
            animation: fadeIn 0.2s ease;
        }

        .delete-slot-confirm-dialog {
            background: rgba(20, 15, 15, 0.98);
            border: 2px solid #882222;
            border-radius: 8px;
            padding: 25px 30px;
            min-width: 320px;
            text-align: center;
            box-shadow: 0 0 30px rgba(136, 34, 34, 0.3);
        }

        .delete-confirm-title {
            font-size: 18px;
            color: #ff6666;
            margin-bottom: 15px;
            font-weight: bold;
        }

        .delete-confirm-text {
            color: #ccc;
            font-size: 14px;
            margin-bottom: 20px;
            line-height: 1.6;
        }

        .delete-confirm-input {
            margin-bottom: 20px;
        }

        .delete-confirm-input span {
            display: block;
            color: #888;
            font-size: 12px;
            margin-bottom: 8px;
        }

        .delete-confirm-input input {
            width: 120px;
            padding: 8px 12px;
            background: #111;
            border: 1px solid #444;
            border-radius: 4px;
            color: #fff;
            font-size: 14px;
            text-align: center;
        }

        .delete-confirm-input input:focus {
            outline: none;
            border-color: #882222;
        }

        .delete-confirm-actions {
            display: flex;
            gap: 15px;
            justify-content: center;
        }

        .delete-cancel-btn {
            background: #333;
            border: 1px solid #555;
            color: #aaa;
            padding: 8px 20px;
            font-family: var(--font-ui);
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.2s;
        }

        .delete-cancel-btn:hover {
            background: #444;
            color: #fff;
        }

        .delete-confirm-btn {
            background: #661111;
            border: 1px solid #882222;
            color: #ff6666;
            padding: 8px 20px;
            font-family: var(--font-ui);
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.2s;
        }

        .delete-confirm-btn:hover:not(:disabled) {
            background: #882222;
            color: #fff;
        }

        .delete-confirm-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Portal overlay */
        #portal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: white;
            opacity: 0;
            pointer-events: none;
            z-index: 9999;
            transition: opacity 0.5s ease-in-out;
        }

        /* Cast bar container */
        #cast-bar-container {
            position: absolute;
            bottom: 120px;
            /* Above the HUD */
            left: 50%;
            transform: translateX(-50%);
            width: 200px;
            height: 20px;
            background: rgba(0, 0, 0, 0.8);
            border: 1px solid #666;
            border-radius: 4px;
            display: none;
            /* Hidden by default */
            z-index: 1000;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        }

        /* Cast bar progress */
        #cast-bar-progress {
            width: 0%;
            height: 100%;
            background: linear-gradient(90deg, #4d94ff, #0056b3);
            border-radius: 3px;
            transition: width 0.1s linear;
        }

        /* Cast bar text */
        #cast-bar-text {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            text-align: center;
            line-height: 20px;
            font-size: 12px;
            color: white;
            text-shadow: 1px 1px 1px black;
        }

        /* ========== Server announcement bar ========== */
        #announcement-bar {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 28px;
            background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 100%);
            border-bottom: 1px solid rgba(200, 150, 50, 0.3);
            overflow: hidden;
            z-index: 100;
            pointer-events: none;
        }

        #announcement-content {
            position: absolute;
            white-space: nowrap;
            line-height: 28px;
            font-size: 14px;
            font-family: var(--font-ui);
            text-shadow: 0 0 8px currentColor, 1px 1px 2px black;
            padding: 0 20px;
        }

        /* Boss kill announce - gold */
        .boss-announcement {
            color: #ffd700;
        }

        /* Set drop announce - green */
        .set-announcement {
            color: #20ff20;
        }

        /* Level milestone announce - purple */
        .level-announcement {
            color: #ff66ff;
        }

        /* Enhance success announce - orange */
        .enhance-announcement {
            color: #ff8800;
        }

        /* Abyss announce - red flame effect */
        .abyss-announcement {
            color: #ff4444;
            text-shadow: 0 0 10px #ff0000, 0 0 20px #ff4400, 1px 1px 2px black;
        }

        /* Title unlock announce - gold crown effect */
        .title-announcement {
            color: #ffd700;
            text-shadow: 0 0 10px #ffa500, 0 0 20px #ff8800, 1px 1px 2px black;
        }

        /* Announce scroll animation */
        @keyframes scrollAnnouncement {
            0% {
                transform: translateX(100vw);
            }

            100% {
                transform: translateX(-100%);
            }
        }

        /* ========== World chat box ========== */
        .chat-box {
            position: absolute;
            bottom: 190px;
            left: 20px;
            width: 330px;
            background: rgba(5, 5, 8, 0.85);
            border: 1px solid rgba(74, 59, 42, 0.6);
            border-radius: 6px;
            z-index: 80;
            pointer-events: auto;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
            transition: all 0.3s ease;
        }

        .chat-box.collapsed {
            width: 120px;
        }

        .chat-box.collapsed .chat-body {
            display: none;
        }

        .chat-box.collapsed .chat-header {
            border-radius: 6px;
        }

        /* Disabled state while chat is not ready */
        .chat-box.chat-disabled {
            opacity: 0.5;
            pointer-events: none;
            /* Fully disable interaction */
        }

        .chat-box.chat-disabled .chat-header {
            cursor: default;
        }

        .chat-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 6px 12px;
            background: linear-gradient(180deg, rgba(40, 35, 30, 0.95) 0%, rgba(25, 22, 18, 0.95) 100%);
            border-bottom: 1px solid rgba(74, 59, 42, 0.4);
            border-radius: 6px 6px 0 0;
            cursor: pointer;
            user-select: none;
        }

        .chat-header:hover {
            background: linear-gradient(180deg, rgba(50, 45, 38, 0.95) 0%, rgba(35, 30, 25, 0.95) 100%);
        }

        .chat-title {
            color: var(--text-gold);
            font-size: 12px;
            font-weight: bold;
        }

        .chat-toggle {
            color: #888;
            font-size: 10px;
            transition: transform 0.3s ease;
        }

        .chat-box.collapsed .chat-toggle {
            transform: rotate(-90deg);
        }

        /* Unread message count */
        .chat-unread {
            color: #ff6b6b;
            font-size: 11px;
            margin-left: 4px;
            white-space: nowrap;
        }

        .chat-unread:empty {
            display: none;
        }

        .chat-title {
            white-space: nowrap;
        }

        .chat-body {
            display: flex;
            flex-direction: column;
        }

        .chat-messages {
            height: 160px;
            overflow-y: auto;
            padding: 8px 10px;
            font-size: 12px;
            line-height: 1.5;
        }

        /* Chat scrollbar */
        .chat-messages::-webkit-scrollbar {
            width: 5px;
        }

        .chat-messages::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 3px;
        }

        .chat-messages::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 3px;
        }

        .chat-messages::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        .chat-messages {
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        .chat-msg {
            margin-bottom: 4px;
            word-break: break-all;
        }

        .chat-msg-nickname {
            color: #88ccff;
            font-weight: bold;
        }

        .chat-msg-level {
            color: #888;
            font-size: 10px;
            margin-left: 2px;
        }

        .chat-msg-title {
            color: #ffd700;
            font-size: 10px;
            margin-left: 4px;
        }

        .chat-msg-content {
            color: #ddd;
            margin-left: 4px;
        }

        /* System message styles */
        .chat-msg.system {
            color: #ffd700;
            font-style: italic;
        }

        .chat-msg.system .chat-msg-nickname {
            color: #ffd700;
        }

        /* Private message styles */
        .chat-msg.whisper {
            background: rgba(180, 100, 220, 0.15);
            border-left: 2px solid #cc88ff;
            padding-left: 6px;
            margin-left: -2px;
        }

        .chat-whisper-tag {
            color: #cc88ff;
            font-size: 10px;
            margin-right: 4px;
        }

        /* Clickable nicknames */
        .chat-nickname-clickable {
            cursor: pointer;
            transition: all 0.15s;
        }

        .chat-nickname-clickable:hover {
            text-decoration: underline;
            text-shadow: 0 0 6px currentColor;
        }

        /* Chat item links */
        .chat-item-link {
            font-weight: bold;
            cursor: pointer;
            padding: 1px 3px;
            border-radius: 3px;
            background: rgba(255, 255, 255, 0.1);
            transition: all 0.15s;
        }

        .chat-item-link:hover {
            background: rgba(255, 255, 255, 0.2);
            text-shadow: 0 0 8px currentColor;
        }

        .chat-input-area {
            display: flex;
            gap: 5px;
            padding: 8px 10px;
            border-top: 1px solid rgba(74, 59, 42, 0.3);
            background: rgba(0, 0, 0, 0.3);
            border-radius: 0 0 6px 6px;
        }

        #chat-input {
            flex: 1;
            padding: 5px 8px;
            font-size: 12px;
            background: rgba(20, 20, 25, 0.9);
            border: 1px solid #444;
            border-radius: 3px;
            color: #fff;
            font-family: 'Roboto', sans-serif;
        }

        #chat-input:focus {
            outline: none;
            border-color: var(--text-gold);
        }

        #chat-input::placeholder {
            color: #666;
        }

        #chat-send-btn {
            padding: 5px 12px;
            font-size: 11px;
            background: linear-gradient(180deg, #4a3b2a 0%, #2a2520 100%);
            border: 1px solid #5a4b3a;
            border-radius: 3px;
            color: var(--text-gold);
            cursor: pointer;
            font-family: var(--font-ui);
            transition: all 0.2s;
        }

        #chat-send-btn:hover {
            background: linear-gradient(180deg, #5a4b3a 0%, #3a3530 100%);
            border-color: var(--text-gold);
        }

        #chat-send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Emoji button */
        .emote-btn {
            padding: 5px 8px;
            font-size: 14px;
            background: linear-gradient(180deg, #4a3b2a 0%, #2a2520 100%);
            border: 1px solid #5a4b3a;
            border-radius: 3px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .emote-btn:hover {
            background: linear-gradient(180deg, #5a4b3a 0%, #3a3530 100%);
            border-color: var(--text-gold);
        }

        /* Emoji panel */
        .emote-panel {
            background: rgba(20, 18, 15, 0.95);
            border: 1px solid rgba(74, 59, 42, 0.6);
            border-radius: 6px;
            padding: 8px;
            margin: 0 10px 5px 10px;
        }

        .emote-row {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-bottom: 6px;
        }

        .emote-row:last-child {
            margin-bottom: 0;
        }

        .emote-row.emote-emoji .emote-item {
            font-size: 15px;
            padding: 4px 6px;
        }

        .emote-row.emote-text .emote-item {
            font-size: 12px;
            padding: 4px 8px;
            color: #ddd;
        }

        .emote-item {
            background: rgba(50, 45, 40, 0.8);
            border: 1px solid rgba(74, 59, 42, 0.4);
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.15s;
            user-select: none;
        }

        .emote-item:hover {
            background: rgba(80, 70, 60, 0.9);
            border-color: var(--text-gold);
            transform: scale(1.05);
        }

        .emote-item:active {
            transform: scale(0.95);
        }

        /* Chat cooldown toast */
        .chat-cooldown {
            color: #ff6666;
            font-size: 10px;
            text-align: center;
            padding: 3px;
        }

        /* ============= Mobile responsive styles ============= */
        @media (max-width: 768px),
        (pointer: coarse) {

            /* Bottom HUD tightening */
            #bottom-hud {
                height: 120px;
                padding: 0 10px 5px;
            }

            /* Smaller HP/mana orbs */
            .orb-container {
                width: 80px;
                height: 80px;
                flex-basis: 80px;
                margin-bottom: 14px;
            }

            .orb-text {
                font-size: 14px;
            }

            /* Bigger skill buttons - easier to tap */
            .skill-bar {
                gap: 4px;
                padding: 4px;
            }

            .skill-btn {
                min-width: 44px;
                min-height: 44px;
                box-sizing: border-box;
                flex-shrink: 0;
            }

            #center-hud {
                flex: 1 1 auto;
                min-width: 0;
                max-width: min(420px, calc(100vw - 196px));
                margin: 0 6px;
                padding: 6px 4px 5px;
            }


            /* Bigger belt cells */
            .belt-bar {
                gap: 8px;
                padding: 5px;
            }

            .belt-slot {
                width: 42px;
                height: 42px;
                font-size: 20px;
            }

            /* Smaller minimap moved to a corner */
            #minimap-container {
                width: 100px;
                height: 100px;
                top: 40px;
                right: 10px;
            }

            /* Floor display stays below the announce bar (28px), left-aligned with the quest tracker */
            #floor-display {
                font-size: 1.1em;
                top: 32px;
                left: 10px;
            }

            /* Quest tracker position - right after the floor display */
            #quest-tracker {
                top: 55px;
                left: 10px;
            }

            /* Menu button adjustments */
            .mobile-fab {
                display: flex;
            }

            .menu-btns {
                right: 10px;
                bottom: 190px;
                flex-wrap: nowrap;
                gap: 6px;
                opacity: 0;
                transform: translateY(10px) scale(0.96);
                pointer-events: none;
                transition: opacity 0.16s ease, transform 0.16s ease;
                z-index: 91;
            }

            body.mobile-menu-open .menu-btns {
                opacity: 1;
                transform: translateY(0) scale(1);
                pointer-events: auto;
            }

            .menu-btns .sys-btn {
                font-size: 10px;
                padding: 7px 10px;
                min-height: 44px !important;
                min-width: 88px !important;
                text-align: center;
            }

            /* Panels full-width or width-fit on phones */
            .panel {
                max-width: calc(100vw - 20px);
                max-height: calc(100vh - 150px);
                overflow-y: auto;
            }

            #inventory-panel {
                top: 5% !important;
                right: 10px;
                box-sizing: border-box;
                width: calc(100vw - 20px);
                max-width: 352px;
                max-height: calc(100dvh - 150px);
            }

            /* Achievement panel mobile fit */
            #achievements-panel {
                width: calc(100vw - 20px);
                max-width: 320px;
            }

            .ach-name {
                font-size: 12px;
            }

            .ach-desc {
                font-size: 10px;
            }

            .ach-tab {
                padding: 3px 8px;
                font-size: 11px;
            }

            /* Inventory cells */
            .bag-slot {
                width: 46px;
                height: 46px;
            }

            /* Bigger equipment slots */
            .equip-slot {
                width: 55px;
                height: 55px;
            }

            /* Auto battle button follows the minimap */
            .auto-battle-container {
                top: 150px;
                right: 10px;
            }

            .auto-battle-btn {
                padding: 0 8px;
                font-size: 11px;
                height: 32px;
            }

            .auto-battle-settings-btn {
                padding: 0 8px;
                font-size: 12px;
                height: 32px;
            }

            #auto-battle-icon {
                font-size: 14px;
            }

            /* Talent HUD follows the minimap */
            #talent-hud {
                top: 40px;
                right: 120px;
                max-height: 86px;
            }

            .talent-hud-icon {
                width: 26px;
                height: 26px;
                font-size: 14px;
            }

            /* Bolder XP bar */
            .xp-bar {
                height: 10px;
            }

            /* Dialog fits the screen */
            #dialog-box {
                max-width: calc(100vw - 40px);
                font-size: 13px;
            }

            /* Quest tracker adjustments */
            #quest-tracker {
                font-size: 11px;
                max-width: 200px;
            }

            /* Chat box adjustments */
            .chat-box {
                display: none;
                left: 10px;
                right: 10px;
                bottom: 132px;
                width: auto;
                max-width: calc(100vw - 20px);
                z-index: 93;
            }

            .chat-box:not(.collapsed) {
                display: block;
            }

            body.mobile-chat-open #mobile-chat-toggle {
                display: none;
            }

            .chat-messages {
                height: 120px;
            }

            /* Emoji panel mobile fit */
            .emote-row.emote-emoji .emote-item {
                font-size: 13px;
                padding: 5px 7px;
            }

            .emote-row.emote-text .emote-item {
                font-size: 12px;
                padding: 5px 7px;
            }

            /* Notification area adjustments */
            #notification-area {
                font-size: 12px;
            }

            /* Minimum touch target size (Apple recommends 44px) */
            button:not(.stat-btn),
            .gamble-slot,
            .buy-slot {
                min-height: 44px;
                min-width: 44px;
            }

            /* Disable hover effects (none on touch devices) - reset to default */
            .gamble-slot:hover,
            .belt-slot:hover,
            .skill-btn:hover {
                filter: none;
                transform: none;
            }

            /* Update announcement panel fit */
            .changelog-panel {
                width: 90vw;
                max-width: 380px;
                max-height: 80vh;
            }

            .changelog-content {
                max-height: 50vh;
            }

            /* Save selection panel fit */
            .slot-selection-panel {
                width: 95vw;
                max-width: 400px;
                padding: 12px;
            }

            .slot-selection-grid {
                flex-direction: column;
                align-items: center;
            }

            .slot-card {
                width: 90%;
                min-height: 100px;
            }
        }

        /* Very small screens (iPhone SE etc.) */
        @media (max-width: 375px) {
            #inventory-panel {
                padding: 8px;
            }

            #inventory-panel .bag-grid {
                grid-template-columns: repeat(6, minmax(0, 1fr));
                gap: 3px;
            }

            #inventory-panel .bag-slot {
                box-sizing: border-box;
                width: 44px;
                height: 44px;
            }

            .orb-container {
                width: 65px;
                height: 65px;
                flex-basis: 65px;
                margin-bottom: 64px;
            }

            #mobile-menu-toggle,
            #mobile-chat-toggle {
                bottom: 156px;
            }

            .skill-btn {
                width: 30px;
                height: 30px;
            }

            .belt-slot {
                width: 36px;
                height: 36px;
                font-size: 16px;
            }

            #minimap-container {
                width: 80px;
                height: 80px;
            }

            .auto-battle-container {
                top: 130px;
            }

            #talent-hud {
                top: 40px;
                right: 100px;
                max-height: 80px;
            }

            .talent-hud-icon {
                width: 24px;
                height: 24px;
                font-size: 12px;
            }

            #center-hud {
                max-width: calc(100vw - 164px);
            }
        }

        /* Landscape mode polish */
        @media (max-height: 500px) and (orientation: landscape) {
            #bottom-hud {
                height: 90px;
            }

            .orb-container {
                width: 70px;
                height: 70px;
                flex-basis: 70px;
            }

            .skill-btn {
                width: 30px;
                height: 30px;
            }

            .belt-slot {
                width: 32px;
                height: 32px;
            }

            #minimap-container {
                width: 80px;
                height: 80px;
                top: 5px;
            }

            .auto-battle-container {
                top: 95px;
            }

            #talent-hud {
                top: 5px;
                right: 100px;
                max-height: 80px;
            }

            .talent-hud-icon {
                width: 24px;
                height: 24px;
                font-size: 12px;
            }
        }

        /* Touch state feedback - all clickable elements */
        @media (pointer: coarse) {

            .skill-btn:active,
            .belt-slot:active,
            .sys-btn:active,
            .gamble-slot:active,
            .bag-slot:active {
                transform: scale(0.92);
                filter: brightness(0.8);
            }

            /* Disable button highlight */
            button,
            .sys-btn,
            .skill-btn,
            .belt-slot {
                -webkit-tap-highlight-color: transparent;
                outline: none;
            }
        }

        /* ========== Embedded inventory area ========== */
        .embedded-bag-section {
            margin-top: 15px;
            padding: 10px;
            background: rgba(0, 0, 0, 0.5);
            border: 1px solid #333;
            border-radius: 5px;
        }

        .embedded-bag-header {
            color: var(--text-gold);
            font-size: 13px;
            font-weight: bold;
            margin-bottom: 8px;
            padding-bottom: 5px;
            border-bottom: 1px solid #333;
        }

        .embedded-bag-grid {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 3px;
        }

        .embedded-bag-slot {
            width: 36px;
            height: 36px;
            border: 1px solid #333;
            background: #080808;
            position: relative;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s;
        }

        .embedded-bag-slot:hover {
            border-color: var(--text-gold);
            background: #151515;
        }

        .embedded-bag-slot:active {
            transform: scale(0.95);
        }

        .embedded-bag-slot .item-count {
            position: absolute;
            bottom: 1px;
            right: 2px;
            color: #fff;
            font-size: 9px;
            font-weight: bold;
            text-shadow: 1px 1px 0 #000;
        }

        .embedded-bag-slot .enhance-level {
            position: absolute;
            top: 0;
            right: 1px;
            color: #0f0;
            font-size: 9px;
            font-weight: bold;
            text-shadow: 1px 1px 0 #000;
        }

        /* Rarity border */
        .embedded-bag-slot.rarity-unique {
            border-color: #b57410;
            box-shadow: inset 0 0 8px rgba(181, 116, 16, 0.5);
        }

        .embedded-bag-slot.rarity-set {
            border-color: #00ff00;
            box-shadow: inset 0 0 8px rgba(0, 255, 0, 0.5);
        }

        .embedded-bag-slot.rarity-rare {
            border-color: #ffff00;
            box-shadow: inset 0 0 5px rgba(255, 255, 0, 0.3);
        }

        /* Sell confirm button styles */
        .embedded-bag-slot.sell-pending {
            border-color: #ff4444 !important;
            box-shadow: inset 0 0 10px rgba(255, 68, 68, 0.6) !important;
        }

        .sell-confirm-btn {
            position: absolute;
            bottom: 2px;
            left: 50%;
            transform: translateX(-50%);
            background: linear-gradient(180deg, #c22 0%, #811 100%);
            color: #fff;
            font-size: 9px;
            padding: 1px 6px;
            border-radius: 2px;
            cursor: pointer;
            z-index: 10;
            text-shadow: 0 1px 1px #000;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
            transition: all 0.1s;
        }

        .sell-confirm-btn:hover {
            background: linear-gradient(180deg, #e33 0%, #a22 100%);
            transform: translateX(-50%) scale(1.1);
        }

        /* Mobile embedded inventory fit */
        @media (max-width: 768px) {
            .embedded-bag-grid {
                grid-template-columns: repeat(6, 1fr);
            }

            .embedded-bag-slot {
                width: 36px;
                height: 36px;
            }

            #shop-panel,
            #stash-panel,
            #blacksmith-panel {
                width: 90vw !important;
                max-width: 380px;
                left: 50% !important;
                right: auto !important;
                top: 5% !important;
                transform: translateX(-50%);
            }

            #skills-panel {
                width: 92vw !important;
                max-width: 340px;
                left: 50% !important;
                right: auto !important;
                top: 3% !important;
                transform: translateX(-50%);
                max-height: 90vh !important;
            }

            .skill-tree-scroll {
                max-height: calc(90vh - 90px) !important;
            }

            .skill-tree-node {
                width: 100px;
                padding: 6px;
            }

            .skill-node-icon {
                width: 32px;
                height: 32px;
            }

            .skill-node-icon .skill-sprite {
                width: 28px;
                height: 28px;
            }

            .skill-node-name {
                font-size: 10px;
            }

            .skill-node-level {
                font-size: 9px;
            }

            .skill-tree-stage.stage-fork {
                gap: 12px;
            }

            .skill-branch-header {
                font-size: 12px;
                padding: 4px;
            }

            /* Stash cells adapt */
            #stash-panel .stash-grid .bag-slot {
                width: auto;
                height: auto;
                aspect-ratio: 1;
                min-width: 30px;
            }

            /* Smaller stat-point buttons */
            .stat-btn {
                width: 28px !important;
                height: 28px !important;
                font-size: 16px !important;
                line-height: 26px !important;
            }

            /* Smaller tutorial bubble buttons */
            .bubble-btn {
                min-height: 32px !important;
                min-width: auto !important;
                padding: 6px 16px !important;
                font-size: 13px !important;
            }

            /* Smaller organize button */
            .sort-btn {
                min-height: auto !important;
                min-width: auto !important;
                padding: 3px 8px !important;
                font-size: 10px !important;
            }
        }

        /* ========== Organize button styles ========== */
        .sort-btn {
            background: linear-gradient(180deg, #4a4a4a 0%, #333 100%);
            border: 1px solid #666;
            border-radius: 4px;
            color: #ddd;
            font-size: 11px;
            padding: 4px 10px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .sort-btn:hover {
            background: linear-gradient(180deg, #5a5a5a 0%, #444 100%);
            color: #fff;
            border-color: #888;
        }

        .sort-btn:active {
            transform: scale(0.95);
        }

        /* ========== Market stall styles ========== */
        #stall-setup-panel {
            top: 10%;
            left: 50%;
            transform: translateX(-50%);
            width: 320px;
            max-width: 95vw;
        }

        #stall-view-panel {
            top: 10%;
            left: 50%;
            transform: translateX(-50%);
            width: 320px;
            max-width: 95vw;
        }

        .stall-section-title {
            color: #888;
            font-size: 12px;
            margin: 10px 0 6px;
            text-align: center;
            border-bottom: 1px solid #333;
            padding-bottom: 4px;
        }

        /* Shelf cells (horizontal, 2 rows x 5 cols) */
        .stall-shelf-grid {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 4px;
            margin-bottom: 8px;
        }

        .stall-shelf-slot {
            width: 100%;
            aspect-ratio: 1;
            border: 1px solid #333;
            background: #080808;
            background-size: contain;
            background-position: center;
            background-repeat: no-repeat;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            position: relative;
            font-size: 10px;
            transition: all 0.15s;
            overflow: hidden;
            box-sizing: border-box;
        }

        .stall-shelf-slot:hover {
            border-color: var(--text-gold);
            background: #151515;
        }

        .stall-shelf-slot.has-item {
            border-width: 2px;
        }

        .stall-shelf-slot.empty {
            color: #444;
            font-size: 18px;
        }

        /* Listed item marker */
        .stall-on-shelf {
            background: #1a1a1a !important;
            cursor: not-allowed !important;
            opacity: 0.6;
        }

        .stall-slot {
            width: 44px;
            height: 44px;
            border: 1px solid #333;
            background: #080808;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            position: relative;
            font-size: 10px;
            transition: all 0.15s;
        }

        .stall-slot:hover {
            border-color: var(--text-gold);
            background: #151515;
        }

        .stall-slot.has-item {
            border-width: 2px;
        }

        .stall-slot.protected {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .stall-slot.empty {
            color: #444;
            font-size: 18px;
        }

        .stall-item-icon {
            font-size: 18px;
        }

        .stall-item-name {
            font-size: 8px;
            max-width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .stall-item-price {
            position: absolute;
            bottom: 1px;
            right: 1px;
            font-size: 9px;
            color: #ffd700;
            text-shadow: 1px 1px 0 #000;
        }

        .stall-name-row {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
        }

        .stall-name-row label {
            font-size: 12px;
            color: #aaa;
            white-space: nowrap;
        }

        .stall-name-row input {
            flex: 1;
            background: #111;
            border: 1px solid #444;
            padding: 6px 10px;
            color: #ffd700;
            font-size: 13px;
            border-radius: 4px;
        }

        .stall-name-row input:focus {
            border-color: var(--text-gold);
            outline: none;
        }

        /* Stall duration selection row */
        .stall-duration-row {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
            padding: 8px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        .stall-duration-row label {
            font-size: 12px;
            color: #aaa;
            white-space: nowrap;
        }

        .stall-duration-row select {
            flex: 1;
            background: #111;
            border: 1px solid #444;
            padding: 6px 10px;
            color: #fff;
            font-size: 13px;
            border-radius: 4px;
            cursor: pointer;
        }

        .stall-duration-row select:focus {
            border-color: var(--text-gold);
            outline: none;
        }

        .stall-fee-display {
            color: #ffd700;
            font-size: 12px;
            font-weight: bold;
            white-space: nowrap;
        }

        /* Tax rate and duration info bar */
        .stall-info-bar {
            display: flex;
            justify-content: space-between;
            gap: 10px;
            margin-bottom: 10px;
        }

        .stall-tax-notice,
        .stall-duration-notice {
            font-size: 11px;
            color: #888;
            padding: 4px 8px;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 4px;
        }

        .stall-setup-footer {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-top: 15px;
            padding-top: 10px;
            border-top: 1px solid #333;
        }

        .stall-btn {
            padding: 10px 24px;
            border: 1px solid #444;
            background: linear-gradient(180deg, #333 0%, #222 100%);
            color: #ccc;
            font-size: 13px;
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.2s;
        }

        .stall-btn:hover {
            background: linear-gradient(180deg, #444 0%, #333 100%);
            border-color: #666;
            color: #fff;
        }

        .stall-btn.primary {
            background: linear-gradient(180deg, #5a4a2a 0%, #3a2a1a 100%);
            border-color: var(--text-gold);
            color: var(--text-gold);
        }

        .stall-btn.primary:hover {
            background: linear-gradient(180deg, #6a5a3a 0%, #4a3a2a 100%);
        }

        .stall-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* View stall panel styles */
        #stall-view-panel {
            width: 340px;
        }

        .stall-view-content {
            max-height: 400px;
            overflow-y: auto;
        }

        .stall-view-grid {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .stall-view-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px;
            background: #111;
            border: 1px solid #333;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .stall-view-item:hover {
            background: #1a1a1a;
            border-color: #555;
        }

        .stall-view-icon {
            width: 40px;
            height: 40px;
            background: #080808;
            border: 2px solid #444;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
        }

        .stall-view-info {
            flex: 1;
        }

        .stall-view-name {
            font-size: 13px;
            font-weight: bold;
        }

        .stall-view-price {
            font-size: 12px;
            color: #ffd700;
            margin-top: 2px;
        }

        .stall-tax {
            color: #888;
            font-size: 10px;
        }

        .stall-buy-btn {
            padding: 6px 14px;
            background: linear-gradient(180deg, #4a8a4a 0%, #2a5a2a 100%);
            border: 1px solid #5a9a5a;
            color: #fff;
            font-size: 12px;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.15s;
        }

        .stall-buy-btn:hover {
            background: linear-gradient(180deg, #5a9a5a 0%, #3a6a3a 100%);
        }

        .stall-empty-notice {
            text-align: center;
            color: #666;
            padding: 30px;
            font-size: 14px;
        }

        /* Scrollbar styles */
        .stall-grid::-webkit-scrollbar,
        .stall-view-content::-webkit-scrollbar {
            width: 6px;
        }

        .stall-grid::-webkit-scrollbar-track,
        .stall-view-content::-webkit-scrollbar-track {
            background: #111;
        }

        .stall-grid::-webkit-scrollbar-thumb,
        .stall-view-content::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 3px;
        }

        .stall-grid::-webkit-scrollbar-thumb:hover,
        .stall-view-content::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        /* Pricing dialog styles */
        .stall-price-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 200;
            pointer-events: auto;
        }

        .stall-price-box {
            background: rgba(20, 20, 24, 0.98);
            border: 2px solid var(--ui-border);
            border-radius: 8px;
            padding: 20px 30px;
            min-width: 260px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
        }

        .stall-price-title {
            text-align: center;
            font-size: 16px;
            color: var(--text-gold);
            margin-bottom: 15px;
            font-weight: bold;
        }

        .stall-price-item {
            text-align: center;
            font-size: 14px;
            margin-bottom: 15px;
            padding: 8px;
            background: rgba(0, 0, 0, 0.5);
            border-radius: 4px;
        }

        .stall-price-input-row {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 20px;
        }

        .stall-price-input-row input {
            width: 120px;
            padding: 10px 12px;
            background: #111;
            border: 1px solid #444;
            color: #ffd700;
            font-size: 16px;
            text-align: center;
            border-radius: 4px;
        }

        .stall-price-input-row input:focus {
            border-color: var(--text-gold);
            outline: none;
        }

        .stall-price-unit {
            color: #ffd700;
            font-size: 16px;
            font-weight: bold;
        }

        .stall-price-actions {
            display: flex;
            justify-content: center;
            gap: 12px;
        }

        /* Stall-close container (follows above the player's head) */
        .close-stall-container {
            position: absolute;
            left: 0;
            top: 0;
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 6px;
            z-index: 50;
            pointer-events: none;
            will-change: transform;
        }

        /* Close stall button */
        .close-stall-btn {
            padding: 4px 10px;
            background: linear-gradient(180deg, #8b4513, #5a2d0c);
            border: 1px solid #d4a574;
            border-radius: 4px;
            color: #ffd700;
            font-size: 12px;
            font-weight: bold;
            cursor: pointer;
            white-space: nowrap;
            pointer-events: auto;
        }

        /* Stall countdown */
        .stall-timer {
            font-size: 11px;
            color: #aaa;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
            background: rgba(0, 0, 0, 0.5);
            padding: 2px 6px;
            border-radius: 3px;
        }

        .close-stall-btn:hover {
            background: linear-gradient(180deg, #a0522d, #6b3a1a);
        }

        .close-stall-btn:active {
            transform: scale(0.95);
        }

        /* Claim earnings button */
        .claim-sales-btn {
            position: fixed;
            bottom: 120px;
            left: 50%;
            transform: translateX(-50%);
            padding: 12px 24px;
            background: linear-gradient(180deg, #2d8f3d, #1a5c26);
            border: 2px solid #6fd97a;
            border-radius: 8px;
            color: #fff;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
            z-index: 150;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
            animation: claimPulse 1.5s ease-in-out infinite;
        }

        @keyframes claimPulse {

            0%,
            100% {
                box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
            }

            50% {
                box-shadow: 0 4px 24px rgba(111, 217, 122, 0.6);
            }
        }

        .claim-sales-btn:hover {
            background: linear-gradient(180deg, #3aa04d, #227032);
        }

        .claim-sales-btn:active {
            transform: translateX(-50%) scale(0.95);
        }

        /* Sales detail panel */
        #sales-panel {
            width: 320px;
            max-height: 400px;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .sales-list {
            max-height: 220px;
            overflow-y: auto;
            padding: 8px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
            margin-bottom: 12px;
        }

        .sales-row {
            display: grid;
            grid-template-columns: 1fr auto auto auto;
            gap: 8px;
            padding: 6px 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            font-size: 12px;
            align-items: center;
        }

        .sales-row:last-child {
            border-bottom: none;
        }

        .sales-item {
            color: #ffd700;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .sales-buyer {
            color: #aaa;
        }

        .sales-price {
            color: #7fff7f;
            font-weight: bold;
        }

        .sales-time {
            color: #888;
            font-size: 10px;
        }

        .sales-empty {
            text-align: center;
            color: #666;
            padding: 20px;
        }

        .sales-total {
            display: flex;
            justify-content: space-between;
            padding: 10px 0;
            border-top: 1px solid rgba(255, 215, 0, 0.3);
            margin-bottom: 12px;
        }

        .sales-total-gold {
            color: #ffd700;
            font-size: 18px;
            font-weight: bold;
        }

        .sales-claim-all {
            width: 100%;
        }

        /* Purchase confirm dialog */
        .buy-confirm-box {
            min-width: 240px;
        }

        .buy-confirm-item {
            font-size: 16px;
            font-weight: bold;
            text-align: center;
            padding: 8px 0;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 12px;
        }

        .buy-confirm-price {
            text-align: center;
            line-height: 1.8;
            margin-bottom: 16px;
        }

        .buy-confirm-tax {
            color: #f4a460;
            font-size: 12px;
        }

        .buy-confirm-total {
            color: #ffd700;
            font-size: 18px;
            font-weight: bold;
            margin-top: 4px;
        }

        /* ========== Offline rewards panel ========== */
        .offline-rewards-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.85);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .offline-rewards-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .offline-rewards-panel {
            background: linear-gradient(180deg, #1a1510 0%, #0d0a08 100%);
            border: 2px solid #4a3b2a;
            border-radius: 12px;
            box-shadow: 0 0 30px rgba(199, 179, 119, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
            min-width: 320px;
            max-width: 400px;
            animation: offline-panel-in 0.4s ease-out;
        }

        @keyframes offline-panel-in {
            from {
                transform: scale(0.8) translateY(-20px);
                opacity: 0;
            }

            to {
                transform: scale(1) translateY(0);
                opacity: 1;
            }
        }

        .offline-rewards-header {
            background: linear-gradient(90deg, #2a2015, #3d2f1f, #2a2015);
            padding: 16px 20px;
            border-bottom: 1px solid #4a3b2a;
            text-align: center;
            border-radius: 10px 10px 0 0;
        }

        .offline-icon {
            font-size: 24px;
            margin-right: 8px;
        }

        .offline-title {
            font-size: 20px;
            color: #c7b377;
            font-weight: bold;
            letter-spacing: 2px;
        }

        .offline-rewards-body {
            padding: 20px;
        }

        .offline-time-row,
        .offline-floor-row {
            display: flex;
            justify-content: space-between;
            padding: 8px 0;
            font-size: 14px;
        }

        .offline-label {
            color: #888;
        }

        .offline-value {
            color: #fff;
            font-weight: bold;
        }

        .offline-divider {
            border: none;
            border-top: 1px solid #4a3b2a;
            margin: 15px 0;
        }

        .offline-reward-row {
            display: flex;
            align-items: center;
            padding: 10px 0;
            font-size: 15px;
        }

        .offline-reward-icon {
            width: 30px;
            font-size: 18px;
        }

        .offline-reward-label {
            flex: 1;
            color: #aaa;
        }

        .offline-reward-value {
            font-weight: bold;
            font-size: 18px;
        }

        .offline-reward-value.gold {
            color: #ffd700;
        }

        .offline-reward-value.xp {
            color: #88ff88;
        }

        .offline-items-section {
            margin-top: 15px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 8px;
            padding: 12px;
            border: 1px solid #333;
        }

        .offline-items-header {
            font-size: 13px;
            color: #888;
            margin-bottom: 10px;
            padding-bottom: 8px;
            border-bottom: 1px solid #333;
        }

        .offline-items-container {
            max-height: 120px;
            overflow-y: auto;
        }

        .offline-items {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .offline-item {
            font-size: 13px;
            padding: 4px 8px;
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        .offline-items-empty {
            color: #666;
            font-size: 12px;
            text-align: center;
            padding: 10px;
        }

        .offline-rewards-footer {
            padding: 15px 20px 20px;
        }

        .offline-claim-btn {
            width: 100%;
            padding: 14px;
            font-size: 16px;
            font-weight: bold;
            color: #fff;
            background: linear-gradient(180deg, #4a6b2a 0%, #2d4a15 100%);
            border: 2px solid #6a8b4a;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
        }

        .offline-claim-btn:hover {
            background: linear-gradient(180deg, #5a7b3a 0%, #3d5a25 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(74, 107, 42, 0.4);
        }

        .offline-claim-btn:active {
            transform: translateY(0);
        }

        .offline-tip {
            text-align: center;
            font-size: 11px;
            color: #666;
            padding: 0 20px 15px;
        }

        /* ========== Death dialog panel ========== */
        .death-panel-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(20, 0, 0, 0.9);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10001;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .death-panel-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .death-panel {
            background: linear-gradient(180deg, #1a0a0a 0%, #0d0505 100%);
            border: 2px solid #6a2a2a;
            border-radius: 12px;
            box-shadow: 0 0 40px rgba(255, 50, 50, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
            min-width: 320px;
            max-width: 400px;
            animation: death-panel-in 0.5s ease-out;
        }

        @keyframes death-panel-in {
            from {
                transform: scale(0.8) translateY(-30px);
                opacity: 0;
            }

            to {
                transform: scale(1) translateY(0);
                opacity: 1;
            }
        }

        .death-panel-header {
            background: linear-gradient(90deg, #2a1515, #3d1f1f, #2a1515);
            padding: 16px 20px;
            border-bottom: 1px solid #6a2a2a;
            text-align: center;
            border-radius: 10px 10px 0 0;
        }

        .death-icon {
            font-size: 28px;
            margin-right: 8px;
            animation: death-icon-pulse 1.5s ease-in-out infinite;
        }

        @keyframes death-icon-pulse {

            0%,
            100% {
                transform: scale(1);
            }

            50% {
                transform: scale(1.1);
            }
        }

        .death-title {
            font-size: 22px;
            color: #ff6666;
            font-weight: bold;
            letter-spacing: 3px;
            text-shadow: 0 0 10px rgba(255, 50, 50, 0.5);
        }

        .death-panel-body {
            padding: 20px;
        }

        .death-stat-row {
            display: flex;
            align-items: center;
            padding: 10px 0;
            font-size: 15px;
        }

        .death-stat-icon {
            width: 30px;
            font-size: 18px;
        }

        .death-stat-label {
            flex: 1;
            color: #999;
        }

        .death-stat-value {
            font-weight: bold;
            color: #fff;
            font-size: 16px;
        }

        .death-divider {
            border: none;
            border-top: 1px solid #6a2a2a;
            margin: 15px 0;
        }

        .death-cause {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 10px;
            background: rgba(255, 0, 0, 0.1);
            border-radius: 8px;
            border: 1px solid #4a1a1a;
        }

        .death-cause-icon {
            font-size: 20px;
            margin-right: 8px;
        }

        .death-cause-text {
            color: #ff8888;
            font-size: 14px;
        }

        .death-panel-footer {
            padding: 15px 20px 10px;
            display: flex;
            gap: 12px;
        }

        .death-btn {
            flex: 1;
            padding: 14px 10px;
            font-size: 14px;
            font-weight: bold;
            color: #fff;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
        }

        .death-btn .btn-icon {
            font-size: 20px;
        }

        .death-btn .btn-text {
            font-size: 14px;
        }

        .death-btn .btn-cost {
            font-size: 12px;
            opacity: 0.9;
        }

        .death-btn.revive-btn {
            background: linear-gradient(180deg, #6a4b2a 0%, #4a3015 100%);
            border: 2px solid #8a6b4a;
        }

        .death-btn.revive-btn:hover:not(:disabled) {
            background: linear-gradient(180deg, #7a5b3a 0%, #5a4025 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(138, 107, 74, 0.4);
        }

        .death-btn.revive-btn:disabled {
            background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
            border-color: #4a4a4a;
            cursor: not-allowed;
            opacity: 0.6;
        }

        .death-btn.revive-btn:disabled .btn-cost {
            color: #ff6666;
        }

        .death-btn.return-btn {
            background: linear-gradient(180deg, #2a4a6a 0%, #153040 100%);
            border: 2px solid #4a6a8a;
        }

        .death-btn.return-btn:hover {
            background: linear-gradient(180deg, #3a5a7a 0%, #254050 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(74, 106, 138, 0.4);
        }

        .death-btn:active {
            transform: translateY(0);
        }

        .death-gold-display {
            text-align: center;
            font-size: 14px;
            color: #ffd700;
            padding: 10px 20px 20px;
        }

        /* ========== Auto battle hire cost reminder panel ========== */
        .auto-battle-fee-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.85);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10001;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .auto-battle-fee-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .auto-battle-fee-panel {
            background: linear-gradient(180deg, #1a1a0a 0%, #0d0d05 100%);
            border: 2px solid #6a5a2a;
            border-radius: 12px;
            box-shadow: 0 0 40px rgba(255, 200, 50, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.5);
            min-width: 300px;
            max-width: 360px;
            animation: fee-panel-in 0.4s ease-out;
        }

        @keyframes fee-panel-in {
            from {
                transform: scale(0.9) translateY(-20px);
                opacity: 0;
            }

            to {
                transform: scale(1) translateY(0);
                opacity: 1;
            }
        }

        .auto-battle-fee-header {
            background: linear-gradient(90deg, #2a2515, #3d3520, #2a2515);
            padding: 16px 20px;
            border-bottom: 1px solid #6a5a2a;
            text-align: center;
            border-radius: 10px 10px 0 0;
        }

        .fee-icon {
            font-size: 24px;
            margin-right: 8px;
        }

        .fee-title {
            font-size: 20px;
            color: #ffd700;
            font-weight: bold;
            letter-spacing: 2px;
            text-shadow: 0 0 10px rgba(255, 200, 50, 0.5);
        }

        .auto-battle-fee-body {
            padding: 25px 20px;
            text-align: center;
            color: #ccc;
            font-size: 15px;
            line-height: 1.8;
        }

        .auto-battle-fee-body p {
            margin: 0;
        }

        .fee-highlight {
            color: #ffd700;
            font-size: 18px;
            font-weight: bold;
        }

        .fee-note {
            color: #888;
            font-size: 13px;
            margin-top: 10px !important;
        }

        .auto-battle-fee-footer {
            padding: 15px 20px 20px;
            text-align: center;
        }

        .fee-confirm-btn {
            padding: 12px 40px;
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            background: linear-gradient(180deg, #6a5a2a 0%, #3d3015 100%);
            border: 2px solid #8a7a4a;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s ease;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
        }

        .fee-confirm-btn:hover {
            background: linear-gradient(180deg, #8a7a4a 0%, #5d5025 100%);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(138, 122, 74, 0.4);
        }

        .fee-confirm-btn:active {
            transform: translateY(0);
        }

        /* Skill button disabled state */
        .skill-btn.disabled {
            cursor: not-allowed;
            opacity: 0.4;
            filter: grayscale(1);
            pointer-events: none;
        }

        .skill-btn.disabled .skill-sprite {
            filter: grayscale(1);
        }

        /* Nickname input error hint */
        .nickname-error {
            background: rgba(255, 0, 0, 0.1);
            border: 1px solid #ff4444;
            border-radius: 4px;
            color: #ff4444;
            padding: 8px 12px;
            margin: 10px 0;
            font-size: 14px;
            text-align: center;
            animation: shake 0.3s ease-in-out;
        }

        @keyframes shake {

            0%,
            100% {
                transform: translateX(0);
            }

            25% {
                transform: translateX(-5px);
            }

            75% {
                transform: translateX(5px);
            }
        }

        /* Generic game dialog styles */
        .game-dialog-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(4px);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 99999;
        }

        .game-dialog-overlay.active {
            display: flex;
        }

        .game-dialog-panel {
            background: var(--ui-panel-bg);
            border: 2px solid var(--ui-border);
            box-shadow: 0 0 40px rgba(0, 0, 0, 0.9), inset 0 0 15px rgba(0, 0, 0, 0.6);
            width: 380px;
            padding: 0;
            position: relative;
            border-radius: 4px;
            animation: dialogAppear 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
        }

        @keyframes dialogAppear {
            from {
                opacity: 0;
                transform: scale(0.8) translateY(20px);
            }

            to {
                opacity: 1;
                transform: scale(1) translateY(0);
            }
        }

        .game-dialog-header {
            background: var(--ui-header-bg);
            color: var(--text-gold);
            padding: 15px 20px;
            font-family: var(--font-ui);
            font-size: 18px;
            text-align: center;
            border-bottom: 1px solid var(--ui-border);
            text-transform: uppercase;
            letter-spacing: 2px;
            font-weight: bold;
        }

        .game-dialog-body {
            padding: 25px 20px;
            color: #d4c6a9;
            font-size: 15px;
            line-height: 1.6;
            text-align: center;
        }

        .game-dialog-footer {
            padding: 15px 20px 20px;
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .game-dialog-btn {
            padding: 10px 25px;
            min-width: 100px;
            background: #2a2218;
            border: 1px solid #4a3e2a;
            color: #d4c6a9;
            font-family: var(--font-ui);
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.2s;
            outline: none;
            border-radius: 2px;
        }

        .game-dialog-btn:hover {
            background: #3d3422;
            border-color: #c7b377;
            color: #fff;
            box-shadow: 0 0 10px rgba(199, 179, 119, 0.2);
        }

        .game-dialog-btn.primary {
            background: #4a3e2a;
            border-color: #c7b377;
            color: #fff;
        }

        .game-dialog-btn.primary:hover {
            background: #5d4e36;
            box-shadow: 0 0 15px rgba(199, 179, 119, 0.3);
        }

        /* Abyss Mode UI */
        #abyss-entrance-panel {
            position: fixed;
            top: 50%;
            left: 50%;
            width: 320px;
            background: rgba(10, 5, 5, 0.95);
            border: 2px solid #a33;
            border-radius: 8px;
            padding: 15px;
            color: #ddd;
            box-shadow: 0 0 30px rgba(170, 50, 50, 0.5);
            z-index: 2000;
            display: none;
            font-family: var(--font-ui);
        }

        #abyss-entrance-panel.active,
        #abyss-contract-panel.active {
            display: block;
        }

        .abyss-title {
            font-size: 24px;
            color: #f66;
            text-align: center;
            margin-bottom: 20px;
            border-bottom: 1px solid #622;
            padding-bottom: 10px;
        }

        .abyss-info-row {
            display: flex;
            justify-content: space-between;
            margin: 10px 0;
            font-size: 16px;
        }

        .abyss-info-label {
            color: #888;
        }

        .abyss-info-value {
            color: #fe0;
            font-weight: bold;
        }

        .abyss-time-left {
            text-align: center;
            margin: 20px 0;
            color: #fa0;
            font-size: 14px;
        }

        .abyss-btn-group {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-top: 20px;
        }

        .abyss-btn {
            background: linear-gradient(to bottom, #722, #400);
            border: 1px solid #844;
            color: #ddd;
            padding: 6px 12px;
            cursor: pointer;
            font-family: inherit;
            font-size: 13px;
            transition: all 0.2s;
            border-radius: 4px;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
        }

        .abyss-btn:hover {
            background: linear-gradient(to bottom, #933, #611);
            border-color: #a55;
            color: #fff;
            box-shadow: 0 0 8px rgba(255, 50, 50, 0.3);
        }

        .abyss-btn:active {
            transform: scale(0.96);
            background: #300;
        }

        #abyss-hud {
            position: fixed;
            top: 32px;
            left: 10px;
            /* Below the floor display */
            background: rgba(80, 20, 20, 0.85);
            padding: 8px 12px;
            border: 1px solid #833;
            border-radius: 4px;
            color: #fff;
            display: none;
            pointer-events: none;
            text-align: left;
            z-index: 100;
        }

        #abyss-hud.active {
            display: block;
        }

        .abyss-hud-floor {
            font-size: 18px;
            color: #f88;
            font-weight: bold;
        }

        .abyss-hud-time {
            color: #aaa;
            font-size: 14px;
        }

        .abyss-hud-warning {
            color: #ff6666;
            font-size: 11px;
            margin-top: 5px;
            animation: pulse-red 2s infinite;
        }

        /* Abyss covenant styles */
        .contract-list-scroll {
            max-height: 280px;
            overflow-y: auto;
            margin: 15px 0;
            padding-right: 5px;
            scrollbar-width: thin;
            scrollbar-color: #500 #200;
        }

        .contract-item {
            display: flex;
            align-items: center;
            background: rgba(30, 20, 20, 0.6);
            border: 1px solid #433;
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 10px;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            position: relative;
            border-left: 4px solid transparent;
        }

        .contract-item:hover {
            background: rgba(50, 30, 30, 0.8);
            border-color: #644;
            transform: translateX(3px);
        }

        .contract-item.selected {
            background: rgba(80, 20, 20, 0.4);
            border-color: #ff4444;
            border-left: 4px solid #ff4444;
            box-shadow: 0 4px 15px rgba(255, 0, 0, 0.1);
        }

        .contract-icon {
            font-size: 24px;
            margin-right: 15px;
            filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
        }

        .contract-info {
            flex: 1;
        }

        .contract-name {
            color: #eee;
            font-size: 15px;
            font-weight: bold;
            margin-bottom: 3px;
        }

        .contract-desc {
            color: #999;
            font-size: 11px;
            line-height: 1.3;
        }

        .contract-multiplier {
            color: #ff4444;
            font-weight: bold;
            font-size: 15px;
            margin-left: 10px;
            text-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
        }

        .contract-item.selected .contract-name {
            color: #ff4444;
        }


        /* Leaderboard UI */
        #abyss-leaderboard-panel {
            position: fixed;
            top: 50%;
            left: 50%;
            width: 320px;
            background: rgba(10, 5, 5, 0.98);
            border: 2px solid #844;
            border-radius: 8px;
            color: #ccc;
            z-index: 2100;
            display: none;
            flex-direction: column;
            box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
            font-family: var(--font-ui);
        }

        #abyss-leaderboard-panel.active {
            display: flex;
        }



        .lb-header {
            padding: 15px;
            border-bottom: 1px solid #622;
            font-size: 20px;
            color: #f66;
            text-align: center;
            position: relative;
            background: linear-gradient(to right, #200, #400, #200);
        }

        .lb-close {
            position: absolute;
            right: 15px;
            top: 15px;
            cursor: pointer;
            color: #888;
        }

        .lb-my-rank {
            background: #311;
            padding: 15px;
            border-bottom: 1px solid #522;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .lb-rank-badge {
            background: #a33;
            color: #fff;
            padding: 2px 8px;
            border-radius: 4px;
            font-weight: bold;
        }

        .lb-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
        }

        .lb-item {
            display: flex;
            padding: 10px;
            border-bottom: 1px solid #333;
            align-items: center;
        }

        .lb-item:nth-child(odd) {
            background: rgba(255, 255, 255, 0.02);
        }

        .lb-item.self {
            background: rgba(100, 50, 50, 0.4);
            border: 1px solid #844;
        }

        /* --- Abyss deification title VFX --- */
        @keyframes gold-shine {
            0% {
                text-shadow: 0 0 5px #ff0, 0 0 10px #f90;
                filter: brightness(1);
            }

            50% {
                text-shadow: 0 0 20px #ff0, 0 0 30px #f90;
                filter: brightness(1.5);
            }

            100% {
                text-shadow: 0 0 5px #ff0, 0 0 10px #f90;
                filter: brightness(1);
            }
        }

        @keyframes silver-shine {
            0% {
                text-shadow: 0 0 5px #fff;
                opacity: 0.8;
            }

            50% {
                text-shadow: 0 0 15px #fff;
                opacity: 1;
            }

            100% {
                text-shadow: 0 0 5px #fff;
                opacity: 0.8;
            }
        }

        @keyframes purple-flame {
            0% {
                text-shadow: 0 0 5px #a0f;
                color: #d8f;
            }

            50% {
                text-shadow: 0 0 15px #f0f;
                color: #fff;
            }

            100% {
                text-shadow: 0 0 5px #a0f;
                color: #d8f;
            }
        }

        .lb-item-rank {
            width: 40px;
            text-align: center;
            font-weight: bold;
            color: #888;
            transition: all 0.3s;
        }

        /* Champion: gold light breathing */
        .lb-item.top1 {
            background: rgba(100, 80, 0, 0.15) !important;
            border-left: 3px solid #fe0 !important;
        }

        .lb-item.top1 .lb-item-rank {
            color: #fe0;
            font-size: 22px;
            animation: gold-shine 2s infinite ease-in-out;
            transform: scale(1.1);
        }

        .lb-item.top1 .lb-item-name {
            color: #fe0 !important;
            font-weight: bold;
            text-shadow: 0 0 8px rgba(255, 230, 0, 0.5);
        }

        /* Runner-up: silver light flow */
        .lb-item.top2 {
            background: rgba(100, 100, 100, 0.1) !important;
            border-left: 3px solid #ddd !important;
        }

        .lb-item.top2 .lb-item-rank {
            color: #ddd;
            font-size: 18px;
            animation: silver-shine 3s infinite ease-in-out;
        }

        .lb-item.top2 .lb-item-name {
            color: #fff !important;
            text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
        }

        /* Third place: purple-gold rising */
        .lb-item.top3 {
            background: rgba(80, 40, 100, 0.1) !important;
            border-left: 3px solid #b84 !important;
        }

        .lb-item.top3 .lb-item-rank {
            color: #b84;
            font-size: 17px;
            animation: purple-flame 2.5s infinite ease-in-out;
        }

        .lb-item.top3 .lb-item-name {
            color: #d8f !important;
        }

        .lb-item-info {
            flex: 1;
            display: flex;
            flex-direction: column;
            margin-left: 10px;
        }

        .lb-item-name {
            color: #ddd;
            font-size: 14px;
        }

        .lb-item-class {
            color: #888;
            font-size: 12px;
        }

        .lb-item-score {
            text-align: right;
            color: #fa0;
            font-family: monospace;
            font-size: 16px;
        }

        .lb-item-floor {
            text-align: right;
            color: #aaa;
            font-size: 12px;
        }


        /* Abyss Scrollbar & Panel Fixes */
        #abyss-entrance-panel,
        #abyss-leaderboard-panel,
        #abyss-result-panel {
            /* Ensure they look like game panels but with Abyss flavor */
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
            pointer-events: auto;
            /* Ensure clicks are captured */
        }

        /* Custom Scrollbar for Abyss Leaderboard */
        .lb-list::-webkit-scrollbar {
            width: 6px;
        }

        .lb-list::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 3px;
        }

        .lb-list::-webkit-scrollbar-thumb {
            background: #622;
            border-radius: 3px;
            border: 1px solid #844;
        }

        .lb-list::-webkit-scrollbar-thumb:hover {
            background: #844;
        }

        .lb-list {
            scrollbar-width: thin;
            scrollbar-color: #622 rgba(0, 0, 0, 0.3);
        }


        /* Deep Abyss Specific Adjustments */
        #abyss-result-panel .panel-btn-group {
            display: flex;
            justify-content: center;
        }

        #abyss-result-panel .btn {
            width: 100%;
            margin: 0;
        }

        /* ========== Title shop panel ========== */
        .title-shop-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.85);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10000;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .title-shop-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .title-shop-panel {
            background: linear-gradient(180deg, #1a1510 0%, #0d0a08 100%);
            border: 2px solid #c7b377;
            border-radius: 12px;
            box-shadow: 0 0 30px rgba(199, 179, 119, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.5);
            min-width: 360px;
            max-width: 420px;
            animation: title-shop-in 0.4s ease-out;
        }

        @keyframes title-shop-in {
            from {
                transform: scale(0.8) translateY(-20px);
                opacity: 0;
            }

            to {
                transform: scale(1) translateY(0);
                opacity: 1;
            }
        }

        .title-shop-header {
            background: linear-gradient(90deg, #2a2015, #4a3b2a, #2a2015);
            padding: 16px 20px;
            border-bottom: 1px solid #c7b377;
            text-align: center;
            border-radius: 10px 10px 0 0;
        }

        .title-shop-icon {
            font-size: 24px;
            margin-right: 8px;
        }

        .title-shop-title {
            font-size: 20px;
            color: #ffd700;
            font-weight: bold;
            letter-spacing: 2px;
        }

        .title-shop-body {
            padding: 20px;
        }

        .title-shop-current {
            text-align: center;
            font-size: 16px;
            color: #aaa;
            margin-bottom: 10px;
        }

        .title-shop-gold {
            text-align: center;
            font-size: 14px;
            color: #ffd700;
            margin-bottom: 10px;
        }

        .title-shop-divider {
            border: none;
            border-top: 1px solid #4a3b2a;
            margin: 15px 0;
        }

        .title-shop-list {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: 320px;
            overflow-y: auto;
            padding-right: 5px;
            scrollbar-width: thin;
            scrollbar-color: #444 rgba(0, 0, 0, 0.3);
        }

        .title-shop-list::-webkit-scrollbar {
            width: 8px;
        }

        .title-shop-list::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.3);
            border-radius: 4px;
        }

        .title-shop-list::-webkit-scrollbar-thumb {
            background: #444;
            border-radius: 4px;
            border: 1px solid #333;
        }

        .title-shop-list::-webkit-scrollbar-thumb:hover {
            background: #555;
        }

        .title-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 15px;
            background: rgba(30, 25, 20, 0.8);
            border: 1px solid #3a3025;
            border-radius: 8px;
            transition: all 0.2s;
        }

        .title-item:hover {
            background: rgba(50, 40, 30, 0.9);
            border-color: #5a4a35;
        }

        .title-item.equipped {
            border-color: #4a4;
            background: rgba(40, 60, 40, 0.5);
        }

        .title-item-info {
            flex: 1;
        }

        .title-item-name {
            font-size: 15px;
            font-weight: bold;
            margin-bottom: 4px;
        }

        .title-item-price {
            font-size: 12px;
            color: #888;
        }

        .title-item-status {
            font-size: 12px;
            color: #4a4;
            margin-left: 8px;
        }

        .title-item-btn {
            padding: 6px 14px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s;
        }

        .title-item-btn.buy {
            background: linear-gradient(180deg, #5a8a3a, #3a6a2a);
            color: #fff;
        }

        .title-item-btn.buy:hover {
            background: linear-gradient(180deg, #6a9a4a, #4a7a3a);
        }

        .title-item-btn.buy:disabled {
            background: #444;
            color: #666;
            cursor: not-allowed;
        }

        .title-item-btn.equip {
            background: linear-gradient(180deg, #4a6a9a, #3a5a7a);
            color: #fff;
        }

        .title-item-btn.equip:hover {
            background: linear-gradient(180deg, #5a7aaa, #4a6a8a);
        }

        .title-shop-footer {
            padding: 15px 20px;
            border-top: 1px solid #4a3b2a;
            text-align: center;
        }

        .title-shop-close-btn {
            padding: 10px 40px;
            background: linear-gradient(180deg, #4a3b2a, #2a2015);
            border: 1px solid #6a5a4a;
            border-radius: 6px;
            color: #c7b377;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .title-shop-close-btn:hover {
            background: linear-gradient(180deg, #5a4b3a, #3a3025);
            border-color: #8a7a6a;
        }

        /* Title VFX styles */
        .title-glow {
            text-shadow: 0 0 8px currentColor;
        }

        .title-rainbow {
            background: linear-gradient(90deg, #ff0000, #ff8800, #ffff00, #00ff00, #0088ff, #8800ff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            font-weight: bold;
        }

        /* ========== Gold spend animation ========== */
        .gold-spend-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            pointer-events: none;
            z-index: 15000;
        }

        .gold-spend-text {
            font-size: 48px;
            font-weight: bold;
            color: #ffd700;
            text-shadow: 0 0 20px #ff6600, 0 0 40px #ff4400, 2px 2px 4px rgba(0, 0, 0, 0.8);
            animation: goldSpendAnim 1.5s ease-out forwards;
        }

        @keyframes goldSpendAnim {
            0% {
                opacity: 1;
                transform: scale(0.5) translateY(0);
            }

            20% {
                opacity: 1;
                transform: scale(1.2) translateY(0);
            }

            40% {
                opacity: 1;
                transform: scale(1) translateY(0);
            }

            100% {
                opacity: 0;
                transform: scale(0.8) translateY(-80px);
            }
        }

        /* ========== Title unlock VFX ========== */
        .title-unlock-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.85);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 16000;
            animation: titleUnlockFadeIn 0.5s ease-out;
            cursor: pointer;
        }

        @keyframes titleUnlockFadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        .title-unlock-panel {
            position: relative;
            text-align: center;
            animation: titleUnlockPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        @keyframes titleUnlockPop {
            0% {
                opacity: 0;
                transform: scale(0.3);
            }

            100% {
                opacity: 1;
                transform: scale(1);
            }
        }

        .title-unlock-glow {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 300px;
            height: 300px;
            transform: translate(-50%, -50%);
            background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, rgba(255, 215, 0, 0) 70%);
            animation: titleGlowPulse 2s ease-in-out infinite;
            pointer-events: none;
        }

        @keyframes titleGlowPulse {

            0%,
            100% {
                transform: translate(-50%, -50%) scale(1);
                opacity: 0.6;
            }

            50% {
                transform: translate(-50%, -50%) scale(1.3);
                opacity: 1;
            }
        }

        .title-unlock-icon {
            font-size: 64px;
            margin-bottom: 15px;
            animation: titleIconBounce 1s ease-in-out infinite;
        }

        @keyframes titleIconBounce {

            0%,
            100% {
                transform: translateY(0);
            }

            50% {
                transform: translateY(-10px);
            }
        }

        .title-unlock-label {
            font-size: 18px;
            color: #888;
            letter-spacing: 4px;
            margin-bottom: 10px;
        }

        .title-unlock-name {
            font-size: 36px;
            font-weight: bold;
            margin-bottom: 20px;
            animation: titleNameShine 2s linear infinite;
        }

        @keyframes titleNameShine {
            0% {
                filter: brightness(1);
            }

            50% {
                filter: brightness(1.3);
            }

            100% {
                filter: brightness(1);
            }
        }

        .title-unlock-hint {
            font-size: 12px;
            color: #666;
            margin-top: 30px;
        }

        /* Text explains, icons identify; locked nodes stay readable. */
        .equipment-slot-label {
            position: absolute;
            bottom: 3px;
            left: 0;
            width: 100%;
            text-align: center;
            font-size: 11px;
            color: #b9aa8e;
            pointer-events: none;
            text-shadow: 0 1px 2px #000;
        }
        .skill-node-desc {
            margin: 5px 0;
            color: #c8bca5;
            font: 12px/1.5 "Microsoft YaHei", sans-serif;
            overflow-wrap: anywhere;
        }
        .skill-tree-node.locked { opacity: 0.78; }
        .skill-route-preview {
            flex: 1;
            min-width: 0;
            padding: 10px;
            border: 1px solid #66543a;
            border-radius: 6px;
            background: #191710;
        }
        .skill-route-option { margin: 10px 0; text-align: left; }
        .skill-route-option strong { color: #deca9b; font-size: 12px; }
        .skill-route-option p { color: #bfb5a3; font: 12px/1.5 sans-serif; margin: 4px 0; }
        .skill-holy_shield { background-position: 0% 0%; }

#art-loading:not([hidden]) { position:absolute; inset:0; z-index:1000000; display:grid; place-items:center; background:#111d; color:#e4c98b; font:16px var(--font-ui); pointer-events:auto; }

/* Multilingual UI Styles */
.lang-selector-bar {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.lang-pill-btn {
    background: rgba(18, 16, 12, 0.85);
    border: 1px solid #7c6843;
    color: #e4c98b;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.lang-pill-btn:hover {
    background: rgba(45, 38, 25, 0.95);
    border-color: #ffd700;
    color: #fff;
    transform: translateY(-1px);
}

.lang-pill-btn.active {
    background: linear-gradient(135deg, #7c6843, #a88948);
    border-color: #ffd700;
    color: #12100c;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.quick-lang-btn {
    position: absolute;
    top: 10px;
    left: 175px;
    background: rgba(20, 20, 20, 0.85);
    border: 1px solid #7c6843;
    color: #e4c98b;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    z-index: 20;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    user-select: none;
}

.quick-lang-btn:hover {
    background: #332b1d;
    border-color: #ffd700;
    color: #fff;
}

/* ========== Pop-up Animation para Ítems Legendarios y de Set ========== */
#loot-popup-container {
    position: absolute;
    top: 65px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 12000;
    pointer-events: none;
    width: 90%;
    max-width: 420px;
}

.loot-popup-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px 10px 12px;
    background: linear-gradient(135deg, rgba(22, 20, 28, 0.96) 0%, rgba(10, 8, 14, 0.98) 100%);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(-25px) scale(0.85);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.35s ease;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.loot-popup-card.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.loot-popup-card.hide {
    opacity: 0;
    transform: translateY(-18px) scale(0.92);
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Unique / Legendary Styling */
.loot-popup-card.rarity-unique {
    border: 1px solid #d4af37;
    box-shadow: 0 0 18px rgba(212, 175, 55, 0.55), inset 0 0 12px rgba(255, 215, 0, 0.15);
}

/* Set Styling */
.loot-popup-card.rarity-set {
    border: 1px solid #20ff20;
    box-shadow: 0 0 18px rgba(32, 255, 32, 0.55), inset 0 0 12px rgba(32, 255, 32, 0.15);
}

/* Shine beam effect across the card */
.loot-popup-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -70%;
    width: 60%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    transform: rotate(25deg);
    animation: lootShine 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s;
    pointer-events: none;
}

@keyframes lootShine {
    0% { left: -70%; }
    100% { left: 140%; }
}

/* Icon Frame */
.loot-popup-icon-frame {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 6px;
    background-color: #121016;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.loot-popup-card.rarity-unique .loot-popup-icon-frame {
    border: 1px solid #d4af37;
    box-shadow: 0 0 8px rgba(212, 175, 55, 0.6), inset 0 0 4px #000;
}

.loot-popup-card.rarity-set .loot-popup-icon-frame {
    border: 1px solid #20ff20;
    box-shadow: 0 0 8px rgba(32, 255, 32, 0.6), inset 0 0 4px #000;
}

.loot-popup-icon-inner {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* Content Container */
.loot-popup-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    flex: 1;
}

.loot-popup-header {
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 2px;
}

.loot-popup-card.rarity-unique .loot-popup-header {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.6);
}

.loot-popup-card.rarity-set .loot-popup-header {
    color: #40ff40;
    text-shadow: 0 0 5px rgba(64, 255, 64, 0.6);
}

.loot-popup-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.loot-popup-card.rarity-unique .loot-popup-title {
    color: #ffb700;
    text-shadow: 0 0 6px rgba(255, 183, 0, 0.6), 0 1px 2px #000;
}

.loot-popup-card.rarity-set .loot-popup-title {
    color: #20ff20;
    text-shadow: 0 0 6px rgba(32, 255, 32, 0.6), 0 1px 2px #000;
}

.loot-popup-subtitle {
    font-size: 11px;
    color: #b0b0c0;
    margin-top: 2px;
}

@media (max-width: 768px) {
    #loot-popup-container {
        top: 50px;
        width: 92%;
    }
    .loot-popup-card {
        padding: 8px 14px 8px 10px;
    }
    .loot-popup-title {
        font-size: 13px;
    }
    .lang-selector-bar {
        top: 10px;
        right: 10px;
        gap: 4px;
    }
    .lang-pill-btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    .quick-lang-btn {
        left: auto;
        right: 10px;
        top: 10px;
    }
}

/* ========== Runes & sockets styles ========== */
.slot-sockets-bar {
    position: absolute;
    bottom: 3px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3px;
    pointer-events: none;
    z-index: 4;
}

.socket-pip {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid #777;
    box-sizing: border-box;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.socket-pip.filled {
    border-color: #ffd700;
    box-shadow: 0 0 4px rgba(255, 215, 0, 0.8), inset 0 0 2px #fff;
}

.socket-source-rune {
    outline: 2px solid #ffb74d !important;
    box-shadow: 0 0 8px #ffb74d, inset 0 0 6px #ffb74d !important;
    animation: runePulse 1s ease-in-out infinite alternate;
}

.socket-target-candidate {
    outline: 2px dashed #40ff40 !important;
    box-shadow: 0 0 8px rgba(64, 255, 64, 0.6) !important;
    cursor: pointer;
    animation: candidateGlow 1.2s ease-in-out infinite alternate;
}

@keyframes runePulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.05); filter: brightness(1.3); }
}

@keyframes candidateGlow {
    from { border-color: #40ff40; box-shadow: 0 0 4px #40ff40; }
    to { border-color: #ffd700; box-shadow: 0 0 10px #ffd700; }
}

.tooltip-sockets-section {
    margin-top: 6px;
    border-top: 1px solid #3d3429;
    padding-top: 5px;
}

.tooltip-runeword-card {
    margin-top: 6px;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid #d4af37;
    border-radius: 4px;
    padding: 6px;
    text-shadow: 0 1px 2px #000;
}

/* ========== Free talent 3-pick-1 modal ========== */
.talent-draft-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.talent-draft-modal.active {
    opacity: 1;
}

.talent-draft-content {
    background: radial-gradient(circle at center, #261f18 0%, #120e0a 100%);
    border: 2px solid #c7b377;
    border-radius: 12px;
    padding: 24px 30px;
    box-shadow: 0 0 35px rgba(212, 175, 55, 0.4), inset 0 0 20px rgba(0, 0, 0, 0.8);
    max-width: 820px;
    width: 90%;
    text-align: center;
    animation: draftPopIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes draftPopIn {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.talent-draft-header {
    font-size: 20px;
    font-weight: 800;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.talent-draft-subtitle {
    font-size: 13px;
    color: #d8c8a8;
    margin-bottom: 22px;
}

.talent-draft-cards {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.talent-draft-card {
    flex: 1;
    min-width: 200px;
    max-width: 240px;
    background: linear-gradient(165deg, rgba(40, 30, 20, 0.95), rgba(15, 12, 8, 0.98));
    border: 1.5px solid var(--tier-color, #c7b377);
    border-radius: 8px;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    position: relative;
    overflow: hidden;
}

.talent-draft-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: skewX(-25deg);
    transition: left 0.5s ease;
}

.talent-draft-card:hover {
    transform: translateY(-6px);
    border-color: #ffd700;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.35);
}

.talent-draft-card:hover::before {
    left: 200%;
}

.talent-draft-icon {
    font-size: 38px;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.5));
}

.talent-draft-tier {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.talent-draft-name {
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px #000;
}

.talent-draft-desc {
    font-size: 12px;
    color: #ccc;
    line-height: 1.45;
    flex-grow: 1;
    margin-bottom: 14px;
    text-align: center;
}

.talent-draft-btn {
    background: linear-gradient(180deg, #d4af37 0%, #aa8020 100%);
    color: #120e0a;
    font-weight: 800;
    font-size: 13px;
    border: 1px solid #ffd700;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: filter 0.15s ease, transform 0.1s ease;
}

.talent-draft-btn:hover {
    filter: brightness(1.2);
    transform: scale(1.04);
}

/* ========== Abyss progress HUD status bar ========== */
#abyss-hud-status {
    position: absolute;
    top: 52px;
    left: 12px;
    background: rgba(18, 14, 10, 0.85);
    border: 1px solid #8a5a2a;
    border-radius: 6px;
    padding: 5px 10px;
    color: #d8c8a8;
    font-size: 11px;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

#abyss-hud-status:hover {
    border-color: #ffd700;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
    transform: scale(1.02);
}

.abyss-hud-badge {
    background: linear-gradient(135deg, #7c1a1a, #3a0d0d);
    color: #ffcccc;
    font-weight: bold;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #ff4444;
}

@media (max-width: 768px) {
    .talent-draft-cards {
        flex-direction: column;
        align-items: center;
    }
    .talent-draft-card {
        max-width: 100%;
        width: 100%;
        min-width: unset;
    }
    #abyss-hud-status {
        top: 45px;
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* ========== Share card system ========== */
.share-card-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 4, 12, 0.88);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    pointer-events: auto;
}

.share-card-panel {
    background: linear-gradient(180deg, #1e1428 0%, #120c1a 100%);
    border: 2px solid #b8860b;
    border-radius: 12px;
    box-shadow: 0 0 35px rgba(0, 0, 0, 0.9), 0 0 20px rgba(218, 165, 32, 0.25);
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.share-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid #4a3820;
}

.share-card-title {
    font-size: 16px;
    font-weight: bold;
    color: #ffd700;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 1px 3px #000;
}

.share-close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.15s;
}

.share-close-btn:hover {
    color: #ff4444;
}

.share-card-body {
    padding: 14px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #09050d;
}

.share-preview-container {
    width: 100%;
    max-width: 440px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.8);
    border: 1px solid #3d2b1f;
    overflow: hidden;
}

.share-preview-container canvas {
    width: 100%;
    height: auto;
    display: block;
}

.share-card-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid #4a3820;
}

.share-action-btn {
    flex: 1;
    background: linear-gradient(180deg, #2a2035 0%, #171120 100%);
    border: 1px solid #6b5030;
    color: #e2d8c8;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.share-action-btn:hover {
    border-color: #ffd700;
    color: #fff;
    transform: translateY(-1px);
}

.share-action-btn.primary {
    background: linear-gradient(180deg, #d4af37 0%, #996515 100%);
    color: #1a0f05;
    border-color: #ffe066;
}

/* ========== Season & ladder journey ========== */
.season-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 3, 8, 0.88);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1040;
    pointer-events: auto;
}

.season-panel {
    background: linear-gradient(180deg, #181124 0%, #0d0914 100%);
    border: 2px solid #9c7a2b;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    width: 90%;
    max-width: 620px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.season-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid #4a3820;
}

.season-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.season-badge {
    background: linear-gradient(135deg, #d4af37, #855a15);
    color: #0d0804;
    font-weight: 900;
    font-size: 16px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #ffd700;
}

.season-title-box h2 {
    margin: 0;
    font-size: 18px;
    color: #ffd700;
}

.season-buff-info {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: #6ee7b7;
}

.season-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
}

.season-close-btn:hover {
    color: #ff4444;
}

.season-body {
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.season-progress-overview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid #443320;
    border-radius: 8px;
    padding: 10px 16px;
}

.season-score-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

.season-score-label {
    font-size: 13px;
    color: #cbd5e1;
}

.season-score-val {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
}

.season-countdown {
    font-size: 12px;
    color: #94a3b8;
}

.season-milestones-title {
    font-size: 14px;
    font-weight: bold;
    color: #e2d8c8;
}

.season-milestones-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.season-milestone-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(20, 15, 30, 0.7);
    border: 1px solid #332540;
    border-radius: 8px;
    padding: 12px 16px;
    transition: all 0.2s;
}

.season-milestone-card.completed {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
}

.season-milestone-card.claimed {
    opacity: 0.65;
    border-color: #27272a;
}

.milestone-name {
    font-size: 14px;
    font-weight: bold;
    color: #f1f5f9;
    margin-bottom: 2px;
}

.milestone-desc {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.milestone-rewards {
    font-size: 11px;
    color: #fbbf24;
}

.season-claim-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid transparent;
}

.season-claim-btn.ready {
    background: linear-gradient(180deg, #10b981 0%, #047857 100%);
    color: #fff;
    border-color: #34d399;
    animation: pulseGlow 1.5s infinite;
}

.season-claim-btn.claimed {
    background: #27272a;
    color: #71717a;
    cursor: default;
}

.season-progress-pill {
    background: #18181b;
    border: 1px solid #3f3f46;
    color: #a1a1aa;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ========== Returning hero bundle ========== */
.return-bonus-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 3, 10, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1060;
    pointer-events: auto;
}

.return-bonus-panel {
    background: linear-gradient(180deg, #241432 0%, #12091c 100%);
    border: 2px solid #e6b422;
    border-radius: 14px;
    box-shadow: 0 0 50px rgba(230, 180, 34, 0.35), 0 0 30px rgba(0, 0, 0, 0.9);
    width: 90%;
    max-width: 540px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
    position: relative;
    animation: zoomIn 0.3s ease-out;
}

.return-bonus-banner h2 {
    margin: 0;
    font-size: 22px;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.return-bonus-banner p {
    margin: 8px 0 0 0;
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.4;
}

.return-rewards-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 8px 0;
}

.return-reward-card {
    background: rgba(15, 10, 24, 0.7);
    border: 1px solid #4a3060;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.return-reward-card .reward-icon {
    font-size: 24px;
}

.return-reward-card h4 {
    margin: 0;
    font-size: 13px;
    color: #f8fafc;
}

.return-reward-card p {
    margin: 2px 0 0 0;
    font-size: 11px;
    color: #94a3b8;
}

.return-claim-btn {
    background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
    border: 1px solid #fbbf24;
    color: #1c0c02;
    font-size: 15px;
    font-weight: 900;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
    transition: all 0.15s ease;
}

.return-claim-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-2px);
}

/* ========== Double XP HUD indicator ========== */
.double-exp-hud-badge {
    position: absolute;
    top: 85px;
    left: 12px;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.9), rgba(180, 83, 9, 0.9));
    color: #170d04;
    font-size: 11px;
    font-weight: bold;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #fef08a;
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.6);
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 100;
    pointer-events: auto;
    animation: badgePulse 2s infinite ease-in-out;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(234, 179, 8, 0.6); }
    50% { transform: scale(1.04); box-shadow: 0 0 16px rgba(234, 179, 8, 0.9); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 14px rgba(16, 185, 129, 0.8); }
}



