Hard Science Fiction is essentially fictional circumstances using only technology that comes from our current understandings of science. All happenings are measurable and correlate to the known universe and our understanding of it.
Therefor, anything attempting to introduce concepts (such as faster than light travel) that have no scientific foundation are not hard. Any seemingly super-natural happening which is not explained by known science by the end of a story disqualifies the story from being hard-science-fiction.
Hard Science Fiction: The End.
Science Fiction vs Fantasy - Soft Science Fiction allows squishier "technology" as referenced elsewhere in the thread. So long as there are rules and those rules apply and "science" is the foundation explanation of everything that occurs, you're in the science fiction space. IE, you could be exploring a theory of the way a law of the universe might impact things. Hand Wavium is stronger in soft science fiction, but the pre-requisite is that some core "Idea" of the world (from MICE) revolves around an idea that is at least proposed to be part of the scientific understanding of the world. This doesn't mean space travel, or advanced tech, or even the future. You can write science fiction if it's about the first applications of the scientific method on some other world in the past. The point is that it's about Science (Rigorous application of the scientific method to acquire and understand the world around you) and how that affects problems that characters are dealing with.
Fantasy is different from science fiction, but not in the exclusive sense. Fantasy is largely an idea story as well; but it's more about Super-Natural/Magic etc forces.
Before we get into where the lines exist, think about this: If both types of stories are idea stories, then they must share something in common. That something is the "What if?" and the super-genre that holds them both is called "Speculative" fiction. This super-genre also holds mysteries and other fictional works that ask the simple question "What If?"
So, how you answer that "What If?", the prerequisites you define for the "What If?", and the ability to answer the "What-If" on the part of the characters all factor into whether you can describe the work as a fantasy or science fiction. I would urge you to think of "Fantasy" and "Science Fiction" as tools or descriptors which can be applied if the work meets specific criteria; not as a fallacious exclusive binary categorization, where the work is either A or B, but not both.
Does the work have anything to do with wish fulfillment? The inability to understand seemingly magical occurrences? Or, possibly spectacularly, but inexplicably powerful beings which influence the story? The author is using fantastical elements in their story and the Fantasy classification can apply.
Does the work have anything to do with the way things work? Are there explicit rules that are discover-able that perfectly describe the interactions of things in the universe? Are there people who investigate how things work via the scientific experiment, and do they codify their findings for others? Do elements, set-pieces, or characters revolve around the combination of such understandings into some sort of construction? If yes, then there are Scientific elements in the story. The story fits a science-fiction classification.
Fantasy & Science Fiction are 2 circles in a ven diagram. They live in the speculative fiction space and there can be overlap. Hard Science fiction is a term given to the section of science fiction that does not overlap with Fantasy's "inexplicable" zone at all.
There are plenty of works out there that already explore this concept. A world that starts out fantasy can be revealed to actually be a world of science, and though rarely recognized the opposite can often happen. Consider most modern religious works, they take our world of logic and reason and try to imply by the end that there's a greater mythology that governs the world, that is perhaps outside of science. This is hardly different than the fantasy book that starts with orcs vs elves and ends with the revelation that they're all descended from gene-modified humans, and that "late earth" is really and always just earth; that magic is really just manipulation of a nano-bot net that's infected a planet.
The point at which you cross the line from one space into the other is the point at which you use an element or concept which rules out the other. IE, explaining that magic was really science all along: welcome to exclusive science fiction. Explaining that science was really magic all along: exclusive fantasy.
Arguing that you can have your cake and eat it too? It depends. Note that just because you explain something doesn't mean it will hold up to the rigor of inspection if your explanation is flawed; this is where the line for hard sci-fi is drawn. Not only must you posit scientific truth, you must adhere to our understanding of scientific truth.
To answer your other question that inspired this one in the context of this answer. Is it ok to have things that aren't explained or explainable by characters in the story and still be hard-science-fiction? Yes, so long as an explanation can exist that is not ruled out by our scientific understanding of the way the universe works. IE, a character not knowing something or not being able to know something is entirely scientific.
There are mathematical proofs that show it is impossible to know everything. It would be fantasy to imply otherwise. There are bounds to the observable universe. You can know the speed of a particle, but not it's position; or you can know it's position, but not it's speed. Science does not grant perfect knowledge; Science leads to the acquisition of models that describe some portion of the universe and it's functioning which has been verified by legitimate, well constructed experiment. These models and discovered rules are the best we can reason based on observation, and we have reason to doubt anything that violates them and can't be re-produced. But, having a set of models and rules does not mean you know everything, it merely means you can likely explain the set of things which have models & rules.
IE, People can go missing, and you might not know why; but there still exist many understandable ways those people might go missing: Tidal Waves, Disease, Alien Abduction, etc.
A final note: Publishers shelve things by genre in order to sell books. This is very important. It also applies to tv, movies, radio and other forms of entertainment. So, while everything I said makes a sort of academic sense (and is frankly far more useful to the writing process), if you're trying to sell a book then you want to describe it in a way that the audience you think will read it will find it, even if it does not totally or neatly fit the definition. Sales-level-genre classifications are used to make short-hand promises to consumers about what they might experience if the individual attempts to consume the work. This means that if you say something is sci-fi, and there's a class of people who thinks that means "has spaceships", but they will buy anything with space-ships; then it would be correct to call the work sci-fi (even if you count up all of the fantasy/sci fi elements and there are more fantasy elements).
But if you're trying to understand components of books and the building blocks of them in order to write, or even analyze what's going on at a higher level for academic purposes, the above definition will suit you better. It's important to know how different communities map genre to works if you're going to sell something because they will expect you to live up to your promise.
The Hard-Sci-Fi community will not tolerate unexplained supernatural forces in a work classified as "Hard" Sci-Fi.