:root {
	--wood-dark: #3a2a1f;
	--wood-light: #5c4030;
	--sand-dark: #b8975f;
	--accent-red: #8b2e2e;
	--text-light: #f2e6d8;
	--font-display: "Arial Black", "Franklin Gothic Bold", Impact, sans-serif;
	--font-body: Georgia, "Times New Roman", serif;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: var(--font-body);
	color: var(--text-light);
	background: linear-gradient(180deg, #241b3d 0%, #4a2f1f 45%, #7a4f2a 75%, #a06a35 100%);
}

/* Strict no-scroll layout is scoped to the duel screen only — the landing page keeps
   normal document flow so it's never at risk of clipping content on a short viewport. */
body.duel-body {
	height: 100vh;
	height: 100dvh;
	min-height: 0;
	overflow: hidden;
}

.landing {
	width: min(90vw, 640px);
	text-align: center;
	padding: 2rem;
}

.duel-page {
	width: min(98vw, 1300px);
	height: 100%;
	padding: 0.75rem;
	display: flex;
	flex-direction: column;
}

h1 {
	font-family: var(--font-display);
	font-size: 2.5rem;
	letter-spacing: 0.03em;
	margin-bottom: 0.25rem;
	text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}

.tagline {
	opacity: 0.85;
	margin-top: 0;
}

.rules {
	text-align: left;
	background: rgba(0, 0, 0, 0.25);
	border: 2px solid var(--sand-dark);
	border-radius: 10px;
	padding: 1rem 1.5rem;
	margin: 1.5rem 0;
}

.btn {
	font-family: inherit;
	font-size: 1.1rem;
	padding: 0.75rem 1.75rem;
	border-radius: 8px;
	border: 2px solid var(--sand-dark);
	cursor: pointer;
	background: var(--wood-light);
	color: var(--text-light);
	text-decoration: none;
	display: inline-block;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 4px rgba(0, 0, 0, 0.35);
}

.btn:hover:not(:disabled) {
	background: var(--wood-dark);
}

.btn:disabled {
	opacity: 0.5;
	cursor: default;
}

.btn-primary {
	background: var(--accent-red);
	border-color: #5f1c1c;
}

.btn-primary:hover:not(:disabled) {
	background: #6f2323;
}

.error-text {
	color: #ffb3b3;
}

/* ===== Duel screen: one full-viewport game panel, everything else overlaid on it.
   This is what guarantees no scrolling — .duel-page exactly fills the viewport height
   and .duel-scene takes all remaining space via flex, instead of stacking sections. */

.duel-scene {
	position: relative;
	flex: 1;
	min-height: 0;
	min-width: 0;
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	background: linear-gradient(
		180deg,
		#241b3d 0%,
		#5a2f52 28%,
		#a4406a 48%,
		#f0a058 62%,
		#c98f4f 65%,
		#a9713c 84%,
		#6b4425 100%
	);
	border: 3px solid var(--wood-dark);
	border-radius: 14px;
	padding: 1.5rem 4rem;
	user-select: none;
	overflow: hidden;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Vignette: darkens the edges for a bit of cinematic depth without needing art assets */
.duel-scene::before {
	content: "";
	position: absolute;
	inset: 0;
	background: radial-gradient(ellipse at 50% 55%, transparent 45%, rgba(0, 0, 0, 0.5) 100%);
	pointer-events: none;
	z-index: 5;
}

/* Distant hills silhouette along the horizon — cheap scenery depth via clip-path */
.scene-hills {
	position: absolute;
	left: -2%;
	right: -2%;
	top: 58%;
	height: 12%;
	background: #7a4a28;
	opacity: 0.6;
	clip-path: polygon(
		0% 100%,
		0% 55%,
		8% 70%,
		18% 30%,
		30% 68%,
		42% 20%,
		55% 60%,
		68% 15%,
		80% 55%,
		92% 35%,
		100% 62%,
		100% 100%
	);
	z-index: 1;
	pointer-events: none;
}

.duel-scene.drawn {
	cursor: crosshair;
}

/* Live aim line: SVG endpoint (x2, y2) is updated on every mousemove to track
   the cursor. x1/y1 stays pinned near where "you" stand (bottom-left), so the
   line always runs from you to your cursor — this is what the server checks
   against the opponent's hit region, not the cursor position alone. */
.aim-line-layer {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.1s ease;
	z-index: 4;
}

.duel-scene.drawn .aim-line-layer {
	opacity: 1;
}

#aim-line {
	stroke: var(--accent-red);
	stroke-width: 2.5;
	stroke-linecap: round;
	stroke-dasharray: 6 4;
	filter: drop-shadow(0 0 3px rgba(224, 82, 79, 0.8));
}

/* Emoji placeholders stand in for sprite art until assets land in public/shooter/assets/sprites.
   Three nested layers so their `transform`s don't fight each other: .gunslinger mirrors
   left/right, .bob runs the idle animation, .sprite handles reactive scale/glow effects. */
.gunslinger {
	position: relative;
	z-index: 2;
	display: inline-block;
	filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.4));
}

.gunslinger.right {
	transform: scaleX(-1);
}

/* Driven by the browser's own animation clock, intentionally not synced between the two
   players. NOT merely decorative: duel.js measures these .bob elements' rects (which
   include this transform) as the shot origin and the opponent's hitbox — you hit them
   where you see them, mid-oscillation. --bob-range is set in duel.js from the scene's
   actual measured height (kept current on resize), so the travel always matches the real
   box instead of a guessed viewport-unit value. */
.bob {
	display: inline-block;
	animation: gunslinger-bob 3.2s ease-in-out infinite;
}

.gunslinger.right .bob {
	animation-delay: -1.6s;
}

@keyframes gunslinger-bob {
	0%,
	100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(calc(-1 * var(--bob-range, 60vh)));
	}
}

.sprite {
	display: inline-block;
	font-size: 8rem;
	transition: transform 0.1s ease, filter 0.1s ease;
}

.duel-scene.armed .sprite {
	transform: scale(1.05);
}

/* Aiming feedback: added via mousemove when the cursor is over the opponent's hit region */
.gunslinger.right.targeted .sprite {
	filter: drop-shadow(0 0 14px var(--accent-red));
	transform: scale(1.15);
}

.draw-banner {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(0.6);
	font-family: var(--font-display);
	font-size: 6rem;
	letter-spacing: 0.05em;
	color: var(--accent-red);
	text-shadow: 3px 3px 0 #000, 0 0 30px rgba(224, 82, 79, 0.6);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.1s ease, transform 0.15s ease;
	z-index: 3;
}

.duel-scene.drawn .draw-banner {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

/* ===== HUD: player badges overlaid in the scene corners instead of a separate row ===== */

.scene-ui {
	z-index: 6;
}

.hud {
	position: absolute;
	top: 1rem;
	padding: 0.5rem 1.1rem;
	background: rgba(15, 9, 6, 0.6);
	border: 1px solid var(--sand-dark);
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hud-you {
	left: 1rem;
}

.hud-opponent {
	right: 1rem;
	text-align: right;
}

.hud-name {
	font-family: var(--font-display);
	font-size: 1rem;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}

.status-banner {
	position: absolute;
	top: 1rem;
	left: 50%;
	transform: translateX(-50%);
	margin: 0;
	max-width: 60%;
	font-size: 1rem;
	text-align: center;
	text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
	min-height: 1.4em;
	pointer-events: none;
}

.share-box {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(15, 9, 6, 0.8);
	border: 2px solid var(--sand-dark);
	border-radius: 12px;
	padding: 1.25rem 1.5rem;
	text-align: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.share-title {
	margin: 0 0 0.75rem;
	font-size: 0.95rem;
	opacity: 0.9;
}

.share-row {
	display: flex;
	gap: 0.5rem;
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
}

.share-row input {
	font-family: monospace;
	font-size: 0.9rem;
	padding: 0.5rem;
	border-radius: 6px;
	border: 1px solid var(--sand-dark);
	width: 16rem;
	max-width: 60vw;
}

/* ===== Roulette wheel: hover to arm, spins while waiting for DRAW ===== */

/* Deliberately near "your" character (left side), not centered — so drawing means
   actually moving the cursor a real distance over to the opponent, not a small flick.
   Fixed width is required: the wheel is centered inside this box via margin:auto, and
   wheel-label's text changes length ("Hover to draw" vs "Waiting for opponent…") — without
   a fixed width the box would shrink/grow to fit that text and drag the wheel sideways
   with it, since only `left` is anchored here (not `right`). */
.wheel-wrap {
	position: absolute;
	bottom: 1.25rem;
	left: 4rem;
	width: 13rem;
	text-align: center;
}

.roulette-wheel {
	width: 84px;
	height: 84px;
	margin: 0 auto;
	border-radius: 50%;
	position: relative;
	cursor: pointer;
	opacity: 0.45;
	background: conic-gradient(
		#8b2e2e 0deg 30deg, #1a1a1a 30deg 60deg,
		#8b2e2e 60deg 90deg, #1a1a1a 90deg 120deg,
		#8b2e2e 120deg 150deg, #1a1a1a 150deg 180deg,
		#8b2e2e 180deg 210deg, #1a1a1a 210deg 240deg,
		#8b2e2e 240deg 270deg, #1a1a1a 270deg 300deg,
		#8b2e2e 300deg 330deg, #1a1a1a 330deg 360deg
	);
	border: 4px solid var(--sand-dark);
	box-shadow: 0 0 0 4px var(--wood-dark), inset 0 2px 6px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.4);
	transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

/* Glossy highlight so it doesn't read as a flat CSS gradient */
.roulette-wheel::before {
	content: "";
	position: absolute;
	inset: 6%;
	border-radius: 50%;
	background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.35), transparent 55%);
	pointer-events: none;
}

.roulette-wheel::after {
	content: "";
	position: absolute;
	inset: 36%;
	background: var(--sand-dark);
	border-radius: 50%;
	border: 2px solid var(--wood-dark);
	box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.roulette-wheel.enabled {
	opacity: 1;
}

.roulette-wheel.armed {
	animation: wheel-spin 1.1s linear infinite;
	box-shadow: 0 0 0 4px var(--accent-red), inset 0 2px 6px rgba(0, 0, 0, 0.5), 0 0 18px rgba(224, 82, 79, 0.7);
}

@keyframes wheel-spin {
	from {
		transform: rotate(0deg);
	}
	to {
		transform: rotate(360deg);
	}
}

.wheel-label {
	text-align: center;
	font-size: 0.85rem;
	opacity: 0.9;
	margin: 0.4rem 0 0;
	text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6);
}

/* ===== Result / error modals: centered dialogs over a darkened scene ===== */

.modal-overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.6);
	z-index: 10;
}

.modal {
	background: rgba(20, 12, 8, 0.92);
	border: 2px solid var(--sand-dark);
	border-radius: 14px;
	padding: 1.75rem 2.25rem;
	max-width: 90%;
	text-align: center;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.modal h2 {
	margin-top: 0;
	font-family: var(--font-display);
	letter-spacing: 0.03em;
}

.result-actions {
	display: flex;
	gap: 0.75rem;
	justify-content: center;
	margin-top: 1rem;
	flex-wrap: wrap;
}

[hidden] {
	display: none !important;
}

@media (max-width: 640px) {
	.sprite {
		font-size: 5rem;
	}

	.draw-banner {
		font-size: 3.5rem;
	}

	.duel-scene {
		padding: 1rem 1.5rem;
	}

	.wheel-wrap {
		left: 1.5rem;
	}

	.hud {
		padding: 0.4rem 0.7rem;
	}

	.hud-name {
		font-size: 0.8rem;
	}
}

