# Build an impregnable fortress in the middle ages with modern technology

Let's say we want to build the strongest possible fortress¹ in a medieval (1300 CE) setting while having access to any modern technology and material.

Said technology can only be used during the construction of the fortress and not afterwards, so e.g. a solar powered device is allowed to continue functioning after the construction is complete, but the denizens of the fortress will not be able to repair it in case of damage.

Soldiers will only have access to regular weapons and armor from their time, not modern weaponry (otherwise we would just build a wooden house equipped with M60s and be done with it).

¹This fortress will have to endure:

• Battering rams on the gate
• Balistas, catapults and trebuchets. No cannons.
• Starvation by means of cutting out supply lines.
• Possibly, ladders and siege towers. (I say "possibly" because it would be a nice addition, but as long as the other 3 problems are covered, this can be handled by the soldiers.)

It is assumed that the inhabitants will learn perfectly how to operate every device/building/etc., but will not be able to understand how/why they work.

This means they won't be able to repair or replicate anything beyond their level of technology. For example, if a carbon fiber wall gets damaged, they will repair it with stones/bricks/concrete.

Location constraints: any location is allowed, provided it is suitable for a medieval population (e.g. an underwater city would be infeasible). It also needs to function as any "regular" castle (allow movement of troops and people in and out, allow counter attacks and so on)

Population: as many people as possible as long as it doesn't compromise security and provisions. At least 200; the more, the better. Let's assume that everyone is completely loyal and would die sooner than "betray the castle".

Resource and time limit: no time limit, and suppose the area isn't attacked or sabotaged in any way during the construction. The resource limit is what realistically could be done by an entity in our society, so obviously no "just build an actual mountain the size of China, made of concrete and steel and hate". Let's say something around \$5B just to give you an idea. Of course, good and cheap is better than good and expensive; but good and expensive is much better than crappy but cheap.

What are the materials and techniques best suited to withstand the problems listed?

If "impregnable" is impossible, then "as strong/durable as possible".

Bonus points if the answer manages to give a great solution to the problem without needing overly complicated technology to keep working (e.g. by focusing on the materials and construction techniques rather than on particular devices)

• Comments are not for extended discussion; this conversation has been moved to chat. – James Oct 12 '18 at 15:56
• Duration of expected siege and the isolation caused by it? Weeks? Years? Generations? – hyde Oct 14 '18 at 7:07
• have a look at the city in "attack on titans" to get the idea :) – D3f4u1t Oct 15 '18 at 14:14

# Colditz Castle

### An impregnable fortress. An inescapable prison.

This is the problem you risk if you make a fortress that's truly impregnable, it could become the prison you spend the rest of your life in. One of the key features of castles is the ability to counter attack. Whether to sally forth with troops, or simply to shoot from the relative safety of the battlements, a castle is more than just a reinforced concrete box.

# Why a castle?

Castles are a statement of control as well as a tool of war, you see it dominating a landscape and it tells the world that there's someone here willing to put up a fight to keep a region. It allows a smaller force to hold a territory against much larger numbers until reinforcements can be gathered. It also acts as garrison, prison, armoury, residence, administrative centre, and food store. Castles are not the purely functional buildings that modern bunkers tend to be.

A castle didn't have to hold out forever when under siege, it just had to hold out for long enough. Long enough for either the attackers to run out of food or money (or healthy men), or for a relief force to reach the castle to break the siege.

Directly assaulting a castle is fairly rare, it's expensive and risky. Far cheaper and safer to sit out the siege for as long as it lasts, and it could last for years (the siege of Donnington castle lasted from July 1644 to April 1646). If your attackers are in a hurry and going for the attack you're probably in luck as defenders, castles were good, well designed and well built they gave significant advantage to the defending force. The ones that survive intact into the modern age were the very best, Dover castle lasted long enough to be hardened against cannon fire with the best technology of the age.

# So what to change?

One of the greatest vulnerabilities of a castle was being undermined. This could bring down even the strongest tower. What we're going to do to compensate for this is dig down a couple of storeys, drill down and put in reinforced concrete foundations. While we're down here we'll also create some basements with water storage tanks and cool food storage areas all surrounded by double layered reinforced concrete walls, infilled with soil and rubble, similar to the main castle structure but underground and concrete. We may leave some secret tunnels down here just in case we need to make a discreet exit. Ideally there will also be a well or similar underground fresh water supply.

For the superstructure I'm not going to change much, the people of the day knew what they were doing and most castles would easily resist a direct assault on the walls. This leaves them in a good position to repair any damage that may be done during the average battle.

Inside the main outer door of the barbican we're going to build a bank vault type door, a simple conical section, smooth on the outside, it can only be controlled from the inside. The corridor between the outer door and this second door is a straight up kill zone, oil holes in the ceiling, spear holes in the walls all the usual "kill anyone in here" stuff, nothing special and fairly standard for the day.

### In summary

Don't underestimate how good castle builders were at their job. Most castles never fell to assault, if they fell it was normally a surrender after a siege. The real change is better understanding of sanitation and food storage. Castles could survive sieges for years.

• +1 for the sanitation. If there is one modern thing you can add to a medieval castle, it should be the plumbing – nzaman Oct 10 '18 at 12:27
• Perhaps worth noting that "inescapable" Colditz had over thirty successful escapes. – anaximander Oct 10 '18 at 14:15
• @anaximander, that subtitle is from the book, it's missing the next couple of words "Until now". – Separatrix Oct 10 '18 at 14:17
• The siege of Rhodes city in 1522 lasted 6 months, but they could easily have lasted much longer if they weren't betrayed. So a good location could make the impregnable castle even better. – Michthan Oct 10 '18 at 14:45
• @Michthan, for location you're talking Masada, and that's an entirely different game from a medieval castle. – Separatrix Oct 10 '18 at 14:51

The secret lies in Agriculture and Sanitation

Most medieval constructions before the advent of cannon/gunpowder were actually sufficient to prevent entry against a determined adversary. Most of these sieges ended through starvation, disease, an insider threat, or a counterattack by the defender's allies.

First of all, let's just make sure that your castle is truly impregnable. To do this, we are interested in two things: height (which means range) and the impregnability of the construction materials. We make our walls higher than any siege engine can launch an object. This will also prevent siege towers from being a factor. Now we can't have outside fire or disease (or deadly projectiles) launched in to our city. We also want to place footers under our walls deeper than can be possibly undermined. Current technology allows for both of these feats. The wall construction will be made of a composite lasting the centuries... likely reinforced concrete, layered with impact absorbers, covered with a durable, yet thin, metal. This will absorb anything thrown against it.

Now, the gate/entry way is the weakest physical assault point. This means that we will want multiple layers of security here and a precarious approach. A narrow, and easily protected, walkway covered by multiple towers on our skyscraper walls will do the trick, we'll just make several of these to be sure (and remove the idea that one person could open the single gate to our city. Also, a system could be developed where only one of the three inrow city gates can be opened at a time, along with much more secure (while still being simple) locking mechanisms.

So what's left... fire? All structures inside of our city are made of steel reinforced concrete. Disease? Sanitation is the name of the game here for the most part and a sewage system is put in place to deal with this. Romans did it with older technology, we can do it as well. Fresh water is provided by placing the castle over a large reservoir and drilling to this point. Modern technology isn't needed to lift water out of this in the event that pumps break. Impart as much medical knowledge as feasible (just the idea of infection and how to prevent it should safe thousands).

Now we're neatly sealed up inside of our city, with plenty of water and housing. We need food. And a way to always have food. You simply enlarge the area enclosed by your massive fortress walls to grow ample food to supply the city. It is likely best to make this area dispersed and divided to prevent disease/fire from spreading among the farms. The area required can be greatly reduced over typical medieval farming practices due to introducing modern agricultural techniques and grains. We also introduce modern grain storage techniques which allows for massive hoarding of food.

As for weapons to defend ourselves, sure, you could introduce all manner of fancy modern weaponry, but given our height and armored supremacy, traditional siege weapons mounted 100m off of the ground can outreach any adversary, if they even bother to assault you, which they never would.

• You do realise the bigger it is, the more expensive it will be to maintain with a medieval economy? – nzaman Oct 10 '18 at 12:46
• Even steel reinforced concrete is not totally immune to fire. – Bergi Oct 10 '18 at 21:22
• I wonder if we could sneak an attack army through that nearly-forgotten sewage system that our city builders made... – Ángel Oct 10 '18 at 23:54
• @nzaman While nothing is maintenance free, high quality, modern concrete core, with sand filled gap covered with a highly resistant metal should be pretty low maintenance for long enough to get out of the medieval ages. – ColonelPanic Oct 11 '18 at 10:50
• @nzaman make the "durable metal" 40ft*40ft*6inch hardened titanium plates, and it'll probably take a month before anybody could cut off a chunk. Plus, its practically unworkable using medieval tech, and it doesn't even hold an edge. – mbrig Oct 12 '18 at 19:30

Build one of these AA-Towers the Nazis build in WW2. The Allied Forces tried to destroy them after the war (with explosives from the inside) and ultimately gave up after having to use 40 tons of TNT on one of them in Berlin.

From KMJ, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=968914

It sure can withstand anything any medieval weapon has to offer. Don´t forget to bore a well in the middle!

• Additional detail: These bunkers are built from reinforced concrete which will likely withstand any attack a 14th century army can dish out. But this is not a Nazi invention. It's a standard material in building construction. But there are two holes in this answer: What about climbing? And how do you prevent starvation? – Philipp Oct 11 '18 at 11:53
• @Philipp: Climbing a sheer concret wall? While getting shot from above? You should do away with most of the windows though. Food is, as with any Fortess a problem. A little rooftop gardening and some chickens should work, storage for the rest, and ultimately you´ll gonna be depleted sooner or later. – Daniel Oct 11 '18 at 14:23
• You'd need to upgrade it to castle standards, replace the windows with arrow slits, lose that curtain at the top, it's creating a safe space for attackers at the bottom of the wall. Add crenelations instead for archers to work with. Don't forget the risks and mode of attack were different in the middle ages. They would have come at the wall with ladders and siege towers rather than climb it directly. – Separatrix Oct 12 '18 at 7:23
• The windows are a latter addition - after we realized it was impossible to destroy without serious damage to the city around it, we decided to use it somehow. There are quite a few old bunkers in germany repurposed as housing or offices. They all got windows, except one which is used as "music bunker" (osnabrück) where you can have full volume concerts in a residential area without the outside hearing a peep. – Christian Sauer Oct 24 '18 at 7:33

As other have noted, castle designs were actually already pretty impressive.

However, two significant things modern technology could enable that medieval technology could not replicate would be:

1. Location

It would be really quite wonderful to build a castle high in some strategic mountain pass, but alas, medieval engineers lacked the means to do so. No longer! With modern advances in engineering, materials, architecture, and logistics, you can now seal that dirty mountain pass as tight as a drum. And to boot, rather than terribly drafty stone, wood, and cladding, you have solid concrete, proper insulation, and an HVAC system with climate control. Watch your enemies freeze to death outside your walls as your people sit happy, warm and safe inside the walls of your modern fortress.

2. Scale

In addition to being able to build a walled structure in some high mountain pass, you can also use modern engineering to build a wall over the ENTIRE mountain pass. The kinds of increases of scale enabled by modern technology could make a structure so incredibly large that it is it's own geographical feature. In addition to providing unassailable dominance over terrain, the sheer size and scope of your structure could serve as it's own kind of deterrent. Could you imagine being a medieval soldier and trying to lay siege to a castle wall the size of the hoover dam? Don't worry, your enemy can't either, which is why their army routed after a mere week into the siege of your mountain fortress.

• Hey man, this is a great idea. We can improve it yet. Use the dam power generation to provide elevators and the ability to flood entrances at will. Add to it multiple tunnels that go for miles in every direction and laying siege becomes straight up ridiculous. – Joshua Oct 12 '18 at 16:00
• If you incorporate the behind the castle/dam wall into your design, you could harness the pressure not only for power generation, but also some truly entertaining water-powered weapons. – Basic Oct 12 '18 at 17:15
• Or, hell, drain the lake, build another wall upriver, turn the canyon floor into farmland, and use the up-river dam to make sure your valley doesn't flood. Have fun trying to besiege a fortress big enough to grow a cities worth of food. – Iron Gremlin Oct 12 '18 at 17:31

Any reasonable medieval castle had stockpiles lasting for months and many had tunnels to enable restocking the castle during siege (or escape). Those castles are already nearly good enough for your purpose. Now take one at a suitable location and it is essentially impregnable as is, without any need for modern stuff - for example https://en.wikipedia.org/wiki/Predjama_Castle would be an existing castle that could be suitable for your purposes (the original one from 13th century would do as well). If you want some "modern magic": add lasers, long lasting batteries and burn wood/fat in a steam engine to charge batteries (or put it somewhere else with suitable natural resources and burn oil or gas). Everything is better with lasers. Also stuff the place with tons of cans to have food for decades. Maybe even reinforce walls with thick concrete.

But if you want the castle to be self sufficient, this won't do - the mentioned castle doesn't have means to generate its own food. Unless you place the same castle to guard the only passage to the other side of impassable mountains with a large enough fertile land. Easy enough, you as the boss could even chill in the palace in the middle of that land in complete safety, while the peons work the fields and defend the castle. It could last for centuries, until finally the explosives get good enough the thing gets slowly blasted apart.

Now, the most interesting thing would be to have a castle that needs to be 100% self-sufficient, yet defendable. But... this isn't possible. The big problem is you require about 2*10^4 m2/person to be self-sufficient (based on a quick search, numbers vary wildly). Now, assume a small garrison of 200, and you are looking at 4*10^6 m2 = square with side of 2km! (obviously you would make it a circle, but it doesn't change much, and it is simpler to calculate with squares). This is enormous already and a tad problematic to defend with mere 200 people, each will be responsible for 40m of the wall. Day and night. And work the fields as well. So, this is clearly impossible to defend, even if you give every one of them machine guns that never run out of ammo or break down. The nice thing for you is that with 20k people, you will have 20km sides of the square, but now 10 will be defending the same 40m section of the wall and do all the rest - so it is doable ... but at that point, you are not looking at a castle, but an island. Just build some guard posts around it put lasers there and just burn all the ships approaching. Think upgraded classical era mirrors :)

In summary, just how good do you want the castle to be? Castles were good enough already, add some modern magic and they are better. Put them in perfect location and you could have them last for centuries under siege. But to make them perfectly self-sufficient, nah, you can't feasibly do that with a castle; while islands don't even require much of a castle to achieve that.

• Upvoted for the "just fortify an island" angle and the farmland-to-meters-of-wall calculation – tucuxi Oct 11 '18 at 12:38

## Resist battering rams on the gate

The best defence against a battering ram is of course to make it really difficult to get a ram up to the gate, but that does not depend on tech level. What you can do is to make a solid steel door. (Easy with modern tech, well understood but very very expensive for a person in the middle ages)

Also construct hinges and fittings carefully. Place some cushioning material (rubber will do nicely) behind the gate post to absorb impact from the ram.

## Resist Balistas, catapults and trebuchets.

You can certainly build strong walls with reinforced concrete. Also add steel plates and a crumble zone in front of the walls to greatly reduce impact from any boulders hurled your way.

## Resist Starvation by means of cutting out supply lines.

Modern tech would not add much here. The key is to have a reliable well inside your fortress and stock up on food beforehand. However, you could definitely build some better facilities for hygiene and sanitation, reducing the risk of your soldiers succumbing to diseases.

## Resist ladders and siege towers.

Using reinforced concrete instead of stone makes it easier to build really high walls, which naturally improves your defence against ladders and towers. Also, you can build some nice defensive constructions, having protruding structures high up from which your defenders can easily cover the walls with arrows (and nastier stuff) making any attack over the walls a suicide mission.

## Resist tunnels (bonus)

The favourite means of breaching a castle wall was to tunnel under it and set fire to the (wooden) support beams. With modern equipment and machinery, you can extend your wall all the way down to bedrock, or at least well below groundwater level, making tunneling very hard.

• Put the gate at the top of a slope. The ram's own weight will pull it backwards. Problem solved – nzaman Oct 10 '18 at 12:28
• Yeah, there were plenty of solutions to battering rams in our real world. Naturally they apply without modification to this question. – Guran Oct 10 '18 at 12:31
• Resisting starvation: rooftop vegetable gardens 250 metre above the ground? – gerrit Oct 10 '18 at 15:24
• "you could definitely build some better facilities for hygiene and sanitation" - the crazy thing here is that you would NOT build better facilities than the ROMANS has. Amazing, though ;) – TomTom Oct 12 '18 at 13:16
• To stop undercutting, secant cutoff walls are pretty easy to make, actually. – Harper - Reinstate Monica Oct 13 '18 at 21:52

I think the previous answers overlook one possibility: the question does not specify that modern weapons can't be included in the fortress design; only that no maintenance can be performed on those weapons.

I'm surrendering the bonus points here because I'm employing devices and not construction methods, but the best approach would probably be:

1. Build this fortress on flat land with clear and unobstructed lines of sight that extend 2x the maximum range of the ranged weapons of your specific era. If the useful range of the catapults of your era is 500 meters (for example), make sure you have sight lines extending a full kilometer.

2. Include pillboxes on your fortress that cover 360 degrees of your frontage. Have overlapping coverage wherever possible.

3. Put automatic weapons emplacements in your pillboxes - one main, and three backups.

4. Store as much ammunition as is feasible given the size of your fortress. Include as many basement levels as you think is feasible and fill them all with ammunition.

No medieval force would be able to even approach this fortress for the foreseeable future, let alone invest or take it. Sapping operations or trench operations wouldn't be feasible, either - the logistical effort it would take to cover a kilometer of ground using such methods would be beyond even the best-organized medieval military. I doubt even the Roman or Han armies could have done it - certainly not while under hostile fire.

Eventually the weapons would wear out, or expire due to lack of maintenance. Or you'd run out of ammo. But any of those events would either take a very, very long time, or would require your enemy to take losses that no medieval power could realistically bear.

• How long until a not-maintained weapon becomes worn and damaged (honest question ! ) ? A century ? Two ? And how would you avoid being infiltrated sneakily ? – Don Pablo Oct 11 '18 at 8:55
• I doubt they would last that long. It depends on whether they are actually called into use. I think that after two engagements, opponents would conclude that this fortress was the Death Star and you'd never actually face an opponent again. Your infiltration plan would then become the best one, and I have no answer for that. I don't think ANYONE ultimately has an answer for that; covert ops undertaken by someone smarter than you will always have a chance to succeed. – tbrookside Oct 11 '18 at 11:51
• @DonPablo I don't know exactly how long it would take before they'd require maintenance, but the fact that soldiers are trained in basic maintenance of their own gear suggests that the number is measured in months at the most. – Ray Oct 15 '18 at 4:31
• Employing guns is totally infeasible imho: you need to train your troops regularly, which requires ammunition. And you need to maintain guns, especially if they are used for training and should always be in working order (and not stored in a vat of oil in the basement). I.e. after a few short years you'll either run out of ammo or your guns would be clogged heaps of rust that are as dangerous to their operators as any approaching enemy. – fgysin reinstate Monica Oct 15 '18 at 9:52
• The question specifies that the occupants of the fortress can conduct maintenance that isn't beyond their technology. I don't see anything in this maintenance guide that's beyond their capacity, other than the production of lubricants, which can be included in the ammunition stockpile. thecmp.org/wp-content/uploads/M1GarandGuide.pdf – tbrookside Oct 15 '18 at 12:10

## Fortify entair island

There actually exists such island in our world entirely, not only Spinalonga https://en.wikipedia.org/wiki/Spinalonga , Gramvousa https://en.wikipedia.org/wiki/Gramvousa but also many other in Greece, which had fortification and a few hectars of fields at them, some been famous as pirate fortresses in history.

With modern technology (and maybe in alternative world) such island can be found somewhere, where is regular rain and so no lack of watter, maybe even little larger, and you have your fortress. Some was sieged for years too.

Just make all sides of the island going straight up from sea, left only small port there, accessible by steep stairs from main and only gate (ofcourse the stairs would not be straight, would provide some cover from bottom, but no cover from hight walls above them) and you are basically done.

• inpenetrable gate: Just the usual construction, not much place before it, massive, so cannot be simply destroyed, kill-way to second gate (narrow, not straight, hight impenetrable walls, second gate even more massive, that the first, maybe to point, that could be blocked by collapsing stones from inside to level with the inside terrain), even getting to the first gate would cost attacker hundreds and hundreds of soldiers, if you will have just few peons throwning stones on them from above, not mentioning trained army with war machines (catapults, balistas ...) on the walls.
• inpenetrable walls - hundred meters of natural stone under, no place, where ship could attach to even start attack on such walls, usual fortification on top, so you can safely shoot on attackers, drop big stones and fired bushes on their ships, if anchored in reach of your walls, shoot them with catapults, balistas long before the ships even approach effective range of their weapons (100m high gives you naturally longer reach and naturally decrease reach of their weapons.
• you spot enemies for tens of kilometers, before they even start approaching, lot of time to orginize yourself
• modern sanitation methods for your people (even the basic would make big difference)
• modern agriculture methods - https://en.wikipedia.org/wiki/Three-field_system or better - and you do not care about food lines, with large enought island, you may even export food
• siege/prison? No problem, just you cannot travel to other nation, but except for routine patrols you are in deep peace regime inside, while enemies struggles to even get in touch. More over you can build cranes anywhere inside, then move them at any point of your walls to lower your ships for take cargo from smuglers and continue restricted trade even under full siege
• undermining island? from ships, which cannot anchor and can be bombarded (without any risk) with tons of boulders, fire, arrows, if they even try? - the same goes for ladders - based only on manuevuring ships they are anything but stable, with more probable overturn the ship and sink it, even if you do not fight them. The more for siege towers, would sink sooner, then they would even reach the base of your walls.

And if you use modern technology just to shape existing island sides to be all vertical, smooth and somehow equally high, with fortified walls growing from top, make the inside somehow flat (nivelation) and then move good portion of good soil like https://en.wikipedia.org/wiki/Chernozem there, you have paradice inside (small streams and lake included - maybe even add rice fields there), with possible thousand of regular inhabitans living peacufully there. It is possible to have nearly all of king homestic animals there too. And trees, of course, not just for fruits and pleasure, but also as improvised source of wood.

And with clean outer walls, permanent stone hoardings and fortified towers on top of the wall ( https://en.wikipedia.org/wiki/Hoarding_(castle) and https://en.wikipedia.org/wiki/Fortified_tower ) nobody can get inside if you not allowe him. Remember for a lot of building stone and wood to be stored inside every time and lot of stones, to be droppen on enemies, and you are good even long after gunpowered cannons came in play, with "purely mediaval technology and mindset"

(And the best of it - 95% already exist in nature, so you not pay for that, and for the rest - the size and price of fortification grows lineary with the size of island, while usable place grow quadratically - larger islands are way cheaper per habitant than smaller)

The equivalent to fortresses in modern times are bunkers. Dig down deep, have a huge sturdy steel gate in a tunnel and that will be the only vulnerable spot - which should be indestructible for medieval level of technology. Consider creating a huge hole in front of the gate with water at the bottom. In order to have a battering ram roll to the gate, which wouldn't be effective anyway, they'd need to construct a lot in order to even get there.

Also they wouldn't be able to dig through mountains and ferroconcrete in any reasonable time and expense, so the gate is the only way in.

• What about supply lines getting cut off? – Hankrecords Oct 10 '18 at 9:54
• Bunkers today already have sufficient supplies to last for many years for many people. You just have to store food which lasts long. Otherwise the answer is the same as for today's bunkers. They are made for nuclear fallouts, assuming you cannot go outside for a long period of time - supply lines are not intended to be had in the first place. Otherwise I can't think of surface structures which could withstand siege for long periods of time... – Battle Oct 10 '18 at 10:12
• And what would be the use of a deep bunker in medieval times? All the enemy has to do is to park some soldiers in front of that steel door, and your army is trapped. Wars are not fought for points, they are fought for control over territory and resources. If you are willing to trap your army in a concrete cage with an easily guarded steel door the enemy will be happy to oblige. – AlexP Oct 10 '18 at 10:49
• In the words of General Callus Tacticus if the enemy has an impregnable stronghold, see he stays there, your bunker sounds like a perfect candidate for this approach. – Separatrix Oct 10 '18 at 10:49
• Whether trapped or not, @Hankrecords has a point - the technology of the day barely allowed for the natural cold weather and salting to allow some foods to be stored over winter, there were no "long life foods" in the modern sense. So without adding preparation by using modern methods (eg canning, freeze drying) to lay in a stockpile of said long life foods, this answer is failing to address one of the OP's key criteria. – KerrAvon2055 Oct 10 '18 at 10:54

# Laputa | The Castle In the Sky | 99 red (hot air) balloons

Disclaimer: You said you wanted simple but impenetrable, not practical. This would never work in practice, but on paper it would be awesome!

The basic idea here is pretty simple. A Flotilla in the sky. A mass of hot air balloons tethered together via ropes/rope-ladders (to keep the flotilla together and to move between them).

Sailing high in the sky beyond the reach of arrows and siege weapons, you're 'castle' will be impenetrable!

Enemies would fear the sky knowing you are able to appear anywhere to rain death (rocks/poo/disease) from above (after some many years/luck to float to the right place)!

Individual balloons could break of from the flotilla to briefly land, pick up supplies, and rejoin the flotilla (actually, this would be a logistical nightmare to coordinate, but plausible... with VERY long rope). If the supply balloon is hijacked, your archers can easily dispatch it from the enemy thanks to the high ground. This also acts as a fail-safe against people trying to sneak in, as a basket floating near the ground for 5 minutes is easier to defend than any wall/gate. You could also sell 'distilled cloud' to the people on land at exorbitant prices (actually pee. Plebeians never touched a cloud before, they don't know better)

Your castle can easily grow to house as many as needed, as you can always add more balloons to the flotilla (again, a nightmare, but theoretically possible with just medieval tech, and blueprints/guide of how to do it with their tech)

The best defense is a good offense.

Plan A moderately expensive Take good food storage, and make the walls out of concrete but the best siege is one that cannot be maintained. Give your castle machine gun nests, sniper rifles and mortars.
Let the siege set up, then at night have your snipers open on command tents. Night vision will make this an unfair manicure. At their tech level they won't even understand what is happening. People will just die.
Then open the mortars. These have range of three miles. If you are lucky there won't be an enemy army left. If you are not they will fall back miles seeking some protection never knowing how far is safe. Anyone trying to instead charge in, would find themselves sliced up by the machine-guns. Now you can no problem supply your castle as needed. Problems solved.

If money is really not an issue.
Convert your castle into a battleship. The core is a nuclear reactor designed for a modern carrier. There is enough fuel to power a carrier for decades. I would assume this could power the castle forever. Once you have power you can construct full battleship turrets. At this point range becomes 24 miles. These guns can be filled with shrapnel instead of solid shells making them devastating against soft targets. That's more than two days of an army march. No enemy would even think of cumming close to the castle again.

.

• The second idea is far better. Aint no rule we can't carve the formula for gunpower into the insides. – Joshua Oct 12 '18 at 16:04
• @Joshua considering a battleship can run you 20 billion a pop, i was worried it was a bit out of budget – Andrey Oct 12 '18 at 16:42
• This would take considerable maintenance by highly educated technicians on an ongoing basis with an extensive logistical support chain. Without access to supplies and replacement parts from modern manufacturing, this will not remain operational for long. – pluckedkiwi Dec 7 '18 at 19:11

projection of force

I'm going take a very different approach from most other answers so far. I'll start by recapping, some key points, and then show some key differences:

This fortress will have to endure:

1. Battering rams on the gate

As has been said, anything on the order of reinforced concrete walls with a bank vault-ish door, are about as much as 'modern' tech would need, with actual medieval tech and practices like bad angles of approach, moats, etc. easily take care of even something like Grond (sans magic).

1. Balistas, catapults and trebuchets. No cannons.

Again, medieval construction was already strong enough (other than the doors/gates? to deal with these impacts. Modern tech just strengthens doors and allows higher walls to help avoid having projectiles lobbed over the walls in to the courtyard or similar areas.

1. Starvation by means of cutting out supply lines.

This, to me, is the most important aspect of this whole exercise. Without addressing this issue, as others have pointed out, the 'castle' becomes a prison. Stocking it with any amount of food or water supply, no matter how long that food and water might last, just makes it a well stocked prison. To prevent this issue, I'd suggest a spiderweb of tunnels (with strong enough walls, they wouldn't even necessarily need to be hidden underground, just completely enclosed above to prevent climbing over walls and in to the pathway) radiating out from the main structure. With modern technology this could be accomplished relatively quickly, easily and inexpensively, and the tunnels could cover much longer distances than medieval tech could compete with (a mile or three, think an hour or two march for a military force). A significant number of exits, both hidden and visible, at varying distances and directions from the main castle would make it very difficult, if not impossible, for a besieging force to guard them all. They would either spread themselves too thin, or leave some unguarded where the forces in the castle could exit. When they do exit, they can harass the besieging force from any number of directions, or simply keep supply and communication lines open. Using tunnels going 2 miles in the 4 Cardinal directions, and 4 more going in the Inter Cardinal directions, with exits at the half way points and the ends, plus the castle's main gate (and any secondary gates), that gives the besieging force 17 gates to try and guard, with an outer perimeter of more than 12.5 miles to spread out their army. Spreading an army over a front line 12 miles long will quickly make the line very thin, while concentrating it will leave openings that the castle defenders can easily exploit through unguarded tunnel exists. An attempt at a direct assault, even not considering the castle's walls and gates, would allow the defenders to exit at a distance farther out than the assault force, and pin them between the defenders inside the castle, and the defenders outside the castle(think siege of alesia, except now the defenders can get out of both sets of walls and pin the besiegers against the walls). If you expect the castle defenders to encounter a large enough force to maintain a 12 mile wall of soldiers, add another mile or two to the tunnles, and a third (and 4th?) set of exits. Tunnels 3 miles long makes the besiegers need to cover almost 20 miles, 4 mile tunnels gives them 25 miles to surround.

1. Possibly, ladders and siege towers.

Again, higher walls and the possibility of far greater overhang takes care of this.

1. Sapping (not mentioned in the origil question, but brought up repeatedly in other answers, and certainly worth considering)

Here I will differ significantly from other answers, again. Others suggest taking the wall very deep, so that undermining them is very difficult. I'd suggest making it very easy to undermine, but useless to do so. To do this, simply make the entire structure self supporting, not relying on any foundation for the integrity of the walls themselves. Modern tech can actually do this even accidentally, so if we intentionally build the entire 'floor' and walls of the castle specifically to maintain structural integrity, they could tunnel under one(front) wall, under the floor, under the other(back) wall, and out the other side of the Castle with no negative effects on the castle itself or the walls. Let them dig, it does no good. If desired, even backfill the courtyard with soil, if needed, so horses don't hurt their feet on concrete, etc.

1. Bonus points if the answer manages to give a great solution to the problem without needing overly complicated technology to keep working

Did I get the bonus points?

• If the enemy learns the locations of the tunnel exits, they don't need to guard them. They just need to bury them. – Ray Oct 15 '18 at 4:52
• @Ray While attempting to bury any single tunnel exit, they would be open to attack from at least 3 others. Example: In an attempt to bury the northernmost exit, the halfway exit on the north tunnel and the far exits of the northeast and northwest tunnel are all within striking distance, and could even provide an opportunity to surround the besiegers. The more they try to bury at a time, the more they run in to the same issue of spreading forces too thin. If they try and bury one, then move on to the next, the castle force simply leaves from an un-buried exit, and un-buries the buried one. – Dalila Oct 15 '18 at 15:35
• You can also use some futuristic tech to make sure it's hard to bury, like exits in cliff walls with a ramp down to ground level. Not very discreet, of course! – Law29 Dec 7 '18 at 11:58
• @Law29 Exactly. Use the terrain to further the advantages. being discreet where it's appropriate, and don't worry about it where it's not needed. Combine types of exits as needed for the terrain, and mix and match tactics on them also as needed ;) – Dalila Dec 12 '18 at 19:36

## Don't forget 1300-1700 technological advances!

During the 15th to 17th centuries, under the pressure of cannon, castles evolved into bastion fortresses, with their distinctive star/triangular shape. You do not have cannon, but the elimination of dead zones is a distinct advantage to defenders, and without cannon assaulting a star fort seems pretty difficult.

The rounded shape that had previously been dominant for the design of turrets created "dead space", or "dead" zones (see figure), which were relatively sheltered from defending fire, because direct fire from other parts of the walls could not be directed around the curved wall. To prevent this, what had previously been round or square turrets were extended into diamond-shaped points to give storming infantry no shelter. The ditches and walls channeled attacking troops into carefully constructed killing grounds where defensive cannon could wreak havoc on troops attempting to storm the walls, with emplacements set so that the attacking troops had no place to shelter from the defensive fire. [Wikipedia - Bastion fort]

Add to that a modern crossbow design with some kind of crank to fire quicker (something a 14th-century smith will be able to understand and reproduce), some low-tech ballistas and springalds in place of cannon, and your besieged army will not have to rely on "modern" tech.

For modern (20th century) tech, some examples of useful things that fall far short of your 5B limit:

• a goodly supply of AK-47s, famed for their ruggedness in face of harsh conditions, with appropriate ammunition of course. Ammunition may not be infinite, but a few cartloads make for lots of bullets, and after a few demonstrations you shouldn't need much. Add in a few boxes of sniper rifles that reach out to that marvelously inviting viewpoint some one or even two kilometers away that any enemy commander will be sure to (try to) make use of to see what devilry he is up against (your snipers can practice against a target there during peacetime), and some boxes of bazookas (some models are designed to be ridiculously easy to operate) for that really annoying guy who managed to build an iron-shielded siege tower or battering ram. No hand grenades, they'll just bounce down the walls and damage them more than the enemy can.

• maybe some Claymore mines for people who get too close to the walls

• shields (think Roman shields to hold over your head if arrows are raining down) and helmets with modern materials and design (the standard WWII German Stahlhelm was so good a design that the US Army found themselves using it later despite the distinctive shape, but even so it wasn't perfect and maybe some features won't be useful to you; see here for some nice points), maybe bullet-proof vests

• modern health knowledge (sanitization, as noted in other answers, but also food storage and what I'd call "hospital knowledge", cleaning of wounds etc.)

• really good armored doors instead of the wooden doors that battering rams are used on (consider also a bent entrance).

• binoculars, and accurate maps of surrounding landscape (if the fortress is on an island or a peninsula with high cliffs, so much the better)

• barbed wire -- lots of it.

If you decide on providing electricity of some kind, then:

• walkie-talkies to coordinate (otherwise speaking tubes should connect key points to the central command room!)

• laser range-finders for the snipers

• arc lights for checking the walls during the night, or, even better and needing less electricity, low-light/night vision goggles

• some low-voltage electricity through a special barbed wire to alert when it gets cut or touched or pulled down into the mud

Do use some really modern (at least 2020s or 2030s) tech for the batteries!

So you want the medieval castle build with modern methods to withstand:

Battering rams on the gate

Balistas, catapults and trebuchets. No cannons.

Starvation by means of cutting out supply lines.

Possibly, ladders and siege towers. (I say "possibly" because it would be a nice addition, but as long as the other 3 problems are covered, this can be handled by the soldiers.)

No medieval castle was totally impregnable. No medieval castle was 100 percent guaranteed to totally withstand any possible medieval assault, or starvation, or treachery, or surrender of the garrison after they had held out for a long time but saw no possibility of being relieved.

The facts are that medieval sieges - both successful and unsuccessful, lasted for days, or weeks, or months, or years, and sometimes over a decade, before they either succeeded or were given up.

So it is a good idea to study the longest lasting medieval sieges and see what made them last so long before they either succeeded or failed. Part of the reason why some medieval sieges last so long was because the attackers had the will and the resources to keep on attacking or besieging for months or years instead of giving up after a few weeks. This means that some of the short sieges may be worth studying too, to learn why the besiegers gave up after a short time.

Here is a link to a long, long, long list of sieges:

Note that most of them, even in the medieval period, were sieges of towns and cities. But there are many sieges of castles listed during the medieval period.

So you can learn a lot from the designs of fortresses, castles, and cities that withstood long sieges.

And you can also try to find out which castles (like Chateau Gaillard, Krak des Chevaliers, Coucy, Caernarvon, etc., etc.) and cities (like Constantinople, etc.) were considered to be the strongest in their times.

So after your research identifies the features of the strongest castles and cities and other fortifications, you can hope to duplicate those features in your fictional castle, city, or fortification, only more so, of course, using the superior modern technology of 2018, or of 3018, or of 201,800, or of whenever your time travelers come from, or the superior technology of an alien civilization that might be millions of years more advanced than 13th century Earth.

A number of highly impressive structures were build by manpower alone in ancient times, and the main superiority of ancient societies over medieval societies was that ancient societies were were better organized and could better organize the efforts of hundreds and thousands of laborers on projects.

So a futuristic society with time travel, or an alien society advanced enough to reach Earth from another star system in our middle ages, would have two possible advantages when building even superior castles, cities, or fortifications than medieval society could.

1) They could use modern earth moving, quarrying, and construction equipment and power tools - only far more advanced than those of 2018 since a society capable of time travel or interstellar travel would be far more advanced than Earth in 2018.

2) They could use the same primitive tools and methods that ancient and medieval societies did, but replace the human muscle power used by ancient and medieval societies with the power of humanoid robots. Tens of humanoid worker robots, or hundreds, or thousands, or tens of thousands, or hundreds of thousands, or millions of worker robots.

Problem number 1:

Battering rams on the gate

Modern day police and military special forces still sometimes use battering rams to break into buildings. But the modern ones are pretty small and look like only two men can swing them at a time. Thus they can batter down ordinary modern house doors but would probably be useless against bank vault doors or medieval castle gates.

I believe that very long battering rams (and also picks to pick apart castle walls) swung by many men were used in medieval times.

And one defense against that was to avoid straight, perpendicular, level approaches to the gates. Instead the approach to the gate would be landscaped or built so that attackers with battering rams would have to approach and swing their rams diagonally, and/or uphill, and/or around a sharp right angle turn (or two sharp right angle turns), or else use very short battering rams which only a few men could swing, thus without enough force to batter open the gates.

And of course many gatehouses were highly defensible miniature castles. Many gatehouses had an inner and an outer gate separated by a passage, which of course could zigzag to prevent using long battering rams. And the passage was usually a killing zone with arrow slits and murder holes in the ceiling.

And one idea to make the inner passage of a gatehouse even more of a killing zone would be to put it over a deep pit with wooden stakes at the bottom. The floor would be a wooden trapdoor or drawbridge keep horizontal. When attackers were on the drawbridge floor it would be released dropping the attackers dozens of feet to be impaled on the spikes or stakes below. Then the drawbridge or trapdoor would be drawn back up to a horizontal position for the next bunch of attackers.

Another idea to make a gatehouse stronger would be to have emergency gates that could be lowered behind the inner wooden but metal reinforced gate. Each gate that would be slowly dowered down behind the inner gate would be a single giant slab of stone, or a masonry wall made of many stones, or a hollow metal gate filled with concrete. And these emergency gates would be slotted in so that each fitted against the back of the previous one. When they were all lowered into position they would form a solid wall behind the inner gate that could be as thick as the outer walls of the castle.

Once the siege or attack was over the castle defenders would no longer be able to use the inner gate to get in or out until they slowly winched up the many emergency gates behind the inner gate, which depending on how much modern power equipment they had, might take months.

So in the meantime they would have to use a weaker side gate in the inner passage of the gatehouse.

If attackers broke down that side gate they would find themselves in a space between inner and outer walls of the castle. The outer wall would have crenellations on the inner side as well as the outer side so that archers on it could turn around and shoot down at any attackers between the walls. The inner wall would be a lot higher than the outer wall so archers on it could shoot down at any attackers who got on top of the outer wall.

The space between inner and outer walls would run all the way around the castle but it would be divided into perhaps a dozen smaller spaces by cross walls with gates in them, so attackers would have to fight their way all around the castle and batter down maybe a dozen gates before coming to a space which had a gate leading to a gate in the inner wall.

And just to make things harder for the attackers there could could be deep pits with stakes outside each gate, or maybe filling the entire space between walls, and trapdoors to drop attackers into those pits.

So once the attackers battle their way through a dozen gates around the castle and batter down the gate in the inner wall, they can enter the ward of the castle - the outer ward of the concentric castle. And they see another gatehouse and another set of double walls ahead of them.

And know they have to repeat the previous process to get through the next two walls and reach the inner ward of the castle. Or possibly the middle ward of the castle if the concentric castle has three wards.

Some castle experts would say that such elaborate plans would be unnecessary gilding the lily since many medieval gatehouses were already the strongest and least vulnerable parts of the castles, so that it was common for it to be easier to breakdown and enter the walls of a castle instead of the gatehouse(s).

So the question should really be how to defend the walls against battering rams.

Many medieval castle walls were not built very well. They would have inner and outer walls made of large rough stones with a lot of mortar between the stones, and the space between the two two walls would be filled with smaller stones, pebbles, and dirt. Such walls were comparatively easy to battler down with rams or picks aimed at the mortar between the stones. That may be why many medieval castle walls were covered with stucco and whitewash, to hide the gaps and week spots between stones.

Defenses against attacks on the wall were:

a) Very sturdy and well built (and very expensive) walls. With the advanced technology of 2018, to say nothing of the far more advanced future or alien technology available to your castle builders, it should be comparatively easy to build walls out of vast quarried blocks of stone or poured concrete slabs, with the total widths and heights of the walls hundreds or thousands of feet or meters.

b) Passive prevention of enemies from reaching the walls of a castle to attack it. Thus there could be a steep slope outside a castle wall making it difficult to pick or batter at the wall, or a deep wide moat outside a castle wall making it difficult to pick or batter at the wall, or a moat with a slope inside it, or a moat with a slope outside it, or a moat with slopes both outside and inside it. Many castles were built on steep hills or mountains, and many had deep wide moats or lakes, sometimes concentric moats, as water defenses, like those of Kenilworth castle.

c) Active prevention of attackers from reaching the walls. The defenders would shoot at attackers to keep them from reaching the walls to try to break down the walls. The goal is to design the castle so that the number of defenders it can hold can defend it against tens, or preferably hundreds, or preferably thousands, of times as many attackers.

Defense against the second threat:

Balistas, catapults and trebuchets. No cannons.

Discussing defending the walls against battering ram attacks, possibility a) was: Very sturdy and well built (and very expensive) walls. With the advanced technology of 2018, to say nothing of the far more advanced future or alien technology available to your castle builders, it should be comparatively easy to build walls out of vast quarried blocks of stone or poured concrete slabs, with the total widths and heights of the walls hundreds or thousands of feet or meters.

Build the walls many tens of feet thick, or hundreds of feet thick, and balistas, catapults, and trebuchets will be unable to seriously damage such thick walls. This will also be a pretty good defense against any cannons likely to be invented in the next few centuries.

Possible defense b)

Also use advanced technology to build more advanced balistas, catapults, and trebuchets than medieval persons can build. Balistas, catapults, and trebuchets so advanced that ideally they can shoot farther than medieval built ones stationed a hundred feet higher than they are. Then build the walls of the the castle hundreds of feet higher than the highest position close enough to reach the castle with medieval balistas, catapults, and trebuchets.

Station your advanced balistas, catapults, and trebuchets on top of those walls to rain death upon anyone who sets up their balistas, catapults, and trebuchets in range of the castle and to slaughter the crews of the medieval balistas, catapults, and trebuchets and wreck those devices. If the attackers pull back their medieval balistas, catapults, and trebuchets to get them out of range of your advanced balistas, catapults, and trebuchets they will have to pull them so far back that they will no longer be able to reach the castle.

Note that women and children can fire balistas, catapults, and trebuchets from the walls of castles and cities and have done so in many sieges, so that refugees can become defenders during sieges.

Defense against the third threat:

Starvation by means of cutting out supply lines.

Many castles and cities were built in places where the irregular lay of the land dictated the irregular outline and layout of the defensive walls. But many other castles and cities were built where the builders were free to choose the exactly layout of the defense walls and outline of the castle of city.

And when castle and city builders had free choice of what plan to use, some chose less wisely and some chose more wisely.

If the methods of defending your castle require one defender for every X feet of outer curtain wall, you better make certain that your castle has no more feet of outer curtain wall than X times the expected number of defenders. The maximum total number of defenders your castle could possibly hold, or the usual number of defenders your castle usually holds, will depend on part on the accommodations for defenders within the castle, which will depend in part on the square footage within the castle.

Suppose that a walled enclosure has 10,000 square feet of ground and is 1 foot by 10,000 feet. it will have 20,002 feet of wall for 10,000 square feet, or 0.4999 square feet for every foot of wall.

Suppose that a walled enclosure has 10,000 square feet of ground and is 2 feet by 5,000 feet. it will have 10,004 feet of wall for 10,000 square feet, or 0.9996 square feet for every foot of wall.

Suppose that a walled enclosure has 10,000 square feet of ground and is 10 feet by 1,000 feet. it will have 2,020 feet of wall for 10,000 square feet, or 4.950 square feet for every foot of wall.

Suppose that a walled enclosure has 10,000 square feet of ground and is 20 feet by 500 feet. it will have 1,040 feet of wall for 10,000 square feet, or 9.615 square feet for every foot of wall.

Suppose that a walled enclosure has 10,000 square feet of ground and is 40 feet by 250 feet. it will have 580 feet of wall for 10,000 square feet, or 17.241 square feet for every foot of wall.

Suppose that a walled enclosure has 10,000 square feet of ground and is 80 feet by 125 feet. it will have 410 feet of wall for 10,000 square feet, or 24.390 square feet for every foot of wall.

Suppose that a walled enclosure has 10,000 square feet of ground and is 100 feet by 100 feet. it will have 400 feet of wall for 10,000 square feet, or 25 square feet for every foot of wall.

So, out of all possible rectangles, a square shape gives the least amount of wall to be defended for the same square footage inside. But a square is not only a type of rectangle, it is also a type of regular polygon. A regular polygon is a many sided geometric figure where all of the sides and all of the angles are identical.

Many other types of regular polygons have shorter perimeters than a square for the same area enclosed. The extreme form of a regular polygon is a circle. A circle with a radius of about 56.4189 feet and diameter of about 112.83796 feet would have an area of 10,000 square feet and a circumference of about 354.49 feet, and so would have a ratio of about 28.2095 square feet of area for every foot of perimeter wall to be manned.

And that is important because one way to avoid having your castle or city starved out is to grow sufficient food within the castle or city to feed the defenders.

Suppose that each person in the city or castle needs an average of one acre to grow food for himself and one tenth acre for other purposes. Suppose that a million people live in a city. They will need 1,100,000 acres of land to grow good and for other purposes.

Therefore, with 43,560 square feet in an acre, a total of 47,916,000,000 square feet would be needed, or a square 218,897.23 feet, or 41.4578 miles, on each side. It would have a total of 875,588.92 feet on all four sides. If there were 1,000,000 people in the city, and 0.25 of them were adult males, there would be a total of 250,000 defenders, so each side would have 62,500 defenders spread over 218,897.23 feet, or about one defender every 3.5023 feet, which seems adequate to defend a wall ten feet high, let alone one hundreds of feet high.

A circle with an area of 47,916,000,000 square feet would have a radius of 123,498.98 feet or 23.3899 miles, and a circumference of about 776,000 feet, with about 3.104 feet per defender. If the walls are hundreds of feet high and thick one defender should be enough to defend hundreds or thousands of feet of wall, so each fighting man could spend a few weeks a year training and stationed at the walls, and the rest of the year tending his farm which could be miles deep within the vast fortress.

Of course medieval methods of farming might require several acres to feed one person. But if the time travelers or aliens introduce more modern methods of agriculture, or hydroponics, or aeroponics, or food synthesizers, they may be able to feed many tens or hundreds of people per acre, and a fortress with a population of a million and 250,000 fighting men might be very tiny compared to one 46.7798 miles in diameter.

Or the super advanced aliens or time travelers might use their high technology to dig vast tunnels through the rocks for tens and hundreds of miles to various locations where their exits might be very strongly fortified. So supplies purchased in distant locations could be secretly brought in to the castle deep underground without besiegers knowing or being able to stop it.

Defense against the fourth threat:

Making the walls hundreds of feet thick and tall would be a perfect defense against ladders and siege towers.

Putting concentric rings of steep slopes and moats around the castle, fortress, or city would also help defend against ladders and siege towers by keeping them away from the walls.

You have five things:

• the castle
• the enemy
• supply storage
• everything else

You want the castle to be as large/impenetrable as possible. Since you have modern-technology, there are many ways to make this near-impenetrable (impossible is possible).

Find a place (too remote you won't be able to get supplies) that is easy to defend, easy to get supplies to, and hard to attack. A snowy mountain range would do. The castle keep and walls could be titanium-reinforced concrete, using the strongest concrete in the world. And you could make them as tall as needed (minimum would be 25 feet tall and five feet thick) and deep (10-25 feet) since you don't want the enemy to collapse them. if you build the walls a certain way, they won't collapse anyway. Put barbed wire near the tops and middle to keep out climbers. Since your on top of a mountain in a snowy environment roofs would need to be put over the walls to keep out snow. guard towers should have fireplaces that are seen for a few miles. During siege you can put special powders that you stake up on in the fire to spook the people attacking.

Build a really tall watchtower(100-200 feet) with a roof for the snow, a lighting rod (cause no one wants to get electrified) with 360 degree view and put good binoculars/telescopes in. It'll be really hard for an enemy to sneak up.

The gate can be concrete curved to withstand a battling ram, with windows above the gate so defenders can easily attack. A portcullis could be built easily and made out of titanium, so a medieval battling ram will have a hard time.

other things to defend: mini catapults/trebutchet and balistas in the towers with oil.

Using modern machines build an easily defensible switchbacks down the mountain into the small valley below. A town at the foot of the mountain, with its own tough walls, defenses, and moat, could be built down there and the farms also.

Your men: Since you have modern technology, build your army stainless steel(or titanium but if you want to) weapons, armor, and such. The town can have a cavalry with armored horses or other big beasts your able to tame using modern tech (bears, wolves, mountain lions, mt. goats).

The enemy
The enemy comes and overtakes your town somehow. If they start up the mountain, flaming oil and rocks could be launched at them and no human formation can withstand that. Build gliders for people to fly over the enemy and drop unpleasant things on them. If they make it to the castle use gunpowder bombs(it was used as a weapon in 904 AD) and eliminate them.

Supply Storage

Build large bunkers under the keep (large with thick walls) and store up for a decade. With this castle, no one in the right mind would waste time attacking a seemingly impenetrable fortress for a decade.

Another thing. Build greenhouses. It would be hard but feasible with modern tech; build large plexiglass or metallic glass(invented in the 20th century and as strong as steel) as the material and make suitable for crops(rich dirt etc). Put this inside your castle and you could last even longer on greens.

Everything Else

There's not much else but if your have extra money, build a few more castles and towns under your control. If you go with a design like this and keep them close together so they can back each other up. Get a suitable army built up and your good!

Modern tech?

Oh boy.

Depending on how long you need to hold out for and what you can bring in....

Modern construction and plumbing can do quite a number.

Any medieval force you're up against is probably going to have to walk, or ride up to your base. Modern concertina wire is going to do a number on any enemy you meet. Unlike many of the other suggestions, I'd go with building somewhere flattish with lots of open ground. You control the killing fields

With modern contruction equipment you can build a series of berms, with nasty surprises at the bottom. Imagine your horses going down a slope into a series of shapened, rusty metal fence posts.

For power I'd suggest an unusual step. Get generators and the equipment to maintain them. If possible set up facilities to refine metals. While in the modern context, we wouldn't power a generator that way - you could probably use animals to power your generators, either directly, or by being used to pump water up to storage tanks.

You could also solve the "seige" problem with modern food tech - canned food lasts for years as would freeze dried food. You could wait out your enemies. You could also have fish tank and use the water from that and your waste cycle to grow fresh food internally.

Now, offence. We did talk about modern equipment and nasty surprises right? You could probably hose down invading armies at a distance with spare waste. You could flood the surrounding area into a mire. The best time to defeat the enemy is before they attack.

Now defence. I'd go old school here. Reinforced concrete is awesome and all, but if you had the lifting power, I'd go with big, multitonne blocks of basalt or granite. Its what the planet's made of, and I'd rather go for nice, thick walls for the outside walls. Add a couple of high towers to snipe your wet, foul smelling enemies for further demoralisation. Have lower internal structures your enemies can't see. If modern weapons, or even semi modern weapons are an option, add some mortars inside with fixed kill zones and pummel em as they come.

The goal here of course is to make your enemies lose the fight before they reach your walls. Even if they do, you have power, food and other means to make their life miserable.

You definitely could do it so you can keep maintaining with 12th century technology while minimizing the costs.

Build your wall with bunker quality concrete, check. Its height should be enough to avoid incendiary projectiles to pass over it. You have to specifically worry about trebuchets. Make sure there is no any high terrain within 200 meters of the walls where these can be placed to shoot higher. I estimate the height of the walls should be at least 30m (100ft). I would keep it under 40m to avoid the defenders getting too tired when climbing up. Anyway you would also have some light elevators (made of aluminum) pulled by horses and/or men. Horses eat a lot, you won't be able to keep them once their food reserves are over but you can turn them into food.

Given the height, the angle of the stone projectiles will be almost vertical. You could design ammunition that projects darts around on impact. Leave the molds and tools so they can cast more. They can make them of Roman concrete and iron.

The outer wall would be a Bastion Fort (as mentioned before, with a sort of star shape) to take advantage of the war machines and crossbows. Use the inner walls to build terraces for crops.

These terraces can help to collect water when rains are abundant but you would combine this with other water collectors and a well. Most of the buildings will be within the wall so all the inner terrain would be profitable for crops. All academic theses indicate that medieval agriculture lack of productivity was greatly derived from decision making mistakes, not lack of knowledge, so they should suffice to survive. You should however have enough preserved foods so to tackle bad crops (cans can last up to a century). Think of climate control for maximum energetic economy, install solar heating (non electrical) for cooking and heating water. Use state of the art insulation techniques and green architecture design.

Build improved war machines and crossbows with modern materials. You can even stash replacement parts to repair them after they wear off. Provision of ammunition might become a issue even if you make reserves, and have some trees and piles of stones to make more. But a battle might be won with a fraction of these reserves (i.e let them come, then target their war chiefs).

Build railways at different levels of the wall with drasines to quickly move troops and war machines along the perimeter.

The gate: install the gate on top of a ramp made of concrete; you can also seal it completely with a curtain like concrete door made of a few embedded stripes reaching the basement and wait till the enemy is gone to open it with pulleys and counterweights. If you feel insecure, replace it with a titanium alloy door with shock absorbers behind.

Could you build it in 20 acres for 200 habitants? (I'm trying to cut costs here), you could, and the wall would be indestructible, but since the height of the wall allows it you can build multiple levels of loopholes to fire outwards. It will be better to do it in 200 acres for 2000 fighters so they can shoot massive volleys.

Final note, the spectacularity of the walls should be enough to discourage any medieval invader to attempt an attack after failing the first time. The reasonable strategy would be to siege, only to discover years later that this doesn't work either. The longest siege in history took 22 years, it was the siege of Candia in the 17th century. The siege of Philadelphia (14th century) lasted 12 years. In both cases the defenders faced the resources of an empire, and the city fell. Exceptional cases as they are, one can estimate this fortress to be practically impregnable.