:root {
	/* Colores base cyberpunk */
	--cyber-bg: #0a0e27;
	--cyber-grid: #1a1f3a;

	/* Colores neón */
	--neon-cyan: #00f0ff;
	--neon-pink: #ff006e;
	--neon-purple: #8b00ff;
	--neon-blue: #0066ff;
	--neon-green: #39ff14;
	--neon-orange: #ff9500;

	/* Sombras de brillo */
	--glow-cyan: 0 0 10px #00f0ff, 0 0 20px #00f0ff, 0 0 30px #00f0ff;
	--glow-pink: 0 0 10px #ff006e, 0 0 20px #ff006e, 0 0 30px #ff006e;
	--glow-purple: 0 0 10px #8b00ff, 0 0 20px #8b00ff, 0 0 30px #8b00ff;

	/* Espaciado de tiles (responsive) */
	--tile-size: 85px;
	--tile-gap: 10px;
	--tile-spacing: 95px;
	/* tile-size + tile-gap */
}

body {
	font-family: 'Orbitron', sans-serif;
}

h1 {
	color: var(--neon-cyan);
	text-shadow:
		0 0 10px var(--neon-cyan),
		0 0 20px var(--neon-cyan),
		0 0 40px var(--neon-cyan),
		0 0 80px var(--neon-cyan);
	letter-spacing: 0.1em;
	animation: neonFlicker 3s infinite alternate;
}

@keyframes neonFlicker {

	0%,
	19%,
	21%,
	23%,
	25%,
	54%,
	56%,
	100% {
		text-shadow:
			0 0 10px var(--neon-cyan),
			0 0 20px var(--neon-cyan),
			0 0 40px var(--neon-cyan),
			0 0 80px var(--neon-cyan);
	}

	20%,
	24%,
	55% {
		text-shadow:
			0 0 5px var(--neon-cyan),
			0 0 10px var(--neon-cyan);
	}
}


#grid {
	position: relative;
	width: 390px;
	height: 390px;
	background: linear-gradient(135deg, var(--cyber-grid) 0%, #0f1428 100%);
	padding: 10px;
	border-radius: 10px;
	margin: 0 auto;
	border: 2px solid var(--neon-cyan);
	box-shadow:
		0 0 20px rgba(0, 240, 255, 0.5),
		inset 0 0 20px rgba(0, 240, 255, 0.1);
}

.tile-background {
	position: absolute;
	width: 85px;
	height: 85px;
	background-color: rgba(26, 31, 58, 0.6);
	border: 1px solid rgba(0, 240, 255, 0.2);
	border-radius: 5px;
	z-index: 1;
}

.tile {
	position: absolute;
	width: 85px;
	height: 85px;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 32px;
	font-weight: bold;
	border-radius: 5px;
	overflow: visible;
	transition: transform 0.2s ease-out, opacity 0.15s ease-out;
	--tx: 0px;
	--ty: 0px;
}

.tile-0 {
	background-color: rgba(26, 31, 58, 0.6);
}

.tile-2 {
	background: linear-gradient(135deg, #1a1f3a 0%, #2a2f4a 100%);
	color: var(--neon-cyan);
	border: 1px solid var(--neon-cyan);
	box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.tile-4 {
	background: linear-gradient(135deg, #1a1f3a 0%, #2a2f4a 100%);
	color: var(--neon-blue);
	border: 1px solid var(--neon-blue);
	box-shadow: 0 0 15px rgba(0, 102, 255, 0.4);
}

.tile-8 {
	background: linear-gradient(135deg, #1a1f3a 0%, #2a2f4a 100%);
	color: var(--neon-purple);
	border: 1px solid var(--neon-purple);
	box-shadow: 0 0 15px rgba(139, 0, 255, 0.5);
	text-shadow: 0 0 5px var(--neon-purple);
}

.tile-16 {
	background: linear-gradient(135deg, #2a1f3a 0%, #3a2f4a 100%);
	color: var(--neon-pink);
	border: 1px solid var(--neon-pink);
	box-shadow: 0 0 20px rgba(255, 0, 110, 0.5);
	text-shadow: 0 0 8px var(--neon-pink);
}

.tile-32 {
	background: linear-gradient(135deg, #2a1f3a 0%, #3a2f4a 100%);
	color: var(--neon-orange);
	border: 1px solid var(--neon-orange);
	box-shadow: 0 0 20px rgba(255, 149, 0, 0.6);
	text-shadow: 0 0 8px var(--neon-orange);
}

.tile-64 {
	background: linear-gradient(135deg, #3a1f3a 0%, #4a2f4a 100%);
	color: var(--neon-green);
	border: 1px solid var(--neon-green);
	box-shadow: 0 0 25px rgba(57, 255, 20, 0.6);
	text-shadow: 0 0 10px var(--neon-green);
}

.tile-128 {
	background: linear-gradient(135deg, #3a2f5a 0%, #4a3f6a 100%);
	color: var(--neon-cyan);
	border: 2px solid var(--neon-cyan);
	box-shadow:
		0 0 30px rgba(0, 240, 255, 0.7),
		inset 0 0 10px rgba(0, 240, 255, 0.2);
	text-shadow:
		0 0 10px var(--neon-cyan),
		0 0 20px var(--neon-cyan);
	font-size: 1.3rem;
}

.tile-256 {
	background: linear-gradient(135deg, #4a2f5a 0%, #5a3f6a 100%);
	color: var(--neon-pink);
	border: 2px solid var(--neon-pink);
	box-shadow:
		0 0 30px rgba(255, 0, 110, 0.7),
		inset 0 0 10px rgba(255, 0, 110, 0.2);
	text-shadow:
		0 0 10px var(--neon-pink),
		0 0 20px var(--neon-pink);
	font-size: 1.3rem;
}

.tile-512 {
	background: linear-gradient(135deg, #5a2f5a 0%, #6a3f6a 100%);
	color: var(--neon-purple);
	border: 2px solid var(--neon-purple);
	box-shadow:
		0 0 35px rgba(139, 0, 255, 0.8),
		inset 0 0 15px rgba(139, 0, 255, 0.3);
	text-shadow:
		0 0 15px var(--neon-purple),
		0 0 25px var(--neon-purple);
	font-size: 1.3rem;
}

.tile-1024 {
	background: linear-gradient(135deg, #6a2f6a 0%, #7a3f7a 100%);
	color: var(--neon-orange);
	border: 3px solid var(--neon-orange);
	box-shadow:
		0 0 40px rgba(255, 149, 0, 0.9),
		inset 0 0 20px rgba(255, 149, 0, 0.3);
	text-shadow:
		0 0 15px var(--neon-orange),
		0 0 30px var(--neon-orange);
	font-size: 1.2rem;
	animation: pulse 2s infinite;
}

.tile-2048 {
	background: linear-gradient(135deg, #7a2f7a 0%, #8a3f8a 100%);
	color: var(--neon-green);
	border: 3px solid var(--neon-green);
	box-shadow:
		0 0 50px rgba(57, 255, 20, 1),
		inset 0 0 25px rgba(57, 255, 20, 0.4);
	text-shadow:
		0 0 20px var(--neon-green),
		0 0 40px var(--neon-green),
		0 0 60px var(--neon-green);
	font-size: 1.2rem;
	animation: pulse 1.5s infinite, rainbow 3s infinite;
}

@keyframes pulse {

	0%,
	100% {
		transform: translate(var(--tx), var(--ty)) scale(1);
	}

	50% {
		transform: translate(var(--tx), var(--ty)) scale(1.05);
	}
}

@keyframes rainbow {
	0% {
		filter: hue-rotate(0deg);
	}

	100% {
		filter: hue-rotate(360deg);
	}
}

/* -------------------------------------------------------- */
/*  ANIMACIÓN OPCIONAL: aparición suave de nuevas fichas    */
/* -------------------------------------------------------- */

/* Animación de aparición */
.tile.tile-new {
	animation: pop 0.2s ease-out forwards;
	transition: none !important;
	/* Desactivar transición para nuevas fichas */
}

@keyframes pop {
	0% {
		opacity: 0;
		transform: translate(var(--tx), var(--ty)) scale(0.5);
		filter: blur(2px);
	}

	100% {
		opacity: 1;
		transform: translate(var(--tx), var(--ty)) scale(1);
		filter: blur(0);
	}
}

/* Animación de fusión */
.tile.tile-merged {
	animation: merge 0.4s ease-in-out;
	z-index: 100 !important;
}

@keyframes merge {
	0% {
		transform: translate(var(--tx), var(--ty)) scale(1);
	}

	50% {
		transform: translate(var(--tx), var(--ty)) scale(1.2);
	}

	100% {
		transform: translate(var(--tx), var(--ty)) scale(1);
	}
}

/* Animación de fundido al cambiar el número */
.tile-fade {
	animation: fadeNumber 0.25s;
}

@keyframes fadeNumber {
	0% {
		opacity: 0;
		transform: scale(1.2);
	}

	100% {
		opacity: 1;
		transform: scale(1);
	}
}

/* -------------------------------------------------------- */
/*  ESTILO CYBERPUNK PARA SCORE Y BOTÓN                    */
/* -------------------------------------------------------- */

#score {
	color: var(--neon-pink);
	font-weight: 900;
	text-shadow:
		0 0 10px var(--neon-pink),
		0 0 20px var(--neon-pink);
	font-size: 1.5rem;
}

.text-xl {
	color: var(--neon-cyan);
	text-shadow: 0 0 5px var(--neon-cyan);
}

#restart-btn {
	background: linear-gradient(135deg, #1a1f3a 0%, #2a2f4a 100%);
	color: var(--neon-purple);
	border: 2px solid var(--neon-purple);
	padding: 8px 16px;
	border-radius: 8px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	cursor: pointer;
	box-shadow:
		0 0 20px rgba(139, 0, 255, 0.4),
		inset 0 0 10px rgba(139, 0, 255, 0.1);
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
}

#restart-btn:hover {
	background: linear-gradient(135deg, #2a2f4a 0%, #3a3f5a 100%);
	box-shadow:
		0 0 30px rgba(139, 0, 255, 0.8),
		inset 0 0 20px rgba(139, 0, 255, 0.2);
	text-shadow:
		0 0 10px var(--neon-purple),
		0 0 20px var(--neon-purple);
	transform: translateY(-2px);
	border-color: var(--neon-pink);
	color: var(--neon-pink);
}

#restart-btn:active {
	transform: translateY(0);
	box-shadow:
		0 0 15px rgba(139, 0, 255, 0.6),
		inset 0 0 15px rgba(139, 0, 255, 0.3);
}

#restart-btn::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0;
	height: 0;
	border-radius: 50%;
	background: rgba(139, 0, 255, 0.3);
	transform: translate(-50%, -50%);
	transition: width 0.6s, height 0.6s;
}

#restart-btn:hover::before {
	width: 300px;
	height: 300px;
}

/* -------------------------------------------------------- */
/*  BOTÓN DE LEADERBOARD                                   */
/* -------------------------------------------------------- */

#leaderboard-btn,
#info-btn {
	background: linear-gradient(135deg, #1a1f3a 0%, #2a2f4a 100%);
	color: var(--neon-cyan);
	border: 2px solid var(--neon-cyan);
	padding: 8px 16px;
	border-radius: 8px;
	font-weight: 700;
	font-size: 1.2rem;
	cursor: pointer;
	box-shadow:
		0 0 20px rgba(0, 240, 255, 0.4),
		inset 0 0 10px rgba(0, 240, 255, 0.1);
	transition: all 0.3s ease;
	position: relative;
	overflow: hidden;
	min-width: 45px;
	display: flex;
	align-items: center;
	justify-content: center;
}

#leaderboard-btn:hover,
#info-btn:hover {
	background: linear-gradient(135deg, #2a2f4a 0%, #3a3f5a 100%);
	box-shadow:
		0 0 30px rgba(0, 240, 255, 0.8),
		inset 0 0 20px rgba(0, 240, 255, 0.2);
	text-shadow:
		0 0 10px var(--neon-cyan),
		0 0 20px var(--neon-cyan);
	transform: translateY(-2px) scale(1.1);
	border-color: var(--neon-pink);
}

#leaderboard-btn:active,
#info-btn:active {
	transform: translateY(0) scale(1);
	box-shadow:
		0 0 15px rgba(0, 240, 255, 0.6),
		inset 0 0 15px rgba(0, 240, 255, 0.3);
}

#leaderboard-btn::before,
#info-btn::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0;
	height: 0;
	border-radius: 50%;
	background: rgba(0, 240, 255, 0.3);
	transform: translate(-50%, -50%);
	transition: width 0.6s, height 0.6s;
}

#leaderboard-btn:hover::before,
#info-btn:hover::before {
	width: 300px;
	height: 300px;
}