The problem here is that you're a stepparent, as per your post. In theory anyway, you have absolutely NO rights to the child except those bestowed upon you by her mother. The natural father, if he's in the picture has far more rights than you in this scenario.
Unfortunately, nothing you've written demonstrates her inability to parent effectively -- what was she charged with when she showed up at your residence intoxicated?
It is unlikely that you will receive full costody of your STEPdaughter. It is probable that she will be awarded to your ex **her mother** or at the very remotest, her biological father **if that's possible** And, sad to say, if she leaves your custody, there's not a damn thing you can do to get to see her -- you can file for visitation all you want, but if her mother doesn't want her to see you, that would be the bottom line.
However -- as she has been left in your care voluntarily, that is a point in your favor. Beware, living in the city mission is NOT to your stbx's detriment as she is now working and I would assume, looking for premises to live in.
There's almost no way to call this one but remember, she's NOT your daughter biologically. The laws in most states don't consider stepparents in their decision making process.
I do think you should take advantage of any free consults with attorneys you can get -- this is going to be a tough one.