/* Match-3 duel slice — owned by the GAME slice.
 * The #game overlay: intro (vs friend + booster pick), the board/HUD play view,
 * and the result screen (stars, both scores, coins). DOM HUD over the canvas.
 * Glassy panels use the shared `.glass` hook (styled by glass.css, not here). */

/* ---- Overlay shell: bottom sheet, like #echo ---- */
#game.sheet {
	justify-content: flex-end;
	padding: 0;
	background: rgba(8, 5, 18, 0.78);
	z-index: 45;
	backdrop-filter: blur(3px);
}

.duel-card,
.duel-play {
	position: relative;
	width: 100%;
	max-width: 440px;
	margin: 0 auto;
	/* Deep, even violet so the gold trophy, white text, and the candy board read
	   cleanly; the brand's violet-peach panel art is too bright/warm here. */
	background: linear-gradient(180deg, #2a1d5c 0%, #171031 100%);
	border-radius: 28px 28px 0 0;
	border-top: 1px solid var(--line2);
	padding: 22px 18px calc(20px + var(--safe-b));
	max-height: 94%;
	overflow-y: auto;
	animation: slideup 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- INTRO (unlock modal) ---- */
.duel-unlocked {
	text-align: center;
}
.duel-result-head {
	text-align: center;
	margin-bottom: 14px;
}
.duel-burst {
	width: 76px;
	height: 76px;
	object-fit: contain;
	margin: 2px auto 6px;
	filter: drop-shadow(0 8px 18px rgba(255, 206, 74, 0.35));
}
.duel-title {
	font-family: var(--display);
	font-weight: 700;
	font-size: 22px;
	margin: 0 0 14px;
}

/* ---- PLAY ---- */
.duel-play {
	display: flex;
	flex-direction: column;
	gap: 12px;
	align-items: center;
}
.duel-hud {
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	padding: 10px 14px;
	border-radius: 18px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid var(--line2);
}
.duel-hud-stat {
	display: flex;
	align-items: center;
	gap: 6px;
	font-family: var(--display);
}
.duel-hud-stat img {
	width: 20px;
	height: 20px;
	object-fit: contain;
}
.duel-hud-stat b {
	font-size: 20px;
	font-weight: 700;
	min-width: 1ch;
}
.duel-hud-stat .faint {
	font-size: 12px;
}

/* Board: centered, square, fits the phone frame */
.duel-board-wrap {
	width: 100%;
	display: flex;
	justify-content: center;
}
.duel-board {
	width: min(100%, 420px);
	aspect-ratio: 1 / 1;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none; /* drags are swaps, not page scroll */
}
.duel-board canvas {
	/* Responsive width/height are set inline by the scene after Phaser boots
	   (see scene.ts); CSS only rounds the corners. */
	border-radius: 16px;
}
.duel-noengine {
	padding: 40px 10px;
	text-align: center;
}

/* ---- RESULT ---- */
.duel-final {
	font-size: 16px;
	color: var(--muted);
	margin-top: 4px;
}
.duel-final b {
	color: var(--fg);
	font-size: 18px;
}
.duel-wait {
	text-align: center;
	padding: 18px 8px;
}
.duel-wait .pulse-line {
	width: 130px;
	margin: 0 auto 8px;
	display: block;
	opacity: 0.95;
	animation: beat 1.4s ease-in-out infinite;
}
.duel-verdict {
	text-align: center;
	font-family: var(--display);
	font-weight: 700;
	font-size: 26px;
	margin: 4px 0 12px;
}
.duel-verdict.win {
	color: var(--gold);
}
.duel-verdict.tie {
	color: var(--sky);
}
.duel-verdict.lose {
	color: var(--muted);
}
.duel-scores {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 14px;
}
.duel-score-cell {
	position: relative;
	background: var(--card2);
	border: 1px solid var(--line2);
	border-radius: 18px;
	padding: 14px 14px 16px;
	text-align: center;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
}
/* The winner cell glows gold and rings its avatar gold (a tie rings both). */
.duel-score-cell.winner {
	border-color: rgba(255, 206, 74, 0.7);
	background: linear-gradient(160deg, rgba(255, 206, 74, 0.16), var(--card2));
	box-shadow: 0 0 0 1px rgba(255, 206, 74, 0.3);
}
.duel-cell-av {
	width: 54px;
	height: 54px;
	margin-bottom: 4px;
	border-radius: 50%;
	object-fit: cover;
	border: 2px solid rgba(255, 255, 255, 0.22);
	background: rgba(255, 255, 255, 0.06);
	animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.duel-score-cell.winner .duel-cell-av {
	border-color: var(--gold);
	box-shadow: 0 4px 14px -3px rgba(255, 206, 74, 0.6);
}
.duel-score-cell b {
	font-family: var(--display);
	font-weight: 700;
	font-size: 26px;
}
/* The reward reads as a centred gold chip below the cards, clear of the button. */
.duel-reveal .coin-earned {
	justify-content: center;
	width: max-content;
	margin: 6px auto 16px;
	padding: 7px 18px;
	border-radius: 999px;
	background: rgba(255, 206, 74, 0.14);
	border: 1px solid rgba(255, 206, 74, 0.4);
	font-size: 18px;
}

/* Small-phone tightening (375px): keep the board and HUD from crowding. */
@media (max-width: 380px) {
	.duel-card,
	.duel-play {
		padding-left: 14px;
		padding-right: 14px;
	}
	.duel-hud-stat b {
		font-size: 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.duel-card,
	.duel-play,
	.duel-star {
		animation: none;
	}
	.duel-wait .pulse-line {
		animation: none;
	}
}
