.memory-game {
	--game-accent: #7c3aed;
}

.memory-stage {
	display: grid;
	padding: clamp(12px, 2.8vw, 24px);
	place-items: center;
	background:
		radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.16), transparent 24%),
		radial-gradient(circle at 85% 80%, rgba(255, 255, 255, 0.13), transparent 28%),
		linear-gradient(145deg, #5b21b6, #7c3aed 48%, #a855f7);
}

.memory-board {
	display: grid;
	width: min(100%, 540px);
	height: min(100%, 430px);
	min-height: 250px;
	grid-template-columns: repeat(4, minmax(48px, 1fr));
	grid-template-rows: repeat(4, minmax(48px, 1fr));
	gap: clamp(6px, 1.4vw, 12px);
	perspective: 900px;
}

.memory-card {
	position: relative;
	min-width: 0;
	min-height: 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 14px;
	cursor: pointer;
	perspective: 800px;
}

.memory-card:focus-visible {
	outline: 3px solid #fde68a;
	outline-offset: 3px;
}

.memory-card-inner {
	position: absolute;
	inset: 0;
	transform-style: preserve-3d;
	transition: transform 320ms cubic-bezier(0.2, 0.75, 0.25, 1.2);
}

.memory-card.is-flipped .memory-card-inner,
.memory-card.is-matched .memory-card-inner {
	transform: rotateY(180deg);
}

.memory-card-face {
	position: absolute;
	inset: 0;
	display: grid;
	place-items: center;
	overflow: hidden;
	backface-visibility: hidden;
	border-radius: 14px;
	box-shadow: 0 8px 20px rgba(28, 12, 65, 0.25);
}

.memory-card-front {
	color: rgba(255, 255, 255, 0.9);
	background:
		linear-gradient(135deg, rgba(255, 255, 255, 0.23), rgba(255, 255, 255, 0.05)),
		#4c1d95;
	border: 2px solid rgba(255, 255, 255, 0.28);
	font-size: clamp(22px, 5vw, 38px);
	font-weight: 950;
}

.memory-card-front::before {
	content: "?";
}

.memory-card-back {
	background: #fff;
	border: 2px solid rgba(124, 58, 237, 0.22);
	font-size: clamp(25px, 6vw, 47px);
	transform: rotateY(180deg);
}

.memory-card.is-matched .memory-card-back {
	background: #ecfdf5;
	border-color: #34d399;
	box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2), 0 10px 25px rgba(28, 12, 65, 0.24);
}

@media (max-width: 510px) {
	.time-stat {
		display: none;
	}

	.memory-stage {
		padding: 10px;
	}

	.memory-board {
		gap: 6px;
	}

	.memory-card-face {
		border-radius: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.memory-card-inner {
		transition: none;
	}
}
