.hud {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 6px;
	background: rgba(20, 23, 31, 0.9);
	border: 1px solid rgba(255, 255, 255, 0.05);
	border-radius: 16px;
	padding: 6px;
}

.hud-health-combined {
	grid-column: 1 / -1;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.health-bar {
	position: relative;
	height: 8px;
	background: rgba(255, 255, 255, 0.08);
	border-radius: 4px;
	overflow: hidden;
}

.health-fill {
	position: absolute;
	top: 0;
	height: 100%;
	transition: width 0.3s ease-out;
	border-radius: 4px;
}

.health-fill-local {
	left: 0;
	background: linear-gradient(90deg, rgba(124, 92, 255, 0.9) 0%, rgba(124, 92, 255, 0.6) 100%);
}

.health-fill-opponent {
	right: 0;
	background: linear-gradient(270deg, rgba(255, 79, 100, 0.8) 0%, rgba(255, 79, 100, 0.5) 100%);
}

.health-values {
	display: grid;
	grid-template-columns: 1fr auto 1fr;
	align-items: center;
}

.health-value {
	display: flex;
	gap: 6px;
	align-items: center;
}

.loadout-reminder {
	text-align: center;
	font-size: 1.1rem;
	line-height: 1;
}

.health-label {
	font-size: 0.75rem;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.health-number {
	font-size: 1.1rem;
	font-weight: 600;
}

.health-value-local .health-number {
	color: var(--accent-light);
}

.health-value-opponent .health-number {
	color: var(--danger);
}

.health-value-local { justify-self: start; }
.health-value-opponent { justify-self: end; }

.hud-section {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.hud-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.95rem;
	background: rgba(31, 36, 48, 0.7);
	padding: 6px 8px;
	border-radius: 8px;
}

.hud-row-combined {
	justify-content: space-between;
}

.hud-label {
	color: var(--muted);
}

.hud-value {
	font-weight: 600;
}

.game-area {
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
	overflow: hidden;
}

.lanes {
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1;
}

.lane {
	flex: 1;
	position: relative;
	min-height: var(--lane-height);
	background: linear-gradient(90deg, rgba(124, 92, 255, 0.08) 0%, rgba(124, 92, 255, 0.03) 100%);
	border: 1px solid rgba(255, 255, 255, 0.08);
	border-radius: 16px;
	overflow: hidden;
	touch-action: manipulation;
}

.lane.selected {
	box-shadow: 0 0 24px rgba(124, 92, 255, 0.35);
	border-color: rgba(124, 92, 255, 0.6);
}

.lane.pending {
	box-shadow: 0 0 16px rgba(124, 92, 255, 0.2);
	border-style: dashed;
}

@keyframes lane-shake {
	0% { transform: translateX(0); }
	20% { transform: translateX(-8px); }
	40% { transform: translateX(8px); }
	60% { transform: translateX(-6px); }
	80% { transform: translateX(6px); }
	100% { transform: translateX(0); }
}

.lane.lane-hit-local {
	box-shadow: inset 0 0 24px rgba(255, 79, 100, 0.4);
	animation: lane-shake 0.3s ease;
}

.lane.lane-hit-opponent {
	box-shadow: inset 0 0 24px rgba(74, 217, 123, 0.4);
}

.lane-label {
	position: absolute;
	top: 8px;
	left: 12px;
	font-size: 0.85rem;
	color: rgba(255, 255, 255, 0.5);
}

.lane .projectile {
	--projectile-core: rgba(255, 111, 92, 0.85);
	--projectile-ring: rgba(255, 111, 92, 0.2);
	--projectile-highlight: rgba(255, 255, 255, 0);
	--projectile-shadow: 0 0 22px rgba(255, 111, 92, 0.6);
	--projectile-translate: translateX(-50%);
	position: absolute;
	top: 50%;
	width: 48px;
	height: 48px;
	margin-top: -24px;
	border-radius: 50%;
	background:
		radial-gradient(circle at 30% 30%, var(--projectile-highlight) 0%, transparent 45%),
		radial-gradient(circle, var(--projectile-core) 0%, var(--projectile-ring) 100%);
	box-shadow: var(--projectile-shadow);
	transform: var(--projectile-translate, translateX(-50%));
	/* Hardware-accelerated smooth movement between render frames */
	/* Transition duration matches render frame time for perfect smoothness */
	transition: left var(--render-frame-time, 100ms) linear;
	will-change: left;
}

.lane .shield {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	pointer-events: none;
	width: 48px;
	height: 48px;
	transform-origin: center;
	background: url('../assets/ShieldGlowing.png') center / contain no-repeat;
	filter: drop-shadow(0 0 8px rgba(128, 128, 255, 0.3));
	transition: opacity var(--transition-fast), transform var(--transition-fast), filter var(--transition-fast);
	opacity: 0;
}

.lane .shield.shield-golden {
	filter: hue-rotate(-195deg) drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
}

.projectile.spell-fireball {
	--projectile-core: rgba(255, 111, 92, 0.9);
	--projectile-ring: rgba(255, 111, 92, 0.2);
	--projectile-shadow: 0 0 20px rgba(255, 111, 92, 0.6);
}

.projectile.spell-lightning {
	--projectile-core: rgba(126, 207, 255, 0.85);
	--projectile-ring: rgba(126, 207, 255, 0.2);
	--projectile-shadow: 0 0 20px rgba(126, 207, 255, 0.55);
}

.projectile.spell-barrage {
	width: 28px;
	height: 28px;
	margin-top: -14px;
	--projectile-core: rgba(167, 20, 216, 0.85);
	--projectile-ring: rgba(211, 77, 255, 0.2);
	--projectile-shadow: 0 0 14px rgba(167, 20, 216, 0.5);
}

.projectile.spell-nuke {
	--projectile-highlight: rgba(255, 255, 224, 0.95);
	--projectile-core: rgba(255, 236, 61, 0.5);
	--projectile-ring: rgba(255, 179, 0, 0.06);
	--projectile-shadow:
		0 0 20px rgba(255, 236, 61, 0.6),
		0 0 45px rgba(255, 179, 0, 0.35);
	border: 2px solid rgba(255, 236, 61, 0.65);
	animation: reckoningPulse 1.3s ease-in-out infinite;
}

@keyframes reckoningPulse {
	0% {
		transform: var(--projectile-translate, translateX(-50%)) scale(0.95);
		opacity: 0.85;
	}
	50% {
		transform: var(--projectile-translate, translateX(-50%)) scale(1.05);
		opacity: 1;
	}
	100% {
		transform: var(--projectile-translate, translateX(-50%)) scale(0.95);
		opacity: 0.85;
	}
}

.sidebar {
	display: grid;
	gap: 8px;
}

.post-game {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	background: rgba(22, 22, 22, 0.4);
	backdrop-filter: blur(1px);
}

.post-game:not(.hidden) #return-to-menu {
	animation: returnToMenuPop 2222ms ease-out forwards;
	transform-origin: center;
}

@keyframes returnToMenuPop {
	0% {
		transform: scale(0);
		opacity: 0;
	}
	50% {
		transform: scale(0.25);
		opacity: 1;
	}
	100% {
		transform: scale(1);
	}
}

.post-game.hidden {
	display: none;
}

.post-game-message {
	font-size: 1.6rem;
	font-weight: 600;
	text-align: center;
	color: #fff;
}

.spell-panel {
	background: rgba(20, 23, 31, 0.9);
	border: 1px solid rgba(255, 255, 255, 0.05);
	border-radius: 16px;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.spell-buttons {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
	gap: 10px;
}

.spell-button {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 64px;
	padding: 8px;
	border-radius: 12px;
	background: rgba(255, 255, 255, 0.08);
	color: inherit;
	border: 1px solid transparent;
}

.spell-button .spell-title {
	font-size: 0.95rem;
	font-weight: 600;
}

.spell-button .spell-cost {
	font-size: 0.8rem;
	color: var(--muted);
}

.spell-button .spell-level {
	position: absolute;
	top: 0;
	right: 0;
	font-size: 0.7rem;
	font-weight: 600;
	color: rgba(255, 215, 0, 0.9);
	background: rgba(0, 0, 0, 0.4);
	padding: 2px 6px;
	border-radius: 4px;
}

.spell-button[data-spell="chaosVolleys"] {
	border-color: #eb5c5c;
	box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

/* Golden styling for invest spell (must come before .selected) */
.spell-button[data-spell="invest"] {
	border-color: rgba(255, 215, 0, 0.4);
	box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
}

/* Selection state overrides all other borders */
.spell-button.selected {
	border-color: var(--accent);
	box-shadow: 0 0 12px rgba(124, 92, 255, 0.4);
}

/* Hide Clear Plan button on mobile to save space */
#clear-selection {
	display: none;
}

/* Very small mobile screens - fit up to 9 spells */
@media (max-width: 399px) {
	.lanes {
		gap: 2px;
	}

	.lane {
		min-height: 16vh;
	}

	.spell-buttons {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
		gap: 6px;
	}

	.spell-button {
		min-height: 56px;
		padding: 6px;
	}

	.spell-button .spell-title {
		font-size: 0.8rem;
	}

	.spell-button .spell-cost {
		font-size: 0.7rem;
	}
}

/* Optimized layout for small to medium mobile screens */
@media (min-width: 400px) and (max-width: 767px) {
	.hud {
		padding: 8px;
		gap: 8px;
		font-size: 0.9rem;
	}

	.lanes {
		gap: 6px;
	}

	.lane {
		min-height: 18vh;
	}

	.spell-buttons {
		grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
		gap: 6px;
	}

	.spell-button {
		min-height: 68px;
		padding: 7px;
	}

	.spell-button .spell-title {
		font-size: 0.9rem;
	}

	.spell-button .spell-cost {
		font-size: 0.75rem;
	}
}

@media (min-width: 768px) {
	.game-area {
		flex-direction: row;
	}

	.lanes {
		flex: 2;
	}

	.sidebar {
		width: 320px;
	}

	/* Show Clear Plan button on desktop with spacing to prevent misclicks */
	#clear-selection {
		display: block;
		margin-top: 36px;
	}
}
