:root {
	--surface: rgba(255, 255, 255, 0.85);
	--border: rgba(15, 23, 42, 0.15);
	--ink: #0b132b;
	--accent: #ff6cd9;
	--gradient: radial-gradient(circle at 20% 20%, #4d2cda, transparent 60%),
		radial-gradient(circle at 80% 0%, #ff8e4d, transparent 50%),
		radial-gradient(circle at 10% 80%, #00c6ff, transparent 55%),
		radial-gradient(circle at 90% 90%, #f72585, transparent 65%),
		linear-gradient(135deg, #050714, #111237);
}

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

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

body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
	background-image: var(--gradient);
	color: var(--ink);
	overflow-x: hidden;
	overflow-y: auto;
}

.app-shell {
	position: relative;
	width: 100%;
	height: 100vh;
	height: 100dvh;
	padding: 0;
}

.toolbar {
	position: absolute;
	top: clamp(0.5rem, 1.5vw, 0.9rem);
	left: clamp(0.5rem, 1.5vw, 0.9rem);
	display: flex;
	align-items: center;
	gap: 0.55rem;
	padding: 0.45rem 0.55rem;
	background: rgba(255, 255, 255, 0.64);
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 999px;
	box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
	backdrop-filter: blur(14px);
	z-index: 2;
	max-width: calc(100vw - 1rem);
}

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

h1 {
	font-size: clamp(0.72rem, 1.7vw, 0.9rem);
	line-height: 1.1;
	margin: 0;
	color: #071224;
	font-weight: 600;
}

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

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

.grid-area {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	grid-template-rows: repeat(4, 1fr);
	gap: clamp(0.5rem, 1.2vw, 1rem);
	padding: clamp(3.5rem, 9vh, 5.5rem) clamp(0.6rem, 2vw, 1.5rem) clamp(0.6rem, 2vw, 1.5rem);
	align-items: stretch;
	justify-items: stretch;
	touch-action: none;
	user-select: none;
}

.letter-tile {
	position: relative;
	border: none;
	border-radius: 1.2rem;
	cursor: pointer;
	background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05));
	background-color: var(--tile-color);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.25);
	transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.15rem;
	padding: 0.4rem;
	overflow: hidden;
}

.letter-tile::before {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: inherit;
	background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.35), transparent 60%);
	opacity: 0;
	transition: opacity 0.2s ease;
	pointer-events: none;
}

.letter-tile:active {
	transform: scale(0.94);
	box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25), inset 0 4px 10px rgba(0, 0, 0, 0.1);
}

.letter-tile.tapped {
	filter: brightness(1.15) saturate(1.1);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), inset 0 2px 6px rgba(255, 255, 255, 0.3), 0 0 0 3px rgba(255, 255, 255, 0.6);
}

.letter-tile.tapped::before {
	opacity: 1;
}

.letter-char {
	font-size: clamp(1.4rem, 3.5vw, 2.6rem);
	font-weight: 700;
	color: rgba(255, 255, 255, 0.95);
	text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
	pointer-events: none;
	line-height: 1;
}

.letter-word {
	font-size: clamp(0.55rem, 1.3vw, 0.85rem);
	font-weight: 500;
	color: rgba(255, 255, 255, 0.9);
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	pointer-events: none;
	line-height: 1.1;
	text-align: center;
}

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

.confetti-piece {
	position: absolute;
	top: -10vh;
	width: 14px;
	height: 22px;
	border-radius: 999px;
	opacity: 0.95;
	animation: confetti-fall var(--duration, 1800ms) linear forwards;
	transform: translate3d(0, 0, 0) rotate(0deg);
}

@keyframes confetti-fall {
	0% {
		opacity: 0;
		transform: translate3d(0, -10vh, 0) rotate(0deg) scale(0.7);
	}
	10% {
		opacity: 1;
	}
	100% {
		opacity: 0;
		transform: translate3d(var(--drift, 0px), 115vh, 0) rotate(var(--spin, 720deg)) scale(1);
	}
}

@media (max-width: 900px) {
	body {
		min-height: 100vh;
	}

	.app-shell {
		display: flex;
		flex-direction: column;
		gap: 1rem;
		min-height: 100vh;
		padding: 0;
	}

	.grid-area {
		position: static;
		flex: 1;
		width: 100%;
		padding-top: 4rem;
		grid-template-columns: repeat(5, 1fr);
		grid-template-rows: repeat(6, 1fr);
	}

	.toolbar {
		position: fixed;
		top: 0.85rem;
		left: 0.85rem;
		right: auto;
		width: auto;
		max-width: calc(100vw - 1.5rem);
		flex-wrap: nowrap;
		gap: 0.4rem;
		padding: 0.45rem 0.65rem;
	}

	.toolbar-actions {
		width: auto;
		flex-wrap: nowrap;
		gap: 0.35rem;
	}
}

@media (max-width: 560px) {
	h1 {
		font-size: 1.05rem;
	}

	.toolbar {
		border-radius: 1rem;
		gap: 0.4rem;
		flex-wrap: wrap;
	}

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

	.grid-area {
		grid-template-columns: repeat(5, 1fr);
		grid-template-rows: repeat(6, 1fr);
		gap: 0.3rem;
		padding: 3.4rem 0.4rem 0.4rem;
	}

	.letter-tile {
		border-radius: 0.7rem;
		gap: 0.05rem;
		padding: 0.25rem;
	}

	.letter-char {
		font-size: clamp(1rem, 4.5vw, 1.6rem);
	}

	.letter-word {
		font-size: clamp(0.45rem, 2.2vw, 0.65rem);
	}
}
