@font-face {
	font-family: "Aldrich";
	src: url("../fonts/Aldrich-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Chakra Petch";
	src: url("../fonts/ChakraPetch-Regular.ttf") format("truetype");
	font-weight: 400;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Chakra Petch";
	src: url("../fonts/ChakraPetch-Medium.ttf") format("truetype");
	font-weight: 500;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Chakra Petch";
	src: url("../fonts/ChakraPetch-SemiBold.ttf") format("truetype");
	font-weight: 600;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "Chakra Petch";
	src: url("../fonts/ChakraPetch-Bold.ttf") format("truetype");
	font-weight: 700;
	font-style: normal;
	font-display: swap;
}

:root {
	--viewport-gap: 1rem;
	--ink: #eaf6ff;
	--muted: #9bc0da;
	--cyan: #5af4ff;
	--mint: #8fff97;
	--danger: #ff8383;
	--panel: rgba(8, 14, 29, 0.78);
	--panel-border: rgba(110, 227, 255, 0.34);
	--button-bg: #8fff97;
	--button-ink: #0f2822;
}

* {
	box-sizing: border-box;
}

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

body {
	min-height: 100dvh;
	height: 100dvh;
	padding: var(--viewport-gap);
	display: grid;
	place-items: center;
	color: var(--ink);
	font-family: "Chakra Petch", "Segoe UI", sans-serif;
	background:
		radial-gradient(
			100% 120% at 0% 0%,
			rgba(57, 128, 255, 0.28),
			transparent 52%
		),
		radial-gradient(
			100% 120% at 100% 100%,
			rgba(255, 87, 87, 0.16),
			transparent 44%
		),
		linear-gradient(160deg, #05070f 0%, #070f21 48%, #11102a 100%);
	overflow-x: hidden;
	overflow-y: hidden;
	touch-action: none;
}

body::before,
body::after {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
}

body::before {
	background-image:
		linear-gradient(rgba(89, 168, 255, 0.09) 1px, transparent 1px),
		linear-gradient(90deg, rgba(89, 168, 255, 0.07) 1px, transparent 1px);
	background-size: 28px 28px;
	mask-image: radial-gradient(circle at center, black, transparent 85%);
}

body::after {
	background: radial-gradient(
		circle at center,
		transparent 66%,
		rgba(0, 0, 0, 0.5) 100%
	);
}

.arcade-shell {
	width: min(1040px, 100%);
	height: calc(100dvh - (var(--viewport-gap) * 2));
	max-height: calc(100dvh - (var(--viewport-gap) * 2));
	min-height: 0;
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	padding: 1rem;
	border: 1px solid var(--panel-border);
	border-radius: 20px;
	background: var(--panel);
	backdrop-filter: blur(8px);
	box-shadow:
		0 18px 60px rgba(0, 0, 0, 0.45),
		0 0 70px rgba(70, 174, 255, 0.15),
		inset 0 0 0 1px rgba(157, 235, 255, 0.08);
	animation: shell-enter 700ms ease-out;
	overflow: hidden;
}

.hud {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 0.75rem;
	min-width: 0;
}

.metric {
	padding: 0.65rem 0.8rem;
	border-radius: 10px;
	border: 1px solid rgba(144, 221, 255, 0.25);
	background: rgba(12, 24, 46, 0.7);
	box-shadow: inset 0 0 0 1px rgba(165, 234, 255, 0.1);
	display: grid;
	gap: 0.2rem;
	min-width: 0;
}

.label {
	font-family: "Aldrich", sans-serif;
	font-size: 0.66rem;
	letter-spacing: 0.18em;
	color: var(--muted);
}

.metric strong {
	font-family: "Aldrich", sans-serif;
	font-size: clamp(1.05rem, 2vw, 1.45rem);
	line-height: 1;
	color: #f6fcff;
	text-shadow: 0 0 16px rgba(122, 238, 255, 0.45);
}

.stage-panel {
	position: relative;
	flex: 1;
	min-height: 0;
	display: grid;
	place-items: center;
	padding: 0.75rem;
	border-radius: 14px;
	background: linear-gradient(
		180deg,
		rgba(9, 21, 42, 0.8),
		rgba(6, 14, 30, 0.95)
	);
	border: 1px solid rgba(115, 200, 255, 0.22);
	overflow: hidden;
}

#game-canvas {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	aspect-ratio: 3 / 2;
	/* Stop mobile browsers from claiming drags as pan/zoom and firing pointercancel. */
	touch-action: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-tap-highlight-color: transparent;
	border-radius: 10px;
	background: #080f20;
	box-shadow:
		inset 0 0 35px rgba(97, 195, 255, 0.22),
		0 0 55px rgba(74, 165, 255, 0.18);
}

#touch-controls {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	z-index: 10;
	pointer-events: none;
	touch-action: none;
}

.control-deck {
	display: grid;
	gap: 0.8rem;
	padding: 0.9rem;
	border-radius: 12px;
	border: 1px solid rgba(118, 198, 255, 0.22);
	background: rgba(11, 21, 41, 0.72);
}

.status {
	margin: 0;
	font-family: "Aldrich", sans-serif;
	font-size: 0.84rem;
	letter-spacing: 0.06em;
	color: var(--muted);
}

.status span {
	color: var(--cyan);
	text-shadow: 0 0 12px rgba(79, 239, 255, 0.42);
}

.buttons {
	display: flex;
	gap: 0.65rem;
	flex-wrap: wrap;
}

button {
	border: 0;
	padding: 0.56rem 1rem;
	border-radius: 999px;
	font-family: "Aldrich", sans-serif;
	font-size: 0.76rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--button-ink);
	background: linear-gradient(180deg, #bcffc2, var(--button-bg));
	cursor: pointer;
	box-shadow: 0 8px 20px rgba(130, 255, 160, 0.28);
	transition:
		transform 150ms ease,
		box-shadow 150ms ease,
		filter 150ms ease;
}

button:hover {
	transform: translateY(-2px);
	box-shadow: 0 12px 24px rgba(130, 255, 160, 0.35);
	filter: saturate(1.05);
}

button:active {
	transform: translateY(0);
}

button.ghost {
	color: var(--ink);
	background: linear-gradient(
		180deg,
		rgba(117, 207, 255, 0.18),
		rgba(117, 207, 255, 0.08)
	);
	border: 1px solid rgba(120, 224, 255, 0.42);
	box-shadow: none;
}

.help {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem 0.9rem;
	font-size: 0.82rem;
	color: #a0b9ce;
}

.help li::before {
	content: "■";
	font-size: 0.54rem;
	margin-right: 0.45rem;
	color: var(--mint);
}

@keyframes shell-enter {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.99);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@media (max-height: 800px) {
	.arcade-shell {
		gap: 0.65rem;
		padding: 0.7rem;
	}

	.hud {
		gap: 0.5rem;
	}

	.metric {
		padding: 0.5rem 0.6rem;
	}

	.metric strong {
		font-size: 1rem;
	}

	.stage-panel {
		padding: 0.5rem;
	}

	.control-deck {
		gap: 0.55rem;
		padding: 0.65rem;
	}

	.help {
		font-size: 0.76rem;
		gap: 0.25rem 0.65rem;
	}
}

@media (max-height: 700px) {
	body {
		--viewport-gap: 0.4rem;
	}

	.arcade-shell {
		gap: 0.45rem;
		padding: 0.5rem;
	}

	.hud {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.label {
		font-size: 0.6rem;
		letter-spacing: 0.13em;
	}

	.metric strong {
		font-size: 0.9rem;
	}

	.status {
		font-size: 0.76rem;
	}

	button {
		padding: 0.44rem 0.78rem;
		font-size: 0.68rem;
	}

	.help {
		display: none;
	}
}

@media (max-height: 620px) {
	body {
		--viewport-gap: 0.25rem;
	}

	.arcade-shell {
		gap: 0.35rem;
		padding: 0.35rem;
		border-radius: 12px;
	}

	.hud {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 0.3rem;
	}

	.metric {
		padding: 0.34rem 0.42rem;
		border-radius: 8px;
	}

	.label {
		font-size: 0.54rem;
		letter-spacing: 0.1em;
	}

	.metric strong {
		font-size: 0.8rem;
	}

	.stage-panel {
		padding: 0.3rem;
		border-radius: 10px;
	}

	.control-deck {
		padding: 0.35rem;
		gap: 0.25rem;
		border-radius: 10px;
	}

	.buttons {
		display: grid;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: 0.25rem;
	}

	.buttons button {
		width: 100%;
		min-height: 1.55rem;
		padding: 0.22rem 0.3rem;
		font-size: 0.55rem;
		letter-spacing: 0.04em;
	}

	.help {
		display: none;
	}
}

@media (max-width: 900px) and (min-height: 621px) {
	.hud {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.help {
		gap: 0.4rem 0.6rem;
	}
}

@media (max-width: 560px) and (min-height: 621px) {
	body {
		--viewport-gap: 0.45rem;
		padding: var(--viewport-gap);
	}

	button {
		width: 100%;
	}
}
