html, body {
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Open Sans', sans-serif;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

#score-display {
    color: #fbbf24;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#best-display {
    color: #94a3b8;
    font-size: 16px;
    font-weight: 600;
}

#board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.cell {
    width: 72px;
    height: 72px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 24px;
    transition: transform 0.12s ease;
    background: rgba(255,255,255,0.04);
    color: transparent;
}

.cell[data-value="2"] { background: #334155; color: #e2e8f0; }
.cell[data-value="4"] { background: #475569; color: #e2e8f0; }
.cell[data-value="8"] { background: #f97316; color: #fff; }
.cell[data-value="16"] { background: #ef4444; color: #fff; }
.cell[data-value="32"] { background: #dc2626; color: #fff; }
.cell[data-value="64"] { background: #b91c1c; color: #fff; }
.cell[data-value="128"] { background: #fbbf24; color: #1e293b; font-size: 20px; }
.cell[data-value="256"] { background: #f59e0b; color: #1e293b; font-size: 20px; }
.cell[data-value="512"] { background: #d97706; color: #fff; font-size: 20px; }
.cell[data-value="1024"] { background: #22c55e; color: #fff; font-size: 16px; }
.cell[data-value="2048"] { background: #8b5cf6; color: #fff; font-size: 16px; box-shadow: 0 0 20px rgba(139,92,246,0.5); }
.cell[data-value="4096"] { background: #ec4899; color: #fff; font-size: 16px; box-shadow: 0 0 20px rgba(236,72,153,0.5); }
.cell[data-value="8192"] { background: #06b6d4; color: #fff; font-size: 16px; box-shadow: 0 0 20px rgba(6,182,212,0.5); }

.cell-pop {
    animation: cellPop 0.2s ease;
}

.cell-merge {
    animation: cellMerge 0.25s ease;
}

@keyframes cellPop {
    0% { transform: scale(0); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes cellMerge {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Start overlay */
.sendmessage {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    cursor: pointer;
}

.sendmessage h1 {
    color: #fbbf24;
    font-size: 1.8rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.4);
}

.niokbutton {
    position: absolute;
    inset: 0;
}

/* Game over overlay */
.hidden { display: none !important; }

#game-over-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    gap: 12px;
}

.game-over-text {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fbbf24;
    letter-spacing: 4px;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.4);
}

.game-over-score {
    font-size: 1.3rem;
    color: #e2e8f0;
    font-weight: 600;
}

.game-over-hint {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-top: 8px;
    animation: hintPulse 2s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

@media (max-width: 400px) {
    .cell {
        width: 58px;
        height: 58px;
        font-size: 18px;
    }
    .cell[data-value="128"],
    .cell[data-value="256"],
    .cell[data-value="512"] { font-size: 16px; }
    .cell[data-value="1024"],
    .cell[data-value="2048"],
    .cell[data-value="4096"],
    .cell[data-value="8192"] { font-size: 13px; }
    #board { gap: 6px; padding: 6px; }
}
