:root {
	--navy: #1d3461;
	--navy-deep: #0f1c36;
	--coral: #e8534a;
	--green: #8cd04a;
	--text: #f3f6fb;
	--muted: #9fb0cc;
}

* {
	box-sizing: border-box;
}

html,
body {
	margin: 0;
	height: 100%;
	background: radial-gradient(circle at 50% 0%, #24427a 0%, var(--navy-deep) 70%);
	color: var(--text);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
	overscroll-behavior: none;
}

.app {
	--stage: min(calc(100vw - 24px), calc(100dvh - 130px), 720px);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	min-height: 100%;
}

.hud {
	width: var(--stage);
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.brand {
	display: flex;
	align-items: center;
	gap: 6px;
	font-weight: 900;
	letter-spacing: 0.08em;
	margin-right: auto;
}

.brand img {
	height: 32px;
}

.stat {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	line-height: 1.1;
	min-width: 44px;
}

.stat small {
	color: var(--muted);
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.stat b {
	font-size: 18px;
	font-variant-numeric: tabular-nums;
}

#lives {
	display: flex;
	gap: 1px;
	height: 22px;
}

#lives img {
	height: 22px;
}

.icon-btn {
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.15);
	color: var(--text);
	border-radius: 8px;
	font-size: 16px;
	width: 34px;
	height: 34px;
	cursor: pointer;
}

.icon-btn {
	display: grid;
	place-items: center;
	padding: 0;
}

.icon-btn .cross,
.icon-btn.muted .wave {
	display: none;
}

.icon-btn.muted .cross {
	display: inline;
}

@media (max-width: 480px) {
	.brand span {
		display: none;
	}
	.hud {
		gap: 8px;
	}
}

.stage {
	position: relative;
	width: var(--stage);
	aspect-ratio: 1;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 0 0 3px var(--navy);
}

canvas {
	display: block;
	width: 100%;
	height: 100%;
	touch-action: none;
	outline: none;
}

.overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(15, 28, 54, 0.78);
	backdrop-filter: blur(2px);
	padding: 16px;
}

.overlay.hidden {
	display: none;
}

.panel {
	text-align: center;
	max-width: 420px;
}

.hero {
	height: calc(var(--stage) * 0.32);
	animation: bob 1.6s ease-in-out infinite;
	filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}

@keyframes bob {
	50% {
		transform: translateY(-8px) rotate(-2deg);
	}
}

.panel h1 {
	margin: 4px 0 6px;
	font-size: clamp(26px, 6vw, 44px);
	font-weight: 900;
	letter-spacing: 0.1em;
	color: var(--green);
	text-shadow: 0 3px 0 var(--navy);
}

.panel p {
	margin: 0 0 12px;
	color: var(--text);
	font-size: clamp(13px, 2.4vw, 16px);
	line-height: 1.4;
}

.panel .hint {
	color: var(--muted);
	font-size: 12px;
	margin-top: 12px;
}

.play {
	background: var(--coral);
	color: white;
	border: none;
	border-radius: 999px;
	padding: 12px 36px;
	font-size: 18px;
	font-weight: 800;
	letter-spacing: 0.06em;
	cursor: pointer;
	box-shadow: 0 4px 0 #a8342d;
}

.play:active {
	transform: translateY(2px);
	box-shadow: 0 2px 0 #a8342d;
}

.timebar {
	width: var(--stage);
	height: 8px;
	background: rgba(255, 255, 255, 0.1);
	border-radius: 4px;
	overflow: hidden;
}

#timefill {
	height: 100%;
	width: 100%;
	background: var(--green);
	transform-origin: left;
}

#timefill.low {
	background: var(--coral);
}

.dpad {
	display: none;
	grid-template-columns: repeat(3, 64px);
	grid-template-rows: repeat(2, 56px);
	gap: 6px;
	touch-action: none;
	user-select: none;
	-webkit-user-select: none;
}

.dpad button {
	background: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.2);
	border-radius: 12px;
	color: var(--text);
	font-size: 22px;
	touch-action: none;
}

.dpad button:active {
	background: rgba(140, 208, 74, 0.35);
}

.dpad [data-dir="up"] {
	grid-column: 2;
	grid-row: 1;
}
.dpad [data-dir="left"] {
	grid-column: 1;
	grid-row: 2;
}
.dpad [data-dir="down"] {
	grid-column: 2;
	grid-row: 2;
}
.dpad [data-dir="right"] {
	grid-column: 3;
	grid-row: 2;
}

@media (pointer: coarse) {
	.app {
		--stage: min(calc(100vw - 24px), calc(100dvh - 270px), 720px);
	}
	.dpad {
		display: grid;
	}
}
