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

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

.container {
    width: 100%;
    max-width: 450px;
    padding: 20px;
}

h1 {
    color: white;
    font-size: 48px;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.score-container {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.score, .best {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    min-width: 100px;
    backdrop-filter: blur(10px);
}

.score span, .best span {
    display: block;
    font-size: 14px;
    opacity: 0.9;
}

#score, #best {
    font-size: 24px;
    font-weight: bold;
    margin-top: 5px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

button {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.game-container {
    background: rgba(255,255,255,0.3);
    border-radius: 15px;
    padding: 15px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    background: #bbada0;
    padding: 10px;
    border-radius: 10px;
    aspect-ratio: 1;
}

.cell {
    background: rgba(238, 228, 218, 0.35);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #776e65;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Tile colors */
.tile-2 {
    background: #eee4da;
}

.tile-4 {
    background: #ede0c8;
}

.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;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2380952380952381), inset 0 0 0 1px rgba(255, 255, 255, 0.14285714285714285);
}

.tile-256 {
    background: #edcc61;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.31746031746031744), inset 0 0 0 1px rgba(255, 255, 255, 0.19047619047619047);
}

.tile-512 {
    background: #ecc850;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.3968253968253968), inset 0 0 0 1px rgba(255, 255, 255, 0.23809523809523808);
}

.tile-1024 {
    background: #edc22e;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.4761904761904762), inset 0 0 0 1px rgba(255, 255, 255, 0.2857142857142857);
    font-size: 18px;
}

.tile-2048 {
    background: #edc20f;
    color: #f9f6f2;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5555555555555556), inset 0 0 0 1px rgba(255, 255, 255, 0.3333333333333333);
    font-size: 18px;
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over.show {
    display: flex;
}

.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.game-over-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 32px;
}

.game-over-content p {
    font-size: 18px;
    margin-bottom: 30px;
    color: #333;
}

.instructions {
    margin-top: 20px;
    text-align: center;
    color: white;
    opacity: 0.9;
    font-size: 14px;
}

.instructions h3 {
    font-size: 20px;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.instruction-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    backdrop-filter: blur(10px);
    text-align: left;
}

.instruction-item {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid rgba(255, 255, 255, 0.5);
}

.instruction-item:last-child {
    margin-bottom: 0;
}

.instruction-item strong {
    display: block;
    margin-bottom: 5px;
    color: #fff;
    font-size: 15px;
}

.instruction-item p {
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
}

@media (max-width: 480px) {
    .instructions h3 {
        font-size: 18px;
    }
    
    .instruction-content {
        padding: 10px;
    }
    
    .instruction-item {
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .instruction-item strong {
        font-size: 14px;
    }
    
    .instruction-item p {
        font-size: 12px;
    }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    h1 {
        font-size: 36px;
    }
    
    .score, .best {
        padding: 12px;
        min-width: 80px;
    }
    
    #score, #best {
        font-size: 20px;
    }
    
    button {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .cell {
        font-size: 20px;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 14px;
    }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
    button:active {
        transform: translateY(2px);
    }
    
    .cell:active {
        transform: scale(0.95);
    }
}