That rule is about the word that comes directly after the article, not specifically the noun.
For instance, in English, we'd say, "an orange shirt," not "a orange shirt," and we'd say "a red ornament" rather than "an red ornament."
In this case, since "mia" doesn't meet the requirements for "lo," the article changes to "il".
Edit 11 months later: Well, my comment here isn't entirely wrong, but for some reason, it didn't occur to me that the correct response would have been to point out that scatola was feminine and not masculine. Judging by the last paragraph, I didn't even realize I was making a similar mistake. I was so focused on the parent comment's use of "lo" and the s+consonant rule that I didn't even notice that the gender was wrong. Oops. I'm sorry about that.