Medusa or jellyfish
The Costa Brava coasts teem with fish making it a perfect place for snorkelling, diving and long distance swimming. However, being a natural environment occasionally you do run into jellyfish (medusa in most European languages - imagine the Gorgon's head). Most of the year you see isolated medusa near the coast and fortunately the waters are normally so clear that if you wear goggles and keep a look out you can avoid them. A day-to-day report of jellyfish presence at beaches can be found at Medjelly.
There are different types of medusa, but the one seen most often on the Costa Brava is the common jellyfish. Like most jellyfish it will sting if you make contact - it feels like a sharp electric shock, or as if the contact point has pressed hard into a prickle, or like a wasp sting. This is considered relatively mild though it still hurts and can leave a weeping rash that lasts for a few days.
At times though there will be larger groups of jellyfish. In these cases the lifeguards tend to switch the beach safety flag from green to yellow. The water may look as still and safe as before, but the lifeguard's warning is there to let you know that it's not as clear as it was (occasionally there is also a separate medusa warning flag). So with the yellow flag watch out for children. Children also need to know not to touch any medusas that have washed up onto the beach. Though they might be dead, their tentacles still contain the stinging cells.
In general if you see an isolated medusa you can just swim by. The time you're more likely to get stung is when the water is cloudy or murky so you can't see anything, or when you're not looking out for them such as on a heads down speed swim (many long distance swimmers take medusa as part of the sport). Normally if there are other people in the water within the buoyed off area swimming is safe and if you are worried, you can make a spotting swim out to check and then return along the same swimming line.
Some medusa are more painful than the common medusa (eg the floating portuguese man'o war which has a floating sack on top). If it's one of these get help from the lifeguard.
If you are stung the main thing is to get out of the water. Like a bee sting very rarely some people can have an allergic reaction with problems breathing. If the sting was in a main bathing area report it to the lifeguard (point and the word 'medusa' will be enough). This will help protect other people. The lifeguards will also be able to help with treatment. If you're on your own remove any tentacles with tweezers or a cloth and wash the sting, the main recommendation is to use vinegar if you have it as this seems the best method. Opinions on washing with water or sea water are mixed, but if it is all you have it may help wash off some nematodes - the poison sacs. Some suggest shaving the area, again to clear away any last nematodes.
The chances are even after doing this you will get a rash for a few days which can swell. If it's in a sensitive area or you are concerned you would be best advised to visit a pharmacy (pharmacists are qualified to provide advice and guidance on medication and treatment in Spain) or a doctor in order to get a painrelieving gel, or an antihistamine (eg Fenistal) to relieve the swelling. The rash tends to weep a yellow goo and it can take several weeks for the whole rash to disappear.
These are rough guides from a non-medic. If you are in any doubt seek medical attention.