/* Card container */
.card-container {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	min-height: 120px;
}

/* Consolidated card styles */
.piece-card {
	width: 18%;
	/* Desktop size */
	height: 110px;
	/* Desktop size */
	border: 2px solid #333;
	border-radius: 8px;
	margin: 5px;
	padding: 8px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	background-color: #f5f5f5;
	transition: transform 0.2s, box-shadow 0.2s, all 0.2s ease;
}

.piece-card:hover {
	border-color: #2196f3;
	/* Highlight border color */
	transform: scale(1.08);
	box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15);
	z-index: 2;
	transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

/* Add hover effect from .card */
.piece-card:hover:not(.disabled) {
	transform: translateY(-5px);
	box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Update the disabled card style */
.piece-card.disabled {
	opacity: 0.5;
	cursor: not-allowed;
	background-color: #ddd;
	filter: grayscale(100%);
	position: relative;
}

/* Add a diagonal line through disabled cards */
.piece-card.disabled::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: linear-gradient(to top right,
			transparent calc(50% - 1px), rgba(255, 0, 0, 0.5),
			transparent calc(50% + 1px));
}

/* Card content - adding this for better control */
.card-content {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.piece-image {
	max-width: 80%;
	height: auto;
}

/* Keep card back styling */
.card-back {
	background-color: #ddd;
	color: #888;
	cursor: default;
}

.card-back .card-inner {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100%;
	font-size: 24px;
	font-weight: bold;
}

/* --- Card draw / discard animations ---
   renderCards() tags freshly drawn cards with .card-enter (slide in from the
   right), overlays absolutely-positioned clones of played/discarded cards with
   .card-discard (play FORWARD — up toward the board, the way a card game tosses a
   card onto the table), and FLIP-slides surviving cards into their new slot.
   --card-anim keeps all three near the board's piece-move speed (chessboard.js
   default 200ms); bump it to slow the whole feel down.
   The container is position:relative so the fly-out clones sit over the hand. */
.card-container {
	position: relative;
	--card-anim: 220ms;
}

/* Drawn cards arrive from the right. */
@keyframes card-deal-in {
	from {
		opacity: 0;
		transform: translateX(46px) scale(0.9);
	}
	to {
		opacity: 1;
		transform: translateX(0) scale(1);
	}
}

.piece-card.card-enter {
	animation: card-deal-in var(--card-anim, 220ms) ease-out both;
}

/* Played cards launch forward — up toward the board — and fade, like tossing a
   card onto the table. (Up = toward the board, since the hand sits below it.) */
@keyframes card-discard {
	from {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
	to {
		opacity: 0;
		transform: translateY(-80px) scale(1.08);
	}
}

.piece-card.card-discard {
	animation: card-discard var(--card-anim, 220ms) ease-in both;
	z-index: 4;
}

@media (prefers-reduced-motion: reduce) {

	.piece-card.card-enter,
	.piece-card.card-discard {
		animation: none;
	}
}

/* Contains AI-generated edits. */