/* Snake game — scoped to #snakeModal so Bootstrap 3 site styles are unaffected */

#snakeModal .modal-header .close {
	margin-top: -6px;
}

#snakeModal .game-body {
	background-color: #f8f9fa;
	min-height: 100vh;
	display: flex;
	align-items: center;
	padding: 20px 0;
}

#snakeModal .snake-game-stack {
	position: relative;
	/* Taller stacking context so game-over / win overlays center in the modal, not only over the column */
	min-height: min(72vh, 640px);
}

#snakeModal .game-header {
	margin-bottom: 2rem;
	display: flex;
	flex-direction: column;
	align-items: center;
}

#snakeModal .game-title {
	color: #2c3e50;
	font-size: 2.5rem;
	font-weight: bold;
	margin-bottom: 1rem;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#snakeModal .game-info {
	display: flex;
	justify-content: center;
	gap: 2rem;
	margin-bottom: 1rem;
}

#snakeModal .info-item {
	background-color: white;
	padding: 0.5rem 1rem;
	border-radius: 8px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#snakeModal .score,
#snakeModal .level {
	font-size: 1.2rem;
	font-weight: bold;
	color: #2c3e50;
}

#snakeModal .game-area {
	position: relative;
	margin-bottom: 2rem;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
}

#snakeModal #game-container {
	position: relative;
	width: min(100%, 28vh);
	max-width: 28vh;
	margin-left: auto;
	margin-right: auto;
	background-color: #dee2e6;
	border: 2px solid #dee2e6;
	border-radius: 8px;
	display: grid;
	grid-template-columns: repeat(var(--grid-cols, 9), 1fr);
	grid-template-rows: repeat(var(--grid-rows, 16), 1fr);
	gap: 1px;
	padding: 1px;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#snakeModal .game-cell {
	background-color: #f8f9fa;
	border-radius: 2px;
	transition: background-color 0.1s ease;
}

#snakeModal .snake-cell {
	background-color: #28a745;
	border-radius: 2px;
	transition: all 0.1s ease;
	box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.2);
}

#snakeModal .food-cell {
	background-color: #dc3545;
	border-radius: 2px;
	animation: snake-food-pulse 1s infinite;
	box-shadow: 0 0 10px rgba(220, 53, 69, 0.5);
}

@keyframes snake-food-pulse {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.1);
	}
	100% {
		transform: scale(1);
	}
}

#snakeModal .progress-container {
	width: min(100%, 28vh);
	max-width: 28vh;
	height: 25px;
	background-color: #e9ecef;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	margin: 0 auto;
}

/* Use id so we never clash with Bootstrap 3’s .progress-bar */
#snakeModal #progress-display {
	height: 100%;
	background-color: #28a745;
	color: white;
	text-align: center;
	line-height: 25px;
	font-weight: bold;
	transition: width 0.3s ease;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#snakeModal .level-up-message {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: rgba(40, 167, 69, 0.9);
	color: white;
	padding: 20px 40px;
	border-radius: 8px;
	font-size: 2rem;
	font-weight: bold;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
	z-index: 20;
}

#snakeModal .level-up-message.show {
	opacity: 1;
}

#snakeModal .controls-info {
	margin-top: 1rem;
	color: #6c757d;
	font-size: 0.9rem;
}

#snakeModal .snake-mobile-controls {
	display: none;
	margin-top: 1rem;
}

@media (max-width: 991px) {
	#snakeModal .snake-mobile-controls {
		display: block;
	}
}

#snakeModal .snake-d-pad {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}

#snakeModal .snake-d-pad-mid {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
}

#snakeModal .snake-mobile-controls .btn {
	min-width: 52px;
	min-height: 48px;
	font-size: 1.35rem;
	line-height: 1;
	padding: 0.5rem 0.65rem;
	margin: 0.15rem;
}

#snakeModal .game-overlay {
	position: absolute;
	inset: 0;
	box-sizing: border-box;
	padding: 1rem;
	background-color: rgba(0, 0, 0, 0.8);
	display: flex;
	justify-content: center;
	align-items: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	z-index: 15;
}

#snakeModal .game-overlay.show {
	opacity: 1;
	visibility: visible;
}

#snakeModal .snake-overlay-content {
	flex-shrink: 0;
	margin: auto;
	background-color: white;
	padding: 2rem;
	border-radius: 12px;
	text-align: center;
	max-width: 90%;
	width: 400px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
	transform: scale(0.9);
	transition: transform 0.3s ease;
}

#snakeModal .game-overlay.show .snake-overlay-content {
	transform: scale(1);
}

#snakeModal .snake-overlay-content h2 {
	color: #2c3e50;
	font-size: 2rem;
	margin-bottom: 1rem;
}

#snakeModal .final-score,
#snakeModal .final-level,
#snakeModal .win-message {
	font-size: 1.2rem;
	color: #6c757d;
	margin-bottom: 0.5rem;
}

#snakeModal .final-score span,
#snakeModal .final-level span {
	font-weight: bold;
	color: #2c3e50;
}

#snakeModal .modal-body .btn-lg {
	padding: 0.75rem 2rem;
	font-size: 1.1rem;
	margin-top: 1rem;
	transition: transform 0.2s ease;
}

#snakeModal .modal-body .btn-lg:hover {
	transform: translateY(-2px);
}

@media (max-width: 576px) {
	#snakeModal .game-title {
		font-size: 2rem;
	}

	#snakeModal .game-info {
		flex-direction: column;
		gap: 0.5rem;
	}

	#snakeModal .info-item {
		width: 100%;
		max-width: 50vh;
	}

	#snakeModal .controls-info {
		font-size: 0.8rem;
	}

	#snakeModal .snake-overlay-content {
		padding: 1.5rem;
	}

	#snakeModal .snake-overlay-content h2 {
		font-size: 1.5rem;
	}

	#snakeModal .final-score,
	#snakeModal .final-level,
	#snakeModal .win-message {
		font-size: 1rem;
	}
}
