* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	min-height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 20px;
}

.container {
	max-width: 500px;
	width: 100%;
	position: relative;
}

.header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

h1 {
	font-size: 4rem;
	font-weight: 900;
	color: #fff;
	text-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.scores {
	display: flex;
	gap: 10px;
}

.score-container {
	background: rgba(255, 255, 255, 0.25);
	backdrop-filter: blur(10px);
	border-radius: 10px;
	padding: 10px 20px;
	min-width: 80px;
	text-align: center;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.score-label {
	font-size: 0.75rem;
	text-transform: uppercase;
	color: rgba(255, 255, 255, 0.8);
	font-weight: 600;
	letter-spacing: 1px;
}

.score {
	font-size: 1.5rem;
	font-weight: 900;
	color: #fff;
	margin-top: 5px;
}

.game-info {
	background: rgba(255, 255, 255, 0.2);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	padding: 20px;
	margin-bottom: 20px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.instructions {
	color: #fff;
	line-height: 1.6;
	font-size: 0.95rem;
	margin-bottom: 15px;
}

.instructions strong {
	color: #ffe066;
}

.new-game-btn {
	background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
	color: #fff;
	border: none;
	padding: 12px 30px;
	border-radius: 10px;
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	transition: all 0.3s ease;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
	text-transform: uppercase;
	letter-spacing: 1px;
}

.new-game-btn:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.new-game-btn.secondary {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.game-container {
	position: relative;
	background: rgba(187, 173, 160, 0.4);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	padding: 15px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
	margin-bottom: 20px;
}

.grid-container {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 15px;
	position: relative;
	z-index: 1;
}

.grid-cell {
	background: rgba(238, 228, 218, 0.35);
	border-radius: 10px;
	aspect-ratio: 1;
}

.tiles-container {
	position: absolute;
	top: 15px;
	left: 15px;
	right: 15px;
	bottom: 15px;
	z-index: 2;
}

.tile {
	position: absolute;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 2rem;
	font-weight: 900;
	border-radius: 10px;
	transition: top 0.15s ease-in-out, left 0.15s ease-in-out, transform 0.15s ease-in-out;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.tile-new {
	animation: appear 0.2s ease-in-out;
}

.tile-merged {
	animation: pop 0.2s ease-in-out;
}

@keyframes appear {
	from {
		opacity: 0;
		transform: scale(0);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

@keyframes pop {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.15);
	}
	100% {
		transform: scale(1);
	}
}

/* Colores de las fichas */
.tile-2 { background: #eee4da; color: #776e65; }
.tile-4 { background: #ede0c8; color: #776e65; }
.tile-8 { background: #f2b179; color: #f9f6f2; }
.tile-16 { background: #f59563; color: #f9f6f2; }
.tile-32 { background: #f67c5f; color: #f9f6f2; }
.tile-64 { background: #f65e3b; color: #f9f6f2; }
.tile-128 { background: #edcf72; color: #f9f6f2; font-size: 1.75rem; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 1.75rem; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 1.75rem; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.5rem; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.5rem; box-shadow: 0 0 30px rgba(243, 215, 116, 0.8); }
.tile-super { background: #3c3a32; color: #f9f6f2; font-size: 1.25rem; }

.game-over-overlay,
.game-won-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.9);
	backdrop-filter: blur(10px);
	display: none;
	justify-content: center;
	align-items: center;
	z-index: 10;
	border-radius: 15px;
	animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.game-over-overlay.show,
.game-won-overlay.show {
	display: flex;
}

.game-over-content,
.game-won-content {
	text-align: center;
	padding: 30px;
}

.game-over-content h2,
.game-won-content h2 {
	font-size: 3rem;
	color: #776e65;
	margin-bottom: 20px;
}

.final-score {
	font-size: 1.5rem;
	color: #776e65;
	margin-bottom: 30px;
	font-weight: 600;
}

.final-score span {
	color: #f67c5f;
	font-weight: 900;
}

.won-buttons {
	display: flex;
	gap: 15px;
	flex-direction: column;
}

.back-btn {
	display: inline-block;
	color: #fff;
	text-decoration: none;
	font-size: 1rem;
	font-weight: 600;
	padding: 12px 25px;
	background: rgba(255, 255, 255, 0.2);
	backdrop-filter: blur(10px);
	border-radius: 10px;
	transition: all 0.3s ease;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.back-btn:hover {
	background: rgba(255, 255, 255, 0.3);
	transform: translateY(-2px);
	box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 520px) {
	h1 {
		font-size: 3rem;
	}
	
	.score-container {
		padding: 8px 15px;
		min-width: 60px;
	}
	
	.score-label {
		font-size: 0.65rem;
	}
	
	.score {
		font-size: 1.2rem;
	}
	
	.tile {
		font-size: 1.5rem;
	}
	
	.tile-128,
	.tile-256,
	.tile-512 {
		font-size: 1.25rem;
	}
	
	.tile-1024,
	.tile-2048 {
		font-size: 1rem;
	}
	
	.tile-super {
		font-size: 0.9rem;
	}
}

/* Controles móviles */
.mobile-controls {
	display: none;
	margin-top: 20px;
	padding: 20px;
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(10px);
	border-radius: 15px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.control-row {
	display: flex;
	justify-content: center;
	gap: 15px;
	margin-bottom: 15px;
}

.control-row:last-child {
	margin-bottom: 0;
}

.control-btn {
	width: 70px;
	height: 70px;
	background: rgba(255, 255, 255, 0.25);
	backdrop-filter: blur(10px);
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 15px;
	color: white;
	font-size: 2rem;
	font-weight: bold;
	cursor: pointer;
	transition: all 0.2s;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
	user-select: none;
	-webkit-tap-highlight-color: transparent;
}

.control-btn:active {
	transform: scale(0.95);
	background: rgba(255, 255, 255, 0.4);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
	.mobile-controls {
		display: block;
	}
}

@media (max-width: 400px) {
	.grid-container {
		gap: 10px;
	}
	
	.game-container {
		padding: 10px;
	}
	
	.tiles-container {
		top: 10px;
		left: 10px;
		right: 10px;
		bottom: 10px;
	}
	
	.control-btn {
		width: 60px;
		height: 60px;
		font-size: 1.8rem;
	}
}
