/* ===== Centered, compact results dialog ===== */

.result-dialog {
	position: fixed; /* над всеми слоями */
	inset: 50% auto auto 50%; /* центрируем */
	transform: translate(-50%, -50%);
	width: min(460px, calc(100vw - 32px));
	max-height: min(80vh, 620px);

	padding: 24px 24px 20px;
	border: none;
	border-radius: 20px;
	background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
	color: var(--text, #f5f5f7);
	border: 1px solid rgba(255, 138, 61, 0.15);

	box-shadow:
		0 20px 50px rgba(0, 0, 0, 0.6),
		0 8px 16px rgba(0, 0, 0, 0.4),
		inset 0 1px 0 rgba(255, 255, 255, 0.05);
	z-index: 10050;
	text-align: center; /* всё по центру */
	overflow: hidden;
}

.result-dialog::before {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(
		circle at 50% 0%,
		rgba(255, 138, 61, 0.08) 0%,
		transparent 70%
	);
	pointer-events: none;
}

.result-dialog[open] {
	display: block;
}
.result-dialog.hidden[open] {
	display: block;
}
.result-dialog.hidden {
	display: none;
}

/* backdrop — затемняем и чуть блюрим фон */
.result-dialog::backdrop {
	background: rgba(0, 0, 0, 0.5);
	backdrop-filter: blur(2px);
	animation: rd-fade 0.18s ease-out both;
}

@keyframes rd-fade {
	from {
		background: rgba(0, 0, 0, 0);
	}
	to {
		background: rgba(0, 0, 0, 0.5);
	}
}
@keyframes rd-pop {
	from {
		transform: translate(-50%, calc(-50% + 6px)) scale(0.985);
		opacity: 0;
	}
	to {
		transform: translate(-50%, -50%) scale(1);
		opacity: 1;
	}
}

.result-dialog[open] {
	animation: rd-pop 0.18s ease-out both;
}

/* заголовок и тело */
.result-dialog .dialog-title {
	margin: 2px 0 6px;
	font-size: 18px;
	font-weight: 800;
	letter-spacing: 0.3px;
}

.result-dialog .dialog-body {
	padding: 4px 2px 6px;
	font-size: 14px;
	line-height: 1.6;
}

/* ——— GAME DIGITS for Score ——— */
#finalScoreLabel {
	display: block;
	margin-bottom: 8px;
	font-size: 13px;
	opacity: 0.7;
	letter-spacing: 0.8px;
	text-transform: uppercase;
	font-weight: 600;
	position: relative;
	z-index: 1;
}

#finalScore {
	display: block;
	font-variant-numeric: tabular-nums;
	font-weight: 900;
	font-size: clamp(40px, 8vw, 72px);
	line-height: 1;
	letter-spacing: 2px;

	/* неоновый градиент с мягкой обводкой */
	background: linear-gradient(
		180deg,
		rgba(255, 255, 255, 1) 0%,
		#ffd6d6 35%,
		#ff9966 55%,
		#ff8a3d 75%,
		#cc6622 100%
	);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;

	/* обводка и свечение */
	-webkit-text-stroke: 1px rgba(0, 0, 0, 0.4);
	text-shadow:
		0 0 30px rgba(255, 138, 61, 0.5),
		0 0 15px rgba(255, 138, 61, 0.3);
	margin-bottom: 12px;
	position: relative;
	z-index: 1;
	animation: score-appear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes score-appear {
	0% {
		transform: scale(0.5) translateY(20px);
		opacity: 0;
		filter: blur(10px);
	}
	100% {
		transform: scale(1) translateY(0);
		opacity: 1;
		filter: blur(0);
	}
}

/* Best + прочее */
#finalBestLabel {
	opacity: 0.7;
	font-size: 12px;
}
#finalBest {
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* кнопки */
.result-dialog .dialog-actions {
	display: flex;
	justify-content: center;
	gap: 12px;
	padding-top: 16px;
	position: relative;
	z-index: 1;
}

.result-dialog .btn {
	border-radius: 12px;
	padding: 12px 24px;
	font-weight: 700;
	font-size: 15px;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	position: relative;
	overflow: hidden;
	cursor: pointer;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-dialog .btn::before {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(
		135deg,
		rgba(255, 255, 255, 0.1) 0%,
		transparent 50%
	);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.result-dialog .btn:hover::before {
	opacity: 1;
}

.result-dialog .btn:active {
	transform: translateY(1px) scale(0.98);
}

.result-dialog .btn-accent {
	background: linear-gradient(135deg, #ff8a3d 0%, #ff7429 100%);
	border-color: rgba(255, 138, 61, 0.3);
	color: #111;
	box-shadow: 0 4px 12px rgba(255, 138, 61, 0.3);
}

.result-dialog .btn-accent:hover {
	filter: brightness(1.08);
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(255, 138, 61, 0.4);
}

.result-dialog .btn-accent:active {
	filter: brightness(1);
	transform: translateY(0) scale(0.98);
	box-shadow: 0 2px 8px rgba(255, 138, 61, 0.3);
}

/* светлая тема */
@media (prefers-color-scheme: light) {
	.result-dialog {
		--surface: #ffffff;
		--text: #111;
		box-shadow:
			0 20px 46px rgba(0, 0, 0, 0.18),
			0 4px 12px rgba(0, 0, 0, 0.1);
	}
	.result-dialog .btn {
		background: rgba(0, 0, 0, 0.05);
		color: #111;
		border-color: rgba(0, 0, 0, 0.08);
	}
	.result-dialog .btn:hover {
		background: rgba(0, 0, 0, 0.08);
	}
}
