The delicate workings at the heart of a 2,000-year-old analogue computer have been revealed by scientists.
The Antikythera Mechanism, discovered more than 100 years ago in a Roman shipwreck, was used by ancient Greeks to display astronomical cycles.
Using advanced imaging techniques, an Anglo-Greek team probed the remaining fragments of the complex geared device.
The results, published in the journal Nature, show it could have been used to predict solar and lunar eclipses.
The elaborate arrangement of bronze gears may also have displayed planetary information.
"This is as important for technology as the Acropolis is for architecture," said Professor John Seiradakis of the Aristotle University of Thessaloniki in Greece, and one of the team. "It is a unique device."
However, not all experts agree with the team's interpretation of the mechanism.
The remains of the device were first discovered in 1902 when archaeologist Valerios Stais noticed a heavily corroded gear wheel amongst artefacts recovered by sponge divers from a sunken Roman cargo ship.
A further 81 fragments have since been found containing a total of 30 hand-cut bronze gears. The largest fragment has 27 cogs.
Researchers believe these would have been housed in a rectangular wooden frame with two doors, covered in instructions for its use. The complete calculator would have been driven by a hand crank.
Although its origins are uncertain, the new studies of the inscriptions suggest it would have been constructed around 100-150 BC, long before such devices appear in other parts of the world.
Writing in Nature, the team says that the mechanism was "technically more complex than any known device for at least a millennium afterwards".
Although much of it is now lost, particularly from the front, what remains has given a century's worth of researchers a tantalising glimpse into the world of ancient Greek astronomy.
One of the most comprehensive studies was done by British science historian Derek Solla Price, who advanced the theory that the device was used to calculate and display celestial information.
This would have been important for timing agricultural and religious festivals. Some researchers now also believe that it could have been used for teaching or navigation.
Although Solla Price's work did much to push forward the state of knowledge about the device's functions, his interpretation of the mechanics is now largely dismissed.
A reinterpretation of the fragments by Michael Wright of Imperial College London between 2002 and 2005, for example, developed an entirely different assembly for the gears.
The new work builds on this legacy.
Using bespoke non-invasive imaging systems, such as three-dimensional X-ray microfocus computed tomography, the team was able to take detailed pictures of the device and uncover new information.
The major structure they describe, like earlier studies, had a single, centrally placed dial on the front plate that showed the Greek zodiac and an Egyptian calendar on concentric scales.
On the back, two further dials displayed information about the timing of lunar cycles and eclipse patterns. Previously, the idea that the mechanism could predict eclipses had only been a hypothesis.
Other aspects are less certain, such as the exact number of cogs that would have been in the complete device. The new research suggests 37 gears could have been used.
However, what is left gives an insight into the complexity of the information the mechanism could display.
For example, the Moon sometimes moves slightly faster in the sky than at others because of the satellite's elliptic orbit.
To overcome this, the designer of the calculator used a "pin-and-slot" mechanism to connect two gear-wheels that introduced the necessary variations.
"When you see it your jaw just drops and you think: 'bloody hell, that's clever'. It's a brilliant technical design," said Professor Mike Edmunds.
The team was also able to decipher more of the text on the mechanism, doubling the amount of text that can now be read.
Combined with analysis of the dials, the inscriptions hint at the possibility that the Antikythera Mechanism could have also displayed planetary motions.
"Inscriptions mention the word 'Venus' and the word 'stationary' which would tend to suggest that it was looking at retrogressions of planets," said Professor Edmunds.
"In my own view, it probably displayed Venus and Mercury, but some people suggest it may display many other planets."
One of those people is Michael Wright. His reconstruction of the device, with 72 gears, suggests it may have been an orrery that displayed the motions of the five known planets of the time.
"There is a feature on the front plate that could have made provision for a bearing with a spindle, that carried motion up to a mechanism used to model the planets of Mars, Jupiter and Saturn as well," he told the BBC News website.
"That's how I see it and my reconstruction shows it works well."
Intriguingly, Mr Wright also believes the device was not a one-off.
"The designer and maker of the device knew what they wanted to achieve and they did it expertly; they made no mistakes," he said.
"To do this, it can't have been very far from their everyday stock work."
The Antikythera Mechanism will be explored in an episode of Unearthing Mysteries on BBC Radio 4 on 12 December