* {
    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 {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

h1 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.label {
    font-size: 0.85em;
    color: #888;
    font-weight: 600;
}

#moves, #timer {
    font-size: 1.5em;
    color: #667eea;
    font-weight: bold;
}

#puzzle-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 20px auto;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 10px;
    position: relative;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 1.5em;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.15s ease;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    will-change: transform;
    position: relative;
}

.tile:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.tile.empty {
    background: transparent;
    cursor: default;
    box-shadow: none;
}

.tile.empty:hover {
    transform: scale(1);
}

.tile.moving {
    z-index: 10;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tile.movable {
    animation: pulse 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

@keyframes slideIn {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.tile.new-tile {
    animation: slideIn 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    will-change: transform;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.win-message {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    border-radius: 10px;
    animation: winSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes winSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    60% {
        transform: translateY(5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.win-message.hidden {
    display: none;
}

.win-message h2 {
    margin-bottom: 10px;
    font-size: 2em;
}

.win-message p {
    margin: 8px 0;
    font-size: 1.1em;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    #puzzle-container {
        gap: 6px;
        padding: 8px;
    }
    
    .tile {
        font-size: 1.2em;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

