* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

html,
body {
	height: 100%;
	overflow: hidden;
	overscroll-behavior: none;
	background: #f3f7ee;
	font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
	user-select: none;
	-webkit-user-select: none;
	touch-action: manipulation;
}

button {
	font-family: inherit;
	border: none;
	border-radius: 10px;
	background: #8fca5a;
	color: #fff;
	font-size: 16px;
	padding: 10px 14px;
	cursor: pointer;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

button:active {
	transform: scale(0.96);
}

.hidden {
	display: none !important;
}

.screen {
	position: fixed;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* ---------- 开始屏 ---------- */
#screen-start {
	justify-content: center;
	padding: 24px;
	background: linear-gradient(180deg, #eaf6d8, #d4ecc0);
}

#screen-start h1 {
	font-size: 34px;
	color: #4c7a2a;
	margin-bottom: 4px;
}

#screen-start .sub {
	color: #7ba35c;
	margin-bottom: 28px;
}

.diff-group {
	display: flex;
	gap: 12px;
	width: 100%;
	max-width: 420px;
	margin-bottom: 26px;
}

.diff-btn {
	flex: 1;
	padding: 14px 6px;
	font-size: 16px;
	background: #cfe6b2;
	color: #4c7a2a;
}

.diff-btn small {
	display: block;
	font-size: 12px;
	margin-top: 4px;
	opacity: 0.8;
}

.diff-btn.active {
	background: #8fca5a;
	color: #fff;
}

.big-btn {
	width: 100%;
	max-width: 420px;
	padding: 14px;
	font-size: 18px;
	background: #6fb337;
}

.row-btns {
	display: flex;
	gap: 10px;
	width: 100%;
	max-width: 420px;
	margin-top: 14px;
	justify-content: center;
	flex-wrap: wrap;
}

.row-btns button {
	flex: 1;
	min-width: 90px;
	background: #9fc67d;
}

.user-label {
	margin-top: 18px;
	color: #6b8f4e;
	font-size: 14px;
}

/* ---------- 游戏屏 ---------- */
#screen-game {
	background: #f3f7ee;
}

#screen-game header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	padding: calc(5px + env(safe-area-inset-top)) 10px 5px;
	font-size: 13px;
	color: #4c7a2a;
	background: #e5f0d5;
}

#screen-game header span {
	margin-right: 8px;
}

#game-time {
	font-weight: bold;
	font-size: 15px;
	color: #d35400;
}

#game-score {
	font-weight: bold;
}

#time-bar {
	width: calc(100% - 20px);
	height: 6px;
	background: #cfe0bb;
	border-radius: 5px;
	overflow: hidden;
	margin: 0 10px 4px;
}

#time-bar-fill {
	height: 100%;
	width: 100%;
	background: #6fb337;
	border-radius: 5px;
	transition: width 0.2s linear, background 0.3s;
}

#time-bar-fill.low {
	background: #e74c3c;
}

#board-wrap {
	flex: 1;
	width: 100%;
	position: relative;
	min-height: 0;
	background: #eef4e2;
}

#board {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	display: block;
	background: #eef4e2;
}

#screen-game footer {
	display: flex;
	gap: 10px;
	width: 100%;
	padding: 5px 10px calc(5px + env(safe-area-inset-bottom));
	background: #e5f0d5;
}

#screen-game footer button {
	flex: 1;
	background: #9fc67d;
	font-size: 14px;
	padding: 9px 6px;
}

/* ---------- 弹层 ---------- */
.modal {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 100;
	padding: 20px;
}

.modal-box {
	background: #fff;
	border-radius: 16px;
	width: 100%;
	max-width: 420px;
	padding: 24px 20px;
	text-align: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	position: relative;
}

.modal-box h2 {
	color: #4c7a2a;
	margin-bottom: 14px;
}

#modal-pause h2.pause-title {
	font-size: 36px;
	color: #4c7a2a;
	margin: 8px 0 20px;
}

.modal-back {
	position: absolute;
	top: 10px;
	left: 10px;
	background: none;
	box-shadow: none;
	color: #4c7a2a;
	font-size: 14px;
	padding: 6px 10px;
	border-radius: 8px;
}

.modal-back:active {
	transform: scale(0.96);
}

.modal-box input {
	width: 100%;
	padding: 12px;
	margin-bottom: 10px;
	border: 1px solid #cfe0bb;
	border-radius: 8px;
	font-size: 16px;
	outline: none;
}

.msg {
	min-height: 18px;
	color: #d35400;
	font-size: 13px;
	margin: 4px 0;
}

.login-actions {
	display: flex;
	gap: 10px;
	margin-top: 6px;
}

.login-btn {
	flex: 1;
	padding: 12px;
	font-size: 16px;
	background: #6fb337;
}

.login-btn-register {
	background: #9fc67d;
}

#modal-deadlock .modal-box {
	background: rgba(255, 246, 214, 0.97);
	color: #8a6d1a;
	font-size: 16px;
}

.modal-rank-box {
	max-height: 80vh;
	display: flex;
	flex-direction: column;
}

.rank-tabs {
	display: flex;
	gap: 8px;
	margin-bottom: 12px;
}

.rank-tab {
	flex: 1;
	background: #dcecd0;
	color: #4c7a2a;
	font-size: 14px;
	padding: 8px;
}

.rank-tab.active {
	background: #8fca5a;
	color: #fff;
}

#rank-list {
	list-style: none;
	overflow-y: auto;
	min-height: 120px;
	max-height: 48vh;
	text-align: left;
	margin-bottom: 12px;
}

#rank-list li {
	display: flex;
	align-items: center;
	padding: 8px 6px;
	border-bottom: 1px solid #eef3e7;
	font-size: 15px;
}

.rank-no {
	width: 36px;
	text-align: center;
	color: #8a6d1a;
}

.rank-name {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.rank-score {
	font-weight: bold;
	color: #4c7a2a;
}

.rank-loading,
.rank-empty {
	text-align: center;
	color: #999;
	padding: 20px 0;
}

.result-score {
	font-size: 22px;
	color: #d35400;
	margin: 8px 0;
}

#result-detail {
	color: #777;
	font-size: 13px;
	margin-bottom: 12px;
}
