Every walled town is essentially a fort. For higher security or a smaller investment they would build a castle, or castelina (small castle I think). The larger ones seem to be called roccas. We have seen a lot of all of these.
Many of these castles have large, cavernous rooms. I was reading the sign on one of these and they said the room was divided into two floors using wood structures. One huge room was divided into two living floors and each “floor” room itself was divided three rooms, which made them of reasonable size.
I had never heard that before but it makes a lot of sense. You build the big rooms in stone which is strong and good for defense but then you build the smaller rooms out of wood which is easier to work with and easier to change. And the wood structure is protected from the elements. Very sensible and it makes the large rooms more logical.
Lucca has a wall all around but was never attacked, maybe because it had walls. The only time the walls were used was to prevent a flood from flooding the city. And now, they use it to bicycle on.