.sw-memory-game {
	max-width: 780px;
	margin: 0 auto;
}

.sw-memory-hud {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1.5rem;
	flex-wrap: wrap;
	margin: 0 0 1.5rem;
	font-weight: 700;
	color: #2E2419;
}

.sw-memory-hud__stat {
	background: #FFFFFF;
	border-radius: 999px;
	padding: .5rem 1.25rem;
	box-shadow: 0 2px 8px rgba(0,0,0,.08);
	font-size: .95rem;
}

.sw-memory-hud__stat strong {
	color: #E8663D;
}

.sw-memory-restart {
	display: inline-block;
	border: 2px solid #2E2419;
	background: transparent;
	color: #2E2419;
	border-radius: 999px;
	padding: .5rem 1.25rem;
	font-weight: 700;
	font-size: .95rem;
	cursor: pointer;
	font-family: inherit;
}

.sw-memory-restart:hover {
	background: #2E2419;
	color: #fff;
}

.sw-memory-board {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: .8rem;
}

.sw-memory-card {
	aspect-ratio: 3 / 4;
	cursor: pointer;
	perspective: 1000px;
}

.sw-memory-card__inner {
	position: relative;
	width: 100%;
	height: 100%;
	transition: transform .55s cubic-bezier(.4, .2, .2, 1);
	transform-style: preserve-3d;
}

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

.sw-memory-card__back,
.sw-memory-card__front {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	border-radius: 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	box-shadow: 0 3px 10px rgba(0,0,0,.12);
}

.sw-memory-card__back {
	background: linear-gradient(155deg, #E8663D, #C94F2B);
}

.sw-memory-card__back picture {
	width: 68%;
	display: flex;
}

.sw-memory-card__back-icon {
	width: 100%;
	height: auto;
	object-fit: contain;
	filter: drop-shadow(0 2px 3px rgba(0,0,0,.2));
}

.sw-memory-card__front {
	background: #FFFFFF;
	transform: rotateY(180deg);
	padding: .5rem;
}

.sw-memory-card__front picture {
	flex: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 0;
}

.sw-memory-card__front img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}

.sw-memory-card__name {
	font-size: .7rem;
	font-weight: 800;
	color: #2E2419;
	text-align: center;
	line-height: 1.2;
	margin-top: .15rem;
}

.sw-memory-card.is-matched .sw-memory-card__front {
	background: #FFF3E9;
}

.sw-memory-card.is-matched {
	animation: sw-memory-pop .4s ease;
}

@keyframes sw-memory-pop {
	0% { transform: scale(1); }
	40% { transform: scale(1.08); }
	100% { transform: scale(1); }
}

.sw-memory-win {
	position: fixed;
	inset: 0;
	background: rgba(46, 36, 25, .55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 200;
	opacity: 0;
	pointer-events: none;
	transition: opacity .3s ease;
	padding: 1rem;
}

.sw-memory-win.is-visible {
	opacity: 1;
	pointer-events: auto;
}

.sw-memory-win__card {
	background: #FFF9F2;
	border-radius: 24px;
	padding: 2rem 2rem 1.75rem;
	text-align: center;
	max-width: 340px;
	box-shadow: 0 12px 40px rgba(0,0,0,.25);
	transform: translateY(10px);
	transition: transform .3s ease;
}

.sw-memory-win.is-visible .sw-memory-win__card {
	transform: translateY(0);
}

.sw-memory-win__card img {
	width: 110px;
	height: auto;
	margin: 0 auto 1rem;
	display: block;
}

.sw-memory-win__card h2 {
	margin: 0 0 .5rem;
	font-size: 1.4rem;
}

.sw-memory-win__card p {
	margin: 0 0 1.25rem;
	color: #6B5D4F;
}

.sw-memory-play-again {
	display: inline-block;
	background: #E8663D;
	color: #fff;
	border: none;
	border-radius: 999px;
	padding: .75rem 1.75rem;
	font-weight: 700;
	font-size: 1rem;
	cursor: pointer;
	font-family: inherit;
}

.sw-memory-play-again:hover {
	background: #C94F2B;
}

@media (max-width: 600px) {
	.sw-memory-board { gap: .5rem; }
	.sw-memory-card__name { font-size: .6rem; }
	.sw-memory-hud { gap: .75rem; }
	.sw-memory-hud__stat { padding: .4rem .9rem; font-size: .85rem; }
}

/* Stays a clean 4x4 grid everywhere — on bigger screens (tablet, PC) it just
   gets roomier instead of changing shape, so it plays well in any orientation. */
@media (min-width: 700px) {
	.sw-memory-game { max-width: 900px; }
	.sw-memory-board { gap: 1rem; }
	.sw-memory-card__name { font-size: .8rem; }
}
@media (min-width: 1000px) {
	.sw-memory-game { max-width: 1020px; }
}

@media (prefers-reduced-motion: reduce) {
	.sw-memory-card__inner { transition: none; }
	.sw-memory-card.is-matched { animation: none; }
}
