/* Game Core boundary
   --------------------------------------------------------------------------
   The legacy Anki game theme owns only the /game workspace. The learning web
   shell keeps its own light design and never inherits .skin-tutien rules. */

body:not(.hw-game-core-active):not(.hw-hud-active) #hw-app-layout #unified-hud-wrapper {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body:not(.hw-game-core-active) #inv-modal,
body:not(.hw-game-core-active) #shop-modal,
body:not(.hw-game-core-active) #tft-modal,
body:not(.hw-game-core-active) #challenge-modal,
body:not(.hw-game-core-active) #gold-topup-modal,
body:not(.hw-game-core-active) #champ-info-modal,
body:not(.hw-game-core-active) #redeem-modal {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Chat and ladder are web-level overlays: opening them must not activate the
   Game Core route. Their own scripts continue to own the display property. */
body:not(.hw-game-core-active) #chat-modal,
body:not(.hw-game-core-active) #ladder-modal {
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Defensive web-shell reset for the community actions shown in the report.
   Their hw- class also excludes them from legacy button:not([class*="hw-"]). */
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action {
    min-height: 39px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    padding: 9px 12px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    background: #ffffff !important;
    color: #475569 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action.is-primary {
    border-color: #4f46e5 !important;
    background: #4f46e5 !important;
    color: #ffffff !important;
}

html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action:hover {
    border-color: #a5b4fc !important;
    background: #eef2ff !important;
    color: #4338ca !important;
    box-shadow: 0 6px 14px rgba(79, 70, 229, 0.1) !important;
}

html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action.is-primary:hover {
    border-color: #4338ca !important;
    background: #4338ca !important;
    color: #ffffff !important;
}

/* Dark Mode Community Actions (High specificity to match ID #hw-app-layout) */
html.dark body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action {
    min-height: 39px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 7px !important;
    padding: 9px 12px !important;
    border: 1px solid #334155 !important;
    border-radius: 12px !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    text-shadow: none !important;
}

html.dark body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action.is-primary {
    border-color: #6366f1 !important;
    background: #4f46e5 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35) !important;
}

html.dark body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action:hover {
    border-color: #475569 !important;
    background: #334155 !important;
    color: #ffffff !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
}

html.dark body:not(.hw-game-core-active) #hw-app-layout .hw-library-community-action.is-primary:hover {
    border-color: #818cf8 !important;
    background: #4338ca !important;
    color: #ffffff !important;
}

/* The Game Core route inherits the unified FlipVocab Next-Gen Game Design System. */
html.hw-game-core-active,
body.hw-game-core-active {
    color-scheme: light dark;
    background: var(--game-bg, #f8fafc) !important;
}

html.dark.hw-game-core-active,
body.dark.hw-game-core-active,
html[data-theme="dark"].hw-game-core-active,
body[data-theme="dark"].hw-game-core-active {
    color-scheme: dark;
    background: var(--game-bg, #0b0f19) !important;
}

body.hw-game-core-active #hw-app-layout {
    min-height: 100svh !important;
    background: var(--game-bg, #f8fafc) !important;
    color: var(--game-text, #0f172a) !important;
}

html.dark body.hw-game-core-active #hw-app-layout,
html[data-theme="dark"] body.hw-game-core-active #hw-app-layout {
    background: var(--game-bg, #0b0f19) !important;
    color: var(--game-text, #f8fafc) !important;
}

body.hw-game-core-active #hw-app-layout > aside,
body.hw-game-core-active #hw-mobile-bottom-nav {
    display: none !important;
}

body.hw-game-core-active #hw-app-layout > main {
    min-height: 100svh !important;
    gap: 16px !important;
    padding-bottom: 0 !important;
    background: transparent !important;
}

body.hw-game-core-active #hw-app-layout > main > .hw-flex-1 {
    width: min(calc(100% - 48px), 1440px) !important;
    max-width: 1440px !important;
    margin-inline: auto !important;
    padding: 0 0 28px !important;
    box-sizing: border-box !important;
}


/* ==========================================================================
   Unified Tu Tiên HUD (Library Dashboard & Game Route)
   Inherits full Tu Tiên features (Avatar, Rank Border, Neon EXP, Boss, Top 1)
   matching Photo 1 across all views.
   ========================================================================== */


body.hw-game-core-active #hw-app-layout #unified-hud-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    align-self: center !important;
    width: min(calc(100% - 48px), 1440px) !important;
    max-width: 1440px !important;
    height: auto !important;
    min-height: 96px !important;
    max-height: none !important;
    margin: 18px auto 0 !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    contain: none !important;
    content-visibility: visible !important;
    isolation: isolate !important;
}

body.hw-hud-active #hw-app-layout #unified-hud-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    align-self: center !important;
    width: min(calc(100% - 32px), 1440px) !important;
    max-width: 1440px !important;
    height: auto !important;
    min-height: 96px !important;
    max-height: none !important;
    margin: 18px auto 0 !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    contain: none !important;
    content-visibility: visible !important;
    isolation: isolate !important;
}

@media (min-width: 768px) {
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper {
        width: min(calc(100% - 48px), 1440px) !important;
        max-width: 1440px !important;
        margin: 18px auto 0 !important;
    }
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper::before,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper::before {
    display: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    min-height: 30px !important;
    height: auto !important;
    max-height: none !important;
    padding: 6px 14px !important;
    border: 0 !important;
    border-radius: 0 !important;
    border-top-left-radius: 15px !important;
    border-top-right-radius: 15px !important;
    box-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .tutien-hud,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .tutien-hud {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 64px !important;
    max-height: none !important;
    pointer-events: auto !important;
    padding: 12px 16px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    contain: none !important;
    content-visibility: visible !important;
    box-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .hud-header-flex,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .hud-header-flex {
    display: flex !important;
    visibility: visible !important;
    min-height: 56px !important;
    height: auto !important;
    max-height: none !important;
    align-items: center !important;
    gap: 14px !important;
    flex-wrap: wrap !important;
    contain: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-area-flex,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .exp-area-flex {
    flex: 1 1 190px !important;
    min-width: 0 !important;
}

body.hw-game-core-active #hw-app-layout #main-hud-container,
body.hw-hud-active #hw-app-layout #main-hud-container {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    flex: 0 0 auto !important;
    height: auto !important;
    min-height: 64px !important;
    max-height: none !important;
    overflow: visible !important;
    contain: none !important;
    content-visibility: visible !important;
    pointer-events: auto !important;
}

/* ==========================================================================
   GAME CORE ROUTE HUD THEME (Unified with Design System for /game)
   ========================================================================== */
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper {
    border: 1px solid var(--game-border, #e2e8f0) !important;
    background: var(--game-surface, #ffffff) !important;
    box-shadow: var(--game-shadow, 0 10px 25px -5px rgba(15, 23, 42, 0.06)) !important;
    color: var(--game-text, #0f172a) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar {
    border-bottom: 1px solid var(--game-border, #e2e8f0) !important;
    background: var(--game-surface-raised, #f8fafc) !important;
    color: var(--game-text-secondary, #475569) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-left,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-right,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .marquee-container,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .marquee-text {
    color: var(--game-text-secondary, #475569) !important;
    text-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #top1-name,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #top1-points {
    color: var(--game-primary, #0f766e) !important;
    text-shadow: none !important;
    font-weight: 800 !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .avatar-cultivation {
    border-color: var(--game-primary, #0f766e) !important;
    background-color: var(--game-surface, #ffffff) !important;
    box-shadow: 0 0 0 2px var(--game-focus-ring, rgba(15, 118, 110, 0.16)) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #rank-badge {
    color: var(--game-primary, #0f766e);
    border-color: var(--game-border, #cbd5e1);
    text-shadow: none;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #user-rank-name,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .cultivator-name,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .rank-name-style {
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    overflow: hidden !important;
    background: transparent !important;
    background-color: transparent !important;
    color: var(--game-text, #0f172a);
    font-weight: 800 !important;
    text-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #user-rank-name .hud-player-name-text {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-text-wrapper.vip-ui-gradient {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    background: none !important;
    background-clip: unset !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: currentColor !important;
    color: var(--game-text, #0f172a) !important;
    text-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-text,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #exp-num,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #hud-copper-num {
    color: var(--game-text-secondary, #475569) !important;
    opacity: 1 !important;
    text-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-bar-bg,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-bar-bg-style {
    border-color: var(--game-border, #e2e8f0) !important;
    background: var(--game-surface-raised, #f1f5f9) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #exp-bar-fill,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-bar-fill,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-bar-fill-style {
    background: var(--game-primary, #0f766e) !important;
    box-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-stats-group,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .gold-stats-group {
    border-color: var(--game-border, #e2e8f0) !important;
    background: var(--game-surface-raised, #f8fafc) !important;
    color: var(--game-text, #0f172a) !important;
    box-shadow: none !important;
}

/* ==========================================================================
   WEB HUD THEME (Clean White Glassmorphism for Library, Learning & Dashboard)
   Preserves 100% of user rank colors without muddy shadows
   ========================================================================== */
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper {
    border: 1px solid var(--hw-hud-rank-border, rgba(226, 232, 240, 0.95)) !important;
    border-radius: 16px !important;
    background:
        radial-gradient(circle at 8% 0%, rgba(99, 102, 241, 0.08), transparent 35%),
        radial-gradient(circle at 92% 12%, rgba(245, 158, 11, 0.08), transparent 30%),
        linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.06), 0 8px 10px -6px rgba(15, 23, 42, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.95) !important;
    color: #0f172a !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar {
    border-bottom: 1px solid #e2e8f0 !important;
    border-top-left-radius: 15px !important;
    border-top-right-radius: 15px !important;
    background: linear-gradient(90deg, rgba(241, 245, 249, 0.95) 0%, rgba(248, 250, 252, 0.98) 50%, rgba(254, 243, 199, 0.6) 100%) !important;
    color: #475569 !important;
    font-size: 11px !important;
    font-weight: 800 !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-left,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-right,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-container,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-text,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-left,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-right,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-container,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-text {
    color: #475569 !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #top1-name,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #top1-name {
    color: #d97706 !important;
    font-weight: 850 !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #top1-points,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #top1-points {
    color: #ef4444 !important;
    font-weight: 850 !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .avatar-cultivation,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .avatar-cultivation {
    border: 2px solid var(--hw-hud-rank-border, #6366f1) !important;
    background-color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1) !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #rank-badge,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #rank-badge {
    color: var(--hw-hud-rank-color, #4f46e5) !important;
    border-color: var(--hw-hud-rank-color, #6366f1) !important;
    text-shadow: none !important;
    background: transparent !important;
}

/* Bảo toàn tuyệt đối màu rank của người chơi (không ép màu đen, bỏ bóng đen) */
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #user-rank-name,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .cultivator-name,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rank-name-style,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #user-rank-name,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .cultivator-name,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rank-name-style {
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    overflow: hidden !important;
    background: transparent !important;
    background-color: transparent !important;
    color: var(--hw-hud-player-name-color, var(--hw-hud-rank-color, currentColor));
    font-weight: 900 !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #user-rank-name .hud-player-name-text,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #user-rank-name .hud-player-name-text {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .vip-ui-text-wrapper.vip-ui-gradient,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .vip-ui-text-wrapper.vip-ui-gradient {
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    background: none !important;
    background-clip: unset !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: currentColor !important;
    color: var(--hw-hud-player-name-color, var(--hw-hud-rank-color, currentColor)) !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg-style,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg-style {
    border: 1px solid rgba(99, 102, 241, 0.14) !important;
    border-radius: 9999px !important;
    background: #e2e8f0 !important;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08) !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #exp-bar-fill,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-fill,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-fill-style,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #exp-bar-fill,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-fill,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-fill-style {
    background: var(--hw-hud-rank-color, linear-gradient(90deg, #38bdf8 0%, #6366f1 55%, #a855f7 100%)) !important;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.28) !important;
    border-radius: 9999px !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-stats-group,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .gold-stats-group,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-stats-group,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .gold-stats-group {
    border: 1px solid #e2e8f0 !important;
    border-radius: 9999px !important;
    background: rgba(255, 255, 255, 0.88) !important;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04) !important;
    color: #334155 !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-text,
body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #exp-num,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-text,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #exp-num {
    color: #1e293b !important;
    font-weight: 800 !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #hud-copper-num,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #hud-copper-num {
    color: #b45309 !important;
    font-weight: 800 !important;
    text-shadow: none !important;
}

body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .vip-ui-badge .vip-ui-days,
body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .vip-ui-badge .vip-ui-days {
    color: #b45309 !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    margin-left: 1px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    text-shadow: none !important;
}

/* ==========================================================================
   DARK THEME FOR WEB HUD (When user activates Dark Mode on web app)
   ========================================================================== */
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper {
    border: 1px solid var(--hw-hud-rank-border, #1e293b) !important;
    border-radius: 16px !important;
    background: #0f172a !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
    color: #f8fafc !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar {
    border-bottom: 1px solid #1e293b !important;
    border-top-left-radius: 15px !important;
    border-top-right-radius: 15px !important;
    background: #131b2e !important;
    color: #cbd5e1 !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-left,
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-right,
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-container,
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-text,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-left,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .rpg-top-bar .top-right,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-container,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .marquee-text {
    color: #94a3b8 !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .avatar-cultivation,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .avatar-cultivation {
    border: 2px solid var(--hw-hud-rank-border, #6366f1) !important;
    border-color: var(--hw-hud-rank-border, #6366f1) !important;
    background-color: #1e293b !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #rank-badge,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #rank-badge {
    color: var(--hw-hud-rank-color, #818cf8) !important;
    border-color: var(--hw-hud-rank-color, var(--hw-hud-rank-border, #6366f1)) !important;
    text-shadow: none !important;
    background: transparent !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .avatar-cultivation .lvl-badge,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .avatar-cultivation .lvl-badge,
html.dark .lvl-badge {
    border: 1px solid var(--hw-hud-rank-border, #ffd700) !important;
    color: var(--hw-hud-rank-border, #ffd700) !important;
    background: rgba(11, 20, 36, 0.95) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.7) !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg,
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg-style,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-bar-bg-style {
    border: 1px solid #334155 !important;
    background: #1e293b !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-stats-group,
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .gold-stats-group,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-stats-group,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .gold-stats-group {
    border: 1px solid #334155 !important;
    background: #1e293b !important;
    color: #cbd5e1 !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-text,
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #exp-num,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .exp-text,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #exp-num {
    color: #cbd5e1 !important;
}
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #hud-copper-num,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #hud-copper-num {
    color: #f59e0b !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-badge-custom,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-badge-custom,
#chat-modal .vip-ui-badge,
#ladder-modal .vip-ui-badge {
    min-height: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 2px !important;
    flex: 0 0 auto !important;
    margin-left: 3px !important;
    padding: 0 2px !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #ffd700 !important;
    font-size: 10px !important;
    font-weight: 850 !important;
    line-height: 1 !important;
    letter-spacing: 0.02em !important;
    text-shadow: none !important;
    box-shadow: none !important;
    -webkit-text-fill-color: currentColor !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge .vip-ui-days,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge .vip-ui-days,
#chat-modal .vip-ui-badge .vip-ui-days,
#ladder-modal .vip-ui-badge .vip-ui-days {
    color: #fbbf24 !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    margin-left: 1px !important;
    display: inline-block !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    -webkit-text-fill-color: currentColor !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown,
#chat-modal .vip-ui-crown,
#ladder-modal .vip-ui-crown {
    display: inline-block !important;
    vertical-align: middle !important;
    width: 14px !important;
    height: 12px !important;
    line-height: 1 !important;
    margin-right: 3px !important;
    margin-left: 2px !important;
    flex-shrink: 0 !important;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'%3E%3Cpath fill='%23000' d='M309 106c11.4-7 19-19.7 19-34c0-22.1-17.9-40-40-40s-40 17.9-40 40c0 14.4 7.6 27 19 34L209.7 220.6 96.5 137.8c7.5-6.8 12.2-16.6 12.2-27.4c0-20.3-16.5-36.8-36.8-36.8S35.2 90.1 35.2 110.4c0 12.8 6.5 24 16.4 30.6L76.1 329.4c3.4 17.1 18.4 29.5 35.8 29.5l352.2 0c17.5 0 32.4-12.4 35.8-29.5l24.5-188.4c9.9-6.6 16.4-17.8 16.4-30.6c0-20.3-16.5-36.8-36.8-36.8s-36.8 16.5-36.8 36.8c0 10.9 4.7 20.6 12.2 27.4L402.3 220.6 345 106h-36zM91.7 416c-15.3 0-27.7 12.4-27.7 27.7c0 15.3 12.4 27.7 27.7 27.7l392.7 0c15.3 0 27.7-12.4 27.7-27.7c0-15.3-12.4-27.7-27.7-27.7L91.7 416z'/%3E%3C/svg%3E") no-repeat center / contain !important;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 576 512'%3E%3Cpath fill='%23000' d='M309 106c11.4-7 19-19.7 19-34c0-22.1-17.9-40-40-40s-40 17.9-40 40c0 14.4 7.6 27 19 34L209.7 220.6 96.5 137.8c7.5-6.8 12.2-16.6 12.2-27.4c0-20.3-16.5-36.8-36.8-36.8S35.2 90.1 35.2 110.4c0 12.8 6.5 24 16.4 30.6L76.1 329.4c3.4 17.1 18.4 29.5 35.8 29.5l352.2 0c17.5 0 32.4-12.4 35.8-29.5l24.5-188.4c9.9-6.6 16.4-17.8 16.4-30.6c0-20.3-16.5-36.8-36.8-36.8s-36.8 16.5-36.8 36.8c0 10.9 4.7 20.6 12.2 27.4L402.3 220.6 345 106h-36zM91.7 416c-15.3 0-27.7 12.4-27.7 27.7c0 15.3 12.4 27.7 27.7 27.7l392.7 0c15.3 0 27.7-12.4 27.7-27.7c0-15.3-12.4-27.7-27.7-27.7L91.7 416z'/%3E%3C/svg%3E") no-repeat center / contain !important;
}
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown::before,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown::before,
#chat-modal .vip-ui-crown::before,
#ladder-modal .vip-ui-crown::before {
    content: "" !important;
    display: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown:not(.vip-ui-crown-lifetime),
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown:not(.vip-ui-crown-lifetime),
#chat-modal .vip-ui-crown:not(.vip-ui-crown-lifetime),
#ladder-modal .vip-ui-crown:not(.vip-ui-crown-lifetime) {
    color: #ffd700 !important;
    background: linear-gradient(135deg, #ffe066 0%, #ffd700 50%, #e6a400 100%) !important;
    background-color: #ffd700 !important;
    font-size: 11px !important;
    filter: drop-shadow(0 0 3px rgba(230, 164, 0, 0.75)) !important;
    text-shadow: none !important;
    -webkit-text-fill-color: unset !important;
}

/* VIP Trọn Đời (Lifetime VIP) - Màu xanh dương quý tộc Sapphire Blue rõ nét, sắc cạnh, không mờ */
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown.vip-ui-crown-lifetime,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-crown.vip-ui-crown-lifetime,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge-lifetime .vip-ui-crown,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge-lifetime .vip-ui-crown,
.vip-ui-crown.vip-ui-crown-lifetime,
.vip-ui-badge-lifetime .vip-ui-crown,
.vip-badge-custom.vip-ui-badge-lifetime .vip-ui-crown {
    color: #38bdf8 !important;
    background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 35%, #2563eb 80%, #1d4ed8 100%) !important;
    background-color: #38bdf8 !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
    filter: drop-shadow(0 0 3px rgba(56, 189, 248, 0.75)) !important;
    text-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge.vip-ui-badge-lifetime,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .vip-ui-badge.vip-ui-badge-lifetime,
.vip-ui-badge.vip-ui-badge-lifetime {
    color: #38bdf8 !important;
    text-shadow: none !important;
    filter: none !important;
}


/* Strict locking for HUD avatar country flag size across card flips & route changes */
.avatar-cultivation .avatar-country-flag,
body #hw-app-layout #unified-hud-wrapper .avatar-cultivation .avatar-country-flag {
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    min-height: 15px !important;
    max-width: 15px !important;
    max-height: 15px !important;
    bottom: -1px !important;
    left: -1px !important;
    background-size: 100% 100% !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border-radius: 50% !important;
    box-shadow: none !important;
    filter: none !important;
    opacity: 1 !important;
    z-index: 32 !important;
    pointer-events: none !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
}

#chat-modal .avatar-country-flag,
.friend-card .avatar-country-flag,
.friend-avatar-circle .avatar-country-flag,
.friend-request-row-v2 .avatar-country-flag,
.search-result-card .avatar-country-flag {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    min-height: 14px !important;
    max-width: 14px !important;
    max-height: 14px !important;
    bottom: -1px !important;
    left: -1px !important;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    border-radius: 50% !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5) !important;
    z-index: 12 !important;
}

.pvp-spec-avatar .avatar-country-flag {
    width: 10px !important;
    height: 10px !important;
    min-width: 10px !important;
    min-height: 10px !important;
    max-width: 10px !important;
    max-height: 10px !important;
    bottom: -1px !important;
    left: -1px !important;
}

/* World Boss and Tribulation use one compact, non-floating HUD pattern. */
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-widget,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-widget {
    box-sizing: border-box !important;
    position: relative !important;
    inset: auto !important;
    width: clamp(132px, 17vw, 176px) !important;
    height: 30px !important;
    flex: 0 0 clamp(132px, 17vw, 176px) !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 0 0 auto !important;
    padding: 3px 7px 3px 3px !important;
    border: 1px solid rgba(240, 98, 146, 0.72) !important;
    border-radius: 9px !important;
    background: linear-gradient(180deg, rgba(25, 35, 57, 0.99), rgba(8, 17, 32, 0.99)) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
    z-index: 3 !important;
    overflow: hidden !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-widget:hover,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-widget:focus-visible,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-widget:hover,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-widget:focus-visible {
    border-color: #fb7185 !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(240, 98, 146, 0.16), 0 8px 18px rgba(0, 0, 0, 0.38) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-widget[data-joined="1"],
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-widget[data-joined="1"] {
    border-color: rgba(52, 211, 153, 0.78) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-icon,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-icon {
    width: 22px !important;
    height: 22px !important;
    flex: 0 0 22px !important;
    margin: 0 !important;
    border: 1px solid rgba(251, 113, 133, 0.9) !important;
    border-radius: 7px !important;
    box-shadow: none !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-inline-main,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-inline-main {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-hp-bg,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-hp-bg {
    height: 20px !important;
    border: 1px solid rgba(255, 255, 255, 0.11) !important;
    border-radius: 6px !important;
    background: #07101f !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-hp-bar,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-hp-bar {
    opacity: 0.74 !important;
    background: linear-gradient(90deg, #be123c 0%, #ec4899 54%, #fb7185 100%) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-overlay-row,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-overlay-row {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto !important;
    gap: 4px !important;
    padding: 0 5px !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-name,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-hp-text,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-timer,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-name,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-hp-text,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-timer {
    display: block !important;
    min-width: 0 !important;
    overflow: hidden !important;
    color: #ffffff !important;
    font-size: 8px !important;
    font-weight: 900 !important;
    line-height: 1 !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.94) !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-name,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-name {
    color: #ffe4e6 !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-timer,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-timer {
    color: #fde68a !important;
}

body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .tribulation-widget,
body.hw-hud-active #hw-app-layout #unified-hud-wrapper .tribulation-widget {
    border-color: rgba(192, 132, 252, 0.78) !important;
}

/* Web HUD Boss & Tribulation Widget Theme (Clean Light Surface) */
html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-widget,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-widget {
    background: #ffffff !important;
    border: 1px solid rgba(240, 98, 146, 0.45) !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06) !important;
}

html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-bg,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-bg {
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
}

html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-name,
html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-text,
html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-timer,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-name,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-text,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-timer {
    text-shadow: none !important;
}

html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-name,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-name {
    color: #e11d48 !important;
}

html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-text,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-text {
    color: #1e293b !important;
}

html:not(.dark) body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-timer,
html:not(.dark) body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-timer {
    color: #d97706 !important;
}

/* Web HUD Tribulation Widget Theme (Dark Mode) */
html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-widget,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-widget {
    background: rgba(15, 23, 42, 0.88) !important;
    border: 1px solid rgba(244, 63, 94, 0.45) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 12px rgba(244, 63, 94, 0.15) !important;
    color: #f8fafc !important;
}

html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #tribulation-widget,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper #tribulation-widget,
html.dark #tribulation-widget {
    background: rgba(15, 23, 42, 0.88) !important;
    border: 1px solid rgba(168, 85, 247, 0.45) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 12px rgba(168, 85, 247, 0.15) !important;
    color: #f8fafc !important;
}

html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-bg,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-bg,
html.dark #tribulation-widget .boss-hp-bg {
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-name,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-name {
    color: #fb7185 !important;
}

html.dark #tribulation-widget .boss-name {
    color: #c084fc !important;
}

html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-text,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-hp-text,
html.dark #tribulation-widget .boss-hp-text {
    color: #e2e8f0 !important;
}

html.dark body.hw-hud-active:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-timer,
html.dark body:not(.hw-game-core-active) #hw-app-layout #unified-hud-wrapper .boss-timer,
html.dark #tribulation-widget .boss-timer {
    color: #fde68a !important;
}

body.hw-game-core-active #view-rpg.hw-game-core-workspace {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 18px !important;
    min-height: min(620px, calc(100svh - 220px));
    padding: clamp(16px, 2.5vw, 26px) !important;
    border: 1px solid var(--game-border, #e2e8f0) !important;
    border-radius: var(--game-radius-lg, 16px) !important;
    background: var(--game-surface, #ffffff) !important;
    box-shadow: var(--game-shadow, 0 4px 16px rgba(15, 23, 42, 0.06)) !important;
    color: var(--game-text, #0f172a) !important;
}

body.hw-game-core-active #view-rpg.hw-hidden {
    display: none !important;
}

.hw-game-core-workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 2px 16px;
    border-bottom: 1px solid var(--game-border, #e2e8f0);
}

.hw-game-core-workspace-header h2 {
    margin: 3px 0 4px;
    font-size: clamp(22px, 2.1vw, 30px) !important;
    color: var(--game-text, #0f172a) !important;
    text-shadow: none !important;
}

.hw-game-core-workspace-header p {
    margin: 0;
    color: var(--game-text-secondary, #475569) !important;
}

.hw-game-core-kicker {
    color: var(--game-primary, #0f766e);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.16em;
}

.hw-game-core-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.hw-game-core-status-row span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 25px;
    padding: 5px 9px;
    border: 1px solid var(--game-border, #e2e8f0);
    border-radius: 999px;
    background: var(--game-surface-raised, #f1f5f9);
    color: var(--game-text-secondary, #475569);
    font-size: 9px;
    font-weight: 800;
}

.hw-game-core-status-row span:first-child i {
    color: var(--game-success, #047857);
    font-size: 6px;
    box-shadow: 0 0 8px rgba(4, 120, 87, 0.45);
}

.hw-game-core-back {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--game-border-strong, #cbd5e1) !important;
    border-radius: var(--game-radius-md, 12px) !important;
    background: var(--game-surface, #ffffff) !important;
    color: var(--game-text-secondary, #475569) !important;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none !important;
    transition: all 0.2s ease;
}

.hw-game-core-back:hover {
    background: var(--game-surface-hover, #f1f5f9) !important;
    color: var(--game-text, #0f172a) !important;
    border-color: var(--game-primary, #0f766e) !important;
}

body.hw-game-core-active #view-rpg #rpg-panel-activities {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.hw-game-core-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.hw-game-core-section-heading h3 {
    margin: 3px 0 0;
    color: var(--game-text, #0f172a);
    font-size: 16px;
    font-weight: 850;
}

.hw-game-core-section-kicker {
    color: var(--game-text-muted, #94a3b8);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.16em;
}

.hw-game-core-feature-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border: 1px solid var(--game-border, #e2e8f0);
    border-radius: 7px;
    color: var(--game-text-secondary, #475569);
    background: var(--game-surface-raised, #f8fafc);
    font-size: 9px;
    font-weight: 800;
}

.hw-game-core-action-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(104px, 1fr);
    gap: 14px;
}

body.hw-game-core-active #view-rpg .hw-btn-adventure-card {
    position: relative !important;
    overflow: hidden !important;
    min-width: 0 !important;
    min-height: 112px !important;
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 16px !important;
    border: 1px solid var(--game-border, #e2e8f0) !important;
    border-radius: var(--game-radius-lg, 16px) !important;
    background: var(--game-surface, #ffffff) !important;
    color: var(--game-text, #0f172a) !important;
    text-align: left !important;
    box-shadow: var(--game-shadow, 0 4px 16px rgba(15, 23, 42, 0.06)) !important;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease !important;
}

body.hw-game-core-active #view-rpg .hw-btn-adventure-card::before {
    display: none !important;
}

body.hw-game-core-active #view-rpg .hw-btn-adventure-card:hover {
    border-color: var(--game-primary, #0f766e) !important;
    background: var(--game-surface-hover, #f1f5f9) !important;
    color: var(--game-text, #0f172a) !important;
    box-shadow: var(--game-shadow-lg, 0 16px 36px rgba(15, 23, 42, 0.14)) !important;
    transform: translateY(-2px);
}

body.hw-game-core-active #view-rpg .hw-btn-adventure-card:hover::before {
    display: none !important;
}

.hw-game-card-live {
    position: absolute;
    top: 9px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--game-primary, #0f766e);
    font-size: 7px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

/* Retired status badge; also hides stale cached module markup. */
body.hw-game-core-active #view-rpg .hw-game-card-live { display: none !important; }

.hw-game-card-live i {
    font-size: 5px;
    filter: drop-shadow(0 0 4px currentColor);
}

body.hw-game-core-active #view-rpg .hw-btn-adventure-card:focus-visible {
    outline: 2px solid var(--game-focus-ring, rgba(15, 118, 110, 0.4)) !important;
    outline-offset: 2px !important;
}

.hw-game-card-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--game-primary-soft, rgba(15, 118, 110, 0.2));
    border-radius: var(--game-radius-md, 12px);
    background: var(--game-primary-soft, #f0fdfa);
    color: var(--game-primary, #0f766e);
    font-size: 20px;
    flex-shrink: 0;
}

.hw-game-card-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hw-game-card-copy strong {
    color: var(--game-text, #0f172a);
    font-size: 13px;
    font-weight: 800;
}

.hw-game-card-copy small {
    overflow: hidden;
    color: var(--game-text-secondary, #475569);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hw-game-card-arrow {
    color: var(--game-text-muted, #94a3b8);
    font-size: 11px;
    transition: transform 160ms ease, color 160ms ease;
}

body.hw-game-core-active #view-rpg .hw-btn-adventure-card:hover .hw-game-card-arrow {
    color: var(--game-primary, #0f766e);
    transform: translateX(3px);
}

@media (max-width: 767px) {
    body.hw-game-core-active #hw-app-layout > main > .hw-flex-1,
    body.hw-hud-active #hw-app-layout > main > .hw-flex-1,
    body #hw-app-layout > main > .hw-flex-1 {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        align-self: stretch !important;
        margin-inline: auto !important;
        padding: 10px !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper,
    body #hw-app-layout #unified-hud-wrapper,
    #unified-hud-wrapper {
        position: sticky !important;
        top: max(0px, env(safe-area-inset-top, 0px)) !important;
        z-index: 80 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        align-self: center !important;
        width: calc(100% - 20px) !important;
        max-width: calc(100% - 20px) !important;
        box-sizing: border-box !important;
        height: auto !important;
        min-height: 91px !important;
        max-height: none !important;
        margin: 8px auto 12px !important;
        margin-inline: auto !important;
        pointer-events: auto !important;
        overflow: hidden !important;
        contain: none !important;
        content-visibility: visible !important;
        border-radius: 18px !important;
        transform: translateZ(0) !important;
        -webkit-transform: translateZ(0) !important;
        backface-visibility: hidden !important;
        -webkit-backface-visibility: hidden !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .rpg-top-bar {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 25px !important;
        max-height: none !important;
        padding: 4px 9px !important;
        font-size: 9px !important;
        contain: none !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .tutien-hud,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .tutien-hud {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 64px !important;
        max-height: none !important;
        padding: 8px 9px !important;
        overflow: visible !important;
        contain: none !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .hud-header-flex,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .hud-header-flex {
        display: flex !important;
        visibility: visible !important;
        min-height: 48px !important;
        height: auto !important;
        max-height: none !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        contain: none !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .avatar-cultivation,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .avatar-cultivation {
        width: 48px !important;
        height: 48px !important;
        flex: 0 0 48px !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .exp-area-flex,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .exp-area-flex {
        flex: 1 1 126px !important;
        min-width: 110px !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper #user-rank-name,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper #user-rank-name {
        max-width: 100% !important;
        font-size: 11px !important;
        line-height: 1.15 !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-widget,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-widget {
        width: 126px !important;
        height: 28px !important;
        flex: 0 0 126px !important;
        margin-left: auto !important;
    }

    body.hw-game-core-active #hw-app-layout #unified-hud-wrapper .boss-icon,
    body.hw-hud-active #hw-app-layout #unified-hud-wrapper .boss-icon {
        width: 20px !important;
        height: 20px !important;
        flex-basis: 20px !important;
    }

    body.hw-game-core-active #view-rpg.hw-game-core-workspace {
        min-height: 0;
        padding: 14px !important;
    }

    .hw-game-core-workspace-header {
        align-items: flex-start;
        flex-direction: column-reverse;
    }

    .hw-game-core-back {
        min-height: 34px;
    }

    .hw-game-core-status-row,
    .hw-game-core-section-heading {
        align-items: flex-start;
    }

    .hw-game-core-feature-count {
        display: none;
    }

    .hw-game-core-action-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-auto-rows: auto;
        gap: 10px;
    }

    body.hw-game-core-active #view-rpg .hw-btn-adventure-card {
        min-height: 78px !important;
        padding: 12px !important;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .hw-game-core-action-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* TIÊN PHỦ CONFIRM MODAL - ABSOLUTE HIGHEST Z-INDEX (TOP OF ALL LAYERS) */
#tiendao-custom-confirm-modal,
.tiendao-custom-confirm-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
    display: flex !important;
}

#tiendao-custom-confirm-modal .td-confirm-card {
    position: relative !important;
    z-index: 2147483647 !important;
}

/* Live Room EPS Navigation Grid Frame Fix (Compact Horizontal Row) */
#eps-nav-grid-container.eps-nav-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 4px !important;
    padding: 4px 6px !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    height: 38px !important;
    min-height: 36px !important;
    max-height: 42px !important;
    align-items: center !important;
    border-radius: 6px !important;
    border: 1px solid #30363d !important;
    background: #161b22 !important;
    scrollbar-width: none !important;
    box-sizing: border-box !important;
}

#eps-nav-grid-container.eps-nav-grid::-webkit-scrollbar {
    display: none !important;
}

#eps-nav-grid-container .eps-nav-item {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    max-width: 26px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    flex-shrink: 0 !important;
    background-color: #21262d !important;
    border: 1px solid #444 !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #c9d1d9 !important;
    font-size: 12px !important;
    font-weight: normal !important;
    transition: all 0.2s !important;
    box-sizing: border-box !important;
}

/* STANDALONE GROUP STUDY HUB MODAL */
#group-study-hub-modal,
#group-study-hub-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483600 !important;
    pointer-events: auto !important;
    display: flex !important;
}

#group-study-hub-box {
    position: relative !important;
    z-index: 2147483601 !important;
}

/* Ẩn hoàn toàn khung HUD cũ khi đang ở giao diện Game Võ Lâm */
body.hw-game-core-active #unified-hud-wrapper,
body.hw-game-core-active #hw-app-layout #unified-hud-wrapper,
html body.hw-game-core-active #unified-hud-wrapper {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

