:root {
	--sky-top: #79d2ff;
	--sky-mid: #8ee0ff;
	--sky-bottom: #b8f0ff;
	--ground: #c8b87e;
	--ground-dark: #b29a5f;
	--frame-dark: #3e3224;
	--frame-light: #fff2bf;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	width: 100%;
	height: 100%;
}

body {
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	font-family: "Courier New", Courier, monospace;
	background:
		radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.72) 0 48px, transparent 49px),
		radial-gradient(circle at 76% 12%, rgba(255, 255, 255, 0.66) 0 44px, transparent 45px),
		radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.55) 0 36px, transparent 37px),
		linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bottom) 78%),
		repeating-linear-gradient(
			0deg,
			rgba(255, 255, 255, 0.08) 0 6px,
			rgba(0, 0, 0, 0.03) 6px 12px
		);
	position: relative;
}

body::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	height: 18vh;
	min-height: 90px;
	background:
		repeating-linear-gradient(
			90deg,
			var(--ground) 0 20px,
			var(--ground-dark) 20px 40px
		),
		repeating-linear-gradient(
			0deg,
			rgba(0, 0, 0, 0.06) 0 4px,
			rgba(255, 255, 255, 0.06) 4px 8px
		);
	border-top: 6px solid #e8d998;
	z-index: 0;
}

#main-canvas {
	position: relative;
	z-index: 1;
	display: block;
	
	/* Scale dynamically to screen width */
	width: 90vw;
	max-width: 400px;
	
	/* The game's native size is 288x512 = 9:16 ratio */
	aspect-ratio: 9 / 16;
	height: auto;
	
	/* Make sure the canvas doesn't push the UI off screen on short devices */
	max-height: calc(100vh - 200px);
	
	/* BUT if the height is maxed out, we MUST cap the width too to preserve the 9:16 ratio */
	/* Because 100vh - 200px is the max height, the max width should be (100vh - 200px) * 9 / 16 */
	/* Without this, the width keeps growing to 90vw while the height is frozen, squashing the image */
	@media (max-width: 800px) {
		max-width: calc((100vh - 200px) * 0.5625);
	}
	
	border: 6px solid var(--frame-dark);
	outline: 4px solid var(--frame-light);
	box-shadow:
		0 0 0 4px rgba(62, 50, 36, 0.35),
		0 14px 0 rgba(62, 50, 36, 0.45),
		0 22px 40px rgba(0, 0, 0, 0.28);
	image-rendering: pixelated;
	image-rendering: crisp-edges;
	touch-action: none;
	-webkit-touch-callout: none;
	user-select: none;
}

.game-container {
	display: flex;
	flex-direction: column;
	align-items: center;
	z-index: 10;
	width: 100vw;
	margin: 0;
	padding: 0 5%;
}

.game-title {
	font-size: 3rem;
	color: white;
	text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
	margin: 0 0 5px 0;
	text-transform: uppercase;
	text-align: center;
}

.score-container h2 {
	font-size: 2rem;
	color: white;
	text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
	margin: 0 0 15px 0;
	text-align: center;
}

.footer {
	margin-top: 20px;
	color: white;
	font-weight: bold;
	font-size: 1.2rem;
	text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
	text-align: center;
}

.footer a {
	color: #e8d998;
	text-decoration: underline;
}

.footer a:hover {
	color: #fff;
}

@media (max-width: 600px) {
	.game-title {
		font-size: 2.2rem;
	}
	.score-container h2 {
		font-size: 1.5rem;
		margin: 0 0 10px 0;
	}
	.footer {
		font-size: 1rem;
		margin-top: 15px;
	}
	#main-canvas {
		border-width: 4px;
		outline-width: 3px;
	}
}
