body {
	margin: 0;
	height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(circle at center, midnightblue, black);
}

.coil {
	position: relative;
	display: flex;
	justify-content: center;
	transform: translateX(1em);
}

.coil::before,
.coil::after {
	content: '';
	position: absolute;
	border-radius: 50%;
	width: 1em;
	height: 1em;
	top: -0.5em;
}

.coil::before {
	left: -1.5em;
	background: darkgreen;
}

.coil::after {
	left: -9.5em;
	background: darkred;
	transform: scale(0.9);
	box-shadow: 0 0 1em white;
	animation: blink 1.5s ease-in-out infinite alternate;
	z-index: -1;
}

.coil span {
	position: absolute;
	width: calc((var(--n) * 2 - 1) * 1em); /* width = 2n - 1 */
	height: calc((var(--n) - 0.5) * 1em); /* height = n - 0.5 */
	border: 1em solid darkgreen;
}

.coil span:nth-child(odd) {
	align-self: flex-end;
	border-radius: 50% 50% 0 0 / 100% 100% 0 0;
	border-bottom: none;
}

.coil span:nth-child(even) {
	border-radius: 0 0 50% 50% / 0 0 100% 100%;
	border-top: none;
	transform: translateX(-1em);
}

.coil span:nth-child(1) {
	--n: 1;
}

.coil span:nth-child(2) {
	--n: 2;
}

.coil span:nth-child(3) {
	--n: 3;
}

.coil span:nth-child(4) {
	--n: 4;
}

.coil span:nth-child(5) {
	--n: 5;
}

.coil span:nth-child(6) {
	--n: 6;
}

.coil span:nth-child(7) {
	--n: 7;
}

.coil span:nth-child(8) {
	--n: 8;
}

@keyframes blink {
	to {
		box-shadow: 0 0 0 white;
	}
}
