:root {
	--bg-a: #05233a;
	--bg-b: #0f5d8f;
	--bg-c: #8cd8ff;
	--panel: rgba(255, 255, 255, 0.86);
	--panel-border: rgba(8, 47, 73, 0.2);
	--ink: #072033;
	--accent: #ff8a24;
	--accent-strong: #e56000;
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

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

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	font-family: 'Baloo 2', 'Trebuchet MS', sans-serif;
	color: var(--ink);
	background: radial-gradient(circle at 15% 15%, #74d6ff, transparent 45%),
		radial-gradient(circle at 85% 5%, #ffd27d, transparent 40%),
		linear-gradient(160deg, var(--bg-a), var(--bg-b) 44%, var(--bg-c));
	overflow: hidden;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
}

.game-shell {
	position: relative;
	height: 100vh;
	height: 100dvh;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	padding: clamp(0.45rem, 1vw, 0.7rem);
	padding-bottom: calc(clamp(4.25rem, 8vw, 4.95rem) + env(safe-area-inset-bottom, 0px));
	gap: clamp(0.35rem, 0.9vw, 0.65rem);
}

.toolbar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 0.8rem;
	padding: 0.45rem 0.6rem;
	background: var(--panel);
	border: 1px solid var(--panel-border);
	border-radius: 14px;
	box-shadow: 0 8px 24px rgba(0, 18, 33, 0.18);
	flex-wrap: wrap;
}

.toolbar-actions,
.stats {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	flex-wrap: wrap;
}

h1 {
	margin: 0;
	font-family: 'Fredoka', 'Baloo 2', sans-serif;
	font-size: clamp(1rem, 2.8vw, 1.5rem);
	font-weight: 800;
	letter-spacing: 0.01em;
	color: #07345c;
}

.stats p {
	margin: 0;
	font-size: clamp(0.78rem, 2.3vw, 0.96rem);
	font-weight: 700;
}

.stats span {
	color: #11497c;
}

#comboValue {
	color: #b91c1c;
	font-weight: 800;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.back-link,
button {
	font: inherit;
	font-weight: 700;
	padding: 0.45rem 0.74rem;
	border-radius: 999px;
	border: none;
	text-decoration: none;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	touch-action: manipulation;
	transition: transform 0.14s ease, box-shadow 0.14s ease;
}

#goBack {
	background: linear-gradient(180deg, #ff6f61 0%, #d82c1f 100%);
	color: #fff;
	border: 2px solid rgba(255, 255, 255, 0.4);
	box-shadow: 0 8px 18px rgba(224, 49, 49, 0.32);
	font-weight: 700;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
}

#soundToggle {
	background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
	box-shadow: 0 7px 16px rgba(21, 128, 61, 0.26);
}

#soundToggle[aria-pressed='false'] {
	background: linear-gradient(180deg, #64748b 0%, #334155 100%);
	box-shadow: 0 7px 16px rgba(51, 65, 85, 0.28);
}

button {
	background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
	color: #fff;
	box-shadow: 0 7px 16px rgba(194, 81, 0, 0.27);
}

#goBack:hover,
#goBack:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 12px 24px rgba(224, 49, 49, 0.38);
	outline: 3px solid rgba(255, 107, 107, 0.3);
	outline-offset: 2px;
}

#goBack:active {
	transform: translateY(1px);
}

button:hover,
button:focus-visible {
	transform: translateY(-1px);
}

.game-area {
	position: relative;
	min-height: 0;
	display: grid;
	place-items: center;
	border-radius: 20px;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.15);
	border: 1px solid rgba(255, 255, 255, 0.24);
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 12px 30px rgba(2, 22, 38, 0.24);
	-webkit-touch-callout: none;
}

#gameCanvas {
	width: 100%;
	height: 100%;
	display: block;
}

.overlay {
	position: absolute;
	inset: 0;
	display: grid;
	align-content: center;
	justify-items: center;
	gap: 0.5rem;
	padding: 1rem;
	text-align: center;
	background: linear-gradient(180deg, rgba(6, 33, 54, 0.68), rgba(6, 33, 54, 0.82));
	color: #f4fbff;
}

.overlay h1,
.overlay h2,
.overlay p {
	margin: 0;
}

.overlay h1 {
	font-size: clamp(1.5rem, 6vw, 2.5rem);
	line-height: 1;
}

.controls-note {
	opacity: 0.9;
	font-size: clamp(0.86rem, 2.8vw, 1rem);
}

.hidden {
	display: none;
}

.touch-controls {
	position: fixed;
	left: clamp(0.35rem, 1vw, 0.7rem);
	right: clamp(0.35rem, 1vw, 0.7rem);
	bottom: calc(clamp(0.42rem, 1.2vw, 0.72rem) + env(safe-area-inset-bottom, 0px));
	z-index: 5;
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.5rem;
	pointer-events: auto;
}

.touch-controls button {
	min-height: 3.25rem;
	font-size: 1.08rem;
}

.debug-info {
	position: fixed;
	left: 0.45rem;
	top: 0.45rem;
	z-index: 9;
	margin: 0;
	padding: 0.2rem 0.45rem;
	border-radius: 0.45rem;
	font-size: 0.66rem;
	font-weight: 700;
	letter-spacing: 0.01em;
	color: #f8fbff;
	background: rgba(8, 20, 31, 0.68);
	border: 1px solid rgba(248, 251, 255, 0.24);
	pointer-events: none;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

@media (min-width: 900px) {
	.touch-controls {
		max-width: 280px;
		margin: 0 auto;
	}
}

@media (max-width: 720px) {
	.game-shell {
		padding: 0.35rem;
		padding-bottom: calc(3.95rem + env(safe-area-inset-bottom, 0px));
		gap: 0.35rem;
	}

	.toolbar {
		padding: 0.38rem;
		gap: 0.4rem;
	}

	h1 {
		width: 100%;
		text-align: center;
	}

	.toolbar-actions {
		width: 100%;
		justify-content: center;
	}

	.stats {
		width: 100%;
		justify-content: space-around;
	}

	.touch-controls button {
		min-height: 2.95rem;
	}
}

@media (max-height: 700px) {
	.game-shell {
		padding-bottom: calc(4.15rem + env(safe-area-inset-bottom, 0px));
	}

	.touch-controls button {
		min-height: 2.55rem;
		font-size: 0.94rem;
	}
}
