/* 贪吃蛇样式 */
.game-layout {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	gap: 20px;
	margin: 20px auto;
	max-width: 900px;
}

.game-area {
	text-align: center;
	flex-shrink: 0;
}

.leaderboard-area {
	width: 280px;
	flex-shrink: 0;
}

.game-controls {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-bottom: 15px;
	flex-wrap: wrap;
}

.game-controls .btn {
	display: inline-block;
}

.game-controls .btn button {
	padding: 8px 20px;
	background: #4CAF50;
	color: #fff;
	border: none;
	border-radius: 5px;
	cursor: pointer;
	font-size: 14px;
	outline: none;
	transition: background 0.2s;
}

.game-controls .btn button:hover {
	background: #45a049;
}

.game-controls .pauseBtn button {
	background: #ff9800;
}

.game-controls .pauseBtn button:hover {
	background: #e68a00;
}

.lb-btn {
	padding: 8px 20px;
	background: #2196F3;
	color: #fff;
	border: none;
	border-radius: 5px;
	cursor: pointer;
	font-size: 14px;
	outline: none;
	transition: background 0.2s;
}

.lb-btn:hover {
	background: #1976D2;
}

/* 蛇游戏面板 */
#snakeWrap {
	width: 400px;
	height: 400px;
	background: #225675;
	border: 20px solid #7dd9ff;
	position: relative;
	margin: 0 auto;
}

.snake {
	background-color: #9ddbb1;
	border-radius: 4px;
}

.food {
	background-color: #ff4444;
	border-radius: 50%;
}

.game-over-msg {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(0, 0, 0, 0.85);
	color: #fff;
	padding: 20px 40px;
	border-radius: 10px;
	font-size: 20px;
	z-index: 10;
	text-align: center;
}

.game-over-msg.win-msg {
	background: rgba(0, 128, 0, 0.85);
}

.pause-msg {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	padding: 15px 30px;
	border-radius: 10px;
	font-size: 18px;
	z-index: 10;
}

/* 排行榜容器 */
.leaderboard-container {
	margin-top: 0;
}

.leaderboard {
	background: #fff;
	border: 2px solid #ddd;
	border-radius: 8px;
	padding: 12px;
	margin: 0;
	max-width: 280px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.1);
	font-size: 13px;
}

.leaderboard h4 {
	text-align: center;
	margin: 0 0 10px 0;
	color: #333;
}

.leaderboard .no-score {
	text-align: center;
	color: #999;
	font-style: italic;
}

.leaderboard table {
	width: 100%;
	border-collapse: collapse;
}

.leaderboard th {
	background: #f5f5f5;
	padding: 8px;
	text-align: center;
	border-bottom: 2px solid #ddd;
}

.leaderboard td {
	padding: 6px 8px;
	text-align: center;
	border-bottom: 1px solid #eee;
}

.leaderboard tr.rank-top {
	background: #fffde7;
}

.lb-buttons {
	text-align: center;
	margin-top: 10px;
}

.close-lb-btn {
	padding: 6px 16px;
	background: #999;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	margin-right: 10px;
}

.clear-lb-btn {
	padding: 6px 16px;
	background: #f44336;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
}

/* 分数输入弹窗 */
.game-score-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.6);
	z-index: 1000;
	display: flex;
	align-items: center;
	justify-content: center;
}

.game-score-content {
	background: #fff;
	padding: 30px 40px;
	border-radius: 12px;
	text-align: center;
	box-shadow: 0 4px 20px rgba(0,0,0,0.3);
	min-width: 320px;
}

.game-score-content h3 {
	margin: 0 0 10px 0;
	color: #333;
}

.game-score-content .final-score {
	font-size: 24px;
	color: #f44336;
	font-weight: bold;
	margin: 10px 0;
}

.name-input-area {
	margin: 15px 0;
}

.name-input-area label {
	display: block;
	margin-bottom: 5px;
	color: #666;
}

.name-input-area input {
	padding: 8px 12px;
	border: 2px solid #ddd;
	border-radius: 5px;
	font-size: 16px;
	width: 200px;
	outline: none;
}

.name-input-area input:focus {
	border-color: #2196F3;
}

.score-buttons {
	margin-top: 15px;
}

.score-buttons button {
	padding: 8px 24px;
	border: none;
	border-radius: 5px;
	cursor: pointer;
	font-size: 14px;
	margin: 0 5px;
}

#score-submit-btn {
	background: #4CAF50;
	color: #fff;
}

#score-submit-btn:hover {
	background: #45a049;
}

#score-skip-btn {
	background: #999;
	color: #fff;
}

#score-skip-btn:hover {
	background: #777;
}

/* ========== 手机端：游戏区纵向堆叠，棋盘自适应缩放，不影响电脑布局 ========== */
@media (max-width: 768px) {
	.game-layout {
		flex-direction: column;
		align-items: center;
		gap: 12px;
		margin: 12px auto;
	}
	.game-area {
		width: 100%;
		overflow-x: auto;            /* 棋盘超过屏宽时可横向滑动，避免被裁切 */
		-webkit-overflow-scrolling: touch;
		text-align: center;
	}
	.leaderboard-area {
		width: 100%;
		max-width: 420px;
	}
	.leaderboard {
		max-width: 100%;
	}
	.game-score-content {
		min-width: 0;
		width: 88%;
		padding: 20px;
	}
}

@media (max-width: 480px) {
	/* 贪吃蛇棋盘含边框约 440px，缩放后适配主流手机宽度（zoom 同时缩小布局盒，不留白） */
	#snakeWrap {
		zoom: 0.82;
	}
	.name-input-area input {
		width: 70%;
	}
}
