A sixth-former was murdered for his mobile phone and a cash card as he walked home from a night out, Swansea Crown court has heard.
Ben Bellamy had been clubbing the night before his body was found
Ben Bellamy, 17, from Sketty Park, was found with severe injuries on a Swansea beach the morning after the attack.
Two boys, aged 16 and 17, and Andrew Rafferty, 18, of Mount Pleasant, Swansea, deny murder and grievous bodily harm with intent.
Ben had been walking home alone along the seafront. The trial continues.
The prosecution alleges that the three defendants saw Ben making calls on his mobile phone to a girl he had a crush on as he walked home.
Robin Spencer QC said; "That might explain, in no short measure, what happened next."
He said Ben was repeatedly and brutually kicked and stamped on before two of the defendants dragged him into the sea and left him. His dead body was found covered in treadmarks from shoes.
Andrew Rafferty denies charges against him
Ben had spent the night of Saturday, 17 September 2005 celebrating a friend's 18th birthday before going to the Cinderella nightclub in Mumbles, near Swansea.
The two boys - who cannot be named because of their age - and Andrew Rafferty were also at the nightclub, the court heard.
Ben left the club at 0200 BST and was walking home along a seafront path, making calls to a girl until 0249 BST.
He ran into the three along the way and initially, the court heard, they all got on well with Ben taking money out on his cashcard to buy everybody Pot Noodles and crisps at a series of garages along the way.
Mr Spencer said: "Suddenly the atmosphere changed. For no apparent reason, the younger two began to punch him in the face.
"He was dragged onto the beach and the assault continued with all three of them taking part. Rafferty used his elbow to keep him on the ground with the other two kicking and stamping on his head and body.
"The motive was robbery. They knew he had a mobile and a cash card. They took them. They made him tell them a pin number."
Andrew Rafferty left to go to a cash machine and the other two continued with a "vicious and sustained attack" in his absence, the jury was told.
They stripped Ben of his clothing and put him 50m into the sea, where, as he was seriously injured, it was "inevitable" he would drown, Mr Spencer added.
"He would have drowned within minutes, quite unable to save himself because of these injuries," he told the court.
One of the unnamed defendants used Ben's mobile at 0527 BST to call his own girlfriend.
All three defendants were arrested within days of Ben's death. Andrew Rafferty admitted trying to use Ben's cash card, but denied taking part in the violence.
But Mr Spencer said: "The prosecution say all three played their parts in the robbery and murder of Ben. They were all in it together.
"All three took part in an attack that made it inevitable that Ben would drown when put into the sea."
Andrew Rafferty and the 17-year-old boy admit robbery, but the 16-year-old denies the charge.
All three deny murder and an alternative charge of inflicting grievous bodily harm with intent.