body {
    margin: 0;
    overflow: hidden;
    background: #030014;
    font-family: 'Wallpoet', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #fff;
    position: relative;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}
#stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -2;
}
.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    opacity: 0.8;
    animation: fall linear infinite;
}
@keyframes fall {
    0% { transform: translateY(-10vh); }
    100% { transform: translateY(110vh); }
}
#flickers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}
.flick {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(#ff00ff, transparent);
    opacity: 0.2;
    animation: flicker 1.6s infinite;
}
@keyframes flicker {
    0% { opacity: 0.05; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.3); }
    100% { opacity: 0.05; transform: scale(1); }
}
#container {
    text-align: center;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}
#title {
    font-size: 48px;
    letter-spacing: 4px;
    text-shadow: 0 0 10px #ff00ff, 0 0 20px #00eaff;
    margin-bottom: 10px;
    animation: glow 2s infinite;
}
@keyframes glow {
    0% { text-shadow: 0 0 10px #ff00ff; }
    50% { text-shadow: 0 0 20px #00eaff; }
    100% { text-shadow: 0 0 10px #ff00ff; }
}
#sub a {
    color: #00eaff;
    text-decoration: none;
    font-size: 14px;
}
#game {
    width: 420px;
    height: 420px;
    margin: 20px auto;
    background: rgba(10, 10, 25, 0.6);
    backdrop-filter: blur(6px);
    border: 2px solid #ff00ff;
    box-shadow: 0 0 25px #ff00ff inset, 0 0 25px #00eaff;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    animation: pulse 3s infinite;
    box-sizing: border-box;
    touch-action: none;
}
@keyframes pulse {
    0% { box-shadow: 0 0 25px #ff00ff inset, 0 0 25px #00eaff; }
    50% { box-shadow: 0 0 40px #00eaff inset, 0 0 40px #ff00ff; }
    100% { box-shadow: 0 0 25px #ff00ff inset, 0 0 25px #00eaff; }
}
.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    border-radius: 8px;
    color: #000;
    transition: transform 0.15s ease, background 0.2s ease;
    animation: pop 0.2s;
}
@keyframes pop {
    0% { transform: scale(0.6); }
    100% { transform: scale(1); }
}
.merge {
    animation: merge 0.2s ease;
}
@keyframes merge {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
.n2 { background: #00eaff; }
.n4 { background: #00ffa3; }
.n8 { background: #ff008c; }
.n16 { background: #ff8c00; }
.n32 { background: #ff003c; }
.n64 { background: #0066ff; }
.n128 { background: #8cff00; }
.n256 { background: #fff000; }
.n512 { background: #00ffe5; }
.n1024 { background: #ff00ff; }
.n2048 { background: #ffffff; }

#gameOverOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
#gameOverBox {
    background: rgba(10, 10, 25, 0.95);
    border: 3px solid #ff00ff;
    border-radius: 15px;
    padding: 40px 60px;
    box-shadow: 0 0 40px #ff00ff, 0 0 60px #00eaff;
    text-align: center;
    animation: scaleIn 0.4s ease;
}
@keyframes scaleIn {
    from { transform: scale(0.7); }
    to { transform: scale(1); }
}
#gameOverText {
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px #ff00ff, 0 0 30px #00eaff;
    margin-bottom: 30px;
    animation: glow 2s infinite;
}
#restartBtn {
    background: linear-gradient(135deg, #ff00ff, #00eaff);
    border: none;
    border-radius: 10px;
    padding: 15px 40px;
    font-size: 20px;
    font-family: 'Wallpoet', sans-serif;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 0 20px #ff00ff;
    touch-action: auto;
    -webkit-tap-highlight-color: rgba(255, 0, 255, 0.3);
}
#restartBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px #00eaff;
}
#restartBtn:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    #game {
        width: 92vw !important;
        height: 92vw !important;
        max-width: 92vw !important;
        max-height: 92vw !important;
    }
    #title {
        font-size: 36px;
    }
    #gameOverBox {
        padding: 30px 40px;
    }
    #gameOverText {
        font-size: 36px;
    }
    #restartBtn {
        font-size: 18px;
        padding: 12px 30px;
    }
}
