/* Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, NotoSans, "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
	background: #faf8ef;
	color: #776e65;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

.container {
	max-width: 520px;
	margin: 24px auto;
	padding: 0 16px;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 12px;
}
.title {
	font-size: 56px;
	margin: 0;
	font-weight: 700;
}
.scores {
	display: flex;
	gap: 8px;
}
.score-box {
	background: #bbada0;
	color: #fff;
	border-radius: 6px;
	padding: 6px 12px;
	text-align: center;
	min-width: 80px;
}
.score-box .label { font-size: 12px; opacity: 0.9; }
.score-box .value { font-size: 22px; font-weight: 700; }

.controls { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 16px; }
.btn {
	background: #8f7a66;
	color: #fff;
	border: 0;
	border-radius: 4px;
	padding: 10px 14px;
	font-size: 14px;
	cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.hint { font-size: 12px; opacity: 0.8; }

.board-wrapper { position: relative; }
.grid {
	position: relative;
	width: 100%;
	max-width: 520px;
	aspect-ratio: 1 / 1;
	background: #bbada0;
	border-radius: 8px;
	padding: 12px;
	margin: 0 auto;
}
.grid-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.grid-row:last-child { margin-bottom: 0; }
.grid-cell { background: #cdc1b4; border-radius: 6px; width: 100%; aspect-ratio: 1 / 1; }

.tiles {
	position: absolute;
	top: 12px; left: 12px; right: 12px; bottom: 12px;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	grid-template-rows: repeat(4, 1fr);
	gap: 12px;
	pointer-events: none;
}
.tile {
	position: relative;
	background: #eee4da;
	border-radius: 6px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: clamp(18px, 6vw, 32px);
	color: #776e65;
	transition: transform 80ms ease, background-color 120ms ease, color 120ms ease;
}
.tile.new { animation: pop 160ms ease; }
@keyframes pop { from { transform: scale(0.4); opacity: 0.6; } to { transform: scale(1); opacity: 1; } }
.tile.merged { animation: bump 120ms ease; }
@keyframes bump { 50% { transform: scale(1.08); } }

/* Tile Colors */
.tile.v2 { background: #eee4da; color: #776e65; }
.tile.v4 { background: #ede0c8; color: #776e65; }
.tile.v8 { background: #f2b179; color: #f9f6f2; }
.tile.v16 { background: #f59563; color: #f9f6f2; }
.tile.v32 { background: #f67c5f; color: #f9f6f2; }
.tile.v64 { background: #f65e3b; color: #f9f6f2; }
.tile.v128 { background: #edcf72; color: #f9f6f2; font-size: clamp(16px, 5.5vw, 28px); }
.tile.v256 { background: #edcc61; color: #f9f6f2; font-size: clamp(16px, 5.5vw, 28px); }
.tile.v512 { background: #edc850; color: #f9f6f2; font-size: clamp(16px, 5.5vw, 28px); }
.tile.v1024 { background: #edc53f; color: #f9f6f2; font-size: clamp(14px, 5vw, 24px); }
.tile.v2048 { background: #edc22e; color: #f9f6f2; font-size: clamp(14px, 5vw, 24px); }
.tile.v4096, .tile.v8192 { background: #3c3a32; color: #f9f6f2; font-size: clamp(12px, 4.5vw, 22px); }

.overlay {
	position: absolute;
	inset: 0;
	background: rgba(238, 228, 218, 0.73);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	border-radius: 8px;
}
.hidden { display: none; }
.message { font-size: 28px; font-weight: 700; margin-bottom: 12px; }
.overlay .btn { pointer-events: auto; }

.footer { text-align: center; margin-top: 16px; font-size: 12px; opacity: 0.8; }

@media (max-width: 360px) {
	.title { font-size: 44px; }
	.score-box { min-width: 68px; }
}



