/* SyntVision Memory match */
.sv-memory-body {
	overflow: hidden;
}

.sv-memory-app {
	height: calc(100vh - 48px);
	height: calc(100dvh - 48px);
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	display: flex;
	flex-direction: column;
	padding: 10px 12px 12px;
	gap: 10px;
	overflow: hidden;
}

.sv-memory-top {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 10px 12px;
	background: var(--svp-panel);
	border: 1px solid var(--svp-panel-border);
	border-radius: var(--svp-radius);
	backdrop-filter: blur(14px);
	flex: 0 0 auto;
}

.sv-memory-top__main {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	min-width: 0;
}

.sv-memory-brand {
	min-width: 0;
	flex: 1 1 auto;
}

.sv-memory-kicker {
	margin: 0 0 2px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--svp-fun, #14b8a6);
}

.sv-memory-heading h1 {
	margin: 0;
	font-family: var(--svp-display);
	font-size: clamp(14px, 1.5vw, 18px);
	font-weight: 700;
	line-height: 1.25;
	white-space: normal;
	overflow: hidden;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.sv-memory-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: flex-end;
	align-items: stretch;
	flex: 0 0 auto;
}

.sv-memory-stat {
	min-width: 68px;
	padding: 6px 10px;
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.22);
	border: 1px solid var(--svp-panel-border);
	text-align: center;
	display: flex;
	flex-direction: column;
	justify-content: center;
}

.sv-memory-stat__label {
	display: block;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--svp-muted);
	margin-bottom: 2px;
}

.sv-memory-stat strong {
	font-size: 18px;
	font-variant-numeric: tabular-nums;
}

.sv-memory-controls {
	--sv-ctrl-h: 36px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	justify-content: flex-start;
	width: 100%;
	padding-top: 10px;
	border-top: 1px solid var(--svp-panel-border);
}

.sv-memory-diff {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: var(--sv-ctrl-h);
	font-size: 12px;
	color: var(--svp-muted);
}

.sv-memory-ctrl-label {
	font-weight: 600;
	white-space: nowrap;
}

.sv-memory-diff select {
	height: var(--sv-ctrl-h);
	min-height: var(--sv-ctrl-h);
	padding: 0 10px;
	border-radius: 10px;
	border: 1px solid var(--svp-panel-border);
	background: rgba(0, 0, 0, 0.28);
	color: var(--svp-text, #e2e8f0);
	font-size: 12px;
	font-weight: 600;
}

.sv-memory-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	height: var(--sv-ctrl-h);
	min-height: var(--sv-ctrl-h);
	padding: 0 14px;
	border-radius: 10px;
	border: 1px solid var(--svp-panel-border);
	background: rgba(0, 0, 0, 0.28);
	color: var(--svp-text, #e2e8f0);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	text-decoration: none;
	box-sizing: border-box;
}

.sv-memory-btn:hover {
	border-color: rgba(56, 189, 248, 0.45);
}

.sv-memory-btn--primary {
	background: var(--svp-accent, #0a86bf);
	border-color: transparent;
	color: #fff;
}

.sv-memory-btn--primary:hover {
	filter: brightness(1.06);
	border-color: transparent;
}

.sv-memory-main {
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	overflow: hidden;
}

.sv-memory-hint {
	margin: 0;
	flex: 0 0 auto;
	font-size: 13px;
	color: var(--svp-muted);
	text-align: center;
}

.sv-memory-board-wrap {
	position: relative;
	flex: 1 1 auto;
	min-height: 220px;
	width: min(100%, 760px);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.sv-memory-board {
	position: relative;
	display: grid;
	gap: 8px;
	margin: 0 auto;
	/* size set in JS */
}

.sv-memory-board.has-reveal .sv-memory-card {
	opacity: 0;
	visibility: hidden;
}

.sv-memory-card {
	position: relative;
	display: block;
	border: none;
	padding: 0;
	margin: 0;
	background: transparent;
	cursor: pointer;
	width: 100%;
	height: 100%;
	min-width: 48px;
	min-height: 48px;
	border-radius: 10px;
	outline: none;
	appearance: none;
	-webkit-appearance: none;
	-webkit-tap-highlight-color: transparent;
	overflow: hidden;
}

.sv-memory-card:focus-visible {
	box-shadow: 0 0 0 2px var(--svp-accent-2, #38bdf8);
}

/* Simple face swap — more reliable than 3D preserve-3d inside <button> */
.sv-memory-card__inner {
	position: absolute;
	inset: 0;
	border-radius: 10px;
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
	overflow: hidden;
}

.sv-memory-card__face {
	position: absolute;
	inset: 0;
	border-radius: 10px;
	overflow: hidden;
	transition: opacity 0.18s ease, transform 0.18s ease;
}

.sv-memory-card__back {
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
	opacity: 1;
	transform: scale(1);
	background:
		radial-gradient(circle at 30% 20%, rgba(56, 189, 248, 0.35), transparent 45%),
		linear-gradient(145deg, #334155 0%, #1e293b 45%, #0f766e 100%);
	border: 1px solid rgba(148, 163, 184, 0.45);
}

.sv-memory-card__eye {
	display: block;
	width: 42%;
	height: 42%;
	max-width: 56px;
	max-height: 56px;
	object-fit: contain;
	pointer-events: none;
	filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

.sv-memory-card__eye-fallback {
	display: block;
	width: 42%;
	height: 42%;
	max-width: 56px;
	max-height: 56px;
	border-radius: 50%;
	background:
		radial-gradient(circle at 68% 32%, #fff 0 18%, transparent 19%),
		radial-gradient(circle at 50% 50%, #0a86bf 0 38%, #e3232a 39% 100%);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.sv-memory-card__front {
	z-index: 1;
	opacity: 0;
	transform: scale(0.96);
	background-color: #0f172a;
	background-repeat: no-repeat;
	border: 1px solid rgba(52, 211, 153, 0.35);
}

.sv-memory-card.is-flipped .sv-memory-card__back,
.sv-memory-card.is-matched .sv-memory-card__back {
	opacity: 0;
	transform: scale(0.96);
	pointer-events: none;
}

.sv-memory-card.is-flipped .sv-memory-card__front,
.sv-memory-card.is-matched .sv-memory-card__front {
	opacity: 1;
	transform: scale(1);
	z-index: 3;
}

.sv-memory-card.is-matched .sv-memory-card__front {
	box-shadow: inset 0 0 0 2px rgba(52, 211, 153, 0.65);
}

.sv-memory-card.is-locked,
.sv-memory-card.is-matched {
	cursor: default;
}

.sv-memory-pause-veil {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(8, 12, 20, 0.72);
	border-radius: 12px;
	z-index: 5;
}

.sv-memory-pause-veil[hidden] {
	display: none !important;
}

.sv-memory-pause-veil p {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
}

.sv-memory-loading {
	position: absolute;
	inset: 48px 0 0;
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	background: rgba(8, 12, 20, 0.55);
	z-index: 20;
}

.sv-memory-app[data-loading='1'] .sv-memory-loading {
	display: flex;
}

.sv-memory-spinner {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	border: 3px solid rgba(148, 163, 184, 0.25);
	border-top-color: var(--svp-fun, #14b8a6);
	animation: sv-memory-spin 0.8s linear infinite;
}

@keyframes sv-memory-spin {
	to {
		transform: rotate(360deg);
	}
}

.sv-memory-peek {
	position: fixed;
	inset: 48px 0 0;
	z-index: 40;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(8, 12, 20, 0.78);
	padding: 20px;
}

.sv-memory-peek[hidden] {
	display: none !important;
}

.sv-memory-peek img {
	max-width: min(92vw, 900px);
	max-height: min(78dvh, 820px);
	object-fit: contain;
	border-radius: 12px;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.sv-memory-win {
	position: fixed;
	inset: 48px 0 0;
	z-index: 50;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(8, 12, 20, 0.42);
	backdrop-filter: blur(2px);
}

.sv-memory-win[hidden] {
	display: none !important;
}

.sv-memory-win__stats {
	display: flex;
	gap: 10px;
	margin: 0 0 14px;
}

.sv-memory-win__stats div {
	flex: 1;
	padding: 10px;
	border-radius: 10px;
	background: rgba(0, 0, 0, 0.25);
	border: 1px solid var(--svp-panel-border);
	text-align: center;
}

.sv-memory-win__stats span {
	display: block;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--svp-muted);
	margin-bottom: 4px;
}

.sv-memory-win__stats strong {
	font-size: 20px;
	font-variant-numeric: tabular-nums;
}

.sv-memory-main .sv-games-leaderboard {
	width: min(100%, 720px);
	flex: 0 0 auto;
	max-height: 160px;
	overflow: auto;
}

@media (max-width: 720px) {
	.sv-memory-top__main {
		flex-direction: column;
		align-items: stretch;
	}

	.sv-memory-stats {
		justify-content: flex-start;
	}

	.sv-memory-board {
		gap: 6px;
	}

	.sv-memory-board-wrap {
		min-height: 180px;
	}

	.sv-memory-main .sv-games-leaderboard {
		max-height: 120px;
	}
}
