In CSS, the most specific rule wins.
It means that the most specific rule is going to style the selected element of the page over other rules that affect it.
When there is more than one rule with the same specificity, the latest wins.
But there is an exception: the importance aspect.
If there is a rule with !important at the end, this rule will be the winner no matter its specificity.
And if you keep more than one !important rule in the code, then the one with more specificity will win.
In general, !important is better to be avoided and just be used to test and find some possible errors.
Here, you can try, play and see different results of specificity and importance.