html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	overflow: hidden;
	background: #0b0c14;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: #fff;
	-webkit-user-select: none;
	user-select: none;
}

.stage-wrap {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 14px;
	box-sizing: border-box;
	background:
		radial-gradient(circle at 20% 15%, rgba(255, 180, 0, 0.10), transparent 45%),
		radial-gradient(circle at 85% 80%, rgba(139, 92, 246, 0.14), transparent 50%),
		#0b0c14;
}

.mag-stage {
	--mag-accent: #ffb400;
	--mag-accent-dark: #cc8f00;
	position: relative;
	width: min(100%, calc((100vh - 28px) * 6 / 7));
	height: min(100%, calc((100vw - 28px) * 7 / 6));
	max-width: 560px;
	max-height: 653px;
	border-radius: 18px;
	overflow: hidden;
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
	background: #000;
	touch-action: none;
}

.mag-canvas {
	display: block;
	width: 100%;
	height: 100%;
}

/* ---- HUD ---- */
.mag-hud {
	position: absolute;
	top: 12px;
	left: 12px;
	right: 12px;
	display: flex;
	justify-content: space-between;
	pointer-events: none;
	z-index: 3;
}

.mag-hud-block {
	display: flex;
	flex-direction: column;
	align-items: center;
	background: rgba(10, 10, 16, 0.55);
	border: 1px solid rgba(255, 255, 255, 0.08);
	backdrop-filter: blur(4px);
	border-radius: 10px;
	padding: 5px 16px;
	color: #fff;
}

.mag-hud-label {
	font-size: 0.62rem;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	opacity: 0.65;
}

.mag-hud-score,
.mag-hud-moves {
	font-size: 1.3rem;
	font-weight: 800;
	line-height: 1.2;
}
.mag-hud-moves.is-low { color: #f87171; }

.mag-btn--finish {
	align-self: center;
	padding: 8px 18px;
	font-size: 0.82rem;
	pointer-events: auto;
	margin-top: 0;
}

.mag-new-top {
	margin: 0;
	font-weight: 800;
	color: #ffd166;
	font-size: 1rem;
}
.mag-new-top.hidden { display: none; }

/* ---- Toast (reshuffle notice) ---- */
.mag-toast {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(10, 10, 16, 0.85);
	border: 1px solid rgba(255, 180, 0, 0.4);
	color: #ffd679;
	padding: 10px 22px;
	border-radius: 999px;
	font-weight: 700;
	font-size: 0.95rem;
	z-index: 6;
	pointer-events: none;
}
.mag-toast[hidden] { display: none; }

/* ---- Overlays ---- */
.mag-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 24px;
	text-align: center;
	background: rgba(6, 6, 10, 0.9);
	backdrop-filter: blur(3px);
	color: #fff;
	z-index: 5;
}
.mag-overlay.hidden { display: none; }

.mag-title {
	margin: 0;
	font-size: 1.7rem;
	font-weight: 800;
	letter-spacing: -0.01em;
}

.mag-instructions {
	margin: 0;
	font-size: 0.92rem;
	line-height: 1.5;
	color: #c7c8d1;
	max-width: 300px;
}

.mag-btn {
	appearance: none;
	border: none;
	border-radius: 999px;
	padding: 13px 30px;
	font-size: 1rem;
	font-weight: 800;
	color: #1c1408;
	background: linear-gradient(180deg, #ffd166, var(--mag-accent));
	cursor: pointer;
	box-shadow: 0 6px 16px rgba(255, 180, 0, 0.35);
	transition: transform 0.08s ease;
	margin-top: 6px;
}
.mag-btn:active { transform: scale(0.96); }

.mag-score-line { margin: 0; font-size: 1.15rem; font-weight: 700; }
.mag-best-line { opacity: 0.7; font-size: 0.9rem; font-weight: 500; margin-bottom: 2px; }

@media (max-width: 380px) {
	.mag-title { font-size: 1.4rem; }
	.mag-btn { padding: 11px 24px; font-size: 0.92rem; }
	.mag-hud-score, .mag-hud-moves { font-size: 1.1rem; }
}
