/* Chapter 5 walk staging: Asuna left, the witch right. */
game-screen .ch5-asuna-left {
	left: 3% !important;
	right: auto !important;
	scale: 0.88;
	transform-origin: bottom left;
}

game-screen .ch5-witch-right {
	left: auto !important;
	right: 5% !important;
	scale: 0.92;
	transform-origin: bottom right;
}





/* True backdrop crossfade: the previous frame stays visible underneath. */
game-screen .ch5-bg-crossfade {
	position: absolute;
	inset: 0;
	z-index: 1;
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	opacity: 0;
	pointer-events: none;
	transition: opacity 1.4s ease-in-out;
}

/* Staggered fireworks. Each burst is positioned by chapter5-fx.js. */
.ch5-firework {
	position: absolute;
	z-index: 2;
	width: 0;
	height: 0;
	pointer-events: none;
}

.ch5-firework span {
	position: absolute;
	left: -3px;
	top: -3px;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--ch5-color);
	box-shadow: 0 0 16px 4px var(--ch5-color);
	opacity: 0;
	animation: ch5-spark 2.4s cubic-bezier(0.15, 0.7, 0.3, 1) var(--ch5-delay) forwards;
}

@keyframes ch5-spark {
	0% { opacity: 0; transform: rotate(var(--ch5-angle)) translateX(0) scale(0.4); }
	12% { opacity: 1; }
	100% { opacity: 0; transform: rotate(var(--ch5-angle)) translateX(var(--ch5-distance)) scale(1.35); }
}

.ch5-firework::before {
	position: absolute;
	left: -14px;
	top: -14px;
	width: 28px;
	height: 28px;
	content: "";
	border-radius: 50%;
	background: #fff5d0;
	box-shadow: 0 0 35px 20px rgba(255, 220, 140, 0.9);
	animation: ch5-flash 0.35s ease-out forwards;
}

@keyframes ch5-flash {
	from { opacity: 1; transform: scale(0.4); }
	to { opacity: 0; transform: scale(1.8); }
}


/* Finale layering: fireworks burn behind the characters. */
game-screen [data-content="visuals"] img[data-character] {
	z-index: 3;
}

/* Finale: only the lake, the fireworks and one way out. */
body.ch5-final-mode quick-menu,
body.ch5-final-mode [data-component="quick-menu"] {
	display: none !important;
}

.ch5-finale-blocker {
	position: fixed;
	inset: 0;
	z-index: 10000;
	background: transparent;
	cursor: default;
	touch-action: none;
}

.ch5-return-button {
	position: fixed;
	right: clamp(24px, 4vw, 76px);
	bottom: clamp(24px, 5vh, 76px);
	z-index: 10001;
	padding: 1rem 2.6rem;
	border: 1px solid rgba(255, 255, 255, 0.55);
	background: rgba(7, 10, 13, 0.38);
	color: #fff;
	font-family: inherit;
	font-size: clamp(15px, 1.35vw, 24px);
	letter-spacing: 0.16em;
	text-transform: uppercase;
	cursor: pointer;
	backdrop-filter: blur(4px);
	transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.ch5-return-button:hover,
.ch5-return-button:focus-visible {
	border-color: #fff;
	background: rgba(7, 10, 13, 0.62);
	transform: translateY(-2px);
	outline: none;
}

.ch5-return-button:disabled {
	opacity: 0.55;
	cursor: default;
	transform: none;
}

/* Any leftover character element must never survive the watch-only finale. */
body.ch5-final-mode [data-character],
body.ch5-final-mode text-box {
	opacity: 0 !important;
	visibility: hidden !important;
	pointer-events: none !important;
}

.ch5-return-button {
	white-space: nowrap;
}

/* Keep the exit label on one centered line at every scale. */
.ch5-return-button {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: auto !important;
	min-width: 0 !important;
	line-height: 1 !important;
	text-align: center !important;
	white-space: nowrap !important;
	flex-wrap: nowrap !important;
}

.ch5-return-button {
	text-transform: none !important;
	letter-spacing: 0.06em !important;
}

/* One-second exit before the final narration. */
body.ch5-asuna-leaving [data-character] {
	animation: none !important;
	opacity: 0 !important;
	transition: opacity 1s ease !important;
	pointer-events: none !important;
}
