My thinking would be to let your (A) department head know. "I've gotten an offer to move to B for higher pay. I am considering it, but wanted to give you a chance to counter." Then just leave it with him.
If he asks for "what do you want", just say "a counteroffer". Then let him and A huddle and see what they can do. (If you get some kerfuffle about "we need to know what you want to put the offer together", say "your best offer". Don't worry about them possibly having to tweak the offer after extended. Everything is negotiable and it is easy to change an offer letter. Just get them moving.
If you get a nice counter, fine. I have seen departments work to keep young superstars.
If it's halfway there, than at that point, negotiate specifics upwards. But it's always better to get them moving first, versus telling them what you want exactly (will "converge"...negotiating salary is like buying cars, always make other person go first to name a number--helps get a higher number. Also gets them psychologically committed, since they've extended themselves.
If they don't counter at all, you probably need to leave.
I'm not sure if salary is the only thing they can offer. Maybe tenure or teaching load or what have you. Just let them see what they can do. You can ask for specifics after they've made an initial counter.
Note: there are others here with much more experience than I who can advise you. I just would be careful to make sure it is in your interest, versus "be fair to the department". It's not like you will have opportunities or leverage like this always.
Also, I'm curious if the B position is post tenure. If so, then if A feels they can't extend tenure (being fair, following process, etc.) they probably need to do something good on money to make up for the tenure difference.
Note, if B is a significant step down in prestige, the leverage is less, but still credible. And you need to consider it if B is post tenure.
(Good luck.)