:root {
	--ink: #0a2540;
	--muted: #4a6a8a;
	--panel: rgba(255, 255, 255, 0.88);
	--ocean-1: #0e7490;
	--ocean-2: #0891b2;
	--ocean-3: #06b6d4;
	--sand: #fde68a;
	--shell-pad: clamp(0.5rem, 2vw, 1.4rem);
	--chrome-space: 10.5rem;
}

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

html, body {
	height: 100%;
	margin: 0;
	overflow: hidden;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
}

body {
	font-family: Nunito, 'Segoe UI', system-ui, sans-serif;
	color: var(--ink);
	background:
		radial-gradient(circle at 20% 80%, rgba(6, 182, 212, 0.35), transparent 40%),
		radial-gradient(circle at 80% 20%, rgba(14, 116, 144, 0.3), transparent 35%),
		linear-gradient(180deg, #e0f7fa 0%, #b2ebf2 30%, #4dd0e1 70%, #0288d1 100%);
}

.app-shell {
	height: 100dvh;
	height: 100vh;
	width: 100%;
	display: grid;
	grid-template-rows: auto auto auto minmax(0, 1fr);
	gap: clamp(0.4rem, 1.5vh, 0.7rem);
	padding: calc(var(--shell-pad) + env(safe-area-inset-top)) calc(var(--shell-pad) + env(safe-area-inset-right)) calc(var(--shell-pad) + max(env(safe-area-inset-bottom), 1rem)) calc(var(--shell-pad) + env(safe-area-inset-left));
}

.toolbar, .prompt-card, .numeral-panel, .ocean-stage {
	position: relative;
}

.toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.6rem;
	border-radius: 1.4rem;
	padding: 0.6rem 0.9rem;
	background: var(--panel);
	border: 2px solid rgba(8, 145, 178, 0.15);
	box-shadow: 0 8px 20px rgba(8, 80, 120, 0.12);
}

.toolbar-start {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.6rem;
}

.eyebrow {
	margin: 0 0 0.1rem;
	color: #0288d1;
	font-weight: 800;
	letter-spacing: 0.16em;
	text-transform: uppercase;
	font-size: 0.68rem;
}

h1 {
	margin: 0;
	font-family: Fredoka, Nunito, sans-serif;
	font-size: clamp(1.3rem, 5vw, 2rem);
	line-height: 0.95;
}

.toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

button, #goBack {
	border: 0;
	border-radius: 999px;
	padding: 0.55rem 0.85rem;
	background: #fff;
	color: var(--ink);
	font: inherit;
	font-weight: 800;
	text-decoration: none;
	cursor: pointer;
	box-shadow: inset 0 -3px rgba(8, 80, 120, 0.06);
	transition: transform 0.12s ease;
}

#goBack {
	font-weight: 700;
	background: linear-gradient(180deg, #ff6b6b 0%, #e03131 100%);
	color: #fff;
	border: 2px solid rgba(255, 255, 255, 0.4);
	padding: 0.5rem 0.85rem;
	font-size: 0.78rem;
	line-height: 1;
	box-shadow: 0 8px 18px rgba(224, 49, 49, 0.32);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	text-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover, button:focus-visible, #goBack:hover, #goBack:focus-visible {
	outline: 3px solid rgba(2, 136, 209, 0.35);
	transform: translateY(-2px);
}

button:active, #goBack:active {
	transform: translateY(0) scale(0.96);
}

#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);
}

#newRoundButton {
	background: linear-gradient(135deg, var(--ocean-2), var(--ocean-3));
	color: #fff;
}

#voiceToggle[aria-pressed="false"], #soundToggle[aria-pressed="false"] {
	opacity: 0.55;
}

.prompt-card {
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 1rem;
	padding: 0.5rem 0.9rem;
	background: var(--panel);
	border: 2px solid rgba(8, 145, 178, 0.12);
}

#promptText {
	margin: 0;
	color: var(--muted);
	font-weight: 800;
	font-size: clamp(0.85rem, 2.3vw, 1rem);
	text-align: center;
}

.numeral-panel {
	display: grid;
	place-items: center;
}

#bigNumeral {
	font-family: Fredoka, Nunito, sans-serif;
	font-size: clamp(3rem, 12vw, 5rem);
	font-weight: 800;
	line-height: 1;
	color: #fff;
	text-shadow: 0 4px 16px rgba(2, 136, 209, 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
	transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#bigNumeral.bump {
	transform: scale(1.3);
}

#bigNumeral.complete {
	color: #fde68a;
	text-shadow: 0 4px 20px rgba(253, 230, 138, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
}

.ocean-stage {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	align-content: center;
	gap: clamp(0.4rem, 1.5vw, 0.8rem);
	padding: 0.5rem;
	overflow: hidden;
}

.creature {
	width: clamp(70px, 16vw, 110px);
	height: clamp(70px, 16vw, 110px);
	cursor: pointer;
	display: grid;
	place-items: center;
	transition: transform 0.2s ease, filter 0.2s ease;
	filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.creature img {
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.creature:hover {
	transform: scale(1.08);
}

.creature.tapped {
	animation: wiggle 0.4s ease;
	border-radius: 50%;
	background: rgba(253, 230, 138, 0.25);
	box-shadow: 0 0 0 4px rgba(253, 230, 138, 0.6), 0 0 20px rgba(253, 230, 138, 0.5);
}

.creature.tapped img {
	filter: drop-shadow(0 0 8px rgba(253, 230, 138, 0.9)) brightness(1.15) saturate(1.3);
}

.creature.untapped {
	opacity: 0.5;
	filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1)) saturate(0.6);
}

.creature.untapped:hover {
	opacity: 1;
}

@keyframes wiggle {
	0%, 100% { transform: scale(1) rotate(0deg); }
	25% { transform: scale(1.2) rotate(-8deg); }
	75% { transform: scale(1.15) rotate(8deg); }
}

#confettiLayer {
	position: fixed;
	inset: 0;
	pointer-events: none;
	overflow: hidden;
	z-index: 5;
}

.confetti-piece {
	position: absolute;
	top: -24px;
	width: 14px;
	height: 22px;
	border-radius: 4px;
	animation: confetti-fall var(--duration, 1800ms) linear forwards;
	will-change: transform, opacity;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

@keyframes confetti-fall {
	0% { opacity: 0; transform: translate3d(var(--x, 0), -24px, 0) rotate(0deg); }
	10% { opacity: 1; }
	100% { opacity: 0; transform: translate3d(var(--x, 0), 110vh, 0) rotate(var(--spin, 540deg)); }
}

@media (max-width: 560px) {
	:root { --shell-pad: 0.4rem; --chrome-space: 9rem; }
	.toolbar { padding: 0.4rem 0.55rem; border-radius: 1rem; }
	.eyebrow { display: none; }
	h1 { font-size: clamp(1rem, 5vw, 1.4rem); }
	.prompt-card { padding: 0.35rem 0.5rem; border-radius: 0.8rem; }
	#promptText { font-size: 0.78rem; }
	#bigNumeral { font-size: clamp(2.2rem, 10vw, 3.5rem); }
	.creature { width: clamp(60px, 18vw, 85px); height: clamp(60px, 18vw, 85px); }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
